@grackle-ai/web 0.115.0 → 0.115.2

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-DbYqtOnr.js","assets/dagview-tHPW3Rz3.js","assets/KnowledgePage-B4fDXJQF.js","assets/grpc-H5EAEPSG.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
- import{r as R2,a as I2,b as y,j as a,d as my,H as hy,P as gy,i as O2,B as L2,c as B2,C as $2,M as z2,e as H2}from"./dagview-tHPW3Rz3.js";import{c as P2,a as Nd,G as U2,b as V2,d as q2,e as G2,f as F2,M as K2,D as R_,A as I_,W as Z2,O as Y2,g as J2,C as fa,h as O_,i as L_,w as W2,t as X2,p as Oc,j as Q2,R as Lc,S as vy}from"./grpc-H5EAEPSG.js";import{v as ej,r as tj,t as Bc,i as nj,f as sj,M as Cd,a as Ed}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();var np={exports:{}},Pr={},sp={exports:{}},ap={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-DbYqtOnr.js","assets/dagview-tHPW3Rz3.js","assets/KnowledgePage-DJcvhfzO.js","assets/grpc-U-Roc9dZ.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
+ import{r as R2,a as I2,b as y,j as a,d as my,H as hy,P as gy,i as O2,B as L2,c as B2,C as $2,M as z2,e as H2}from"./dagview-tHPW3Rz3.js";import{c as P2,a as Nd,G as U2,b as V2,d as q2,e as G2,f as F2,M as K2,D as R_,A as I_,W as Z2,O as Y2,g as J2,C as fa,h as O_,i as L_,w as W2,t as X2,p as Oc,j as Q2,R as Lc,S as vy}from"./grpc-U-Roc9dZ.js";import{v as ej,r as tj,t as Bc,i as nj,f as sj,M as Cd,a as Ed}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();var np={exports:{}},Pr={},sp={exports:{}},ap={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -325,7 +325,7 @@ ${r.content}`);break}}}return s.join(`
325
325
 
326
326
  ${r}
327
327
 
328
- --- End forwarded ---`}function kI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function SI({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,j)=>{if(j&&u.current!==void 0){const w=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let O=w;O<=T;O++)O<t.length&&pl(t[O])&&D.add(O);return D})}else d(w=>{const T=new Set(w);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),_=y.useCallback(()=>{const k=new Set;for(let j=0;j<t.length;j++)pl(t[j])&&k.add(j);d(k)},[t]),b=y.useCallback(()=>{d(new Set)},[]),x=y.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const w=s(j);try{return await navigator.clipboard.writeText(w),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:_,deselectAll:b,copySelected:x}}const jI="_wrapper_1cdza_1",wI="_scrollContainer_1cdza_9",TI="_selectingPadding_1cdza_16",NI="_toolbar_1cdza_20",CI="_directionToggle_1cdza_27",EI="_scrollToAnchor_1cdza_65",AI="_scrollToAnchorBottom_1cdza_89",DI="_scrollToAnchorTop_1cdza_93",MI="_eventOverflowWarning_1cdza_97",ra={wrapper:jI,scrollContainer:wI,selectingPadding:TI,toolbar:NI,directionToggle:CI,scrollToAnchor:EI,scrollToAnchorBottom:AI,scrollToAnchorTop:DI,eventOverflowWarning:MI},RI=10*1024,II=new Set(["running","idle"]);function OI(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const F1="grackle-stream-direction";function LI(){try{return localStorage.getItem(F1)==="reversed"}catch{return!1}}function BI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:ra.eventOverflowWarning,role:"alert",children:[a.jsx(Nm,{size:Vt,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function yh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[_,b]=y.useState(LI),x=Y3(),[k,j]=y.useState(!1),[w,T]=y.useState(!1),[C,D]=y.useState(void 0),O=SI({events:t,formatForClipboard:G1}),E=y.useMemo(()=>t.filter(pl).length,[t]),M=y.useMemo(()=>c?c.filter(ce=>II.has(ce.status)&&ce.id!==d):[],[c,d]),L=y.useMemo(()=>_?[...t].reverse():t,[t,_]),{isAtAnchor:A,scrollToAnchor:P}=yI({scrollRef:v,contentLength:t.length,isReversed:_,paused:O.isSelecting}),Y=()=>{const ce=!_;b(ce);try{localStorage.setItem(F1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!O.isSelecting)return;const ce=fe=>{fe.key==="Escape"&&!k&&!w&&O.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[O.isSelecting,O.cancelSelection,k,w]);const q=y.useCallback(async()=>{await O.copySelected()&&(r==null||r(`Copied ${O.selectedCount} message${O.selectedCount===1?"":"s"} to clipboard`,"success"))},[O,r]),ee=y.useCallback(()=>[...O.selectedIndices].sort((fe,ge)=>fe-ge).filter(fe=>fe<t.length).map(fe=>t[fe]),[O.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const fe=c==null?void 0:c.find(Ae=>Ae.id===ce);if(!fe)return ce.slice(0,8);const ge=u==null?void 0:u.find(Ae=>Ae.id===fe.environmentId);return(ge==null?void 0:ge.displayName)??fe.environmentId.slice(0,8)},[c,u]),W=y.useCallback(async(ce,fe)=>{if(!m)return;const ge=le(ce);try{await m(ce,fe);const Ae=O.selectedCount;r==null||r(`Forwarded ${Ae} message${Ae===1?"":"s"} to ${ge}`,"success"),O.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,O]),re=y.useCallback(ce=>{j(!1);const fe=ee(),ge=le(d),Ae=xI(ge,fe);if(new TextEncoder().encode(Ae).length>RI){D({sessionId:ce,text:Ae}),T(!0);return}W(ce,Ae).catch(()=>{})},[ee,le,d,W]),$=y.useCallback(()=>{T(!1),C&&(W(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,W]),B=y.useCallback(()=>{T(!1),D(void 0)},[]),se=x?0:.2,oe=_?-8:8,X=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:ra.wrapper,children:[a.jsx("div",{className:ra.toolbar,children:a.jsx(Bi,{text:_?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:ra.directionToggle,onClick:Y,"aria-label":_?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:_?a.jsx(wy,{size:Vt,"aria-hidden":"true"}):a.jsx(Ty,{size:Vt,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${ra.scrollContainer} ${O.isSelecting?ra.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(BI,{eventsDropped:s}),a.jsx(is,{initial:!1,children:L.map((ce,fe)=>{const ge=_?t.length-1-fe:fe;return a.jsx(Ct.div,{initial:{opacity:0,y:oe},animate:{opacity:1,y:0},transition:{duration:se,ease:"easeOut"},children:a.jsx($6,{copyText:_I(ce),isContentBearing:pl(ce),isSelecting:O.isSelecting,isSelected:O.selectedIndices.has(ge),checkboxLabel:OI(ce),onSelect:()=>{O.enterSelectionMode(ge)},onToggle:Ae=>{O.toggleEvent(ge,Ae)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(SD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${ge}`)})})]}),a.jsx(is,{children:O.isSelecting&&a.jsx(K6,{selectedCount:O.selectedCount,totalSelectable:E,onSelectAll:O.selectAll,onDeselectAll:O.deselectAll,onCopy:()=>{q().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:M.length===0,onCancel:O.cancelSelection})}),a.jsx(hI,{isOpen:k,sessions:M,environments:u??[],personas:p,onSelect:re,onCancel:()=>{j(!1)}}),a.jsx(xs,{isOpen:w,title:"Send large message?",description:`This will forward a large message (${X} KB). Continue?`,confirmLabel:"Send",onConfirm:$,onCancel:B}),a.jsx(is,{children:!A&&a.jsxs(Ct.button,{className:`${ra.scrollToAnchor} ${_?ra.scrollToAnchorTop:ra.scrollToAnchorBottom}`,onClick:P,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[_?a.jsx(Ty,{size:Vt,"aria-hidden":"true"}):a.jsx(wy,{size:Vt,"aria-hidden":"true"})," New events"]})})]})}function bh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[_,b]=y.useState(""),x=y.useRef(!1),k=d===c,j=y.useCallback(L=>{v(L),b("")},[]),w=y.useCallback(()=>{b("")},[]),T=y.useCallback(()=>{x.current=!1,u==null||u(null),v(""),b("")},[u]),C=y.useCallback(()=>{const L=m?g.trim():g;if(r){const P=r(g);if(P){b(P);return}}const A=m?s.trim():s;if(L===A){T();return}o(L),T()},[g,s,m,r,o,T]),D=y.useCallback(()=>{x.current=!0,u==null||u(c),v(s),b("")},[c,s,u]),O=y.useCallback(L=>{if(x.current){x.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(L=>{L.key==="Escape"?T():L.key==="Enter"&&p&&C()},[T,p,C]),M=(()=>{if(!k)return!1;const L=m?s.trim():s;return(m?g.trim():g)!==L})();return y.useEffect(()=>{!k&&(g!==""||_!=="")&&(v(""),b(""))},[k,g,_]),{isEditing:k,draft:g,error:_,isDirty:M,startEdit:D,cancelEdit:T,save:C,setDraft:j,clearError:w,handleBlur:O,handleKeyDown:E,ignoreInitialBlurRef:x}}const $I="_editFieldWrapper_yuzty_1",zI="_editInput_yuzty_10",HI="_editTextarea_yuzty_42",PI="_editSelect_yuzty_78",UI="_editError_yuzty_111",VI="_editInputInvalid_yuzty_118",qI="_editHint_yuzty_123",GI="_unsavedDot_yuzty_132",FI="_metaValueClickable_yuzty_140",KI="_editButton_yuzty_159",ZI="_metaPlaceholder_yuzty_175",YI="_worktreeToggle_yuzty_180",it={editFieldWrapper:$I,editInput:zI,editTextarea:HI,editSelect:PI,editError:UI,editInputInvalid:VI,editHint:qI,unsavedDot:GI,metaValueClickable:FI,editButton:KI,metaPlaceholder:ZI,worktreeToggle:YI};function Pt(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:_,ariaLabel:b,"data-testid":x}=t,k=y.useRef(null),j=bh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:T,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:k,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function bm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,x=y.useRef(null),k=bh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const w=window.setTimeout(()=>{var T;(T=x.current)==null||T.focus()},0);return()=>window.clearTimeout(w)}},[k.isEditing]),c==="create"){const w=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${T?it.editInputInvalid:""}`,value:s,onChange:w,placeholder:v,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),T&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:x,className:`${it.editTextarea} ${k.error?it.editInputInvalid:""}`,value:k.draft,onChange:w=>k.setDraft(w.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:_,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),k.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),k.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:k.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function Sd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,x=y.useRef(null),k=bh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const O=window.setTimeout(()=>{var E;(E=x.current)==null||E.focus()},0);return()=>window.clearTimeout(O)}},[k.isEditing]);const j=y.useCallback(O=>{const E=O.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),w=y.useCallback(O=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:O=>m==null?void 0:m(O.target.value),"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))});if(k.isEditing)return a.jsx("select",{ref:x,className:it.editSelect,value:k.draft,onChange:j,onBlur:w,title:_,"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))});const T=g==null?void 0:g(s),C=(D=c.find(O=>O.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[T!==void 0?T:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function JI(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const WI="_nav_1snmp_1",XI="_searchForm_1snmp_8",QI="_searchInput_1snmp_15",e5="_searchButton_1snmp_33",t5="_clearButton_1snmp_68",n5="_workspaceSelect_1snmp_85",s5="_listHeader_1snmp_99",a5="_nodeList_1snmp_108",i5="_nodeItem_1snmp_116",o5="_indicator_1snmp_129",r5="_label_1snmp_136",l5="_badge_1snmp_145",ts={nav:WI,searchForm:XI,searchInput:QI,searchButton:e5,clearButton:t5,workspaceSelect:n5,listHeader:s5,nodeList:a5,nodeItem:i5,indicator:o5,label:r5,badge:l5};function c5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),_=y.useCallback(()=>{g(""),d()},[d]),b=y.useCallback(k=>{u(k)},[u]),x=y.useCallback(k=>{g(""),p(k)},[p]);return a.jsxs("div",{className:ts.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:ts.searchForm,onSubmit:v,children:[a.jsx("input",{className:ts.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:ts.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:ts.clearButton,onClick:_,children:"Clear search"}),a.jsxs("select",{className:ts.workspaceSelect,onChange:k=>{x(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>a.jsx("option",{value:k.id,children:k.name},k.id))]}),a.jsxs("div",{className:ts.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:ts.nodeList,children:t.map(k=>a.jsxs("li",{className:ts.nodeItem,onClick:()=>{b(k.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),b(k.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:ts.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:ts.label,children:k.label}),a.jsx("span",{className:ts.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const d5="_container_bwu10_1",u5="_hamburger_bwu10_33",f5="_brand_bwu10_49",p5="_brandLogo_bwu10_68",m5="_info_bwu10_75",h5="_connectionLabel_bwu10_90",g5="_connectionDot_bwu10_103",v5="_connected_bwu10_106",y5="_disconnected_bwu10_110",b5="_connecting_bwu10_113",Ds={container:d5,hamburger:u5,brand:f5,brandLogo:p5,info:m5,connectionLabel:h5,connectionDot:g5,connected:v5,disconnected:y5,connecting:b5},_5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},x5={connected:Ds.connected,connecting:Ds.connecting,disconnected:Ds.disconnected};function k5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=ut(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=_5[t];return a.jsxs("div",{className:Ds.container,children:[r&&a.jsx("button",{type:"button",className:Ds.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(Sw,{size:kt,"aria-hidden":"true"})}),a.jsx(Bi,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ds.brand,onClick:()=>d(Zo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:qd("icon-192x192.png"),alt:"",className:Ds.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ds.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ds.connectionDot} ${x5[t]}`,"aria-hidden":"true",children:a.jsx(Ja,{size:Cm,fill:"currentColor"})})," ",a.jsx("span",{className:Ds.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const S5="_nav_gx5h3_1",j5="_tab_gx5h3_35",w5="_tabIcon_gx5h3_68",T5="_tabLabel_gx5h3_79",N5="_tabActive_gx5h3_84",C5="_tabEnd_gx5h3_90",Mo={nav:S5,tab:j5,tabIcon:w5,tabLabel:T5,tabActive:N5,tabEnd:C5},rd=[{view:"dashboard",label:"Dashboard",icon:a.jsx(dw,{size:kt}),route:Zo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(Vj,{size:kt}),route:iC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(Ew,{size:kt}),route:Ho,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(ww,{size:kt}),route:aC,testId:"sidebar-tab-chat",order:3},{view:"findings",label:"Findings",icon:a.jsx(ud,{size:kt}),route:Bd,testId:"sidebar-tab-findings",order:4},{view:"knowledge",label:"Knowledge",icon:a.jsx(Oj,{size:kt}),route:dx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(Dw,{size:kt}),route:lx,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(qw,{size:kt}),route:QN,testId:"sidebar-tab-settings",align:"end"}];function E5(t){return t===Zo||t==="/"?"dashboard":t.startsWith(lx)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(dx)?"knowledge":t.startsWith(Bd)?"findings":t.startsWith(Ii)?"settings":"tasks"}function A5({tabs:t=rd}){var g;const s=an(),o=ut(),r=y.useRef(null),c=E5(s.pathname),d=y.useMemo(()=>{const v=(_,b)=>(_.order??Number.MAX_SAFE_INTEGER)-(b.order??Number.MAX_SAFE_INTEGER);return[...t.filter(_=>_.align!=="end").sort(v),...t.filter(_=>_.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,w;const _=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!_)return;const b=Array.from(_).findIndex(T=>T===document.activeElement),x=b>=0?b:d.findIndex(T=>T.view===c);let k=x;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),k=(x+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),k=(x-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),k=0;else if(v.key==="End")v.preventDefault(),k=d.length-1;else return;o(d[k].route),(w=_[k])==null||w.focus()},[c,o,d]);return a.jsx("nav",{className:Mo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const _=v.view===c,b=v.view===u;return a.jsx(Bi,{text:v.label,placement:"bottom",className:b?Mo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":_,tabIndex:_?0:-1,className:`${Mo.tab} ${_?Mo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:Mo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:Mo.tabLabel,children:v.label})]})},v.view)})})}const D5="_container_pi6ii_1",M5="_content_pi6ii_66",i_={container:D5,content:M5},R5=320,K1=220,Z1=600,Y1="grackle-sidebar-width";function I5(){try{const t=localStorage.getItem(Y1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=K1&&s<=Z1)return s}}catch{}return R5}function O5(t){try{localStorage.setItem(Y1,String(t))}catch{}}function L5({content:t}){const[s]=y.useState(I5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=K1&&m<=Z1&&O5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:i_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:i_.content,children:t})})}const B5="_bar_tnfsh_1",$5="_btnPrimary_tnfsh_32",z5="_statusText_tnfsh_85",H5="_statusCompleted_tnfsh_90",P5="_statusFailed_tnfsh_94",U5="_statusBlocked_tnfsh_98",V5="_hintText_tnfsh_103",Nt={bar:B5,btnPrimary:$5,statusText:z5,statusCompleted:H5,statusFailed:P5,statusBlocked:U5,hintText:V5};function q5({sessions:t,tasks:s,environments:o}){const r=ut(),c=an(),d=Ot("/sessions/:sessionId"),u=Ot("/tasks/:taskId"),p=Ot("/tasks/:taskId/stream"),m=Ot("/tasks/:taskId/findings"),g=Ot("/tasks/:taskId/edit"),v=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),_=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),x=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=Ot("/sessions/new"),j=Ot("/environments/:environmentId/workspaces/:workspaceId"),w=Ot("/tasks/new"),T=Ot("/chat"),C=Ot("/"),D=Ot("/settings/*"),O=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(_==null?void 0:_.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId),M=v??_??b??x,L=(M==null?void 0:M.params.environmentId)??(j==null?void 0:j.params.environmentId),A=c.pathname.startsWith("/environments")&&!j&&!M,P=!!T,Y=!!k,q=!!j&&!v&&!_&&!b&&!x,ee=!!w;if(!!C&&!Y&&!q&&!ee||!!D||(!!g||!!x)||ee||A||Y)return a.jsx(a.Fragment,{});if(P)return o.find(B=>B.adapterType==="local"&&B.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Add a local environment to start chatting"})});if(q)return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Select a task or click + to create one"})});if(E){const $=s.find(oe=>oe.id===E);if(!$)return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Loading..."})});const B=new Map(s.map(oe=>[oe.id,oe])),se=$.dependsOn.some(oe=>{const X=B.get(oe);return X!==void 0&&X.status!=="complete"});if($.status==="not_started"){const oe=se?$.dependsOn.map(X=>B.get(X)).filter(X=>X&&X.status!=="complete").map(X=>X.title):[];return a.jsx("div",{className:Nt.bar,children:se?a.jsxs("span",{className:Nt.statusBlocked,children:["Blocked by: ",oe.join(", ")]}):a.jsx("span",{className:Nt.hintText,children:"Use the buttons above to start or manage this task"})})}if($.status==="working"||$.status==="paused"){const oe=$.latestSessionId||void 0,X=oe?t.find(fe=>fe.id===oe):void 0;return X&&X.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Waiting for agent..."})})}if($.status==="complete")return a.jsxs("div",{className:Nt.bar,children:[a.jsx("span",{className:`${Nt.statusText} ${Nt.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Hi($.workspaceId,void 0,L)),className:Nt.btnPrimary,children:"+ New Task"})]});if($.status==="failed")return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:`${Nt.statusText} ${Nt.statusFailed}`,children:"Task failed"})})}if(O){const $=t.find(oe=>oe.id===O),B=($==null?void 0:$.status)==="stopped";if($!==void 0&&!B)return a.jsx(a.Fragment,{});if(B)return a.jsxs("div",{className:Nt.bar,children:[a.jsxs("span",{className:`${Nt.statusText} ${Nt.hintText}`,children:["Session ",$.endReason||$.status]}),a.jsx("button",{onClick:()=>r(ix($.environmentId)),className:Nt.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Loading..."})})}const G5="_nav_14i94_1",F5="_tab_14i94_24",K5="_tabActive_14i94_62",Z5="_tabLabel_14i94_75",Y5="_statusDot_14i94_81",J5="_pulse_14i94_87",W5="_addButton_14i94_99",X5="_empty_14i94_132",qa={nav:G5,tab:F5,tabActive:K5,tabLabel:Z5,statusDot:Y5,pulse:J5,addButton:W5,empty:X5},Q5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function eO({environments:t}){const s=ut(),o=y.useRef(null),r=Ot("/environments/:environmentId"),c=Ot("/environments/:environmentId/edit"),d=Ot("/environments/:environmentId/workspaces/:workspaceId"),u=Ot("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(b=>{s(Li(b))},[s]),v=y.useCallback(b=>{var T;const x=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const k=Array.from(x).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===m);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&s(Li(t[w].id)),x[w].focus()},[m,t,s]),_=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:qa.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(b=>{const x=b.id===m,k=b.id===_,j=Q5[b.status]||"var(--text-tertiary)",w=b.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:k?0:-1,className:`${qa.tab} ${x?qa.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${qa.statusDot} ${w?qa.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(Ja,{size:Cm,fill:"currentColor"})}),a.jsx("span",{className:qa.tabLabel,title:b.displayName||b.id,children:b.displayName||b.id})]},b.id)})}),a.jsx("button",{type:"button",className:qa.addButton,onClick:()=>s(WN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:qa.empty,children:"No environments yet."})]})}function Go(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function J1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const o_={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function jd(t){return o_[t]||o_.general}const tO="_nav_dlm8m_1",nO="_categoryPills_dlm8m_24",sO="_categoryPill_dlm8m_24",aO="_tab_dlm8m_42",iO="_tabActive_dlm8m_80",oO="_tabContent_dlm8m_93",rO="_tabLabel_dlm8m_100",lO="_tabMeta_dlm8m_106",cO="_categoryDot_dlm8m_111",dO="_empty_dlm8m_118",Es={nav:tO,categoryPills:nO,categoryPill:sO,tab:aO,tabActive:iO,tabContent:oO,tabLabel:rO,tabMeta:lO,categoryDot:cO,empty:dO};function uO({findings:t,workspaceId:s,environmentId:o}){const r=ut(),c=y.useRef(null),d=Ot("/findings/:findingId"),u=Ot("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const b=new Set(t.map(x=>x.category).filter(Boolean));return Array.from(b).sort()},[t]),g=y.useCallback(b=>{r(em(b,s,o))},[r,s,o]),v=y.useCallback(b=>{var T;const x=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const k=Array.from(x).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===p);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&r(em(t[w].id,s,o)),x[w].focus()},[p,t,r,s,o]),_=p??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Es.nav,"data-testid":"findings-nav",children:[m.length>1&&a.jsx("div",{className:Es.categoryPills,"data-testid":"findings-nav-categories",children:m.map(b=>a.jsx("span",{className:Es.categoryPill,style:{color:jd(b).text},children:b},b))}),a.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(b=>{const x=b.id===p,k=b.id===_;return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:k?0:-1,className:`${Es.tab} ${x?Es.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"finding-nav-item",children:[a.jsx("span",{className:Es.categoryDot,style:{color:jd(b.category).text},"aria-hidden":"true",children:a.jsx(Ja,{size:Cm,fill:"currentColor"})}),a.jsxs("span",{className:Es.tabContent,children:[a.jsx("span",{className:Es.tabLabel,title:b.title,children:b.title}),a.jsx("span",{className:Es.tabMeta,title:b.createdAt,children:Go(b.createdAt)})]})]},b.id)})}),t.length===0&&a.jsx("div",{className:Es.empty,children:"No findings yet. Agents will post discoveries here."})]})}function fO(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function W1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=fO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function pO(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function mO(t,s){const o=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of tT){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Wa(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Wa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const hO="_container_z4i38_1",gO="_header_z4i38_5",vO="_headerActions_z4i38_17",yO="_searchInput_z4i38_23",bO="_searchHighlight_z4i38_56",_O="_groupToggle_z4i38_62",xO="_groupToggleActive_z4i38_89",kO="_addButton_z4i38_93",SO="_taskRow_z4i38_120",jO="_selected_z4i38_140",wO="_expandArrow_z4i38_150",TO="_expanded_z4i38_157",NO="_leafSpacer_z4i38_161",CO="_taskStatusIcon_z4i38_166",EO="_taskTitle_z4i38_170",AO="_workspaceBadge_z4i38_177",DO="_childCountBadge_z4i38_195",MO="_dependencyBadge_z4i38_208",RO="_blockedBadge_z4i38_220",IO="_addChildButton_z4i38_225",OO="_emptyState_z4i38_268",LO="_statusGroupHeader_z4i38_275",BO="_statusGroupIcon_z4i38_294",$O="_statusGroupLabel_z4i38_298",zO="_statusGroupCount_z4i38_303",Qe={container:hO,header:gO,headerActions:vO,searchInput:yO,searchHighlight:bO,groupToggle:_O,groupToggleActive:xO,addButton:kO,taskRow:SO,selected:jO,expandArrow:wO,expanded:TO,leafSpacer:NO,taskStatusIcon:CO,taskTitle:EO,workspaceBadge:AO,childCountBadge:DO,dependencyBadge:MO,blockedBadge:RO,addChildButton:IO,emptyState:OO,statusGroupHeader:LO,statusGroupIcon:BO,statusGroupLabel:$O,statusGroupCount:zO},HO=[{name:"title",weight:2},{name:"description",weight:1}],X1=16,PO=16,Q1="grackle-task-group-by-status";function r_(){try{return localStorage.getItem(Q1)==="true"}catch{return!1}}function UO(t){try{localStorage.setItem(Q1,String(t))}catch{}}function VO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:Qe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${Qe.expandArrow} ${s?Qe.expanded:""}`,"aria-hidden":"true",children:a.jsx(ga,{size:We})}),a.jsx("span",{className:Qe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:Qe.statusGroupLabel,children:t.label}),a.jsx("span",{className:Qe.statusGroupCount,children:t.tasks.length})]}),a.jsx(is,{children:s&&a.jsx(Ct.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=Wa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(Pn(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:_=>{_.currentTarget===_.target&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c(Pn(p.id)))},className:`${Qe.taskRow} ${g?Qe.selected:""}`,style:{"--task-indent":`${X1}px`},"data-task-id":p.id,children:[a.jsx("span",{className:Qe.leafSpacer}),a.jsx("span",{className:Qe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ml(p.status)}`,children:m.icon}),a.jsx("span",{className:Qe.taskTitle,title:p.title,children:a.jsx(W1,{text:p.title,indices:d.get(p.id),highlightClass:Qe.searchHighlight})}),v&&a.jsx("span",{className:Qe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ek({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Wa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),_=o.has(t.id),b=t.children.length>0,x=c===t.id,k=X1+s*PO,w=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(Pn(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(Pn(t.id)))},className:`${Qe.taskRow} ${x?Qe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[b&&a.jsx("span",{className:`${Qe.expandArrow} ${_?Qe.expanded:""}`,role:"button",tabIndex:0,"aria-label":_?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:a.jsx(ga,{size:We,"aria-hidden":"true"})}),!b&&a.jsx("span",{className:Qe.leafSpacer}),a.jsx("span",{className:Qe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ml(t.status)}`,children:g.icon}),a.jsx("span",{className:Qe.taskTitle,title:t.title,children:a.jsx(W1,{text:t.title,indices:p.get(t.id),highlightClass:Qe.searchHighlight})}),w&&a.jsx("span",{className:Qe.workspaceBadge,title:w,children:w}),b&&a.jsxs("span",{className:Qe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${Qe.dependencyBadge} ${v?Qe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<K2&&a.jsx(Bi,{text:"Add child task",children:a.jsx("button",{onClick:T=>{T.stopPropagation(),d(Hi(t.workspaceId,t.id))},"aria-label":"Add child task",className:Qe.addChildButton,children:"+"})})]}),a.jsx(is,{children:b&&_&&a.jsx(Ct.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>a.jsx(ek,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function qO({workspaces:t,tasks:s}){const o=ut(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(r_),[g,v]=y.useState(r_),[_,b]=y.useState(new Map),x=Ot("/tasks/:taskId/*"),k=(x==null?void 0:x.params.taskId)!=="new"?x==null?void 0:x.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(W=>[W.id,W.status])),[s]),w=y.useMemo(()=>new Map(t.map(W=>[W.id,W.name])),[t]),T=()=>{const W=!p;UO(W),m(W),W&&(v(!0),b(new Map))},C=W=>{b(re=>{const $=new Map(re),B=$.has(W)?$.get(W):g;return $.set(W,!B),$})},D=W=>_.has(W)?_.get(W):g,O=W=>{c(re=>{const $=new Set(re);return $.has(W)?($.delete(W),u(B=>new Set(B).add(W))):($.add(W),u(B=>{const se=new Set(B);return se.delete(W),se})),$})};y.useEffect(()=>{const W=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));W.size>0&&c(re=>{const $=new Set(re);for(const B of W)d.has(B)||$.add(B);return $})},[s,d]);const[E,M]=y.useState(""),{directMatchTaskIds:L,treeMatchTaskIds:A,titleHighlights:P}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const W=F2(s,E,HO),re=new Set(W.map(oe=>oe.item.id)),$=new Map;for(const oe of W){const X=oe.matches.find(ce=>ce.key==="title");X&&$.set(oe.item.id,X.indices)}const B=new Set(re),se=new Map(s.map(oe=>[oe.id,oe]));for(const oe of[...re]){let X=se.get(oe);for(;X!=null&&X.parentTaskId;)B.add(X.parentTaskId),X=se.get(X.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:B,titleHighlights:$}},[E,s]),Y=L!==null,q=Y?p?L:A:null,ee=q?s.filter(W=>q.has(W.id)):s,le=p?[]:pO(ee);return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx(Bi,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${Qe.groupToggle} ${p?Qe.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(bw,{size:Vt})})}),a.jsx(Bi,{text:"New task",children:a.jsx("button",{className:Qe.addButton,onClick:()=>o(Hi()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:W=>M(W.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Qe.searchInput,"data-testid":"sidebar-search"}),p?mO(ee,j).map(W=>a.jsx(VO,{group:W,isExpanded:D(W.status),onToggle:()=>C(W.status),selectedTaskId:k,navigate:o,titleHighlights:P,workspaceNames:w},W.status)):le.map(W=>a.jsx(ek,{node:W,depth:0,expandedTasks:r,toggleTask:O,selectedTaskId:k,navigate:o,taskStatusById:j,titleHighlights:P,workspaceNames:w},W.id)),ee.length===0&&!Y&&a.jsx("div",{className:Qe.emptyState,children:"No tasks yet. Click + to create one."}),ee.length===0&&Y&&a.jsx("div",{className:Qe.emptyState,children:"No matching tasks"})]})}const GO="_toast_ed2dk_1",FO="_success_ed2dk_18",KO="_icon_ed2dk_22",ZO="_error_ed2dk_25",YO="_warning_ed2dk_32",JO="_info_ed2dk_38",WO="_message_ed2dk_53",XO="_close_ed2dk_60",Fr={toast:GO,success:FO,icon:KO,error:ZO,warning:YO,info:JO,message:WO,close:XO},QO={success:a.jsx($i,{size:kt}),error:a.jsx(Ls,{size:kt}),warning:a.jsx(Nm,{size:kt}),info:a.jsx(Tm,{size:kt})};function eL({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Ct.div,{className:`${Fr.toast} ${Fr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[a.jsx("span",{className:Fr.icon,"aria-hidden":"true",children:QO[t.variant]}),a.jsx("span",{className:Fr.message,children:t.message}),a.jsx("button",{type:"button",className:Fr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]})}const tL="_container_qqse2_1",nL={container:tL};function sL({toasts:t,onDismiss:s}){return a.jsx("div",{className:nL.container,"data-testid":"toast-container",children:a.jsx(is,{children:t.map(o=>a.jsx(eL,{toast:o,onDismiss:s},o.id))})})}const aL="_callout_e5awm_1",iL="_success_e5awm_11",oL="_icon_e5awm_15",rL="_error_e5awm_18",lL="_warning_e5awm_25",cL="_info_e5awm_32",dL="_content_e5awm_48",uL="_close_e5awm_53",Kr={callout:aL,success:iL,icon:oL,error:rL,warning:lL,info:cL,content:dL,close:uL},fL={success:a.jsx($i,{size:kt}),error:a.jsx(Ls,{size:kt}),warning:a.jsx(Nm,{size:kt}),info:a.jsx(Tm,{size:kt})};function pL({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Kr.callout,Kr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Kr.icon,"aria-hidden":"true",children:fL[t]}),a.jsx("span",{className:Kr.content,children:s}),o&&a.jsx("button",{type:"button",className:Kr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]})})}function mL({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(pL,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",a.jsx("code",{children:c})]})})}const hL="_container_de44x_1",gL="_emptyState_de44x_8",vL="_card_de44x_14",yL="_cardClickable_de44x_34",bL="_cardHeader_de44x_42",_L="_categoryBadge_de44x_54",xL="_findingTitle_de44x_62",kL="_findingDate_de44x_68",SL="_findingContent_de44x_80",jL="_tags_de44x_86",wL="_tag_de44x_86",vs={container:hL,emptyState:gL,card:vL,cardClickable:yL,cardHeader:bL,categoryBadge:_L,findingTitle:xL,findingDate:kL,findingContent:SL,tags:jL,tag:wL};function tk({findings:t,onFindingClick:s}){return t.length===0?a.jsx("div",{className:vs.emptyState,children:"No findings yet. Agents will post discoveries here."}):a.jsx("div",{className:vs.container,children:t.map((o,r)=>{const c=jd(o.category),d=s?Ct.button:Ct.div;return a.jsxs(d,{type:s?"button":void 0,className:`${vs.card} ${s?vs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[a.jsxs("div",{className:vs.cardHeader,children:[a.jsx("span",{className:vs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),a.jsx("span",{className:vs.findingTitle,children:o.title}),a.jsx("span",{className:vs.findingDate,title:o.createdAt,children:Go(o.createdAt)})]}),a.jsx("div",{className:vs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&a.jsx("div",{className:vs.tags,children:o.tags.map(u=>a.jsx("span",{className:vs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const TL="_container_m1fsr_1",NL="_heading_m1fsr_7",CL="_section_m1fsr_14",EL="_sectionTitle_m1fsr_26",AL="_sectionDescription_m1fsr_35",DL="_emptyState_m1fsr_41",ML="_tokenList_m1fsr_48",RL="_tokenRow_m1fsr_55",IL="_tokenBadge_m1fsr_68",OL="_tokenName_m1fsr_83",LL="_tokenTarget_m1fsr_90",BL="_deleteButton_m1fsr_99",$L="_addForm_m1fsr_113",zL="_formRow_m1fsr_119",HL="_input_m1fsr_125",PL="_select_m1fsr_155",UL="_addButton_m1fsr_187",VL="_emptyStateInfo_m1fsr_221",qL="_themeOptions_m1fsr_229",GL="_themeOption_m1fsr_229",FL="_themeOptionSelected_m1fsr_254",KL="_themeOptionHeader_m1fsr_259",ZL="_themeOptionLabel_m1fsr_266",YL="_themeOptionDesc_m1fsr_273",JL="_variantToggle_m1fsr_279",WL="_variantButton_m1fsr_286",XL="_variantActive_m1fsr_305",QL="_themeSwatches_m1fsr_311",eB="_themeSwatch_m1fsr_311",tB="_systemToggle_m1fsr_325",nB="_systemToggleHint_m1fsr_341",sB="_themeActive_m1fsr_348",aB="_aboutGrid_m1fsr_354",iB="_aboutItem_m1fsr_360",oB="_aboutLabel_m1fsr_373",rB="_aboutValue_m1fsr_379",lB="_aboutDot_m1fsr_387",cB="_aboutDotConnected_m1fsr_394",dB="_aboutDotDisconnected_m1fsr_398",uB="_aboutDotConnecting_m1fsr_402",pe={container:TL,heading:NL,section:CL,sectionTitle:EL,sectionDescription:AL,emptyState:DL,tokenList:ML,tokenRow:RL,tokenBadge:IL,tokenName:OL,tokenTarget:LL,deleteButton:BL,addForm:$L,formRow:zL,input:HL,select:PL,addButton:UL,emptyStateInfo:VL,themeOptions:qL,themeOption:GL,themeOptionSelected:FL,themeOptionHeader:KL,themeOptionLabel:ZL,themeOptionDesc:YL,variantToggle:JL,variantButton:WL,variantActive:XL,themeSwatches:QL,themeSwatch:eB,systemToggle:tB,systemToggleHint:nB,themeActive:sB,aboutGrid:aB,aboutItem:iB,aboutLabel:oB,aboutValue:rB,aboutDot:lB,aboutDotConnected:cB,aboutDotDisconnected:dB,aboutDotConnecting:uB},fB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function pB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,_]=y.useState(""),[b,x]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),_("")},j=T=>{x(T)},w=()=>{b&&(o(b),r==null||r("Token deleted","info")),x(null)};return a.jsxs(a.Fragment,{children:[a.jsx(xs,{isOpen:b!==null,title:"Delete Token?",description:b?`"${b}" will be permanently removed.`:void 0,onConfirm:w,onCancel:()=>x(null)}),a.jsxs("section",{className:pe.section,children:[a.jsx("h3",{className:pe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:pe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:pe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:pe.tokenList,children:t.map(T=>a.jsxs("div",{className:pe.tokenRow,children:[a.jsx("span",{className:pe.tokenBadge,children:T.tokenType}),a.jsx("span",{className:pe.tokenName,children:T.name}),a.jsx("span",{className:pe.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),a.jsx("button",{className:pe.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]},T.name))}),a.jsxs("form",{className:pe.addForm,onSubmit:k,children:[a.jsxs("div",{className:pe.formRow,children:[a.jsx("input",{className:pe.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),a.jsx("input",{className:pe.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),a.jsxs("div",{className:pe.formRow,children:[a.jsx("select",{className:pe.select,value:m,onChange:T=>g(T.target.value),children:fB.map(T=>a.jsx("option",{value:T.value,children:T.label},T.value))}),a.jsx("input",{className:pe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>_(T.target.value)}),a.jsx("button",{className:pe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Gd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],nk=new Set(Gd.map(t=>t.id)),l_="grackle";function _m(t){return Gd.find(s=>s.id===t)}function mB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:pe.section,children:[a.jsx("h3",{className:pe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:pe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:pe.themeOptions,children:Gd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return a.jsxs("button",{type:"button",className:`${pe.themeOption} ${p?pe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:pe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:pe.themeOptionLabel,children:d.label}),a.jsx("span",{className:pe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:pe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${p&&m?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${p&&!m?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:pe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:pe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:pe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:pe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:pe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const hB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},gB={connected:pe.aboutDotConnected,connecting:pe.aboutDotConnecting,disconnected:pe.aboutDotDisconnected};function vB({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:pe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:pe.sectionTitle,children:"About"}),a.jsx("p",{className:pe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:pe.aboutGrid,children:[a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:pe.aboutValue,children:[a.jsx("span",{className:`${pe.aboutDot} ${gB[t]}`}),hB[t]]})]}),a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:pe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:pe.aboutValue,children:d})]}),a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Version"}),a.jsx("span",{className:pe.aboutValue,children:"0.114.0"})]})]})]})}const yB="_container_cddyd_1",bB="_header_cddyd_8",_B="_headerTitle_cddyd_35",xB="_badge_cddyd_44",kB="_headerActions_cddyd_54",SB="_body_cddyd_61",jB="_formContent_cddyd_73",wB="_section_cddyd_85",TB="_label_cddyd_91",NB="_titleInput_cddyd_98",CB="_descriptionTextarea_cddyd_131",EB="_parentContext_cddyd_167",AB="_parentLabel_cddyd_175",DB="_parentName_cddyd_182",MB="_personaSelect_cddyd_186",RB="_depList_cddyd_220",IB="_depItem_cddyd_226",OB="_depItemSelected_cddyd_248",LB="_noDeps_cddyd_252",BB="_btnPrimary_cddyd_258",$B="_btnGhost_cddyd_289",at={container:yB,header:bB,headerTitle:_B,badge:xB,headerActions:kB,body:SB,formContent:jB,section:wB,label:TB,titleInput:NB,descriptionTextarea:CB,parentContext:EB,parentLabel:AB,parentName:DB,personaSelect:MB,depList:RB,depItem:IB,depItemSelected:OB,noDeps:LB,btnPrimary:BB,btnGhost:$B};function sk({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:_}){const b=ut(),x=t==="edit",k=x&&s?d.find(_e=>_e.id===s):void 0,j=x?(k==null?void 0:k.workspaceId)??"":o??"",[w,T]=y.useState(j),C=j||w,D=u.find(_e=>_e.id===C),O=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!x&&!o,M=x?(k==null?void 0:k.parentTaskId)??"":r??"",L=M?d.find(_e=>_e.id===M):void 0,[A,P]=y.useState((k==null?void 0:k.title)??""),[Y,q]=y.useState((k==null?void 0:k.description)??""),[ee,le]=y.useState((k==null?void 0:k.dependsOn)??[]),[W,re]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[$,B]=y.useState((k==null?void 0:k.canDecompose)??!1),[se,oe]=y.useState(!1),X=y.useRef(!1);y.useEffect(()=>{x&&k&&!X.current&&(X.current=!0,P(k.title),q(k.description),le(k.dependsOn),re(k.defaultPersonaId),B(k.canDecompose))},[x,k]);const ce=d.filter(_e=>_e.workspaceId===C&&(!x||_e.id!==s)&&_e.id!==M),fe=A.trim().length>0&&(!x||k!==void 0)&&C.length>0,ge=_e=>{le(qe=>qe.includes(_e)?qe.filter(Bt=>Bt!==_e):[...qe,_e])},Ae=()=>{!fe||se||x&&k===void 0||(x&&s?(g(s,A.trim(),Y,ee,W),_==null||_("Task updated","success"),v?v():b(Pn(s,void 0,C,O),{replace:!0})):(oe(!0),m(C,A.trim(),Y,ee.length>0?ee:void 0,M||void 0,W,$,()=>{_==null||_("Task created","success"),b(o?Xa(o,O):"/tasks",{replace:!0})},_e=>{_==null||_(_e,"error"),oe(!1)})))},vt=()=>{if(v){v();return}b(x&&s?Pn(s,void 0,C,O):o?Xa(o,O):"/tasks")},wt=x?"edit task":M?"child task":"new task";return a.jsxs("div",{className:at.container,children:[a.jsxs("div",{className:at.header,children:[a.jsxs("div",{className:at.headerTitle,children:[a.jsx("span",{className:at.badge,children:wt}),L&&a.jsxs("span",{className:at.parentContext,children:[a.jsx("span",{className:at.parentLabel,children:"Child of"}),a.jsx("span",{className:at.parentName,children:L.title})]})]}),a.jsxs("div",{className:at.headerActions,children:[a.jsx("button",{onClick:Ae,disabled:!fe||se,className:at.btnPrimary,"data-testid":"task-edit-save",children:se?"Creating…":x?"Save Changes":"Create"}),a.jsx("button",{onClick:vt,className:at.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:at.body,children:a.jsxs("div",{className:at.formContent,children:[E&&a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:w,onChange:_e=>T(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(_e=>a.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:A,onChange:_e=>P(_e.target.value),placeholder:"Task title...",autoFocus:!0,className:at.titleInput,"data-testid":"task-edit-title",onKeyDown:_e=>{_e.key==="Enter"&&fe&&Ae()}})]}),a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:_e=>q(_e.target.value),placeholder:"Describe the task... (markdown supported)",className:at.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:W,onChange:_e=>re(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(_e=>a.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),!x&&a.jsx("div",{className:at.section,children:a.jsxs("label",{className:at.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:$,onChange:_e=>B(_e.target.checked)}),"Can spawn subtasks"]})}),a.jsxs("div",{className:at.section,children:[a.jsx("div",{className:at.label,children:"Dependencies"}),ce.length===0?a.jsx("div",{className:at.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:at.depList,children:ce.map(_e=>{const qe=ee.includes(_e.id);return a.jsxs("label",{className:`${at.depItem} ${qe?at.depItemSelected:""}`,"data-testid":`dep-option-${_e.id}`,children:[a.jsx("input",{type:"checkbox",checked:qe,onChange:()=>ge(_e.id)}),_e.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",_e.status,")"]})]},_e.id)})})]})]})})]})}const zB="_actionButtons_1rjka_1",HB="_btnPrimary_1rjka_8",PB="_btnDanger_1rjka_39",UB="_btnGhost_1rjka_78",nn={actionButtons:zB,btnPrimary:HB,btnDanger:PB,btnGhost:UB};function VB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:m,className:nn.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:r,className:nn.btnPrimary,children:"Start"}),a.jsx("button",{onClick:m,className:nn.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:nn.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:u,disabled:!s,className:nn.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:nn.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:c,className:nn.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return a.jsx("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:r,className:nn.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const qB="_workpadSection_y8nj9_1",GB="_workpadLabel_y8nj9_9",FB="_workpadStatus_y8nj9_17",KB="_workpadSummary_y8nj9_23",ZB="_workpadExtra_y8nj9_29",Ga={workpadSection:qB,workpadLabel:GB,workpadStatus:FB,workpadSummary:KB,workpadExtra:ZB};function YB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),a.jsx("div",{className:Ga.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:Ga.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:Ga.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:Ga.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const JB="_overviewDashboard_r05qm_1",WB="_overviewHero_r05qm_7",XB="_statusBadge_r05qm_14",QB="_statusPending_r05qm_26",e8="_statusAssigned_r05qm_31",t8="_statusInProgress_r05qm_36",n8="_statusReview_r05qm_41",s8="_statusDone_r05qm_46",a8="_statusFailed_r05qm_51",i8="_statusWaitingInput_r05qm_56",o8="_overviewBranchPill_r05qm_61",r8="_branchLink_r05qm_76",l8="_overviewSection_r05qm_87",c8="_overviewLabel_r05qm_93",d8="_overviewValue_r05qm_100",u8="_overviewMuted_r05qm_105",f8="_overviewMarkdown_r05qm_111",p8="_envRow_r05qm_180",m8="_envDot_r05qm_186",h8="_envDotGreen_r05qm_193",g8="_envDotYellow_r05qm_197",v8="_envDotRed_r05qm_201",y8="_envDotGray_r05qm_205",b8="_depList_r05qm_209",_8="_depItem_r05qm_215",x8="_depBlocked_r05qm_222",k8="_depDone_r05qm_226",S8="_timeline_r05qm_230",j8="_timelineRow_r05qm_236",w8="_timelineKey_r05qm_243",T8="_timelineValue_r05qm_249",N8="_timelineDelta_r05qm_253",C8="_reviewNotes_r05qm_264",be={overviewDashboard:JB,overviewHero:WB,statusBadge:XB,statusPending:QB,statusAssigned:e8,statusInProgress:t8,statusReview:n8,statusDone:s8,statusFailed:a8,statusWaitingInput:i8,overviewBranchPill:o8,branchLink:r8,overviewSection:l8,overviewLabel:c8,overviewValue:d8,overviewMuted:u8,overviewMarkdown:f8,envRow:p8,envDot:m8,envDotGreen:h8,envDotYellow:g8,envDotRed:v8,envDotGray:y8,depList:b8,depItem:_8,depBlocked:x8,depDone:k8,timeline:S8,timelineRow:j8,timelineKey:w8,timelineValue:T8,timelineDelta:N8,reviewNotes:C8};function Zc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function $p(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function c_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function E8({status:t}){const s=Wa(t),o=eT(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function A8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,_=r.find(k=>k.id===t.workspaceId),b=o.find(k=>k.id===d),x=t.branch&&(_!=null&&_.repoUrl)?`${_.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(E8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:x?a.jsxs("a",{href:x,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(Cd,{remarkPlugins:[Ed],children:t.description})})]}),t.workpad&&a.jsx(YB,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):b?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(b.status)}`,title:b.status,"aria-label":`Status: ${b.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:b.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(k=>{const j=s.get(k),w=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${w?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:w?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??k})]},k)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=$p(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.assignedAt)}),k!==void 0&&a.jsx("span",{className:be.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=$p(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.startedAt)}),k!==void 0&&a.jsx("span",{className:be.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=$p(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.completedAt)}),k!==void 0&&a.jsx("span",{className:be.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Ms(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Ms(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Po(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Po(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Ms((u==null?void 0:u.costMillicents)??0)," / ",Ms(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function D8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:pe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:pe.heading,children:"Plugins"}),a.jsxs("div",{className:pe.section,children:[a.jsx("p",{className:pe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:pe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:pe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:pe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:pe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:pe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:pe.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function M8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[_,b]=y.useState(!1),[x,k]=y.useState(!1),[j,w]=y.useState(!1),[T,C]=y.useState(null),D=t.find(A=>A.id===T),O=async A=>{if(A.preventDefault(),!(!p.trim()||!g.trim())){k(!0);try{await o(p.trim(),g.trim(),"",_),u==null||u("GitHub account added","success"),m(""),v(""),b(!1)}catch(P){const Y=P instanceof Error?P.message:"Failed to add account";u==null||u(Y,"error")}finally{k(!1)}}},E=async A=>{try{await r(A,{isDefault:!0}),u==null||u("Default account updated","success")}catch(P){const Y=P instanceof Error?P.message:"Failed to update account";u==null||u(Y,"error")}},M=async()=>{if(T)try{await c(T),u==null||u("GitHub account removed","info")}catch(A){const P=A instanceof Error?A.message:"Failed to remove account";u==null||u(P,"error")}finally{C(null)}},L=async()=>{w(!0);try{const A=await d();A.imported>0?u==null||u(`Imported ${A.imported} account(s): ${A.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(A){const P=A instanceof Error?A.message:"Import failed";u==null||u(P,"error")}finally{w(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(xs,{isOpen:T!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{M().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:pe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:pe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:pe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:pe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:pe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:pe.tokenList,children:t.map(A=>a.jsxs("div",{className:pe.tokenRow,"data-testid":`github-account-row-${A.id}`,children:[A.isDefault&&a.jsx("span",{className:pe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:pe.tokenName,children:A.label}),A.username&&a.jsxs("span",{className:pe.tokenTarget,children:["@",A.username]}),!A.isDefault&&a.jsx("button",{className:pe.deleteButton,onClick:()=>{E(A.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${A.label} as default`,"data-testid":`github-account-set-default-${A.id}`,children:a.jsx(Zw,{size:Vt,"aria-hidden":"true"})}),a.jsx("button",{className:pe.deleteButton,onClick:()=>C(A.id),title:`Remove ${A.label}`,"aria-label":`Remove ${A.label}`,"data-testid":`github-account-remove-${A.id}`,children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]},A.id))}),a.jsxs("form",{className:pe.addForm,onSubmit:A=>{O(A).catch(()=>{})},children:[a.jsxs("div",{className:pe.formRow,children:[a.jsx("input",{className:pe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:A=>m(A.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:pe.input,type:"password",placeholder:"Personal access token",value:g,onChange:A=>v(A.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:pe.formRow,children:[a.jsxs("label",{className:pe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:_,onChange:A=>b(A.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:pe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||x,"data-testid":"github-account-add-button",children:x?"Adding...":"Add Account"}),a.jsx("button",{className:pe.addButton,type:"button",onClick:()=>{L().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const R8="_container_legrg_1",I8="_header_legrg_8",O8="_headerTitle_legrg_35",L8="_badge_legrg_44",B8="_headerActions_legrg_54",$8="_body_legrg_61",z8="_formContent_legrg_73",H8="_section_legrg_85",P8="_label_legrg_91",U8="_nameInput_legrg_98",V8="_fieldInput_legrg_131",q8="_adapterSelect_legrg_164",G8="_readOnlyValue_legrg_198",F8="_codespaceSection_legrg_204",K8="_codespaceActions_legrg_210",Z8="_creatingHint_legrg_216",Y8="_errorHint_legrg_222",J8="_btnPrimary_legrg_235",W8="_btnGhost_legrg_266",ie={container:R8,header:I8,headerTitle:O8,badge:L8,headerActions:B8,body:$8,formContent:z8,section:H8,label:P8,nameInput:U8,fieldInput:V8,adapterSelect:q8,readOnlyValue:G8,codespaceSection:F8,codespaceActions:K8,creatingHint:Z8,errorHint:Y8,btnPrimary:J8,btnGhost:W8},ld=1,cd=65535;function zp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=ld&&s<=cd}function Hp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function X8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[_,b]=y.useState(""),[x,k]=y.useState("");return g==="create"?a.jsxs("div",{className:ie.codespaceSection,children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Repository"}),a.jsx("input",{type:"text",value:_,onChange:j=>b(j.target.value),placeholder:"owner/repo",className:ie.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:x,onChange:j=>k(j.target.value),placeholder:"Machine type (optional)...",className:ie.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:ie.codespaceActions,children:[a.jsx("button",{onClick:()=>{_.trim()&&(m(_.trim(),x.trim()||void 0),v("pick"),b(""),k(""))},disabled:!_.trim(),className:ie.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),b(""),k("")},className:ie.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:ie.codespaceSection,children:a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:ie.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:ie.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ie.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:ie.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:ie.errorHint,children:d})]})})}function ak({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_,onListDockerContainers:b,dockerContainers:x,dockerContainersError:k,onShowToast:j}){const w=ut(),T=t==="edit",C=T&&s?o.find(H=>H.id===s):void 0,[D,O]=y.useState(""),[E,M]=y.useState("local"),[L,A]=y.useState(""),[P,Y]=y.useState(""),[q,ee]=y.useState(""),[le,W]=y.useState(""),[re,$]=y.useState(""),[B,se]=y.useState(""),[oe,X]=y.useState(""),[ce,fe]=y.useState(""),[ge,Ae]=y.useState("create"),[vt,wt]=y.useState(""),[_e,qe]=y.useState(null),Bt=y.useCallback(()=>{const H={};if(E==="local"){if(L.trim()&&(H.host=L.trim()),P.trim()){const ve=Number(P);Number.isInteger(ve)&&(H.port=ve)}}else if(E==="ssh"){if(H.host=L.trim(),q.trim()&&(H.user=q.trim()),P.trim()){const ve=Number(P);Number.isInteger(ve)&&(H.sshPort=ve)}le.trim()&&(H.identityFile=le.trim())}else E==="docker"?ge==="attach"?vt.trim()&&(H.attach=vt.trim()):(re.trim()&&(H.image=re.trim()),B.trim()&&(H.repo=B.trim())):E==="codespace"&&(H.codespaceName=oe.trim());return H},[E,L,P,q,le,re,B,oe,ge,vt]),Wt=()=>!(!D.trim()||E==="ssh"&&!L.trim()||E==="codespace"&&!oe.trim()||E==="docker"&&ge==="attach"&&!vt.trim()||(E==="local"||E==="ssh")&&!zp(P)),de=()=>{Wt()&&(c(D.trim(),E,Bt(),ce||void 0),j==null||j("Environment added successfully","success"),w(Ho,{replace:!0}))},Ue=()=>{w(s?Li(s):Ho)},yt=y.useCallback((H,ve)=>{if(!C||!s)return;const tt=Hp(C.adapterConfig),Dt=ve.trim();Dt?tt[H]=Dt:delete tt[H],d(s,{adapterConfig:tt})},[C,s,d]),At=y.useCallback((H,ve)=>{if(!C||!s)return;const tt=Hp(C.adapterConfig);if(ve.trim()){const Dt=Number(ve);Number.isInteger(Dt)&&Dt>=ld&&Dt<=cd&&(tt[H]=Dt)}else delete tt[H];d(s,{adapterConfig:tt})},[C,s,d]);if(T){if(!C)return a.jsxs("div",{className:ie.container,children:[a.jsxs("div",{className:ie.header,children:[a.jsx("div",{className:ie.headerTitle,children:a.jsx("span",{className:ie.badge,children:"edit environment"})}),a.jsx("div",{className:ie.headerActions,children:a.jsx("button",{onClick:Ue,className:ie.btnGhost,children:"Back"})})]}),a.jsx("div",{className:ie.body,children:a.jsx("div",{className:ie.formContent,children:a.jsx("span",{className:ie.readOnlyValue,children:"Environment not found"})})})]});const H=Hp(C.adapterConfig);return a.jsxs("div",{className:ie.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:ie.header,children:[a.jsx("div",{className:ie.headerTitle,children:a.jsx("span",{className:ie.badge,children:"edit environment"})}),a.jsx("div",{className:ie.headerActions,children:a.jsx("button",{onClick:Ue,className:ie.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:ie.body,children:a.jsxs("div",{className:ie.formContent,children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Name"}),a.jsx(Pt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:_e,onActivate:qe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Adapter Type"}),a.jsx("span",{className:ie.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:ie.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Host"}),a.jsx(Pt,{value:String(H.host??""),onSave:ve=>yt("host",ve),mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Port"}),a.jsx(Pt,{value:String(H.port??""),onSave:ve=>At("port",ve),validate:ve=>zp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Host"}),a.jsx(Pt,{value:String(H.host??""),onSave:ve=>yt("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:qe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"User"}),a.jsx(Pt,{value:String(H.user??""),onSave:ve=>yt("user",ve),mode:"edit",fieldId:"user",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"SSH Port"}),a.jsx(Pt,{value:String(H.sshPort??""),onSave:ve=>At("sshPort",ve),validate:ve=>zp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:_e,onActivate:qe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Identity File"}),a.jsx(Pt,{value:String(H.identityFile??""),onSave:ve=>yt("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:_e,onActivate:qe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&H.attach!==void 0&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Attach (container)"}),a.jsx(Pt,{value:String(H.attach??""),onSave:ve=>yt("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:_e,onActivate:qe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&H.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Image"}),a.jsx(Pt,{value:String(H.image??""),onSave:ve=>yt("image",ve),mode:"edit",fieldId:"image",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Repo"}),a.jsx(Pt,{value:String(H.repo??""),onSave:ve=>yt("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:_e,onActivate:qe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Codespace Name"}),a.jsx(Pt,{value:String(H.codespaceName??""),onSave:ve=>yt("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:_e,onActivate:qe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:ie.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:ie.header,children:[a.jsx("div",{className:ie.headerTitle,children:a.jsx("span",{className:ie.badge,children:"new environment"})}),a.jsxs("div",{className:ie.headerActions,children:[a.jsx("button",{onClick:de,disabled:!Wt(),className:ie.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Ue,className:ie.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:ie.body,children:a.jsxs("div",{className:ie.formContent,children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:H=>O(H.target.value),placeholder:"Environment name...",autoFocus:!0,className:ie.nameInput,"data-testid":"env-create-name",onKeyDown:H=>{H.key==="Enter"&&Wt()&&de()}})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:H=>{M(H.target.value),H.target.value==="codespace"&&u(ce||void 0)},className:ie.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:H=>{fe(H.target.value),E==="codespace"&&u(H.target.value||void 0)},className:ie.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(H=>a.jsxs("option",{value:H.id,children:[H.label," (@",H.username,")",H.isDefault?" — default":""]},H.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:H=>A(H.target.value),placeholder:"Host (optional)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:ld,max:cd,value:P,onChange:H=>Y(H.target.value),placeholder:"Port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:H=>A(H.target.value),placeholder:"Host (required)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:q,onChange:H=>ee(H.target.value),placeholder:"User (optional)...",className:ie.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:ld,max:cd,value:P,onChange:H=>Y(H.target.value),placeholder:"SSH port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:H=>W(H.target.value),placeholder:"Identity file (optional)...",className:ie.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:ge,onChange:H=>{const ve=H.target.value;Ae(ve),ve==="attach"&&b()},className:ie.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),ge==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:re,onChange:H=>$(H.target.value),placeholder:"Image (optional)...",className:ie.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:H=>se(H.target.value),placeholder:"Repo (optional)...",className:ie.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Container"}),!k&&x.length>0&&a.jsxs("select",{value:vt,onChange:H=>{wt(H.target.value),H.target.value&&!D.trim()&&O(H.target.value)},className:ie.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),x.map(H=>a.jsxs("option",{value:H.name,children:[H.name," (",H.image,") ",H.status]},H.id))]}),(k||x.length===0)&&a.jsxs(a.Fragment,{children:[k?a.jsx("span",{className:ie.errorHint,children:k}):a.jsx("span",{className:ie.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:vt,onChange:H=>{wt(H.target.value),H.target.value&&!D.trim()&&O(H.target.value)},placeholder:"Enter container name/ID...",className:ie.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(X8,{codespaceName:oe,onCodespaceNameChange:X,envName:D,onEnvNameChange:O,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_})]})})]})}const Q8="_group_1iprv_1",e7="_groupTitle_1iprv_8",t7="_shortcutList_1iprv_17",n7="_shortcutRow_1iprv_23",s7="_keys_1iprv_36",a7="_kbd_1iprv_43",i7="_description_1iprv_60",Ai={group:Q8,groupTitle:e7,shortcutList:t7,shortcutRow:n7,keys:s7,kbd:a7,description:i7},o7=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function r7(){return a.jsxs("section",{className:pe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:pe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:pe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),o7.map(t=>a.jsxs("div",{className:Ai.group,children:[a.jsx("h4",{className:Ai.groupTitle,children:t.title}),a.jsx("div",{className:Ai.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:Ai.shortcutRow,children:[a.jsx("span",{className:Ai.keys,children:s.keys.map(o=>a.jsx("kbd",{className:Ai.kbd,children:o},o))}),a.jsx("span",{className:Ai.description,children:s.description})]},s.description))})]},t.title))]})}const l7=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function c7({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:pe.section,children:[a.jsx("h3",{className:pe.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:pe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:pe.tokenList,children:l7.map(r=>a.jsxs("div",{className:pe.tokenRow,children:[a.jsx("span",{className:pe.tokenName,children:r.label}),a.jsx("span",{className:pe.tokenTarget,children:r.description}),a.jsx("select",{className:pe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const d7="_container_10efq_1",u7="_header_10efq_7",f7="_list_10efq_105",p7="_card_10efq_111",m7="_cardHeader_10efq_125",h7="_cardTitle_10efq_135",g7="_defaultBadge_10efq_141",v7="_cardActions_10efq_155",y7="_description_10efq_160",b7="_meta_10efq_166",_7="_empty_10efq_212",x7="_typeBadge_10efq_362",ns={container:d7,header:u7,list:f7,card:p7,cardHeader:m7,cardTitle:h7,defaultBadge:g7,cardActions:v7,description:y7,meta:b7,empty:_7,typeBadge:x7};function k7({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:ns.container,children:[a.jsxs("div",{className:ns.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(cn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ns.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ns.list,children:t.map(v=>{const _=s===v.id,b=v.type==="script";return a.jsxs("div",{className:ns.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ns.cardHeader,children:[a.jsxs("span",{className:ns.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ns.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:b?"Script":"Agent"}),_&&a.jsx("span",{className:ns.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ns.cardActions,onClick:x=>x.stopPropagation(),children:[!_&&a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ns.description,children:v.description}),a.jsxs("div",{className:ns.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(xs,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const S7="_container_uy08i_1",j7="_header_uy08i_7",w7="_count_uy08i_13",T7="_presets_uy08i_18",N7="_presetButton_uy08i_24",C7="_filterInput_uy08i_41",E7="_groups_uy08i_53",A7="_group_uy08i_53",D7="_groupHeader_uy08i_68",M7="_groupName_uy08i_77",R7="_groupCount_uy08i_81",I7="_toolList_uy08i_87",O7="_toolItem_uy08i_95",L7="_toolName_uy08i_103",xn={container:S7,header:j7,count:w7,presets:T7,presetButton:N7,filterInput:C7,groups:E7,group:A7,groupHeader:D7,groupName:M7,groupCount:R7,toolList:I7,toolItem:O7,toolName:L7},B7=(()=>{const t=new Map;for(const s of I_){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),$7=[{name:"default",label:"Default",tools:R_},{name:"worker",label:"Worker",tools:Z2},{name:"orchestrator",label:"Orchestrator",tools:Y2},{name:"admin",label:"Admin",tools:J2}];function d_({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const _=new Set(d);_.has(v)?_.delete(v):_.add(v),s([..._].sort())},[d,s,o]),p=y.useCallback((v,_)=>{if(o)return;const b=new Set(d);for(const x of v)_?b.delete(x):b.add(x);s([...b].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:xn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:xn.header,children:a.jsx("span",{className:xn.count,children:t.length===0?`Using default (${R_.length} tools)`:`${t.length} of ${I_.size} tools selected`})}),a.jsxs("div",{className:xn.presets,"data-testid":"mcp-tool-presets",children:[$7.map(v=>a.jsx("button",{type:"button",className:xn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:xn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:xn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:xn.groups,children:B7.map(({group:v,tools:_})=>{const b=g?_.filter(k=>k.toLowerCase().includes(g)):_;if(b.length===0)return null;const x=b.every(k=>d.has(k));return a.jsxs("div",{className:xn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:xn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:x,onChange:()=>p(b,x),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:xn.groupName,children:v}),a.jsxs("span",{className:xn.groupCount,children:["(",b.filter(k=>d.has(k)).length,"/",b.length,")"]})]}),a.jsx("div",{className:xn.toolList,children:b.map(k=>a.jsxs("label",{className:xn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),a.jsx("span",{className:xn.toolName,children:k})]},k))})]},v)})})]})}const z7="_container_1gfuq_1",H7="_header_1gfuq_7",P7="_list_1gfuq_19",U7="_card_1gfuq_25",V7="_cardHeader_1gfuq_40",q7="_cardTitle_1gfuq_46",G7="_statusBadge_1gfuq_56",F7="_enabled_1gfuq_68",K7="_disabled_1gfuq_71",Z7="_cardActions_1gfuq_75",Y7="_cardMeta_1gfuq_80",J7="_empty_1gfuq_98",ss={container:z7,header:H7,list:P7,card:U7,cardHeader:V7,cardTitle:q7,statusBadge:G7,enabled:F7,disabled:K7,cardActions:Z7,cardMeta:Y7,empty:J7};function W7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(b=>b.id===u):void 0,g=async b=>{await o(b),p(null)},v=y.useMemo(()=>{const b=new Map;for(const x of s)b.set(x.id,x.name);return b},[s]),_=b=>v.get(b)??b;return a.jsxs("div",{className:ss.container,children:[a.jsxs("div",{className:ss.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(cn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ss.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ss.list,children:t.map(b=>a.jsxs("div",{className:ss.card,"data-testid":`schedule-card-${b.id}`,onClick:()=>d(b.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(b.id))},children:[a.jsxs("div",{className:ss.cardHeader,children:[a.jsxs("span",{className:ss.cardTitle,children:[a.jsx("strong",{children:b.title}),a.jsx("span",{className:`${ss.statusBadge} ${b.enabled?ss.enabled:ss.disabled}`,"data-testid":`schedule-status-badge-${b.id}`,children:b.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ss.cardActions,onClick:x=>x.stopPropagation(),children:[a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(b.id,{enabled:!b.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${b.id}`,title:b.enabled?"Disable schedule":"Enable schedule",children:b.enabled?"Disable":"Enable"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>d(b.id),"data-testid":`schedule-edit-${b.id}`,children:"Edit"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>p(b.id),"data-testid":`schedule-delete-${b.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ss.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${b.id}`,children:b.scheduleExpression}),b.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${b.id}`,children:["Persona: ",_(b.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${b.id}`,children:["Last run: ",b.lastRunAt?Go(b.lastRunAt):"Never"]}),b.enabled&&b.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${b.id}`,children:["Next run: ",J1(b.nextRunAt)]}):null,b.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${b.id}`,children:["Runs: ",b.runCount]})]})]},b.id))}),a.jsx(xs,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const X7="_nav_1bhou_1",Q7="_tab_1bhou_24",e$="_tabIcon_1bhou_62",t$="_tabActive_1bhou_68",Yc={nav:X7,tab:Q7,tabIcon:e$,tabActive:t$},oa=[{path:"credentials",label:"Credentials",icon:a.jsx(pw,{size:kt})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(ow,{size:kt})},{path:"personas",label:"Personas",icon:a.jsx(Ww,{size:kt})},{path:"schedules",label:"Schedules",icon:a.jsx(Bj,{size:kt})},{path:"appearance",label:"Appearance",icon:a.jsx(Rw,{size:kt})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(hw,{size:kt})},{path:"plugins",label:"Plugins",icon:a.jsx(zw,{size:kt})},{path:"about",label:"About",icon:a.jsx(Tm,{size:kt})}];function n$(){var u;const t=an(),s=ut(),o=y.useRef(null),r=((u=oa.find(p=>{const m=`${Ii}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??oa[0].path,c=y.useCallback(p=>{s(`${Ii}/${p}`)},[s]),d=y.useCallback(p=>{var x,k;const m=(x=o.current)==null?void 0:x.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:oa.findIndex(j=>j.path===r);let _=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),_=(v+1)%oa.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),_=(v-1+oa.length)%oa.length;else if(p.key==="Home")p.preventDefault(),_=0;else if(p.key==="End")p.preventDefault(),_=oa.length-1;else return;const b=oa[_].path;s(`${Ii}/${b}`),(k=m[_])==null||k.focus()},[r,s]);return a.jsx("nav",{className:Yc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:oa.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Yc.tab} ${m?Yc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Yc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const s$=["lifecycle:","pipe:","stdin:"];function ik(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function a$(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function i$(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=a$(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const o$="_container_16qkd_1",r$="_header_16qkd_7",l$="_title_16qkd_15",c$="_headerActions_16qkd_21",d$="_internalsToggle_16qkd_27",u$="_refreshButton_16qkd_37",f$="_state_16qkd_52",p$="_group_16qkd_59",m$="_groupHeader_16qkd_63",h$="_row_16qkd_72",g$="_selected_16qkd_92",v$="_kindBadge_16qkd_96",y$="_kindChatroom_16qkd_108",b$="_kindPipe_16qkd_114",_$="_kindChannel_16qkd_120",x$="_streamName_16qkd_126",k$="_meta_16qkd_135",sn={container:o$,header:r$,title:l$,headerActions:c$,internalsToggle:d$,refreshButton:u$,state:f$,group:p$,groupHeader:m$,row:h$,selected:g$,kindBadge:v$,kindChatroom:y$,kindPipe:b$,kindChannel:_$,streamName:x$,meta:k$},S$={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function j$({kind:t}){return t==="chatroom"?a.jsx(Nw,{size:We,"aria-hidden":"true"}):t==="pipe"?a.jsx(aw,{size:We,"aria-hidden":"true"}):a.jsx(lw,{size:We,"aria-hidden":"true"})}function w$({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v}){const _=i$(t,s),b={chatroom:sn.kindChatroom,pipe:sn.kindPipe,channel:sn.kindChannel},x=k=>{var j;return((j=o.find(w=>w.id===k))==null?void 0:j.title)??k};return a.jsxs("div",{className:sn.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:sn.header,children:[a.jsx("span",{className:sn.title,children:"Coordination"}),a.jsxs("div",{className:sn.headerActions,children:[a.jsxs("label",{className:sn.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:k=>p(k.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:sn.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(Pw,{size:We,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:sn.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:sn.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:sn.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(k=>a.jsxs("div",{className:sn.group,children:[a.jsx("div",{className:sn.groupHeader,children:k.taskId?x(k.taskId):"Unattached / external (CLI · MCP)"}),k.streams.map(j=>{const w=ik(j),T=j.id===m;return a.jsxs("button",{type:"button",className:`${sn.row}${T?` ${sn.selected}`:""}`,onClick:()=>g(j.id),"data-testid":`coordination-row-${j.id}`,"aria-current":T?"page":void 0,children:[a.jsxs("span",{className:`${sn.kindBadge} ${b[w]}`,children:[a.jsx(j$,{kind:w})," ",S$[w]]}),a.jsx("span",{className:sn.streamName,children:j.name}),a.jsxs("span",{className:sn.meta,children:[j.subscriberCount," ",j.subscriberCount===1?"sub":"subs"," ","·"," ",j.messageBufferDepth," buffered"]})]},j.id)})]},k.taskId??"__orphans__"))]})}const T$="_panel_iibrt_1",N$="_header_iibrt_24",C$="_title_iibrt_33",E$="_closeButton_iibrt_43",A$="_body_iibrt_57",D$="_section_iibrt_63",M$="_sectionLabel_iibrt_67",R$="_metaRow_iibrt_76",I$="_metaKey_iibrt_84",O$="_metaValue_iibrt_90",L$="_subscriberCard_iibrt_99",B$="_subscriberHeader_iibrt_107",$$="_sessionLink_iibrt_114",z$="_badges_iibrt_132",H$="_badgeRw_iibrt_150 _badge_iibrt_132",P$="_badgeR_iibrt_150 _badge_iibrt_132",U$="_badgeW_iibrt_162 _badge_iibrt_132",V$="_badgeAsync_iibrt_168 _badge_iibrt_132",q$="_badgeSync_iibrt_174 _badge_iibrt_132",G$="_badgeDetach_iibrt_178 _badge_iibrt_132",F$="_spawnTag_iibrt_184 _badge_iibrt_132",K$="_fdNumber_iibrt_189",Z$="_emptySubscribers_iibrt_195",Y$="_metaValueMono_iibrt_201 _metaValue_iibrt_90",J$="_placeholder_iibrt_207",W$="_advanced_iibrt_216",X$="_advancedSummary_iibrt_220",Pe={panel:T$,header:N$,title:C$,closeButton:E$,body:A$,section:D$,sectionLabel:M$,metaRow:R$,metaKey:I$,metaValue:O$,subscriberCard:L$,subscriberHeader:B$,sessionLink:$$,badges:z$,badgeRw:H$,badgeR:P$,badgeW:U$,badgeAsync:V$,badgeSync:q$,badgeDetach:G$,spawnTag:F$,fdNumber:K$,emptySubscribers:Z$,metaValueMono:Y$,placeholder:J$,advanced:W$,advancedSummary:X$},Q$={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function ez({permission:t}){const s=t==="rw"?Pe.badgeRw:t==="r"?Pe.badgeR:Pe.badgeW;return a.jsx("span",{className:s,children:t})}function tz({mode:t}){const s=t==="async"?Pe.badgeAsync:t==="detach"?Pe.badgeDetach:Pe.badgeSync;return a.jsx("span",{className:s,children:t})}function nz({stream:t,onClose:s}){const o=ut();return y.useEffect(()=>{const r=c=>{c.key==="Escape"&&s()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[s]),a.jsxs("div",{className:Pe.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:Pe.header,children:[a.jsx("h3",{className:Pe.title,children:t.name}),a.jsx("button",{type:"button",className:Pe.closeButton,onClick:s,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:Pe.body,children:[a.jsxs("div",{className:Pe.section,children:[a.jsx("div",{className:Pe.sectionLabel,children:"Overview"}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Kind"}),a.jsx("span",{className:Pe.metaValue,children:Q$[ik(t)]})]}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Participants"}),a.jsx("span",{className:Pe.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Buffered"}),a.jsxs("span",{className:Pe.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:Pe.section,children:[a.jsx("div",{className:Pe.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:Pe.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(r=>a.jsxs("div",{className:Pe.subscriberCard,"data-testid":`subscriber-card-${r.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:Pe.sessionLink,onClick:()=>{o(Ld(r.sessionId))},title:r.sessionId,children:[r.sessionId.slice(0,12),"…"]}),r.createdBySpawn&&a.jsx("span",{className:Pe.spawnTag,children:"spawn"})]},r.subscriptionId))]}),a.jsxs("div",{className:Pe.section,children:[a.jsx("div",{className:Pe.sectionLabel,children:"Conversation"}),a.jsx("div",{className:Pe.placeholder,"data-testid":"stream-conversation-placeholder",children:"Live conversation view — coming in V2."})]}),a.jsxs("details",{className:Pe.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:Pe.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Stream ID"}),a.jsx("span",{className:Pe.metaValueMono,children:t.id})]}),t.subscribers.map(r=>a.jsxs("div",{className:Pe.subscriberCard,children:[a.jsxs("div",{className:Pe.subscriberHeader,children:[a.jsxs("span",{className:Pe.fdNumber,children:["fd ",r.fd]}),a.jsxs("span",{className:Pe.metaValueMono,title:r.subscriptionId,children:[r.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:Pe.badges,children:[a.jsx(ez,{permission:r.permission}),a.jsx(tz,{mode:r.deliveryMode})]})]},r.subscriptionId))]})]})]})}function sz({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(Ny.map(d=>[d,[]]));for(const d of t){const u=ml(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let _;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?_="Needs input":k==="completed"&&(_="Ready to complete")}const b={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:_},x=c.get(u);x?x.push(b):c.get("not_started").push(b)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Ny.map(d=>{const u=Wa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const az="_boardContainer_1c4y1_1",iz="_column_1c4y1_17",oz="_columnHeader_1c4y1_34",rz="_columnIcon_1c4y1_47",lz="_columnLabel_1c4y1_52",cz="_columnCount_1c4y1_57",dz="_cardList_1c4y1_67",uz="_emptyPlaceholder_1c4y1_76",fz="_card_1c4y1_67",pz="_cardHeader_1c4y1_107",mz="_cardStatusIcon_1c4y1_113",hz="_cardTitle_1c4y1_119",gz="_cardBadges_1c4y1_127",vz="_badge_1c4y1_134",yz="_blockedBadge_1c4y1_146",bz="_childBadge_1c4y1_151",_z="_depBadge_1c4y1_155",xz="_parentBadge_1c4y1_159",kz="_pausedSubBadge_1c4y1_166",Sz="_personaBadge_1c4y1_170",jz="_envBadge_1c4y1_174",wz="_emptyCta_1c4y1_178",Tz="_ctaButton_1c4y1_188",Nz="_ctaDescription_1c4y1_204",lt={boardContainer:az,column:iz,columnHeader:oz,columnIcon:rz,columnLabel:lz,columnCount:cz,cardList:dz,emptyPlaceholder:uz,card:fz,cardHeader:pz,cardStatusIcon:mz,cardTitle:hz,cardBadges:gz,badge:vz,blockedBadge:yz,childBadge:bz,depBadge:_z,parentBadge:xz,pausedSubBadge:kz,personaBadge:Sz,envBadge:jz,emptyCta:wz,ctaButton:Tz,ctaDescription:Nz};function Cz({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=ut(),p=y.useMemo(()=>o.filter(b=>b.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(b=>[b.id,b.status])),[o]),g=y.useMemo(()=>new Map(p.map(b=>[b.id,b])),[p]),v=y.useMemo(()=>{const b=new Map(r.map(C=>[C.id,C])),x=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),j=new Map,w=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=b.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const O=x.get(D.personaId);O&&w.set(C.id,O.name)}if(D.environmentId){const O=k.get(D.environmentId);O&&T.set(C.id,O.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:w,environmentNameByTaskId:T}},[p,r,c,d]),_=y.useMemo(()=>sz({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:lt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:lt.ctaButton,onClick:()=>u(Hi(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:lt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:lt.boardContainer,"data-testid":"board-container",children:_.map(b=>a.jsxs("section",{className:lt.column,"data-testid":`board-column-${b.status}`,"aria-label":`${b.label}, ${b.tasks.length} ${b.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:lt.columnHeader,children:[a.jsx("span",{className:lt.columnIcon,style:{color:b.style.color},children:b.style.icon}),a.jsx("span",{className:lt.columnLabel,children:b.label}),a.jsx("span",{className:lt.columnCount,"data-testid":`board-count-${b.status}`,children:b.tasks.length})]}),a.jsx("div",{className:lt.cardList,children:b.tasks.length===0?a.jsx("div",{className:lt.emptyPlaceholder,children:"No tasks"}):a.jsx(is,{mode:"popLayout",children:b.tasks.map(x=>a.jsx(Ct.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(Ez,{boardTask:x,tasksById:g,personaName:v.personaNameByTaskId.get(x.task.id),envName:v.environmentNameByTaskId.get(x.task.id),onClick:()=>u(Pn(x.task.id,void 0,t,s))})},x.task.id))})})]},b.status))})}function Ez({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Wa(d.status),_=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:lt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c())},children:[a.jsxs("div",{className:lt.cardHeader,children:[a.jsx("span",{className:lt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:lt.cardTitle,children:d.title})]}),a.jsxs("div",{className:lt.cardBadges,children:[_&&a.jsx("span",{className:`${lt.badge} ${lt.parentBadge}`,title:_.title,children:_.title}),p>0&&a.jsxs("span",{className:`${lt.badge} ${lt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${lt.badge} ${lt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${lt.badge} ${lt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${lt.badge} ${lt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${lt.badge} ${lt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${lt.badge} ${lt.envBadge}`,children:r})]})]})}const Az="_formContent_ymnez_1",Dz="_section_ymnez_13",Mz="_label_ymnez_19",Rz="_titleInput_ymnez_26",Iz="_descriptionTextarea_ymnez_58",Oz="_selectField_ymnez_94",Lz="_checkboxRow_ymnez_128",Bz="_checkboxLabel_ymnez_141",$z="_fieldError_ymnez_146",xt={formContent:Az,section:Dz,label:Mz,titleInput:Rz,descriptionTextarea:Iz,selectField:Oz,checkboxRow:Lz,checkboxLabel:Bz,fieldError:$z};function zz(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const Hz=100;function Pz({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:xt.formContent,children:[a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:Hz,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:xt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&a.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:xt.section,children:a.jsxs("label",{className:xt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:xt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const ok=y.createContext(void 0),Uz=4e3;function Vz({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=Uz)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(ok.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function gn(){const t=y.useContext(ok);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const xm="grackle-theme",rk="grackle-prefer-system",lk="(prefers-color-scheme: dark)";let Xr=[],dd;function Pp(){dd=void 0;for(const t of Xr)t()}function km(){return typeof window>"u"?!1:window.matchMedia(lk).matches}function al(){if(typeof localStorage>"u")return l_;try{const t=localStorage.getItem(xm);if(t!==null&&nk.has(t))return t}catch{}return l_}function wd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(rk)==="true"}catch{return!1}}function Sm(t){return Gd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function ck(t,s){const o=_m(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?km()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=Sm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return km()?r.variantDarkId:r.variantLightId}return t}function Io(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=ck(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Io(al(),wd());function qz(){return dd===void 0&&(dd={themeId:al(),systemDark:km(),preferSystem:wd()}),dd}function Gz(t){return Xr=[...Xr,t],()=>{Xr=Xr.filter(s=>s!==t)}}function Fz(){const t=y.useSyncExternalStore(Gz,qz),{themeId:s,preferSystem:o}=t,r=ck(s,o),c=y.useCallback(u=>{if(nk.has(u)){try{localStorage.setItem(xm,u)}catch{}Io(u,wd(),!0),Pp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(rk,u?"true":"false")}catch{}if(u){const p=al(),m=_m(p);if(m!=null&&m.hidden){const g=Sm(p);if(g)try{localStorage.setItem(xm,g.id)}catch{}}}Io(al(),u,!0),Pp()},[]);return y.useEffect(()=>{Io(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(lk),p=()=>{const m=al(),g=wd();if(g){const v=_m(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Io(m,g),v!=null&&v.hidden){const _=Sm(m);_!=null&&_.variantDarkId&&_.variantLightId&&Io(m,g)}}Pp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const dk=y.createContext(void 0);function Kz({children:t}){const s=Fz();return a.jsx(dk.Provider,{value:s,children:t})}function uk(){const t=y.useContext(dk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const fk=y.createContext(void 0),pk=y.createContext(void 0);function Zz({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(pk.Provider,{value:r,children:a.jsx(fk.Provider,{value:s,children:t})})}function Yz(){return y.useContext(fk)}function Jz(){const t=y.useContext(pk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const _h=y.createContext(void 0);function ot(){const t=y.useContext(_h);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function mk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function hk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function Wz(t){return mk(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const Xz=new Set(["off","subscription","api_key"]),Jc=new Set(["off","on"]);function Qz(t){return mk(t)&&Xz.has(t.claude)&&Jc.has(t.github)&&Jc.has(t.copilot)&&Jc.has(t.codex)&&Jc.has(t.goose)}function gk(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function vk(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Ro=5e3;function eH(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const ha={label:"Home",url:Zo};function tH(t){return t?[ha,{label:"Settings",url:Ii},{label:t,url:void 0}]:[ha,{label:"Settings",url:void 0}]}const xh={label:"Environments",url:Ho};function nH(){return[ha,{label:"Environments",url:void 0}]}function sH(){return[ha,{label:"New Chat",url:void 0}]}function aH(t){return[ha,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function iH(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[ha,xh,{label:(d==null?void 0:d.displayName)??"Environment",url:Li(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function oH(t,s,o,r,c){const d=eH(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(x=>x.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(x=>x.id===g):void 0,_=[ha];v&&g&&(_.push(xh),_.push({label:v.displayName,url:Li(g)})),m&&g&&_.push({label:m.name,url:Xa(m.id,g)});for(let x=0;x<d.length-1;x++)_.push({label:d[x].title,url:Pn(d[x].id,void 0,p,g)});const b=d[d.length-1];return _.push({label:(b==null?void 0:b.title)??t,url:void 0}),_}const rH={label:"Findings",url:Bd};function lH(){return[ha,{label:"Findings",url:void 0}]}function yk(t,s,o,r,c){const d=[ha];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(xh),p&&d.push({label:p.displayName,url:Li(o)}),u&&d.push({label:u.name,url:Xa(s,o)}),d.push({label:"Findings",url:oC(s,o)})}else d.push(rH);return d.push({label:t,url:void 0}),d}function kh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Wc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function cH(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function Sh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const _=s.get(v),b=_?Wc(_):void 0;if(b)try{const x=JSON.parse(v.content);o.set(b,{tool:x.tool,args:x.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,_)=>{if(v.eventType!=="tool_result")return v;const b=s.get(v),x=b?cH(b):void 0;if(!x)return v;const k=o.get(x);if(!k)return v;r.add(x),c.add(_);let j;const w=v.content.trim();if(w.startsWith("{"))try{const T=JSON.parse(w);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const _=s.get(d[v]),b=_?Wc(_):void 0;b&&r.has(b)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const _=p[m];if(_!==v+1)continue;const b=d[v],x=d[_];let k;try{const j=JSON.parse(b.content);k={tool:j.tool,args:j.args}}catch{}if(k){let j;const w=x.content.trim();if(w.startsWith("{"))try{const D=JSON.parse(w);typeof D.detailedContent=="string"&&(j=D.detailedContent)}catch{}d[_]={...x,toolUseCtx:{...k,detailedResult:j}},c.add(_);const T=s.get(b),C=T?Wc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(b,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const _=s.get(v);if(!_)return!0;const b=Wc(_);if(b&&r.has(b))return!1;const x=_.__seqId;return!(x&&r.has(x))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let _=!1;for(let b=v+1;b<g.length;b++)if(g[b].eventType!=="tool_use"){_=!0;break}_&&(g[v]={...g[v],settled:!0})}return g}function dH(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=bk(s),d=s.filter(m=>jm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||jm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function bk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function jm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function uH(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=bk(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):jm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function fH(t,s){const o=new Map;for(const r of s)o.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function pH(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const As=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
328
+ --- End forwarded ---`}function kI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function SI({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,j)=>{if(j&&u.current!==void 0){const w=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let O=w;O<=T;O++)O<t.length&&pl(t[O])&&D.add(O);return D})}else d(w=>{const T=new Set(w);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),_=y.useCallback(()=>{const k=new Set;for(let j=0;j<t.length;j++)pl(t[j])&&k.add(j);d(k)},[t]),b=y.useCallback(()=>{d(new Set)},[]),x=y.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const w=s(j);try{return await navigator.clipboard.writeText(w),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:_,deselectAll:b,copySelected:x}}const jI="_wrapper_1cdza_1",wI="_scrollContainer_1cdza_9",TI="_selectingPadding_1cdza_16",NI="_toolbar_1cdza_20",CI="_directionToggle_1cdza_27",EI="_scrollToAnchor_1cdza_65",AI="_scrollToAnchorBottom_1cdza_89",DI="_scrollToAnchorTop_1cdza_93",MI="_eventOverflowWarning_1cdza_97",ra={wrapper:jI,scrollContainer:wI,selectingPadding:TI,toolbar:NI,directionToggle:CI,scrollToAnchor:EI,scrollToAnchorBottom:AI,scrollToAnchorTop:DI,eventOverflowWarning:MI},RI=10*1024,II=new Set(["running","idle"]);function OI(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const F1="grackle-stream-direction";function LI(){try{return localStorage.getItem(F1)==="reversed"}catch{return!1}}function BI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:ra.eventOverflowWarning,role:"alert",children:[a.jsx(Nm,{size:Vt,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function yh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[_,b]=y.useState(LI),x=Y3(),[k,j]=y.useState(!1),[w,T]=y.useState(!1),[C,D]=y.useState(void 0),O=SI({events:t,formatForClipboard:G1}),E=y.useMemo(()=>t.filter(pl).length,[t]),M=y.useMemo(()=>c?c.filter(ce=>II.has(ce.status)&&ce.id!==d):[],[c,d]),L=y.useMemo(()=>_?[...t].reverse():t,[t,_]),{isAtAnchor:A,scrollToAnchor:P}=yI({scrollRef:v,contentLength:t.length,isReversed:_,paused:O.isSelecting}),Y=()=>{const ce=!_;b(ce);try{localStorage.setItem(F1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!O.isSelecting)return;const ce=fe=>{fe.key==="Escape"&&!k&&!w&&O.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[O.isSelecting,O.cancelSelection,k,w]);const q=y.useCallback(async()=>{await O.copySelected()&&(r==null||r(`Copied ${O.selectedCount} message${O.selectedCount===1?"":"s"} to clipboard`,"success"))},[O,r]),ee=y.useCallback(()=>[...O.selectedIndices].sort((fe,ge)=>fe-ge).filter(fe=>fe<t.length).map(fe=>t[fe]),[O.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const fe=c==null?void 0:c.find(Ae=>Ae.id===ce);if(!fe)return ce.slice(0,8);const ge=u==null?void 0:u.find(Ae=>Ae.id===fe.environmentId);return(ge==null?void 0:ge.displayName)??fe.environmentId.slice(0,8)},[c,u]),W=y.useCallback(async(ce,fe)=>{if(!m)return;const ge=le(ce);try{await m(ce,fe);const Ae=O.selectedCount;r==null||r(`Forwarded ${Ae} message${Ae===1?"":"s"} to ${ge}`,"success"),O.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,O]),re=y.useCallback(ce=>{j(!1);const fe=ee(),ge=le(d),Ae=xI(ge,fe);if(new TextEncoder().encode(Ae).length>RI){D({sessionId:ce,text:Ae}),T(!0);return}W(ce,Ae).catch(()=>{})},[ee,le,d,W]),$=y.useCallback(()=>{T(!1),C&&(W(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,W]),B=y.useCallback(()=>{T(!1),D(void 0)},[]),se=x?0:.2,oe=_?-8:8,X=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:ra.wrapper,children:[a.jsx("div",{className:ra.toolbar,children:a.jsx(Bi,{text:_?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:ra.directionToggle,onClick:Y,"aria-label":_?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:_?a.jsx(wy,{size:Vt,"aria-hidden":"true"}):a.jsx(Ty,{size:Vt,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${ra.scrollContainer} ${O.isSelecting?ra.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(BI,{eventsDropped:s}),a.jsx(is,{initial:!1,children:L.map((ce,fe)=>{const ge=_?t.length-1-fe:fe;return a.jsx(Ct.div,{initial:{opacity:0,y:oe},animate:{opacity:1,y:0},transition:{duration:se,ease:"easeOut"},children:a.jsx($6,{copyText:_I(ce),isContentBearing:pl(ce),isSelecting:O.isSelecting,isSelected:O.selectedIndices.has(ge),checkboxLabel:OI(ce),onSelect:()=>{O.enterSelectionMode(ge)},onToggle:Ae=>{O.toggleEvent(ge,Ae)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(SD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${ge}`)})})]}),a.jsx(is,{children:O.isSelecting&&a.jsx(K6,{selectedCount:O.selectedCount,totalSelectable:E,onSelectAll:O.selectAll,onDeselectAll:O.deselectAll,onCopy:()=>{q().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:M.length===0,onCancel:O.cancelSelection})}),a.jsx(hI,{isOpen:k,sessions:M,environments:u??[],personas:p,onSelect:re,onCancel:()=>{j(!1)}}),a.jsx(xs,{isOpen:w,title:"Send large message?",description:`This will forward a large message (${X} KB). Continue?`,confirmLabel:"Send",onConfirm:$,onCancel:B}),a.jsx(is,{children:!A&&a.jsxs(Ct.button,{className:`${ra.scrollToAnchor} ${_?ra.scrollToAnchorTop:ra.scrollToAnchorBottom}`,onClick:P,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[_?a.jsx(Ty,{size:Vt,"aria-hidden":"true"}):a.jsx(wy,{size:Vt,"aria-hidden":"true"})," New events"]})})]})}function bh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[_,b]=y.useState(""),x=y.useRef(!1),k=d===c,j=y.useCallback(L=>{v(L),b("")},[]),w=y.useCallback(()=>{b("")},[]),T=y.useCallback(()=>{x.current=!1,u==null||u(null),v(""),b("")},[u]),C=y.useCallback(()=>{const L=m?g.trim():g;if(r){const P=r(g);if(P){b(P);return}}const A=m?s.trim():s;if(L===A){T();return}o(L),T()},[g,s,m,r,o,T]),D=y.useCallback(()=>{x.current=!0,u==null||u(c),v(s),b("")},[c,s,u]),O=y.useCallback(L=>{if(x.current){x.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(L=>{L.key==="Escape"?T():L.key==="Enter"&&p&&C()},[T,p,C]),M=(()=>{if(!k)return!1;const L=m?s.trim():s;return(m?g.trim():g)!==L})();return y.useEffect(()=>{!k&&(g!==""||_!=="")&&(v(""),b(""))},[k,g,_]),{isEditing:k,draft:g,error:_,isDirty:M,startEdit:D,cancelEdit:T,save:C,setDraft:j,clearError:w,handleBlur:O,handleKeyDown:E,ignoreInitialBlurRef:x}}const $I="_editFieldWrapper_yuzty_1",zI="_editInput_yuzty_10",HI="_editTextarea_yuzty_42",PI="_editSelect_yuzty_78",UI="_editError_yuzty_111",VI="_editInputInvalid_yuzty_118",qI="_editHint_yuzty_123",GI="_unsavedDot_yuzty_132",FI="_metaValueClickable_yuzty_140",KI="_editButton_yuzty_159",ZI="_metaPlaceholder_yuzty_175",YI="_worktreeToggle_yuzty_180",it={editFieldWrapper:$I,editInput:zI,editTextarea:HI,editSelect:PI,editError:UI,editInputInvalid:VI,editHint:qI,unsavedDot:GI,metaValueClickable:FI,editButton:KI,metaPlaceholder:ZI,worktreeToggle:YI};function Pt(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:_,ariaLabel:b,"data-testid":x}=t,k=y.useRef(null),j=bh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:T,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:k,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function bm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,x=y.useRef(null),k=bh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const w=window.setTimeout(()=>{var T;(T=x.current)==null||T.focus()},0);return()=>window.clearTimeout(w)}},[k.isEditing]),c==="create"){const w=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${T?it.editInputInvalid:""}`,value:s,onChange:w,placeholder:v,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),T&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:x,className:`${it.editTextarea} ${k.error?it.editInputInvalid:""}`,value:k.draft,onChange:w=>k.setDraft(w.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:_,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),k.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),k.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:k.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function Sd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,x=y.useRef(null),k=bh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const O=window.setTimeout(()=>{var E;(E=x.current)==null||E.focus()},0);return()=>window.clearTimeout(O)}},[k.isEditing]);const j=y.useCallback(O=>{const E=O.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),w=y.useCallback(O=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:O=>m==null?void 0:m(O.target.value),"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))});if(k.isEditing)return a.jsx("select",{ref:x,className:it.editSelect,value:k.draft,onChange:j,onBlur:w,title:_,"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))});const T=g==null?void 0:g(s),C=(D=c.find(O=>O.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[T!==void 0?T:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function JI(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const WI="_nav_1snmp_1",XI="_searchForm_1snmp_8",QI="_searchInput_1snmp_15",e5="_searchButton_1snmp_33",t5="_clearButton_1snmp_68",n5="_workspaceSelect_1snmp_85",s5="_listHeader_1snmp_99",a5="_nodeList_1snmp_108",i5="_nodeItem_1snmp_116",o5="_indicator_1snmp_129",r5="_label_1snmp_136",l5="_badge_1snmp_145",ts={nav:WI,searchForm:XI,searchInput:QI,searchButton:e5,clearButton:t5,workspaceSelect:n5,listHeader:s5,nodeList:a5,nodeItem:i5,indicator:o5,label:r5,badge:l5};function c5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),_=y.useCallback(()=>{g(""),d()},[d]),b=y.useCallback(k=>{u(k)},[u]),x=y.useCallback(k=>{g(""),p(k)},[p]);return a.jsxs("div",{className:ts.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:ts.searchForm,onSubmit:v,children:[a.jsx("input",{className:ts.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:ts.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:ts.clearButton,onClick:_,children:"Clear search"}),a.jsxs("select",{className:ts.workspaceSelect,onChange:k=>{x(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>a.jsx("option",{value:k.id,children:k.name},k.id))]}),a.jsxs("div",{className:ts.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:ts.nodeList,children:t.map(k=>a.jsxs("li",{className:ts.nodeItem,onClick:()=>{b(k.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),b(k.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:ts.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:ts.label,children:k.label}),a.jsx("span",{className:ts.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const d5="_container_bwu10_1",u5="_hamburger_bwu10_33",f5="_brand_bwu10_49",p5="_brandLogo_bwu10_68",m5="_info_bwu10_75",h5="_connectionLabel_bwu10_90",g5="_connectionDot_bwu10_103",v5="_connected_bwu10_106",y5="_disconnected_bwu10_110",b5="_connecting_bwu10_113",Ds={container:d5,hamburger:u5,brand:f5,brandLogo:p5,info:m5,connectionLabel:h5,connectionDot:g5,connected:v5,disconnected:y5,connecting:b5},_5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},x5={connected:Ds.connected,connecting:Ds.connecting,disconnected:Ds.disconnected};function k5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=ut(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=_5[t];return a.jsxs("div",{className:Ds.container,children:[r&&a.jsx("button",{type:"button",className:Ds.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(Sw,{size:kt,"aria-hidden":"true"})}),a.jsx(Bi,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ds.brand,onClick:()=>d(Zo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:qd("icon-192x192.png"),alt:"",className:Ds.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ds.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ds.connectionDot} ${x5[t]}`,"aria-hidden":"true",children:a.jsx(Ja,{size:Cm,fill:"currentColor"})})," ",a.jsx("span",{className:Ds.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const S5="_nav_gx5h3_1",j5="_tab_gx5h3_35",w5="_tabIcon_gx5h3_68",T5="_tabLabel_gx5h3_79",N5="_tabActive_gx5h3_84",C5="_tabEnd_gx5h3_90",Mo={nav:S5,tab:j5,tabIcon:w5,tabLabel:T5,tabActive:N5,tabEnd:C5},rd=[{view:"dashboard",label:"Dashboard",icon:a.jsx(dw,{size:kt}),route:Zo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(Vj,{size:kt}),route:iC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(Ew,{size:kt}),route:Ho,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(ww,{size:kt}),route:aC,testId:"sidebar-tab-chat",order:3},{view:"findings",label:"Findings",icon:a.jsx(ud,{size:kt}),route:Bd,testId:"sidebar-tab-findings",order:4},{view:"knowledge",label:"Knowledge",icon:a.jsx(Oj,{size:kt}),route:dx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(Dw,{size:kt}),route:lx,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(qw,{size:kt}),route:QN,testId:"sidebar-tab-settings",align:"end"}];function E5(t){return t===Zo||t==="/"?"dashboard":t.startsWith(lx)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(dx)?"knowledge":t.startsWith(Bd)?"findings":t.startsWith(Ii)?"settings":"tasks"}function A5({tabs:t=rd}){var g;const s=an(),o=ut(),r=y.useRef(null),c=E5(s.pathname),d=y.useMemo(()=>{const v=(_,b)=>(_.order??Number.MAX_SAFE_INTEGER)-(b.order??Number.MAX_SAFE_INTEGER);return[...t.filter(_=>_.align!=="end").sort(v),...t.filter(_=>_.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,w;const _=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!_)return;const b=Array.from(_).findIndex(T=>T===document.activeElement),x=b>=0?b:d.findIndex(T=>T.view===c);let k=x;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),k=(x+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),k=(x-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),k=0;else if(v.key==="End")v.preventDefault(),k=d.length-1;else return;o(d[k].route),(w=_[k])==null||w.focus()},[c,o,d]);return a.jsx("nav",{className:Mo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const _=v.view===c,b=v.view===u;return a.jsx(Bi,{text:v.label,placement:"bottom",className:b?Mo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":_,tabIndex:_?0:-1,className:`${Mo.tab} ${_?Mo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:Mo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:Mo.tabLabel,children:v.label})]})},v.view)})})}const D5="_container_pi6ii_1",M5="_content_pi6ii_66",i_={container:D5,content:M5},R5=320,K1=220,Z1=600,Y1="grackle-sidebar-width";function I5(){try{const t=localStorage.getItem(Y1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=K1&&s<=Z1)return s}}catch{}return R5}function O5(t){try{localStorage.setItem(Y1,String(t))}catch{}}function L5({content:t}){const[s]=y.useState(I5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=K1&&m<=Z1&&O5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:i_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:i_.content,children:t})})}const B5="_bar_tnfsh_1",$5="_btnPrimary_tnfsh_32",z5="_statusText_tnfsh_85",H5="_statusCompleted_tnfsh_90",P5="_statusFailed_tnfsh_94",U5="_statusBlocked_tnfsh_98",V5="_hintText_tnfsh_103",Nt={bar:B5,btnPrimary:$5,statusText:z5,statusCompleted:H5,statusFailed:P5,statusBlocked:U5,hintText:V5};function q5({sessions:t,tasks:s,environments:o}){const r=ut(),c=an(),d=Ot("/sessions/:sessionId"),u=Ot("/tasks/:taskId"),p=Ot("/tasks/:taskId/stream"),m=Ot("/tasks/:taskId/findings"),g=Ot("/tasks/:taskId/edit"),v=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),_=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),x=Ot("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=Ot("/sessions/new"),j=Ot("/environments/:environmentId/workspaces/:workspaceId"),w=Ot("/tasks/new"),T=Ot("/chat"),C=Ot("/"),D=Ot("/settings/*"),O=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(_==null?void 0:_.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId),M=v??_??b??x,L=(M==null?void 0:M.params.environmentId)??(j==null?void 0:j.params.environmentId),A=c.pathname.startsWith("/environments")&&!j&&!M,P=!!T,Y=!!k,q=!!j&&!v&&!_&&!b&&!x,ee=!!w;if(!!C&&!Y&&!q&&!ee||!!D||(!!g||!!x)||ee||A||Y)return a.jsx(a.Fragment,{});if(P)return o.find(B=>B.adapterType==="local"&&B.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Add a local environment to start chatting"})});if(q)return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Select a task or click + to create one"})});if(E){const $=s.find(oe=>oe.id===E);if(!$)return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Loading..."})});const B=new Map(s.map(oe=>[oe.id,oe])),se=$.dependsOn.some(oe=>{const X=B.get(oe);return X!==void 0&&X.status!=="complete"});if($.status==="not_started"){const oe=se?$.dependsOn.map(X=>B.get(X)).filter(X=>X&&X.status!=="complete").map(X=>X.title):[];return a.jsx("div",{className:Nt.bar,children:se?a.jsxs("span",{className:Nt.statusBlocked,children:["Blocked by: ",oe.join(", ")]}):a.jsx("span",{className:Nt.hintText,children:"Use the buttons above to start or manage this task"})})}if($.status==="working"||$.status==="paused"){const oe=$.latestSessionId||void 0,X=oe?t.find(fe=>fe.id===oe):void 0;return X&&X.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Waiting for agent..."})})}if($.status==="complete")return a.jsxs("div",{className:Nt.bar,children:[a.jsx("span",{className:`${Nt.statusText} ${Nt.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Hi($.workspaceId,void 0,L)),className:Nt.btnPrimary,children:"+ New Task"})]});if($.status==="failed")return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:`${Nt.statusText} ${Nt.statusFailed}`,children:"Task failed"})})}if(O){const $=t.find(oe=>oe.id===O),B=($==null?void 0:$.status)==="stopped";if($!==void 0&&!B)return a.jsx(a.Fragment,{});if(B)return a.jsxs("div",{className:Nt.bar,children:[a.jsxs("span",{className:`${Nt.statusText} ${Nt.hintText}`,children:["Session ",$.endReason||$.status]}),a.jsx("button",{onClick:()=>r(ix($.environmentId)),className:Nt.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Nt.bar,children:a.jsx("span",{className:Nt.hintText,children:"Loading..."})})}const G5="_nav_14i94_1",F5="_tab_14i94_24",K5="_tabActive_14i94_62",Z5="_tabLabel_14i94_75",Y5="_statusDot_14i94_81",J5="_pulse_14i94_87",W5="_addButton_14i94_99",X5="_empty_14i94_132",qa={nav:G5,tab:F5,tabActive:K5,tabLabel:Z5,statusDot:Y5,pulse:J5,addButton:W5,empty:X5},Q5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function eO({environments:t}){const s=ut(),o=y.useRef(null),r=Ot("/environments/:environmentId"),c=Ot("/environments/:environmentId/edit"),d=Ot("/environments/:environmentId/workspaces/:workspaceId"),u=Ot("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(b=>{s(Li(b))},[s]),v=y.useCallback(b=>{var T;const x=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const k=Array.from(x).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===m);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&s(Li(t[w].id)),x[w].focus()},[m,t,s]),_=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:qa.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(b=>{const x=b.id===m,k=b.id===_,j=Q5[b.status]||"var(--text-tertiary)",w=b.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:k?0:-1,className:`${qa.tab} ${x?qa.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${qa.statusDot} ${w?qa.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(Ja,{size:Cm,fill:"currentColor"})}),a.jsx("span",{className:qa.tabLabel,title:b.displayName||b.id,children:b.displayName||b.id})]},b.id)})}),a.jsx("button",{type:"button",className:qa.addButton,onClick:()=>s(WN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:qa.empty,children:"No environments yet."})]})}function Go(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function J1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const o_={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function jd(t){return o_[t]||o_.general}const tO="_nav_dlm8m_1",nO="_categoryPills_dlm8m_24",sO="_categoryPill_dlm8m_24",aO="_tab_dlm8m_42",iO="_tabActive_dlm8m_80",oO="_tabContent_dlm8m_93",rO="_tabLabel_dlm8m_100",lO="_tabMeta_dlm8m_106",cO="_categoryDot_dlm8m_111",dO="_empty_dlm8m_118",Es={nav:tO,categoryPills:nO,categoryPill:sO,tab:aO,tabActive:iO,tabContent:oO,tabLabel:rO,tabMeta:lO,categoryDot:cO,empty:dO};function uO({findings:t,workspaceId:s,environmentId:o}){const r=ut(),c=y.useRef(null),d=Ot("/findings/:findingId"),u=Ot("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const b=new Set(t.map(x=>x.category).filter(Boolean));return Array.from(b).sort()},[t]),g=y.useCallback(b=>{r(em(b,s,o))},[r,s,o]),v=y.useCallback(b=>{var T;const x=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const k=Array.from(x).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===p);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&r(em(t[w].id,s,o)),x[w].focus()},[p,t,r,s,o]),_=p??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Es.nav,"data-testid":"findings-nav",children:[m.length>1&&a.jsx("div",{className:Es.categoryPills,"data-testid":"findings-nav-categories",children:m.map(b=>a.jsx("span",{className:Es.categoryPill,style:{color:jd(b).text},children:b},b))}),a.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(b=>{const x=b.id===p,k=b.id===_;return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:k?0:-1,className:`${Es.tab} ${x?Es.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"finding-nav-item",children:[a.jsx("span",{className:Es.categoryDot,style:{color:jd(b.category).text},"aria-hidden":"true",children:a.jsx(Ja,{size:Cm,fill:"currentColor"})}),a.jsxs("span",{className:Es.tabContent,children:[a.jsx("span",{className:Es.tabLabel,title:b.title,children:b.title}),a.jsx("span",{className:Es.tabMeta,title:b.createdAt,children:Go(b.createdAt)})]})]},b.id)})}),t.length===0&&a.jsx("div",{className:Es.empty,children:"No findings yet. Agents will post discoveries here."})]})}function fO(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function W1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=fO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function pO(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function mO(t,s){const o=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of tT){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Wa(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Wa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const hO="_container_z4i38_1",gO="_header_z4i38_5",vO="_headerActions_z4i38_17",yO="_searchInput_z4i38_23",bO="_searchHighlight_z4i38_56",_O="_groupToggle_z4i38_62",xO="_groupToggleActive_z4i38_89",kO="_addButton_z4i38_93",SO="_taskRow_z4i38_120",jO="_selected_z4i38_140",wO="_expandArrow_z4i38_150",TO="_expanded_z4i38_157",NO="_leafSpacer_z4i38_161",CO="_taskStatusIcon_z4i38_166",EO="_taskTitle_z4i38_170",AO="_workspaceBadge_z4i38_177",DO="_childCountBadge_z4i38_195",MO="_dependencyBadge_z4i38_208",RO="_blockedBadge_z4i38_220",IO="_addChildButton_z4i38_225",OO="_emptyState_z4i38_268",LO="_statusGroupHeader_z4i38_275",BO="_statusGroupIcon_z4i38_294",$O="_statusGroupLabel_z4i38_298",zO="_statusGroupCount_z4i38_303",Qe={container:hO,header:gO,headerActions:vO,searchInput:yO,searchHighlight:bO,groupToggle:_O,groupToggleActive:xO,addButton:kO,taskRow:SO,selected:jO,expandArrow:wO,expanded:TO,leafSpacer:NO,taskStatusIcon:CO,taskTitle:EO,workspaceBadge:AO,childCountBadge:DO,dependencyBadge:MO,blockedBadge:RO,addChildButton:IO,emptyState:OO,statusGroupHeader:LO,statusGroupIcon:BO,statusGroupLabel:$O,statusGroupCount:zO},HO=[{name:"title",weight:2},{name:"description",weight:1}],X1=16,PO=16,Q1="grackle-task-group-by-status";function r_(){try{return localStorage.getItem(Q1)==="true"}catch{return!1}}function UO(t){try{localStorage.setItem(Q1,String(t))}catch{}}function VO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:Qe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${Qe.expandArrow} ${s?Qe.expanded:""}`,"aria-hidden":"true",children:a.jsx(ga,{size:We})}),a.jsx("span",{className:Qe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:Qe.statusGroupLabel,children:t.label}),a.jsx("span",{className:Qe.statusGroupCount,children:t.tasks.length})]}),a.jsx(is,{children:s&&a.jsx(Ct.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=Wa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(Pn(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:_=>{_.currentTarget===_.target&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c(Pn(p.id)))},className:`${Qe.taskRow} ${g?Qe.selected:""}`,style:{"--task-indent":`${X1}px`},"data-task-id":p.id,children:[a.jsx("span",{className:Qe.leafSpacer}),a.jsx("span",{className:Qe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ml(p.status)}`,children:m.icon}),a.jsx("span",{className:Qe.taskTitle,title:p.title,children:a.jsx(W1,{text:p.title,indices:d.get(p.id),highlightClass:Qe.searchHighlight})}),v&&a.jsx("span",{className:Qe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ek({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Wa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),_=o.has(t.id),b=t.children.length>0,x=c===t.id,k=X1+s*PO,w=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(Pn(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(Pn(t.id)))},className:`${Qe.taskRow} ${x?Qe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[b&&a.jsx("span",{className:`${Qe.expandArrow} ${_?Qe.expanded:""}`,role:"button",tabIndex:0,"aria-label":_?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:a.jsx(ga,{size:We,"aria-hidden":"true"})}),!b&&a.jsx("span",{className:Qe.leafSpacer}),a.jsx("span",{className:Qe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ml(t.status)}`,children:g.icon}),a.jsx("span",{className:Qe.taskTitle,title:t.title,children:a.jsx(W1,{text:t.title,indices:p.get(t.id),highlightClass:Qe.searchHighlight})}),w&&a.jsx("span",{className:Qe.workspaceBadge,title:w,children:w}),b&&a.jsxs("span",{className:Qe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${Qe.dependencyBadge} ${v?Qe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<K2&&a.jsx(Bi,{text:"Add child task",children:a.jsx("button",{onClick:T=>{T.stopPropagation(),d(Hi(t.workspaceId,t.id))},"aria-label":"Add child task",className:Qe.addChildButton,children:"+"})})]}),a.jsx(is,{children:b&&_&&a.jsx(Ct.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>a.jsx(ek,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function qO({workspaces:t,tasks:s}){const o=ut(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(r_),[g,v]=y.useState(r_),[_,b]=y.useState(new Map),x=Ot("/tasks/:taskId/*"),k=(x==null?void 0:x.params.taskId)!=="new"?x==null?void 0:x.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(W=>[W.id,W.status])),[s]),w=y.useMemo(()=>new Map(t.map(W=>[W.id,W.name])),[t]),T=()=>{const W=!p;UO(W),m(W),W&&(v(!0),b(new Map))},C=W=>{b(re=>{const $=new Map(re),B=$.has(W)?$.get(W):g;return $.set(W,!B),$})},D=W=>_.has(W)?_.get(W):g,O=W=>{c(re=>{const $=new Set(re);return $.has(W)?($.delete(W),u(B=>new Set(B).add(W))):($.add(W),u(B=>{const se=new Set(B);return se.delete(W),se})),$})};y.useEffect(()=>{const W=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));W.size>0&&c(re=>{const $=new Set(re);for(const B of W)d.has(B)||$.add(B);return $})},[s,d]);const[E,M]=y.useState(""),{directMatchTaskIds:L,treeMatchTaskIds:A,titleHighlights:P}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const W=F2(s,E,HO),re=new Set(W.map(oe=>oe.item.id)),$=new Map;for(const oe of W){const X=oe.matches.find(ce=>ce.key==="title");X&&$.set(oe.item.id,X.indices)}const B=new Set(re),se=new Map(s.map(oe=>[oe.id,oe]));for(const oe of[...re]){let X=se.get(oe);for(;X!=null&&X.parentTaskId;)B.add(X.parentTaskId),X=se.get(X.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:B,titleHighlights:$}},[E,s]),Y=L!==null,q=Y?p?L:A:null,ee=q?s.filter(W=>q.has(W.id)):s,le=p?[]:pO(ee);return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx(Bi,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${Qe.groupToggle} ${p?Qe.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(bw,{size:Vt})})}),a.jsx(Bi,{text:"New task",children:a.jsx("button",{className:Qe.addButton,onClick:()=>o(Hi()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:W=>M(W.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Qe.searchInput,"data-testid":"sidebar-search"}),p?mO(ee,j).map(W=>a.jsx(VO,{group:W,isExpanded:D(W.status),onToggle:()=>C(W.status),selectedTaskId:k,navigate:o,titleHighlights:P,workspaceNames:w},W.status)):le.map(W=>a.jsx(ek,{node:W,depth:0,expandedTasks:r,toggleTask:O,selectedTaskId:k,navigate:o,taskStatusById:j,titleHighlights:P,workspaceNames:w},W.id)),ee.length===0&&!Y&&a.jsx("div",{className:Qe.emptyState,children:"No tasks yet. Click + to create one."}),ee.length===0&&Y&&a.jsx("div",{className:Qe.emptyState,children:"No matching tasks"})]})}const GO="_toast_ed2dk_1",FO="_success_ed2dk_18",KO="_icon_ed2dk_22",ZO="_error_ed2dk_25",YO="_warning_ed2dk_32",JO="_info_ed2dk_38",WO="_message_ed2dk_53",XO="_close_ed2dk_60",Fr={toast:GO,success:FO,icon:KO,error:ZO,warning:YO,info:JO,message:WO,close:XO},QO={success:a.jsx($i,{size:kt}),error:a.jsx(Ls,{size:kt}),warning:a.jsx(Nm,{size:kt}),info:a.jsx(Tm,{size:kt})};function eL({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Ct.div,{className:`${Fr.toast} ${Fr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[a.jsx("span",{className:Fr.icon,"aria-hidden":"true",children:QO[t.variant]}),a.jsx("span",{className:Fr.message,children:t.message}),a.jsx("button",{type:"button",className:Fr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]})}const tL="_container_qqse2_1",nL={container:tL};function sL({toasts:t,onDismiss:s}){return a.jsx("div",{className:nL.container,"data-testid":"toast-container",children:a.jsx(is,{children:t.map(o=>a.jsx(eL,{toast:o,onDismiss:s},o.id))})})}const aL="_callout_e5awm_1",iL="_success_e5awm_11",oL="_icon_e5awm_15",rL="_error_e5awm_18",lL="_warning_e5awm_25",cL="_info_e5awm_32",dL="_content_e5awm_48",uL="_close_e5awm_53",Kr={callout:aL,success:iL,icon:oL,error:rL,warning:lL,info:cL,content:dL,close:uL},fL={success:a.jsx($i,{size:kt}),error:a.jsx(Ls,{size:kt}),warning:a.jsx(Nm,{size:kt}),info:a.jsx(Tm,{size:kt})};function pL({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Kr.callout,Kr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Kr.icon,"aria-hidden":"true",children:fL[t]}),a.jsx("span",{className:Kr.content,children:s}),o&&a.jsx("button",{type:"button",className:Kr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]})})}function mL({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(pL,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",a.jsx("code",{children:c})]})})}const hL="_container_de44x_1",gL="_emptyState_de44x_8",vL="_card_de44x_14",yL="_cardClickable_de44x_34",bL="_cardHeader_de44x_42",_L="_categoryBadge_de44x_54",xL="_findingTitle_de44x_62",kL="_findingDate_de44x_68",SL="_findingContent_de44x_80",jL="_tags_de44x_86",wL="_tag_de44x_86",vs={container:hL,emptyState:gL,card:vL,cardClickable:yL,cardHeader:bL,categoryBadge:_L,findingTitle:xL,findingDate:kL,findingContent:SL,tags:jL,tag:wL};function tk({findings:t,onFindingClick:s}){return t.length===0?a.jsx("div",{className:vs.emptyState,children:"No findings yet. Agents will post discoveries here."}):a.jsx("div",{className:vs.container,children:t.map((o,r)=>{const c=jd(o.category),d=s?Ct.button:Ct.div;return a.jsxs(d,{type:s?"button":void 0,className:`${vs.card} ${s?vs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[a.jsxs("div",{className:vs.cardHeader,children:[a.jsx("span",{className:vs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),a.jsx("span",{className:vs.findingTitle,children:o.title}),a.jsx("span",{className:vs.findingDate,title:o.createdAt,children:Go(o.createdAt)})]}),a.jsx("div",{className:vs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&a.jsx("div",{className:vs.tags,children:o.tags.map(u=>a.jsx("span",{className:vs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const TL="_container_m1fsr_1",NL="_heading_m1fsr_7",CL="_section_m1fsr_14",EL="_sectionTitle_m1fsr_26",AL="_sectionDescription_m1fsr_35",DL="_emptyState_m1fsr_41",ML="_tokenList_m1fsr_48",RL="_tokenRow_m1fsr_55",IL="_tokenBadge_m1fsr_68",OL="_tokenName_m1fsr_83",LL="_tokenTarget_m1fsr_90",BL="_deleteButton_m1fsr_99",$L="_addForm_m1fsr_113",zL="_formRow_m1fsr_119",HL="_input_m1fsr_125",PL="_select_m1fsr_155",UL="_addButton_m1fsr_187",VL="_emptyStateInfo_m1fsr_221",qL="_themeOptions_m1fsr_229",GL="_themeOption_m1fsr_229",FL="_themeOptionSelected_m1fsr_254",KL="_themeOptionHeader_m1fsr_259",ZL="_themeOptionLabel_m1fsr_266",YL="_themeOptionDesc_m1fsr_273",JL="_variantToggle_m1fsr_279",WL="_variantButton_m1fsr_286",XL="_variantActive_m1fsr_305",QL="_themeSwatches_m1fsr_311",eB="_themeSwatch_m1fsr_311",tB="_systemToggle_m1fsr_325",nB="_systemToggleHint_m1fsr_341",sB="_themeActive_m1fsr_348",aB="_aboutGrid_m1fsr_354",iB="_aboutItem_m1fsr_360",oB="_aboutLabel_m1fsr_373",rB="_aboutValue_m1fsr_379",lB="_aboutDot_m1fsr_387",cB="_aboutDotConnected_m1fsr_394",dB="_aboutDotDisconnected_m1fsr_398",uB="_aboutDotConnecting_m1fsr_402",pe={container:TL,heading:NL,section:CL,sectionTitle:EL,sectionDescription:AL,emptyState:DL,tokenList:ML,tokenRow:RL,tokenBadge:IL,tokenName:OL,tokenTarget:LL,deleteButton:BL,addForm:$L,formRow:zL,input:HL,select:PL,addButton:UL,emptyStateInfo:VL,themeOptions:qL,themeOption:GL,themeOptionSelected:FL,themeOptionHeader:KL,themeOptionLabel:ZL,themeOptionDesc:YL,variantToggle:JL,variantButton:WL,variantActive:XL,themeSwatches:QL,themeSwatch:eB,systemToggle:tB,systemToggleHint:nB,themeActive:sB,aboutGrid:aB,aboutItem:iB,aboutLabel:oB,aboutValue:rB,aboutDot:lB,aboutDotConnected:cB,aboutDotDisconnected:dB,aboutDotConnecting:uB},fB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function pB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,_]=y.useState(""),[b,x]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),_("")},j=T=>{x(T)},w=()=>{b&&(o(b),r==null||r("Token deleted","info")),x(null)};return a.jsxs(a.Fragment,{children:[a.jsx(xs,{isOpen:b!==null,title:"Delete Token?",description:b?`"${b}" will be permanently removed.`:void 0,onConfirm:w,onCancel:()=>x(null)}),a.jsxs("section",{className:pe.section,children:[a.jsx("h3",{className:pe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:pe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:pe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:pe.tokenList,children:t.map(T=>a.jsxs("div",{className:pe.tokenRow,children:[a.jsx("span",{className:pe.tokenBadge,children:T.tokenType}),a.jsx("span",{className:pe.tokenName,children:T.name}),a.jsx("span",{className:pe.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),a.jsx("button",{className:pe.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]},T.name))}),a.jsxs("form",{className:pe.addForm,onSubmit:k,children:[a.jsxs("div",{className:pe.formRow,children:[a.jsx("input",{className:pe.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),a.jsx("input",{className:pe.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),a.jsxs("div",{className:pe.formRow,children:[a.jsx("select",{className:pe.select,value:m,onChange:T=>g(T.target.value),children:fB.map(T=>a.jsx("option",{value:T.value,children:T.label},T.value))}),a.jsx("input",{className:pe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>_(T.target.value)}),a.jsx("button",{className:pe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Gd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],nk=new Set(Gd.map(t=>t.id)),l_="grackle";function _m(t){return Gd.find(s=>s.id===t)}function mB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:pe.section,children:[a.jsx("h3",{className:pe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:pe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:pe.themeOptions,children:Gd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return a.jsxs("button",{type:"button",className:`${pe.themeOption} ${p?pe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:pe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:pe.themeOptionLabel,children:d.label}),a.jsx("span",{className:pe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:pe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${p&&m?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${p&&!m?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:pe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:pe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:pe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:pe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:pe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const hB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},gB={connected:pe.aboutDotConnected,connecting:pe.aboutDotConnecting,disconnected:pe.aboutDotDisconnected};function vB({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:pe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:pe.sectionTitle,children:"About"}),a.jsx("p",{className:pe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:pe.aboutGrid,children:[a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:pe.aboutValue,children:[a.jsx("span",{className:`${pe.aboutDot} ${gB[t]}`}),hB[t]]})]}),a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:pe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:pe.aboutValue,children:d})]}),a.jsxs("div",{className:pe.aboutItem,children:[a.jsx("span",{className:pe.aboutLabel,children:"Version"}),a.jsx("span",{className:pe.aboutValue,children:"0.115.1"})]})]})]})}const yB="_container_cddyd_1",bB="_header_cddyd_8",_B="_headerTitle_cddyd_35",xB="_badge_cddyd_44",kB="_headerActions_cddyd_54",SB="_body_cddyd_61",jB="_formContent_cddyd_73",wB="_section_cddyd_85",TB="_label_cddyd_91",NB="_titleInput_cddyd_98",CB="_descriptionTextarea_cddyd_131",EB="_parentContext_cddyd_167",AB="_parentLabel_cddyd_175",DB="_parentName_cddyd_182",MB="_personaSelect_cddyd_186",RB="_depList_cddyd_220",IB="_depItem_cddyd_226",OB="_depItemSelected_cddyd_248",LB="_noDeps_cddyd_252",BB="_btnPrimary_cddyd_258",$B="_btnGhost_cddyd_289",at={container:yB,header:bB,headerTitle:_B,badge:xB,headerActions:kB,body:SB,formContent:jB,section:wB,label:TB,titleInput:NB,descriptionTextarea:CB,parentContext:EB,parentLabel:AB,parentName:DB,personaSelect:MB,depList:RB,depItem:IB,depItemSelected:OB,noDeps:LB,btnPrimary:BB,btnGhost:$B};function sk({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:_}){const b=ut(),x=t==="edit",k=x&&s?d.find(_e=>_e.id===s):void 0,j=x?(k==null?void 0:k.workspaceId)??"":o??"",[w,T]=y.useState(j),C=j||w,D=u.find(_e=>_e.id===C),O=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!x&&!o,M=x?(k==null?void 0:k.parentTaskId)??"":r??"",L=M?d.find(_e=>_e.id===M):void 0,[A,P]=y.useState((k==null?void 0:k.title)??""),[Y,q]=y.useState((k==null?void 0:k.description)??""),[ee,le]=y.useState((k==null?void 0:k.dependsOn)??[]),[W,re]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[$,B]=y.useState((k==null?void 0:k.canDecompose)??!1),[se,oe]=y.useState(!1),X=y.useRef(!1);y.useEffect(()=>{x&&k&&!X.current&&(X.current=!0,P(k.title),q(k.description),le(k.dependsOn),re(k.defaultPersonaId),B(k.canDecompose))},[x,k]);const ce=d.filter(_e=>_e.workspaceId===C&&(!x||_e.id!==s)&&_e.id!==M),fe=A.trim().length>0&&(!x||k!==void 0)&&C.length>0,ge=_e=>{le(qe=>qe.includes(_e)?qe.filter(Bt=>Bt!==_e):[...qe,_e])},Ae=()=>{!fe||se||x&&k===void 0||(x&&s?(g(s,A.trim(),Y,ee,W),_==null||_("Task updated","success"),v?v():b(Pn(s,void 0,C,O),{replace:!0})):(oe(!0),m(C,A.trim(),Y,ee.length>0?ee:void 0,M||void 0,W,$,()=>{_==null||_("Task created","success"),b(o?Xa(o,O):"/tasks",{replace:!0})},_e=>{_==null||_(_e,"error"),oe(!1)})))},vt=()=>{if(v){v();return}b(x&&s?Pn(s,void 0,C,O):o?Xa(o,O):"/tasks")},wt=x?"edit task":M?"child task":"new task";return a.jsxs("div",{className:at.container,children:[a.jsxs("div",{className:at.header,children:[a.jsxs("div",{className:at.headerTitle,children:[a.jsx("span",{className:at.badge,children:wt}),L&&a.jsxs("span",{className:at.parentContext,children:[a.jsx("span",{className:at.parentLabel,children:"Child of"}),a.jsx("span",{className:at.parentName,children:L.title})]})]}),a.jsxs("div",{className:at.headerActions,children:[a.jsx("button",{onClick:Ae,disabled:!fe||se,className:at.btnPrimary,"data-testid":"task-edit-save",children:se?"Creating…":x?"Save Changes":"Create"}),a.jsx("button",{onClick:vt,className:at.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:at.body,children:a.jsxs("div",{className:at.formContent,children:[E&&a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:w,onChange:_e=>T(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(_e=>a.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:A,onChange:_e=>P(_e.target.value),placeholder:"Task title...",autoFocus:!0,className:at.titleInput,"data-testid":"task-edit-title",onKeyDown:_e=>{_e.key==="Enter"&&fe&&Ae()}})]}),a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:_e=>q(_e.target.value),placeholder:"Describe the task... (markdown supported)",className:at.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:at.section,children:[a.jsx("label",{className:at.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:W,onChange:_e=>re(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(_e=>a.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),!x&&a.jsx("div",{className:at.section,children:a.jsxs("label",{className:at.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:$,onChange:_e=>B(_e.target.checked)}),"Can spawn subtasks"]})}),a.jsxs("div",{className:at.section,children:[a.jsx("div",{className:at.label,children:"Dependencies"}),ce.length===0?a.jsx("div",{className:at.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:at.depList,children:ce.map(_e=>{const qe=ee.includes(_e.id);return a.jsxs("label",{className:`${at.depItem} ${qe?at.depItemSelected:""}`,"data-testid":`dep-option-${_e.id}`,children:[a.jsx("input",{type:"checkbox",checked:qe,onChange:()=>ge(_e.id)}),_e.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",_e.status,")"]})]},_e.id)})})]})]})})]})}const zB="_actionButtons_1rjka_1",HB="_btnPrimary_1rjka_8",PB="_btnDanger_1rjka_39",UB="_btnGhost_1rjka_78",nn={actionButtons:zB,btnPrimary:HB,btnDanger:PB,btnGhost:UB};function VB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:m,className:nn.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:r,className:nn.btnPrimary,children:"Start"}),a.jsx("button",{onClick:m,className:nn.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:nn.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:u,disabled:!s,className:nn.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:nn.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:c,className:nn.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return a.jsx("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:nn.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:r,className:nn.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:p,className:nn.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const qB="_workpadSection_y8nj9_1",GB="_workpadLabel_y8nj9_9",FB="_workpadStatus_y8nj9_17",KB="_workpadSummary_y8nj9_23",ZB="_workpadExtra_y8nj9_29",Ga={workpadSection:qB,workpadLabel:GB,workpadStatus:FB,workpadSummary:KB,workpadExtra:ZB};function YB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),a.jsx("div",{className:Ga.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:Ga.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:Ga.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:Ga.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const JB="_overviewDashboard_r05qm_1",WB="_overviewHero_r05qm_7",XB="_statusBadge_r05qm_14",QB="_statusPending_r05qm_26",e8="_statusAssigned_r05qm_31",t8="_statusInProgress_r05qm_36",n8="_statusReview_r05qm_41",s8="_statusDone_r05qm_46",a8="_statusFailed_r05qm_51",i8="_statusWaitingInput_r05qm_56",o8="_overviewBranchPill_r05qm_61",r8="_branchLink_r05qm_76",l8="_overviewSection_r05qm_87",c8="_overviewLabel_r05qm_93",d8="_overviewValue_r05qm_100",u8="_overviewMuted_r05qm_105",f8="_overviewMarkdown_r05qm_111",p8="_envRow_r05qm_180",m8="_envDot_r05qm_186",h8="_envDotGreen_r05qm_193",g8="_envDotYellow_r05qm_197",v8="_envDotRed_r05qm_201",y8="_envDotGray_r05qm_205",b8="_depList_r05qm_209",_8="_depItem_r05qm_215",x8="_depBlocked_r05qm_222",k8="_depDone_r05qm_226",S8="_timeline_r05qm_230",j8="_timelineRow_r05qm_236",w8="_timelineKey_r05qm_243",T8="_timelineValue_r05qm_249",N8="_timelineDelta_r05qm_253",C8="_reviewNotes_r05qm_264",be={overviewDashboard:JB,overviewHero:WB,statusBadge:XB,statusPending:QB,statusAssigned:e8,statusInProgress:t8,statusReview:n8,statusDone:s8,statusFailed:a8,statusWaitingInput:i8,overviewBranchPill:o8,branchLink:r8,overviewSection:l8,overviewLabel:c8,overviewValue:d8,overviewMuted:u8,overviewMarkdown:f8,envRow:p8,envDot:m8,envDotGreen:h8,envDotYellow:g8,envDotRed:v8,envDotGray:y8,depList:b8,depItem:_8,depBlocked:x8,depDone:k8,timeline:S8,timelineRow:j8,timelineKey:w8,timelineValue:T8,timelineDelta:N8,reviewNotes:C8};function Zc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function $p(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function c_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function E8({status:t}){const s=Wa(t),o=eT(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function A8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,_=r.find(k=>k.id===t.workspaceId),b=o.find(k=>k.id===d),x=t.branch&&(_!=null&&_.repoUrl)?`${_.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(E8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:x?a.jsxs("a",{href:x,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(Cd,{remarkPlugins:[Ed],children:t.description})})]}),t.workpad&&a.jsx(YB,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):b?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(b.status)}`,title:b.status,"aria-label":`Status: ${b.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:b.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(k=>{const j=s.get(k),w=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${w?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:w?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??k})]},k)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=$p(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.assignedAt)}),k!==void 0&&a.jsx("span",{className:be.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=$p(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.startedAt)}),k!==void 0&&a.jsx("span",{className:be.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=$p(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Zc(t.completedAt)}),k!==void 0&&a.jsx("span",{className:be.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Ms(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Ms(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Po(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Po(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Ms((u==null?void 0:u.costMillicents)??0)," / ",Ms(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function D8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:pe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:pe.heading,children:"Plugins"}),a.jsxs("div",{className:pe.section,children:[a.jsx("p",{className:pe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:pe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:pe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:pe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:pe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:pe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:pe.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function M8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[_,b]=y.useState(!1),[x,k]=y.useState(!1),[j,w]=y.useState(!1),[T,C]=y.useState(null),D=t.find(A=>A.id===T),O=async A=>{if(A.preventDefault(),!(!p.trim()||!g.trim())){k(!0);try{await o(p.trim(),g.trim(),"",_),u==null||u("GitHub account added","success"),m(""),v(""),b(!1)}catch(P){const Y=P instanceof Error?P.message:"Failed to add account";u==null||u(Y,"error")}finally{k(!1)}}},E=async A=>{try{await r(A,{isDefault:!0}),u==null||u("Default account updated","success")}catch(P){const Y=P instanceof Error?P.message:"Failed to update account";u==null||u(Y,"error")}},M=async()=>{if(T)try{await c(T),u==null||u("GitHub account removed","info")}catch(A){const P=A instanceof Error?A.message:"Failed to remove account";u==null||u(P,"error")}finally{C(null)}},L=async()=>{w(!0);try{const A=await d();A.imported>0?u==null||u(`Imported ${A.imported} account(s): ${A.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(A){const P=A instanceof Error?A.message:"Import failed";u==null||u(P,"error")}finally{w(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(xs,{isOpen:T!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{M().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:pe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:pe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:pe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:pe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:pe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:pe.tokenList,children:t.map(A=>a.jsxs("div",{className:pe.tokenRow,"data-testid":`github-account-row-${A.id}`,children:[A.isDefault&&a.jsx("span",{className:pe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:pe.tokenName,children:A.label}),A.username&&a.jsxs("span",{className:pe.tokenTarget,children:["@",A.username]}),!A.isDefault&&a.jsx("button",{className:pe.deleteButton,onClick:()=>{E(A.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${A.label} as default`,"data-testid":`github-account-set-default-${A.id}`,children:a.jsx(Zw,{size:Vt,"aria-hidden":"true"})}),a.jsx("button",{className:pe.deleteButton,onClick:()=>C(A.id),title:`Remove ${A.label}`,"aria-label":`Remove ${A.label}`,"data-testid":`github-account-remove-${A.id}`,children:a.jsx(Ls,{size:Vt,"aria-hidden":"true"})})]},A.id))}),a.jsxs("form",{className:pe.addForm,onSubmit:A=>{O(A).catch(()=>{})},children:[a.jsxs("div",{className:pe.formRow,children:[a.jsx("input",{className:pe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:A=>m(A.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:pe.input,type:"password",placeholder:"Personal access token",value:g,onChange:A=>v(A.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:pe.formRow,children:[a.jsxs("label",{className:pe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:_,onChange:A=>b(A.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:pe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||x,"data-testid":"github-account-add-button",children:x?"Adding...":"Add Account"}),a.jsx("button",{className:pe.addButton,type:"button",onClick:()=>{L().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const R8="_container_legrg_1",I8="_header_legrg_8",O8="_headerTitle_legrg_35",L8="_badge_legrg_44",B8="_headerActions_legrg_54",$8="_body_legrg_61",z8="_formContent_legrg_73",H8="_section_legrg_85",P8="_label_legrg_91",U8="_nameInput_legrg_98",V8="_fieldInput_legrg_131",q8="_adapterSelect_legrg_164",G8="_readOnlyValue_legrg_198",F8="_codespaceSection_legrg_204",K8="_codespaceActions_legrg_210",Z8="_creatingHint_legrg_216",Y8="_errorHint_legrg_222",J8="_btnPrimary_legrg_235",W8="_btnGhost_legrg_266",ie={container:R8,header:I8,headerTitle:O8,badge:L8,headerActions:B8,body:$8,formContent:z8,section:H8,label:P8,nameInput:U8,fieldInput:V8,adapterSelect:q8,readOnlyValue:G8,codespaceSection:F8,codespaceActions:K8,creatingHint:Z8,errorHint:Y8,btnPrimary:J8,btnGhost:W8},ld=1,cd=65535;function zp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=ld&&s<=cd}function Hp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function X8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[_,b]=y.useState(""),[x,k]=y.useState("");return g==="create"?a.jsxs("div",{className:ie.codespaceSection,children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Repository"}),a.jsx("input",{type:"text",value:_,onChange:j=>b(j.target.value),placeholder:"owner/repo",className:ie.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:x,onChange:j=>k(j.target.value),placeholder:"Machine type (optional)...",className:ie.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:ie.codespaceActions,children:[a.jsx("button",{onClick:()=>{_.trim()&&(m(_.trim(),x.trim()||void 0),v("pick"),b(""),k(""))},disabled:!_.trim(),className:ie.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),b(""),k("")},className:ie.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:ie.codespaceSection,children:a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:ie.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:ie.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ie.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:ie.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:ie.errorHint,children:d})]})})}function ak({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_,onListDockerContainers:b,dockerContainers:x,dockerContainersError:k,onShowToast:j}){const w=ut(),T=t==="edit",C=T&&s?o.find(H=>H.id===s):void 0,[D,O]=y.useState(""),[E,M]=y.useState("local"),[L,A]=y.useState(""),[P,Y]=y.useState(""),[q,ee]=y.useState(""),[le,W]=y.useState(""),[re,$]=y.useState(""),[B,se]=y.useState(""),[oe,X]=y.useState(""),[ce,fe]=y.useState(""),[ge,Ae]=y.useState("create"),[vt,wt]=y.useState(""),[_e,qe]=y.useState(null),Bt=y.useCallback(()=>{const H={};if(E==="local"){if(L.trim()&&(H.host=L.trim()),P.trim()){const ve=Number(P);Number.isInteger(ve)&&(H.port=ve)}}else if(E==="ssh"){if(H.host=L.trim(),q.trim()&&(H.user=q.trim()),P.trim()){const ve=Number(P);Number.isInteger(ve)&&(H.sshPort=ve)}le.trim()&&(H.identityFile=le.trim())}else E==="docker"?ge==="attach"?vt.trim()&&(H.attach=vt.trim()):(re.trim()&&(H.image=re.trim()),B.trim()&&(H.repo=B.trim())):E==="codespace"&&(H.codespaceName=oe.trim());return H},[E,L,P,q,le,re,B,oe,ge,vt]),Wt=()=>!(!D.trim()||E==="ssh"&&!L.trim()||E==="codespace"&&!oe.trim()||E==="docker"&&ge==="attach"&&!vt.trim()||(E==="local"||E==="ssh")&&!zp(P)),de=()=>{Wt()&&(c(D.trim(),E,Bt(),ce||void 0),j==null||j("Environment added successfully","success"),w(Ho,{replace:!0}))},Ue=()=>{w(s?Li(s):Ho)},yt=y.useCallback((H,ve)=>{if(!C||!s)return;const tt=Hp(C.adapterConfig),Dt=ve.trim();Dt?tt[H]=Dt:delete tt[H],d(s,{adapterConfig:tt})},[C,s,d]),At=y.useCallback((H,ve)=>{if(!C||!s)return;const tt=Hp(C.adapterConfig);if(ve.trim()){const Dt=Number(ve);Number.isInteger(Dt)&&Dt>=ld&&Dt<=cd&&(tt[H]=Dt)}else delete tt[H];d(s,{adapterConfig:tt})},[C,s,d]);if(T){if(!C)return a.jsxs("div",{className:ie.container,children:[a.jsxs("div",{className:ie.header,children:[a.jsx("div",{className:ie.headerTitle,children:a.jsx("span",{className:ie.badge,children:"edit environment"})}),a.jsx("div",{className:ie.headerActions,children:a.jsx("button",{onClick:Ue,className:ie.btnGhost,children:"Back"})})]}),a.jsx("div",{className:ie.body,children:a.jsx("div",{className:ie.formContent,children:a.jsx("span",{className:ie.readOnlyValue,children:"Environment not found"})})})]});const H=Hp(C.adapterConfig);return a.jsxs("div",{className:ie.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:ie.header,children:[a.jsx("div",{className:ie.headerTitle,children:a.jsx("span",{className:ie.badge,children:"edit environment"})}),a.jsx("div",{className:ie.headerActions,children:a.jsx("button",{onClick:Ue,className:ie.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:ie.body,children:a.jsxs("div",{className:ie.formContent,children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Name"}),a.jsx(Pt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:_e,onActivate:qe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Adapter Type"}),a.jsx("span",{className:ie.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:ie.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Host"}),a.jsx(Pt,{value:String(H.host??""),onSave:ve=>yt("host",ve),mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Port"}),a.jsx(Pt,{value:String(H.port??""),onSave:ve=>At("port",ve),validate:ve=>zp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Host"}),a.jsx(Pt,{value:String(H.host??""),onSave:ve=>yt("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:qe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"User"}),a.jsx(Pt,{value:String(H.user??""),onSave:ve=>yt("user",ve),mode:"edit",fieldId:"user",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"SSH Port"}),a.jsx(Pt,{value:String(H.sshPort??""),onSave:ve=>At("sshPort",ve),validate:ve=>zp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:_e,onActivate:qe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Identity File"}),a.jsx(Pt,{value:String(H.identityFile??""),onSave:ve=>yt("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:_e,onActivate:qe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&H.attach!==void 0&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Attach (container)"}),a.jsx(Pt,{value:String(H.attach??""),onSave:ve=>yt("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:_e,onActivate:qe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&H.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Image"}),a.jsx(Pt,{value:String(H.image??""),onSave:ve=>yt("image",ve),mode:"edit",fieldId:"image",activeFieldId:_e,onActivate:qe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Repo"}),a.jsx(Pt,{value:String(H.repo??""),onSave:ve=>yt("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:_e,onActivate:qe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Codespace Name"}),a.jsx(Pt,{value:String(H.codespaceName??""),onSave:ve=>yt("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:_e,onActivate:qe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:ie.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:ie.header,children:[a.jsx("div",{className:ie.headerTitle,children:a.jsx("span",{className:ie.badge,children:"new environment"})}),a.jsxs("div",{className:ie.headerActions,children:[a.jsx("button",{onClick:de,disabled:!Wt(),className:ie.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Ue,className:ie.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:ie.body,children:a.jsxs("div",{className:ie.formContent,children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:H=>O(H.target.value),placeholder:"Environment name...",autoFocus:!0,className:ie.nameInput,"data-testid":"env-create-name",onKeyDown:H=>{H.key==="Enter"&&Wt()&&de()}})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:H=>{M(H.target.value),H.target.value==="codespace"&&u(ce||void 0)},className:ie.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:H=>{fe(H.target.value),E==="codespace"&&u(H.target.value||void 0)},className:ie.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(H=>a.jsxs("option",{value:H.id,children:[H.label," (@",H.username,")",H.isDefault?" — default":""]},H.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:H=>A(H.target.value),placeholder:"Host (optional)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:ld,max:cd,value:P,onChange:H=>Y(H.target.value),placeholder:"Port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:H=>A(H.target.value),placeholder:"Host (required)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:q,onChange:H=>ee(H.target.value),placeholder:"User (optional)...",className:ie.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:ld,max:cd,value:P,onChange:H=>Y(H.target.value),placeholder:"SSH port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:H=>W(H.target.value),placeholder:"Identity file (optional)...",className:ie.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:ge,onChange:H=>{const ve=H.target.value;Ae(ve),ve==="attach"&&b()},className:ie.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),ge==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:re,onChange:H=>$(H.target.value),placeholder:"Image (optional)...",className:ie.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:H=>se(H.target.value),placeholder:"Repo (optional)...",className:ie.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:ie.section,children:[a.jsx("label",{className:ie.label,children:"Container"}),!k&&x.length>0&&a.jsxs("select",{value:vt,onChange:H=>{wt(H.target.value),H.target.value&&!D.trim()&&O(H.target.value)},className:ie.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),x.map(H=>a.jsxs("option",{value:H.name,children:[H.name," (",H.image,") ",H.status]},H.id))]}),(k||x.length===0)&&a.jsxs(a.Fragment,{children:[k?a.jsx("span",{className:ie.errorHint,children:k}):a.jsx("span",{className:ie.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:vt,onChange:H=>{wt(H.target.value),H.target.value&&!D.trim()&&O(H.target.value)},placeholder:"Enter container name/ID...",className:ie.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(X8,{codespaceName:oe,onCodespaceNameChange:X,envName:D,onEnvNameChange:O,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_})]})})]})}const Q8="_group_1iprv_1",e7="_groupTitle_1iprv_8",t7="_shortcutList_1iprv_17",n7="_shortcutRow_1iprv_23",s7="_keys_1iprv_36",a7="_kbd_1iprv_43",i7="_description_1iprv_60",Ai={group:Q8,groupTitle:e7,shortcutList:t7,shortcutRow:n7,keys:s7,kbd:a7,description:i7},o7=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function r7(){return a.jsxs("section",{className:pe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:pe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:pe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),o7.map(t=>a.jsxs("div",{className:Ai.group,children:[a.jsx("h4",{className:Ai.groupTitle,children:t.title}),a.jsx("div",{className:Ai.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:Ai.shortcutRow,children:[a.jsx("span",{className:Ai.keys,children:s.keys.map(o=>a.jsx("kbd",{className:Ai.kbd,children:o},o))}),a.jsx("span",{className:Ai.description,children:s.description})]},s.description))})]},t.title))]})}const l7=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function c7({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:pe.section,children:[a.jsx("h3",{className:pe.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:pe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:pe.tokenList,children:l7.map(r=>a.jsxs("div",{className:pe.tokenRow,children:[a.jsx("span",{className:pe.tokenName,children:r.label}),a.jsx("span",{className:pe.tokenTarget,children:r.description}),a.jsx("select",{className:pe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const d7="_container_10efq_1",u7="_header_10efq_7",f7="_list_10efq_105",p7="_card_10efq_111",m7="_cardHeader_10efq_125",h7="_cardTitle_10efq_135",g7="_defaultBadge_10efq_141",v7="_cardActions_10efq_155",y7="_description_10efq_160",b7="_meta_10efq_166",_7="_empty_10efq_212",x7="_typeBadge_10efq_362",ns={container:d7,header:u7,list:f7,card:p7,cardHeader:m7,cardTitle:h7,defaultBadge:g7,cardActions:v7,description:y7,meta:b7,empty:_7,typeBadge:x7};function k7({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:ns.container,children:[a.jsxs("div",{className:ns.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(cn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ns.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ns.list,children:t.map(v=>{const _=s===v.id,b=v.type==="script";return a.jsxs("div",{className:ns.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ns.cardHeader,children:[a.jsxs("span",{className:ns.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ns.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:b?"Script":"Agent"}),_&&a.jsx("span",{className:ns.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ns.cardActions,onClick:x=>x.stopPropagation(),children:[!_&&a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ns.description,children:v.description}),a.jsxs("div",{className:ns.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(xs,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const S7="_container_uy08i_1",j7="_header_uy08i_7",w7="_count_uy08i_13",T7="_presets_uy08i_18",N7="_presetButton_uy08i_24",C7="_filterInput_uy08i_41",E7="_groups_uy08i_53",A7="_group_uy08i_53",D7="_groupHeader_uy08i_68",M7="_groupName_uy08i_77",R7="_groupCount_uy08i_81",I7="_toolList_uy08i_87",O7="_toolItem_uy08i_95",L7="_toolName_uy08i_103",xn={container:S7,header:j7,count:w7,presets:T7,presetButton:N7,filterInput:C7,groups:E7,group:A7,groupHeader:D7,groupName:M7,groupCount:R7,toolList:I7,toolItem:O7,toolName:L7},B7=(()=>{const t=new Map;for(const s of I_){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),$7=[{name:"default",label:"Default",tools:R_},{name:"worker",label:"Worker",tools:Z2},{name:"orchestrator",label:"Orchestrator",tools:Y2},{name:"admin",label:"Admin",tools:J2}];function d_({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const _=new Set(d);_.has(v)?_.delete(v):_.add(v),s([..._].sort())},[d,s,o]),p=y.useCallback((v,_)=>{if(o)return;const b=new Set(d);for(const x of v)_?b.delete(x):b.add(x);s([...b].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:xn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:xn.header,children:a.jsx("span",{className:xn.count,children:t.length===0?`Using default (${R_.length} tools)`:`${t.length} of ${I_.size} tools selected`})}),a.jsxs("div",{className:xn.presets,"data-testid":"mcp-tool-presets",children:[$7.map(v=>a.jsx("button",{type:"button",className:xn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:xn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:xn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:xn.groups,children:B7.map(({group:v,tools:_})=>{const b=g?_.filter(k=>k.toLowerCase().includes(g)):_;if(b.length===0)return null;const x=b.every(k=>d.has(k));return a.jsxs("div",{className:xn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:xn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:x,onChange:()=>p(b,x),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:xn.groupName,children:v}),a.jsxs("span",{className:xn.groupCount,children:["(",b.filter(k=>d.has(k)).length,"/",b.length,")"]})]}),a.jsx("div",{className:xn.toolList,children:b.map(k=>a.jsxs("label",{className:xn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),a.jsx("span",{className:xn.toolName,children:k})]},k))})]},v)})})]})}const z7="_container_1gfuq_1",H7="_header_1gfuq_7",P7="_list_1gfuq_19",U7="_card_1gfuq_25",V7="_cardHeader_1gfuq_40",q7="_cardTitle_1gfuq_46",G7="_statusBadge_1gfuq_56",F7="_enabled_1gfuq_68",K7="_disabled_1gfuq_71",Z7="_cardActions_1gfuq_75",Y7="_cardMeta_1gfuq_80",J7="_empty_1gfuq_98",ss={container:z7,header:H7,list:P7,card:U7,cardHeader:V7,cardTitle:q7,statusBadge:G7,enabled:F7,disabled:K7,cardActions:Z7,cardMeta:Y7,empty:J7};function W7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(b=>b.id===u):void 0,g=async b=>{await o(b),p(null)},v=y.useMemo(()=>{const b=new Map;for(const x of s)b.set(x.id,x.name);return b},[s]),_=b=>v.get(b)??b;return a.jsxs("div",{className:ss.container,children:[a.jsxs("div",{className:ss.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(cn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ss.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ss.list,children:t.map(b=>a.jsxs("div",{className:ss.card,"data-testid":`schedule-card-${b.id}`,onClick:()=>d(b.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(b.id))},children:[a.jsxs("div",{className:ss.cardHeader,children:[a.jsxs("span",{className:ss.cardTitle,children:[a.jsx("strong",{children:b.title}),a.jsx("span",{className:`${ss.statusBadge} ${b.enabled?ss.enabled:ss.disabled}`,"data-testid":`schedule-status-badge-${b.id}`,children:b.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ss.cardActions,onClick:x=>x.stopPropagation(),children:[a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(b.id,{enabled:!b.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${b.id}`,title:b.enabled?"Disable schedule":"Enable schedule",children:b.enabled?"Disable":"Enable"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>d(b.id),"data-testid":`schedule-edit-${b.id}`,children:"Edit"}),a.jsx(cn,{variant:"ghost",size:"sm",onClick:()=>p(b.id),"data-testid":`schedule-delete-${b.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ss.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${b.id}`,children:b.scheduleExpression}),b.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${b.id}`,children:["Persona: ",_(b.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${b.id}`,children:["Last run: ",b.lastRunAt?Go(b.lastRunAt):"Never"]}),b.enabled&&b.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${b.id}`,children:["Next run: ",J1(b.nextRunAt)]}):null,b.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${b.id}`,children:["Runs: ",b.runCount]})]})]},b.id))}),a.jsx(xs,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const X7="_nav_1bhou_1",Q7="_tab_1bhou_24",e$="_tabIcon_1bhou_62",t$="_tabActive_1bhou_68",Yc={nav:X7,tab:Q7,tabIcon:e$,tabActive:t$},oa=[{path:"credentials",label:"Credentials",icon:a.jsx(pw,{size:kt})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(ow,{size:kt})},{path:"personas",label:"Personas",icon:a.jsx(Ww,{size:kt})},{path:"schedules",label:"Schedules",icon:a.jsx(Bj,{size:kt})},{path:"appearance",label:"Appearance",icon:a.jsx(Rw,{size:kt})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(hw,{size:kt})},{path:"plugins",label:"Plugins",icon:a.jsx(zw,{size:kt})},{path:"about",label:"About",icon:a.jsx(Tm,{size:kt})}];function n$(){var u;const t=an(),s=ut(),o=y.useRef(null),r=((u=oa.find(p=>{const m=`${Ii}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??oa[0].path,c=y.useCallback(p=>{s(`${Ii}/${p}`)},[s]),d=y.useCallback(p=>{var x,k;const m=(x=o.current)==null?void 0:x.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:oa.findIndex(j=>j.path===r);let _=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),_=(v+1)%oa.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),_=(v-1+oa.length)%oa.length;else if(p.key==="Home")p.preventDefault(),_=0;else if(p.key==="End")p.preventDefault(),_=oa.length-1;else return;const b=oa[_].path;s(`${Ii}/${b}`),(k=m[_])==null||k.focus()},[r,s]);return a.jsx("nav",{className:Yc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:oa.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Yc.tab} ${m?Yc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Yc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const s$=["lifecycle:","pipe:","stdin:"];function ik(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function a$(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function i$(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=a$(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const o$="_container_16qkd_1",r$="_header_16qkd_7",l$="_title_16qkd_15",c$="_headerActions_16qkd_21",d$="_internalsToggle_16qkd_27",u$="_refreshButton_16qkd_37",f$="_state_16qkd_52",p$="_group_16qkd_59",m$="_groupHeader_16qkd_63",h$="_row_16qkd_72",g$="_selected_16qkd_92",v$="_kindBadge_16qkd_96",y$="_kindChatroom_16qkd_108",b$="_kindPipe_16qkd_114",_$="_kindChannel_16qkd_120",x$="_streamName_16qkd_126",k$="_meta_16qkd_135",sn={container:o$,header:r$,title:l$,headerActions:c$,internalsToggle:d$,refreshButton:u$,state:f$,group:p$,groupHeader:m$,row:h$,selected:g$,kindBadge:v$,kindChatroom:y$,kindPipe:b$,kindChannel:_$,streamName:x$,meta:k$},S$={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function j$({kind:t}){return t==="chatroom"?a.jsx(Nw,{size:We,"aria-hidden":"true"}):t==="pipe"?a.jsx(aw,{size:We,"aria-hidden":"true"}):a.jsx(lw,{size:We,"aria-hidden":"true"})}function w$({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v}){const _=i$(t,s),b={chatroom:sn.kindChatroom,pipe:sn.kindPipe,channel:sn.kindChannel},x=k=>{var j;return((j=o.find(w=>w.id===k))==null?void 0:j.title)??k};return a.jsxs("div",{className:sn.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:sn.header,children:[a.jsx("span",{className:sn.title,children:"Coordination"}),a.jsxs("div",{className:sn.headerActions,children:[a.jsxs("label",{className:sn.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:k=>p(k.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:sn.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(Pw,{size:We,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:sn.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:sn.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:sn.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(k=>a.jsxs("div",{className:sn.group,children:[a.jsx("div",{className:sn.groupHeader,children:k.taskId?x(k.taskId):"Unattached / external (CLI · MCP)"}),k.streams.map(j=>{const w=ik(j),T=j.id===m;return a.jsxs("button",{type:"button",className:`${sn.row}${T?` ${sn.selected}`:""}`,onClick:()=>g(j.id),"data-testid":`coordination-row-${j.id}`,"aria-current":T?"page":void 0,children:[a.jsxs("span",{className:`${sn.kindBadge} ${b[w]}`,children:[a.jsx(j$,{kind:w})," ",S$[w]]}),a.jsx("span",{className:sn.streamName,children:j.name}),a.jsxs("span",{className:sn.meta,children:[j.subscriberCount," ",j.subscriberCount===1?"sub":"subs"," ","·"," ",j.messageBufferDepth," buffered"]})]},j.id)})]},k.taskId??"__orphans__"))]})}const T$="_panel_iibrt_1",N$="_header_iibrt_24",C$="_title_iibrt_33",E$="_closeButton_iibrt_43",A$="_body_iibrt_57",D$="_section_iibrt_63",M$="_sectionLabel_iibrt_67",R$="_metaRow_iibrt_76",I$="_metaKey_iibrt_84",O$="_metaValue_iibrt_90",L$="_subscriberCard_iibrt_99",B$="_subscriberHeader_iibrt_107",$$="_sessionLink_iibrt_114",z$="_badges_iibrt_132",H$="_badgeRw_iibrt_150 _badge_iibrt_132",P$="_badgeR_iibrt_150 _badge_iibrt_132",U$="_badgeW_iibrt_162 _badge_iibrt_132",V$="_badgeAsync_iibrt_168 _badge_iibrt_132",q$="_badgeSync_iibrt_174 _badge_iibrt_132",G$="_badgeDetach_iibrt_178 _badge_iibrt_132",F$="_spawnTag_iibrt_184 _badge_iibrt_132",K$="_fdNumber_iibrt_189",Z$="_emptySubscribers_iibrt_195",Y$="_metaValueMono_iibrt_201 _metaValue_iibrt_90",J$="_placeholder_iibrt_207",W$="_advanced_iibrt_216",X$="_advancedSummary_iibrt_220",Pe={panel:T$,header:N$,title:C$,closeButton:E$,body:A$,section:D$,sectionLabel:M$,metaRow:R$,metaKey:I$,metaValue:O$,subscriberCard:L$,subscriberHeader:B$,sessionLink:$$,badges:z$,badgeRw:H$,badgeR:P$,badgeW:U$,badgeAsync:V$,badgeSync:q$,badgeDetach:G$,spawnTag:F$,fdNumber:K$,emptySubscribers:Z$,metaValueMono:Y$,placeholder:J$,advanced:W$,advancedSummary:X$},Q$={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function ez({permission:t}){const s=t==="rw"?Pe.badgeRw:t==="r"?Pe.badgeR:Pe.badgeW;return a.jsx("span",{className:s,children:t})}function tz({mode:t}){const s=t==="async"?Pe.badgeAsync:t==="detach"?Pe.badgeDetach:Pe.badgeSync;return a.jsx("span",{className:s,children:t})}function nz({stream:t,onClose:s}){const o=ut();return y.useEffect(()=>{const r=c=>{c.key==="Escape"&&s()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[s]),a.jsxs("div",{className:Pe.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:Pe.header,children:[a.jsx("h3",{className:Pe.title,children:t.name}),a.jsx("button",{type:"button",className:Pe.closeButton,onClick:s,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:Pe.body,children:[a.jsxs("div",{className:Pe.section,children:[a.jsx("div",{className:Pe.sectionLabel,children:"Overview"}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Kind"}),a.jsx("span",{className:Pe.metaValue,children:Q$[ik(t)]})]}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Participants"}),a.jsx("span",{className:Pe.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Buffered"}),a.jsxs("span",{className:Pe.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:Pe.section,children:[a.jsx("div",{className:Pe.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:Pe.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(r=>a.jsxs("div",{className:Pe.subscriberCard,"data-testid":`subscriber-card-${r.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:Pe.sessionLink,onClick:()=>{o(Ld(r.sessionId))},title:r.sessionId,children:[r.sessionId.slice(0,12),"…"]}),r.createdBySpawn&&a.jsx("span",{className:Pe.spawnTag,children:"spawn"})]},r.subscriptionId))]}),a.jsxs("div",{className:Pe.section,children:[a.jsx("div",{className:Pe.sectionLabel,children:"Conversation"}),a.jsx("div",{className:Pe.placeholder,"data-testid":"stream-conversation-placeholder",children:"Live conversation view — coming in V2."})]}),a.jsxs("details",{className:Pe.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:Pe.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:Pe.metaRow,children:[a.jsx("span",{className:Pe.metaKey,children:"Stream ID"}),a.jsx("span",{className:Pe.metaValueMono,children:t.id})]}),t.subscribers.map(r=>a.jsxs("div",{className:Pe.subscriberCard,children:[a.jsxs("div",{className:Pe.subscriberHeader,children:[a.jsxs("span",{className:Pe.fdNumber,children:["fd ",r.fd]}),a.jsxs("span",{className:Pe.metaValueMono,title:r.subscriptionId,children:[r.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:Pe.badges,children:[a.jsx(ez,{permission:r.permission}),a.jsx(tz,{mode:r.deliveryMode})]})]},r.subscriptionId))]})]})]})}function sz({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(Ny.map(d=>[d,[]]));for(const d of t){const u=ml(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let _;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?_="Needs input":k==="completed"&&(_="Ready to complete")}const b={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:_},x=c.get(u);x?x.push(b):c.get("not_started").push(b)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Ny.map(d=>{const u=Wa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const az="_boardContainer_1c4y1_1",iz="_column_1c4y1_17",oz="_columnHeader_1c4y1_34",rz="_columnIcon_1c4y1_47",lz="_columnLabel_1c4y1_52",cz="_columnCount_1c4y1_57",dz="_cardList_1c4y1_67",uz="_emptyPlaceholder_1c4y1_76",fz="_card_1c4y1_67",pz="_cardHeader_1c4y1_107",mz="_cardStatusIcon_1c4y1_113",hz="_cardTitle_1c4y1_119",gz="_cardBadges_1c4y1_127",vz="_badge_1c4y1_134",yz="_blockedBadge_1c4y1_146",bz="_childBadge_1c4y1_151",_z="_depBadge_1c4y1_155",xz="_parentBadge_1c4y1_159",kz="_pausedSubBadge_1c4y1_166",Sz="_personaBadge_1c4y1_170",jz="_envBadge_1c4y1_174",wz="_emptyCta_1c4y1_178",Tz="_ctaButton_1c4y1_188",Nz="_ctaDescription_1c4y1_204",lt={boardContainer:az,column:iz,columnHeader:oz,columnIcon:rz,columnLabel:lz,columnCount:cz,cardList:dz,emptyPlaceholder:uz,card:fz,cardHeader:pz,cardStatusIcon:mz,cardTitle:hz,cardBadges:gz,badge:vz,blockedBadge:yz,childBadge:bz,depBadge:_z,parentBadge:xz,pausedSubBadge:kz,personaBadge:Sz,envBadge:jz,emptyCta:wz,ctaButton:Tz,ctaDescription:Nz};function Cz({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=ut(),p=y.useMemo(()=>o.filter(b=>b.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(b=>[b.id,b.status])),[o]),g=y.useMemo(()=>new Map(p.map(b=>[b.id,b])),[p]),v=y.useMemo(()=>{const b=new Map(r.map(C=>[C.id,C])),x=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),j=new Map,w=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=b.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const O=x.get(D.personaId);O&&w.set(C.id,O.name)}if(D.environmentId){const O=k.get(D.environmentId);O&&T.set(C.id,O.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:w,environmentNameByTaskId:T}},[p,r,c,d]),_=y.useMemo(()=>sz({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:lt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:lt.ctaButton,onClick:()=>u(Hi(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:lt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:lt.boardContainer,"data-testid":"board-container",children:_.map(b=>a.jsxs("section",{className:lt.column,"data-testid":`board-column-${b.status}`,"aria-label":`${b.label}, ${b.tasks.length} ${b.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:lt.columnHeader,children:[a.jsx("span",{className:lt.columnIcon,style:{color:b.style.color},children:b.style.icon}),a.jsx("span",{className:lt.columnLabel,children:b.label}),a.jsx("span",{className:lt.columnCount,"data-testid":`board-count-${b.status}`,children:b.tasks.length})]}),a.jsx("div",{className:lt.cardList,children:b.tasks.length===0?a.jsx("div",{className:lt.emptyPlaceholder,children:"No tasks"}):a.jsx(is,{mode:"popLayout",children:b.tasks.map(x=>a.jsx(Ct.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(Ez,{boardTask:x,tasksById:g,personaName:v.personaNameByTaskId.get(x.task.id),envName:v.environmentNameByTaskId.get(x.task.id),onClick:()=>u(Pn(x.task.id,void 0,t,s))})},x.task.id))})})]},b.status))})}function Ez({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Wa(d.status),_=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:lt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c())},children:[a.jsxs("div",{className:lt.cardHeader,children:[a.jsx("span",{className:lt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:lt.cardTitle,children:d.title})]}),a.jsxs("div",{className:lt.cardBadges,children:[_&&a.jsx("span",{className:`${lt.badge} ${lt.parentBadge}`,title:_.title,children:_.title}),p>0&&a.jsxs("span",{className:`${lt.badge} ${lt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${lt.badge} ${lt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${lt.badge} ${lt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${lt.badge} ${lt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${lt.badge} ${lt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${lt.badge} ${lt.envBadge}`,children:r})]})]})}const Az="_formContent_ymnez_1",Dz="_section_ymnez_13",Mz="_label_ymnez_19",Rz="_titleInput_ymnez_26",Iz="_descriptionTextarea_ymnez_58",Oz="_selectField_ymnez_94",Lz="_checkboxRow_ymnez_128",Bz="_checkboxLabel_ymnez_141",$z="_fieldError_ymnez_146",xt={formContent:Az,section:Dz,label:Mz,titleInput:Rz,descriptionTextarea:Iz,selectField:Oz,checkboxRow:Lz,checkboxLabel:Bz,fieldError:$z};function zz(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const Hz=100;function Pz({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:xt.formContent,children:[a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:Hz,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:xt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&a.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:xt.section,children:a.jsxs("label",{className:xt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:xt.section,children:[a.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:xt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const ok=y.createContext(void 0),Uz=4e3;function Vz({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=Uz)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(ok.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function gn(){const t=y.useContext(ok);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const xm="grackle-theme",rk="grackle-prefer-system",lk="(prefers-color-scheme: dark)";let Xr=[],dd;function Pp(){dd=void 0;for(const t of Xr)t()}function km(){return typeof window>"u"?!1:window.matchMedia(lk).matches}function al(){if(typeof localStorage>"u")return l_;try{const t=localStorage.getItem(xm);if(t!==null&&nk.has(t))return t}catch{}return l_}function wd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(rk)==="true"}catch{return!1}}function Sm(t){return Gd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function ck(t,s){const o=_m(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?km()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=Sm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return km()?r.variantDarkId:r.variantLightId}return t}function Io(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=ck(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Io(al(),wd());function qz(){return dd===void 0&&(dd={themeId:al(),systemDark:km(),preferSystem:wd()}),dd}function Gz(t){return Xr=[...Xr,t],()=>{Xr=Xr.filter(s=>s!==t)}}function Fz(){const t=y.useSyncExternalStore(Gz,qz),{themeId:s,preferSystem:o}=t,r=ck(s,o),c=y.useCallback(u=>{if(nk.has(u)){try{localStorage.setItem(xm,u)}catch{}Io(u,wd(),!0),Pp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(rk,u?"true":"false")}catch{}if(u){const p=al(),m=_m(p);if(m!=null&&m.hidden){const g=Sm(p);if(g)try{localStorage.setItem(xm,g.id)}catch{}}}Io(al(),u,!0),Pp()},[]);return y.useEffect(()=>{Io(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(lk),p=()=>{const m=al(),g=wd();if(g){const v=_m(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Io(m,g),v!=null&&v.hidden){const _=Sm(m);_!=null&&_.variantDarkId&&_.variantLightId&&Io(m,g)}}Pp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const dk=y.createContext(void 0);function Kz({children:t}){const s=Fz();return a.jsx(dk.Provider,{value:s,children:t})}function uk(){const t=y.useContext(dk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const fk=y.createContext(void 0),pk=y.createContext(void 0);function Zz({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(pk.Provider,{value:r,children:a.jsx(fk.Provider,{value:s,children:t})})}function Yz(){return y.useContext(fk)}function Jz(){const t=y.useContext(pk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const _h=y.createContext(void 0);function ot(){const t=y.useContext(_h);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function mk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function hk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function Wz(t){return mk(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const Xz=new Set(["off","subscription","api_key"]),Jc=new Set(["off","on"]);function Qz(t){return mk(t)&&Xz.has(t.claude)&&Jc.has(t.github)&&Jc.has(t.copilot)&&Jc.has(t.codex)&&Jc.has(t.goose)}function gk(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function vk(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Ro=5e3;function eH(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const ha={label:"Home",url:Zo};function tH(t){return t?[ha,{label:"Settings",url:Ii},{label:t,url:void 0}]:[ha,{label:"Settings",url:void 0}]}const xh={label:"Environments",url:Ho};function nH(){return[ha,{label:"Environments",url:void 0}]}function sH(){return[ha,{label:"New Chat",url:void 0}]}function aH(t){return[ha,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function iH(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[ha,xh,{label:(d==null?void 0:d.displayName)??"Environment",url:Li(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function oH(t,s,o,r,c){const d=eH(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(x=>x.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(x=>x.id===g):void 0,_=[ha];v&&g&&(_.push(xh),_.push({label:v.displayName,url:Li(g)})),m&&g&&_.push({label:m.name,url:Xa(m.id,g)});for(let x=0;x<d.length-1;x++)_.push({label:d[x].title,url:Pn(d[x].id,void 0,p,g)});const b=d[d.length-1];return _.push({label:(b==null?void 0:b.title)??t,url:void 0}),_}const rH={label:"Findings",url:Bd};function lH(){return[ha,{label:"Findings",url:void 0}]}function yk(t,s,o,r,c){const d=[ha];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(xh),p&&d.push({label:p.displayName,url:Li(o)}),u&&d.push({label:u.name,url:Xa(s,o)}),d.push({label:"Findings",url:oC(s,o)})}else d.push(rH);return d.push({label:t,url:void 0}),d}function kh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Wc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function cH(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function Sh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const _=s.get(v),b=_?Wc(_):void 0;if(b)try{const x=JSON.parse(v.content);o.set(b,{tool:x.tool,args:x.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,_)=>{if(v.eventType!=="tool_result")return v;const b=s.get(v),x=b?cH(b):void 0;if(!x)return v;const k=o.get(x);if(!k)return v;r.add(x),c.add(_);let j;const w=v.content.trim();if(w.startsWith("{"))try{const T=JSON.parse(w);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const _=s.get(d[v]),b=_?Wc(_):void 0;b&&r.has(b)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const _=p[m];if(_!==v+1)continue;const b=d[v],x=d[_];let k;try{const j=JSON.parse(b.content);k={tool:j.tool,args:j.args}}catch{}if(k){let j;const w=x.content.trim();if(w.startsWith("{"))try{const D=JSON.parse(w);typeof D.detailedContent=="string"&&(j=D.detailedContent)}catch{}d[_]={...x,toolUseCtx:{...k,detailedResult:j}},c.add(_);const T=s.get(b),C=T?Wc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(b,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const _=s.get(v);if(!_)return!0;const b=Wc(_);if(b&&r.has(b))return!1;const x=_.__seqId;return!(x&&r.has(x))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let _=!1;for(let b=v+1;b<g.length;b++)if(g[b].eventType!=="tool_use"){_=!0;break}_&&(g[v]={...g[v],settled:!0})}return g}function dH(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=bk(s),d=s.filter(m=>jm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||jm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function bk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function jm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function uH(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=bk(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):jm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function fH(t,s){const o=new Map;for(const r of s)o.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function pH(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const As=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
329
329
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
330
330
  const header = req.headers.authorization;
331
331
  if (!header?.startsWith("Bearer ")) {
@@ -766,4 +766,4 @@ const grackle = await host.mcpServer({
766
766
  url: env.vars.GRACKLE_MCP_URL,
767
767
  });
768
768
 
769
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(d_,{selectedTools:Y,onChange:de=>{q(de),_e(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,de),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ge&&!fe&&a.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,a.jsx(xs,{isOpen:ee,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:wt,onCancel:()=>le(!1)})]})}function DV(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=gn(),d=ut();return a.jsx(W7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(tC),onNavigateToSchedule:u=>d(rx(u))})}const MV="_container_1g4qh_1",RV="_form_1g4qh_7",IV="_formActions_1g4qh_66",OV="_editableSection_1g4qh_73",LV="_helperText_1g4qh_84",BV="_metaSection_1g4qh_90",$V="_optional_1g4qh_108",zV="_readonlyValue_1g4qh_113",$n={container:MV,form:RV,formActions:IV,editableSection:OV,helperText:LV,metaSection:BV,optional:$V,readonlyValue:zV};function C_(){const{scheduleId:t}=ls(),s=ut(),{showToast:o}=gn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ot(),v=t===void 0,_=v?void 0:r.find(x=>x.id===t);if(!v&&!c&&r.length>0&&!_)return a.jsx(zn,{to:dp,replace:!0});const b=[{label:"Settings",url:Ii},{label:"Schedules",url:dp},{label:v?"New Schedule":(_==null?void 0:_.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:$n.container,children:[a.jsx(ks,{segments:b}),a.jsx(HV,{existing:_,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(dp)},showToast:o})]})}function HV({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var $;const g=ut(),[v,_]=y.useState((t==null?void 0:t.title)??""),[b,x]=y.useState((t==null?void 0:t.description)??""),[k,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[w,T]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[O,E]=y.useState(!1),[M,L]=y.useState(null);y.useEffect(()=>{s||t&&M===null&&(_(t.title),x(t.description),j(t.scheduleExpression),T(t.personaId),D(t.workspaceId))},[s,t,M]);const A=!s&&t===void 0,P=s&&v.trim().length>0&&k.trim().length>0&&w.length>0,Y=o.map(B=>({value:B.id,label:B.name})),q=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ee=B=>{B.preventDefault(),P&&c(v,b,k,w,C||void 0).then(se=>{m("Schedule created","success"),g(rx(se.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,se)=>{t&&d(t.id,{[B]:se}).then(()=>{m("Schedule updated","success"),B==="title"&&_(String(se)),B==="description"&&x(String(se)),B==="scheduleExpression"&&j(String(se)),B==="personaId"&&T(String(se))},()=>{m("Failed to update schedule","error")})},W=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},re=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[A?a.jsxs("div",{className:$n.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:ee,className:$n.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:B=>_(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:$n.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:b,onChange:B=>x(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:k,onChange:B=>j(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:$n.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:w,onChange:B=>T(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:$n.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:q.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))})]}),a.jsxs("div",{className:$n.formActions,children:[a.jsx(cn,{type:"submit",variant:"primary",size:"md",disabled:!P,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(cn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:$n.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:$n.formActions,children:[a.jsx(cn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(cn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:W,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(cn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:$n.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx(Pt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:M,onActivate:L,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx(Pt,{value:b,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:M,onActivate:L,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx(Pt,{value:k,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:M,onActivate:L,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(Sd,{value:w,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:M,onActivate:L,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:$n.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:$n.readonlyValue,"data-testid":"schedule-detail-workspace",children:(($=r.find(B=>B.id===t.workspaceId))==null?void 0:$.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:$n.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",Go(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",J1(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",Go(t.createdAt)]})]})]}):null,a.jsx(xs,{isOpen:O,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:re,onCancel:()=>E(!1)})]})}function PV(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=uk();return a.jsx(mB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function UV(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await $e.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function VV(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=UV();return a.jsxs(a.Fragment,{children:[r&&a.jsx(mL,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(vB,{connectionStatus:t,environments:s,sessions:o})]})}function qV(){return a.jsx(r7,{})}function GV(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return a.jsx(D8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const E_=Hi();function FV(){const t=ut();return ua({key:"?"},()=>{t(nC)}),ua({key:"n"},()=>{t(E_)}),ua({key:"N"},()=>{t(E_)}),a.jsx(a.Fragment,{})}function xl(t){const s=Jz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function KV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=y.useMemo(()=>a.jsx(qO,{workspaces:t,tasks:s}),[t,s]);return xl(o),a.jsx(ti,{})}function ZV(){const{environments:{environments:t}}=ot(),s=y.useMemo(()=>a.jsx(eO,{environments:t}),[t]);return xl(s),a.jsx(ti,{})}function YV(){const t=y.useMemo(()=>a.jsx(n$,{}),[]);return xl(t),a.jsx(ti,{})}function JV(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=ls();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>a.jsx(uO,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return xl(d),a.jsx(ti,{})}function WV(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(c5,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return xl(u),a.jsx(ti,{})}const XV="_container_ce571_1",QV="_title_ce571_6",Td={container:XV,title:QV};function eq(){return a.jsxs("div",{className:Td.container,"aria-hidden":"true",children:[a.jsx("h1",{className:Td.title,children:"Findings"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>a.jsx(kd,{lines:3},s))})]})}function A_(){const{environmentId:t,workspaceId:s}=ls(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=ut();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(em(v,s,t))},[p,s,t]);if(r)return a.jsx(eq,{});const g=s&&t?yk("Findings",s,t,d,u).slice(0,-1):lH();return a.jsxs("div",{className:Td.container,"data-testid":"findings-list-page",children:[a.jsx(ks,{segments:g}),a.jsx("h1",{className:Td.title,children:"Findings"}),a.jsx(tk,{findings:o,onFindingClick:m})]})}const tq="_container_1wwpb_1",nq="_notFound_1wwpb_6",sq="_header_1wwpb_12",aq="_categoryBadge_1wwpb_19",iq="_title_1wwpb_28",oq="_content_1wwpb_35",rq="_tags_1wwpb_77",lq="_tag_1wwpb_77",cq="_meta_1wwpb_92",dq="_metaTimestamp_1wwpb_100",uq="_metaLink_1wwpb_105",kn={container:tq,notFound:nq,header:sq,categoryBadge:aq,title:iq,content:oq,tags:rq,tag:lq,meta:cq,metaTimestamp:dq,metaLink:uq};function D_(){const{findingId:t,environmentId:s,workspaceId:o}=ls(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=ut();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Loading..."})});if(!r)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Finding not found."})});const g=yk(r.title,o,s,u,p),v=jd(r.category);return a.jsxs("div",{className:kn.container,"data-testid":"finding-detail-page",children:[a.jsx(ks,{segments:g}),a.jsxs("div",{className:kn.header,children:[a.jsx("span",{className:kn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),a.jsx("h1",{className:kn.title,children:r.title})]}),r.content&&a.jsx("div",{className:kn.content,children:a.jsx(Cd,{remarkPlugins:[Ed],children:r.content})}),r.tags.length>0&&a.jsx("div",{className:kn.tags,children:r.tags.map(_=>a.jsx("span",{className:kn.tag,children:_},_))}),a.jsxs("div",{className:kn.meta,children:[a.jsx("span",{className:kn.metaTimestamp,title:r.createdAt,children:Go(r.createdAt)}),r.taskId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Pn(r.taskId))},children:"View Task"}),r.sessionId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Ld(r.sessionId))},children:"View Session"})]})]})}const fq="_wizard_1260s_1",pq="_container_1260s_10",mq="_stepContent_1260s_19",hq="_logoArea_1260s_28",gq="_logoImage_1260s_32",vq="_heading_1260s_41",yq="_tagline_1260s_49",bq="_subtitle_1260s_56",_q="_featureList_1260s_64",xq="_runtimeGrid_1260s_89",kq="_runtimeCard_1260s_101",Sq="_runtimeName_1260s_133",jq="_runtimeDescription_1260s_139",wq="_buttonRow_1260s_144",Tq="_primaryButton_1260s_151",Nq="_ghostButton_1260s_185",Cq="_dots_1260s_213",Eq="_dot_1260s_213",et={wizard:fq,container:pq,stepContent:mq,logoArea:hq,logoImage:gq,heading:vq,tagline:yq,subtitle:bq,featureList:_q,runtimeGrid:xq,runtimeCard:kq,runtimeName:Sq,runtimeDescription:jq,buttonRow:wq,primaryButton:Tq,ghostButton:Nq,dots:Cq,dot:Eq};function Aq({onNext:t}){return a.jsxs("div",{className:et.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:et.logoArea,children:a.jsx("img",{src:qd("grackle-logo.png"),alt:"Grackle",className:et.logoImage})}),a.jsx("h1",{className:et.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:et.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function Dq({onNext:t,onBack:s}){return a.jsxs("div",{className:et.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:et.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:et.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:et.buttonRow,children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Mq=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function Rq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:et.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:et.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:et.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:et.runtimeGrid,children:Mq.map(u=>a.jsxs("button",{type:"button",className:et.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:et.runtimeName,children:u.name}),a.jsx("span",{className:et.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:et.buttonRow,children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function Iq(){return typeof Notification<"u"}function Oq({onFinish:t,onBack:s,finishDisabled:o}){const r=Iq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:et.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:et.heading,children:"Stay in the Loop"}),a.jsx("p",{className:et.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:et.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:et.buttonRow,children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:et.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const Lq=4,M_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function Bq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=gn(),d=ut(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,_]=y.useState(!1),b=t.find(j=>j.id==="claude-code"),x=y.useCallback(j=>{g(j),p(3)},[]),k=y.useCallback(()=>{const j=m;_(!0);const w=[];if(b&&j!==b.runtime){const C=M_[j]??"sonnet";w.push(s(b.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===vy);if(T&&j!==T.runtime){const C=M_[j]??"sonnet";w.push(s(vy,void 0,void 0,void 0,j,C))}Promise.all(w).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),_(!1)})},[m,b,t,s,o,d,c]);return r===!0?a.jsx(zn,{to:"/",replace:!0}):a.jsx("div",{className:et.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:et.container,children:[a.jsx(is,{mode:"wait",children:a.jsxs(Ct.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Aq,{onNext:()=>p(1)}),u===1&&a.jsx(Dq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(Rq,{currentRuntime:m,onFinish:x,onBack:()=>p(1),finishDisabled:!b}),u===3&&a.jsx(Oq,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:et.dots,children:Array.from({length:Lq},(j,w)=>a.jsx("span",{className:et.dot,"data-active":w===u},w))})]})})}const $q="_root_zndgp_1",zq="_body_zndgp_7",Hq="_main_zndgp_19",Pq="_sidebarWrapper_zndgp_26",Uq="_overlay_zndgp_51",Qr={root:$q,body:zq,main:Hq,sidebarWrapper:Pq,overlay:Uq},Vq=y.lazy(()=>B_(()=>import("./KnowledgePage-B4fDXJQF.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.KnowledgePage}))),Sk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function qq({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=gn(),p=an(),m=Yz(),g=m!==void 0,[v,_]=y.useState(!1),b=y.useCallback(()=>_(x=>!x),[]);return y.useEffect(()=>{_(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const x=k=>{k.key==="Escape"&&_(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(k5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?b:void 0,sidebarOpen:v}),a.jsx(A5,{tabs:t}),a.jsxs("div",{className:Qr.body,children:[g&&a.jsx("div",{className:Qr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(L5,{content:m})}),g&&v&&a.jsx("div",{className:Qr.overlay,"data-testid":"drawer-overlay",onClick:()=>_(!1)}),a.jsxs("div",{className:Qr.main,children:[a.jsx(ti,{}),a.jsx(q5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(sL,{toasts:d,onDismiss:u}),a.jsx(FV,{})]})}function Gq(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ot(),{pluginNames:p}=Fd(),{showToast:m}=gn();r9(s,m),f9(c,m),l9(o,r,m);const g=ut(),v=an();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Ld(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(zn,{to:"/setup",replace:!0});const _=AH(p);return a.jsx(Zz,{children:a.jsxs("div",{className:Qr.root,children:[Sk&&a.jsx(MC,{}),a.jsx(qq,{tabs:_})]})})}function Yp(){const{workspaceId:t}=ls(),{workspaces:{workspaces:s}}=ot(),o=an(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(zn,{to:m,replace:!0})}function Fq(){const{pluginNames:t}=Fd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(gN,{children:[a.jsx(je,{path:"setup",element:a.jsx(Bq,{})}),a.jsxs(je,{element:a.jsx(Gq,{}),children:[a.jsx(je,{index:!0,element:a.jsx(XP,{})}),a.jsx(je,{path:"sessions/new",element:a.jsx(fU,{})}),a.jsx(je,{path:"chat",element:a.jsx(lU,{})}),a.jsx(je,{path:"chat/:streamId",element:a.jsx(zn,{to:"/coordination",replace:!0})}),a.jsx(je,{path:"coordination",element:a.jsx(uU,{})}),a.jsx(je,{path:"sessions/:sessionId",element:a.jsx(gU,{})}),o&&a.jsx(je,{element:a.jsx(WV,{}),children:a.jsx(je,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(V1,{}),children:a.jsx(Vq,{})})})}),s&&a.jsxs(je,{element:a.jsx(KV,{}),children:[a.jsx(je,{path:"tasks",element:a.jsx(JP,{})}),a.jsx(je,{path:"tasks/new",element:a.jsx(j_,{})}),a.jsx(je,{path:"tasks/:taskId",element:a.jsx(Za,{})}),a.jsx(je,{path:"tasks/:taskId/edit",element:a.jsx(Za,{})}),a.jsx(je,{path:"tasks/:taskId/stream",element:a.jsx(Za,{})}),a.jsx(je,{path:"tasks/:taskId/findings",element:a.jsx(Za,{})})]}),s&&a.jsxs(je,{element:a.jsx(JV,{}),children:[a.jsx(je,{path:"findings",element:a.jsx(A_,{})}),a.jsx(je,{path:"findings/:findingId",element:a.jsx(D_,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:a.jsx(A_,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:a.jsx(D_,{})})]}),a.jsxs(je,{element:a.jsx(ZV,{}),children:[a.jsx(je,{path:"workspaces",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(je,{path:"workspaces/new",element:a.jsx(DU,{})}),a.jsx(je,{path:"workspaces/:workspaceId",element:a.jsx(Yp,{})}),a.jsx(je,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Yp,{})}),a.jsx(je,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Yp,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(_U,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(j_,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Za,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Za,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Za,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:a.jsx(Za,{})}),a.jsxs(je,{path:"environments",element:a.jsx($U,{}),children:[a.jsx(je,{index:!0,element:a.jsx(WP,{})}),a.jsx(je,{path:"new",element:a.jsx(RU,{})}),a.jsx(je,{path:":environmentId",element:a.jsx(mV,{})}),a.jsx(je,{path:":environmentId/edit",element:a.jsx(IU,{})})]})]}),a.jsx(je,{element:a.jsx(YV,{}),children:a.jsxs(je,{path:"settings",element:a.jsx(vV,{}),children:[a.jsx(je,{index:!0,element:a.jsx(zn,{to:"credentials",replace:!0})}),a.jsx(je,{path:"environments",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(je,{path:"credentials",element:a.jsx(yV,{})}),a.jsx(je,{path:"github-accounts",element:a.jsx(bV,{})}),a.jsx(je,{path:"tokens",element:a.jsx(zn,{to:"../credentials",replace:!0})}),a.jsx(je,{path:"personas",element:a.jsx(_V,{})}),a.jsx(je,{path:"personas/new",element:a.jsx(N_,{})}),a.jsx(je,{path:"personas/:personaId",element:a.jsx(N_,{})}),a.jsx(je,{path:"schedules",element:a.jsx(DV,{})}),a.jsx(je,{path:"schedules/new",element:a.jsx(C_,{})}),a.jsx(je,{path:"schedules/:scheduleId",element:a.jsx(C_,{})}),a.jsx(je,{path:"appearance",element:a.jsx(PV,{})}),a.jsx(je,{path:"shortcuts",element:a.jsx(qV,{})}),a.jsx(je,{path:"plugins",element:a.jsx(GV,{})}),a.jsx(je,{path:"about",element:a.jsx(VV,{})})]})}),a.jsx(je,{path:"*",element:a.jsx(zn,{to:"/",replace:!0})})]})]})}const Kq=1e4;function Zq(){const{onboardingCompleted:t}=ot(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),Kq);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(is,{mode:"wait",children:r?a.jsx(Ct.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(V1,{})},"splash"):a.jsx(Ct.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(PN,{basename:"/".replace(/\/$/,""),children:a.jsx(Fq,{})})},"app")})}function Yq(){const t=Sk?SH:o9;return a.jsx(TH,{children:a.jsx(Kz,{children:a.jsx(Vz,{children:a.jsx(t,{children:a.jsx(Zq,{})})})})})}lj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(Yq,{})}));export{ks as B,dx as K,ot as a,em as f,Ld as s,Pn as t,ut as u};
769
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(d_,{selectedTools:Y,onChange:de=>{q(de),_e(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,de),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ge&&!fe&&a.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,a.jsx(xs,{isOpen:ee,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:wt,onCancel:()=>le(!1)})]})}function DV(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=gn(),d=ut();return a.jsx(W7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(tC),onNavigateToSchedule:u=>d(rx(u))})}const MV="_container_1g4qh_1",RV="_form_1g4qh_7",IV="_formActions_1g4qh_66",OV="_editableSection_1g4qh_73",LV="_helperText_1g4qh_84",BV="_metaSection_1g4qh_90",$V="_optional_1g4qh_108",zV="_readonlyValue_1g4qh_113",$n={container:MV,form:RV,formActions:IV,editableSection:OV,helperText:LV,metaSection:BV,optional:$V,readonlyValue:zV};function C_(){const{scheduleId:t}=ls(),s=ut(),{showToast:o}=gn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ot(),v=t===void 0,_=v?void 0:r.find(x=>x.id===t);if(!v&&!c&&r.length>0&&!_)return a.jsx(zn,{to:dp,replace:!0});const b=[{label:"Settings",url:Ii},{label:"Schedules",url:dp},{label:v?"New Schedule":(_==null?void 0:_.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:$n.container,children:[a.jsx(ks,{segments:b}),a.jsx(HV,{existing:_,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(dp)},showToast:o})]})}function HV({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var $;const g=ut(),[v,_]=y.useState((t==null?void 0:t.title)??""),[b,x]=y.useState((t==null?void 0:t.description)??""),[k,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[w,T]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[O,E]=y.useState(!1),[M,L]=y.useState(null);y.useEffect(()=>{s||t&&M===null&&(_(t.title),x(t.description),j(t.scheduleExpression),T(t.personaId),D(t.workspaceId))},[s,t,M]);const A=!s&&t===void 0,P=s&&v.trim().length>0&&k.trim().length>0&&w.length>0,Y=o.map(B=>({value:B.id,label:B.name})),q=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ee=B=>{B.preventDefault(),P&&c(v,b,k,w,C||void 0).then(se=>{m("Schedule created","success"),g(rx(se.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,se)=>{t&&d(t.id,{[B]:se}).then(()=>{m("Schedule updated","success"),B==="title"&&_(String(se)),B==="description"&&x(String(se)),B==="scheduleExpression"&&j(String(se)),B==="personaId"&&T(String(se))},()=>{m("Failed to update schedule","error")})},W=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},re=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[A?a.jsxs("div",{className:$n.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:ee,className:$n.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:B=>_(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:$n.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:b,onChange:B=>x(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:k,onChange:B=>j(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:$n.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:w,onChange:B=>T(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:$n.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:q.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))})]}),a.jsxs("div",{className:$n.formActions,children:[a.jsx(cn,{type:"submit",variant:"primary",size:"md",disabled:!P,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(cn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:$n.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:$n.formActions,children:[a.jsx(cn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(cn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:W,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(cn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:$n.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx(Pt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:M,onActivate:L,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx(Pt,{value:b,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:M,onActivate:L,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx(Pt,{value:k,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:M,onActivate:L,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(Sd,{value:w,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:M,onActivate:L,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:$n.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:$n.readonlyValue,"data-testid":"schedule-detail-workspace",children:(($=r.find(B=>B.id===t.workspaceId))==null?void 0:$.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:$n.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",Go(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",J1(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",Go(t.createdAt)]})]})]}):null,a.jsx(xs,{isOpen:O,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:re,onCancel:()=>E(!1)})]})}function PV(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=uk();return a.jsx(mB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function UV(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await $e.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function VV(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=UV();return a.jsxs(a.Fragment,{children:[r&&a.jsx(mL,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(vB,{connectionStatus:t,environments:s,sessions:o})]})}function qV(){return a.jsx(r7,{})}function GV(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return a.jsx(D8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const E_=Hi();function FV(){const t=ut();return ua({key:"?"},()=>{t(nC)}),ua({key:"n"},()=>{t(E_)}),ua({key:"N"},()=>{t(E_)}),a.jsx(a.Fragment,{})}function xl(t){const s=Jz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function KV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=y.useMemo(()=>a.jsx(qO,{workspaces:t,tasks:s}),[t,s]);return xl(o),a.jsx(ti,{})}function ZV(){const{environments:{environments:t}}=ot(),s=y.useMemo(()=>a.jsx(eO,{environments:t}),[t]);return xl(s),a.jsx(ti,{})}function YV(){const t=y.useMemo(()=>a.jsx(n$,{}),[]);return xl(t),a.jsx(ti,{})}function JV(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=ls();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>a.jsx(uO,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return xl(d),a.jsx(ti,{})}function WV(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(c5,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return xl(u),a.jsx(ti,{})}const XV="_container_ce571_1",QV="_title_ce571_6",Td={container:XV,title:QV};function eq(){return a.jsxs("div",{className:Td.container,"aria-hidden":"true",children:[a.jsx("h1",{className:Td.title,children:"Findings"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>a.jsx(kd,{lines:3},s))})]})}function A_(){const{environmentId:t,workspaceId:s}=ls(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=ut();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(em(v,s,t))},[p,s,t]);if(r)return a.jsx(eq,{});const g=s&&t?yk("Findings",s,t,d,u).slice(0,-1):lH();return a.jsxs("div",{className:Td.container,"data-testid":"findings-list-page",children:[a.jsx(ks,{segments:g}),a.jsx("h1",{className:Td.title,children:"Findings"}),a.jsx(tk,{findings:o,onFindingClick:m})]})}const tq="_container_1wwpb_1",nq="_notFound_1wwpb_6",sq="_header_1wwpb_12",aq="_categoryBadge_1wwpb_19",iq="_title_1wwpb_28",oq="_content_1wwpb_35",rq="_tags_1wwpb_77",lq="_tag_1wwpb_77",cq="_meta_1wwpb_92",dq="_metaTimestamp_1wwpb_100",uq="_metaLink_1wwpb_105",kn={container:tq,notFound:nq,header:sq,categoryBadge:aq,title:iq,content:oq,tags:rq,tag:lq,meta:cq,metaTimestamp:dq,metaLink:uq};function D_(){const{findingId:t,environmentId:s,workspaceId:o}=ls(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=ut();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Loading..."})});if(!r)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Finding not found."})});const g=yk(r.title,o,s,u,p),v=jd(r.category);return a.jsxs("div",{className:kn.container,"data-testid":"finding-detail-page",children:[a.jsx(ks,{segments:g}),a.jsxs("div",{className:kn.header,children:[a.jsx("span",{className:kn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),a.jsx("h1",{className:kn.title,children:r.title})]}),r.content&&a.jsx("div",{className:kn.content,children:a.jsx(Cd,{remarkPlugins:[Ed],children:r.content})}),r.tags.length>0&&a.jsx("div",{className:kn.tags,children:r.tags.map(_=>a.jsx("span",{className:kn.tag,children:_},_))}),a.jsxs("div",{className:kn.meta,children:[a.jsx("span",{className:kn.metaTimestamp,title:r.createdAt,children:Go(r.createdAt)}),r.taskId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Pn(r.taskId))},children:"View Task"}),r.sessionId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Ld(r.sessionId))},children:"View Session"})]})]})}const fq="_wizard_1260s_1",pq="_container_1260s_10",mq="_stepContent_1260s_19",hq="_logoArea_1260s_28",gq="_logoImage_1260s_32",vq="_heading_1260s_41",yq="_tagline_1260s_49",bq="_subtitle_1260s_56",_q="_featureList_1260s_64",xq="_runtimeGrid_1260s_89",kq="_runtimeCard_1260s_101",Sq="_runtimeName_1260s_133",jq="_runtimeDescription_1260s_139",wq="_buttonRow_1260s_144",Tq="_primaryButton_1260s_151",Nq="_ghostButton_1260s_185",Cq="_dots_1260s_213",Eq="_dot_1260s_213",et={wizard:fq,container:pq,stepContent:mq,logoArea:hq,logoImage:gq,heading:vq,tagline:yq,subtitle:bq,featureList:_q,runtimeGrid:xq,runtimeCard:kq,runtimeName:Sq,runtimeDescription:jq,buttonRow:wq,primaryButton:Tq,ghostButton:Nq,dots:Cq,dot:Eq};function Aq({onNext:t}){return a.jsxs("div",{className:et.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:et.logoArea,children:a.jsx("img",{src:qd("grackle-logo.png"),alt:"Grackle",className:et.logoImage})}),a.jsx("h1",{className:et.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:et.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function Dq({onNext:t,onBack:s}){return a.jsxs("div",{className:et.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:et.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:et.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:et.buttonRow,children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Mq=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function Rq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:et.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:et.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:et.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:et.runtimeGrid,children:Mq.map(u=>a.jsxs("button",{type:"button",className:et.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:et.runtimeName,children:u.name}),a.jsx("span",{className:et.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:et.buttonRow,children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function Iq(){return typeof Notification<"u"}function Oq({onFinish:t,onBack:s,finishDisabled:o}){const r=Iq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:et.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:et.heading,children:"Stay in the Loop"}),a.jsx("p",{className:et.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:et.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:et.buttonRow,children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:et.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:et.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:et.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const Lq=4,M_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function Bq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=gn(),d=ut(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,_]=y.useState(!1),b=t.find(j=>j.id==="claude-code"),x=y.useCallback(j=>{g(j),p(3)},[]),k=y.useCallback(()=>{const j=m;_(!0);const w=[];if(b&&j!==b.runtime){const C=M_[j]??"sonnet";w.push(s(b.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===vy);if(T&&j!==T.runtime){const C=M_[j]??"sonnet";w.push(s(vy,void 0,void 0,void 0,j,C))}Promise.all(w).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),_(!1)})},[m,b,t,s,o,d,c]);return r===!0?a.jsx(zn,{to:"/",replace:!0}):a.jsx("div",{className:et.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:et.container,children:[a.jsx(is,{mode:"wait",children:a.jsxs(Ct.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Aq,{onNext:()=>p(1)}),u===1&&a.jsx(Dq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(Rq,{currentRuntime:m,onFinish:x,onBack:()=>p(1),finishDisabled:!b}),u===3&&a.jsx(Oq,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:et.dots,children:Array.from({length:Lq},(j,w)=>a.jsx("span",{className:et.dot,"data-active":w===u},w))})]})})}const $q="_root_zndgp_1",zq="_body_zndgp_7",Hq="_main_zndgp_19",Pq="_sidebarWrapper_zndgp_26",Uq="_overlay_zndgp_51",Qr={root:$q,body:zq,main:Hq,sidebarWrapper:Pq,overlay:Uq},Vq=y.lazy(()=>B_(()=>import("./KnowledgePage-DJcvhfzO.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.KnowledgePage}))),Sk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function qq({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=gn(),p=an(),m=Yz(),g=m!==void 0,[v,_]=y.useState(!1),b=y.useCallback(()=>_(x=>!x),[]);return y.useEffect(()=>{_(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const x=k=>{k.key==="Escape"&&_(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(k5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?b:void 0,sidebarOpen:v}),a.jsx(A5,{tabs:t}),a.jsxs("div",{className:Qr.body,children:[g&&a.jsx("div",{className:Qr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(L5,{content:m})}),g&&v&&a.jsx("div",{className:Qr.overlay,"data-testid":"drawer-overlay",onClick:()=>_(!1)}),a.jsxs("div",{className:Qr.main,children:[a.jsx(ti,{}),a.jsx(q5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(sL,{toasts:d,onDismiss:u}),a.jsx(FV,{})]})}function Gq(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ot(),{pluginNames:p}=Fd(),{showToast:m}=gn();r9(s,m),f9(c,m),l9(o,r,m);const g=ut(),v=an();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Ld(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(zn,{to:"/setup",replace:!0});const _=AH(p);return a.jsx(Zz,{children:a.jsxs("div",{className:Qr.root,children:[Sk&&a.jsx(MC,{}),a.jsx(qq,{tabs:_})]})})}function Yp(){const{workspaceId:t}=ls(),{workspaces:{workspaces:s}}=ot(),o=an(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(zn,{to:m,replace:!0})}function Fq(){const{pluginNames:t}=Fd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(gN,{children:[a.jsx(je,{path:"setup",element:a.jsx(Bq,{})}),a.jsxs(je,{element:a.jsx(Gq,{}),children:[a.jsx(je,{index:!0,element:a.jsx(XP,{})}),a.jsx(je,{path:"sessions/new",element:a.jsx(fU,{})}),a.jsx(je,{path:"chat",element:a.jsx(lU,{})}),a.jsx(je,{path:"chat/:streamId",element:a.jsx(zn,{to:"/coordination",replace:!0})}),a.jsx(je,{path:"coordination",element:a.jsx(uU,{})}),a.jsx(je,{path:"sessions/:sessionId",element:a.jsx(gU,{})}),o&&a.jsx(je,{element:a.jsx(WV,{}),children:a.jsx(je,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(V1,{}),children:a.jsx(Vq,{})})})}),s&&a.jsxs(je,{element:a.jsx(KV,{}),children:[a.jsx(je,{path:"tasks",element:a.jsx(JP,{})}),a.jsx(je,{path:"tasks/new",element:a.jsx(j_,{})}),a.jsx(je,{path:"tasks/:taskId",element:a.jsx(Za,{})}),a.jsx(je,{path:"tasks/:taskId/edit",element:a.jsx(Za,{})}),a.jsx(je,{path:"tasks/:taskId/stream",element:a.jsx(Za,{})}),a.jsx(je,{path:"tasks/:taskId/findings",element:a.jsx(Za,{})})]}),s&&a.jsxs(je,{element:a.jsx(JV,{}),children:[a.jsx(je,{path:"findings",element:a.jsx(A_,{})}),a.jsx(je,{path:"findings/:findingId",element:a.jsx(D_,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:a.jsx(A_,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:a.jsx(D_,{})})]}),a.jsxs(je,{element:a.jsx(ZV,{}),children:[a.jsx(je,{path:"workspaces",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(je,{path:"workspaces/new",element:a.jsx(DU,{})}),a.jsx(je,{path:"workspaces/:workspaceId",element:a.jsx(Yp,{})}),a.jsx(je,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Yp,{})}),a.jsx(je,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Yp,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(_U,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(j_,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Za,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Za,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Za,{})}),a.jsx(je,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:a.jsx(Za,{})}),a.jsxs(je,{path:"environments",element:a.jsx($U,{}),children:[a.jsx(je,{index:!0,element:a.jsx(WP,{})}),a.jsx(je,{path:"new",element:a.jsx(RU,{})}),a.jsx(je,{path:":environmentId",element:a.jsx(mV,{})}),a.jsx(je,{path:":environmentId/edit",element:a.jsx(IU,{})})]})]}),a.jsx(je,{element:a.jsx(YV,{}),children:a.jsxs(je,{path:"settings",element:a.jsx(vV,{}),children:[a.jsx(je,{index:!0,element:a.jsx(zn,{to:"credentials",replace:!0})}),a.jsx(je,{path:"environments",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(je,{path:"credentials",element:a.jsx(yV,{})}),a.jsx(je,{path:"github-accounts",element:a.jsx(bV,{})}),a.jsx(je,{path:"tokens",element:a.jsx(zn,{to:"../credentials",replace:!0})}),a.jsx(je,{path:"personas",element:a.jsx(_V,{})}),a.jsx(je,{path:"personas/new",element:a.jsx(N_,{})}),a.jsx(je,{path:"personas/:personaId",element:a.jsx(N_,{})}),a.jsx(je,{path:"schedules",element:a.jsx(DV,{})}),a.jsx(je,{path:"schedules/new",element:a.jsx(C_,{})}),a.jsx(je,{path:"schedules/:scheduleId",element:a.jsx(C_,{})}),a.jsx(je,{path:"appearance",element:a.jsx(PV,{})}),a.jsx(je,{path:"shortcuts",element:a.jsx(qV,{})}),a.jsx(je,{path:"plugins",element:a.jsx(GV,{})}),a.jsx(je,{path:"about",element:a.jsx(VV,{})})]})}),a.jsx(je,{path:"*",element:a.jsx(zn,{to:"/",replace:!0})})]})]})}const Kq=1e4;function Zq(){const{onboardingCompleted:t}=ot(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),Kq);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(is,{mode:"wait",children:r?a.jsx(Ct.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(V1,{})},"splash"):a.jsx(Ct.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(PN,{basename:"/".replace(/\/$/,""),children:a.jsx(Fq,{})})},"app")})}function Yq(){const t=Sk?SH:o9;return a.jsx(TH,{children:a.jsx(Kz,{children:a.jsx(Vz,{children:a.jsx(t,{children:a.jsx(Zq,{})})})})})}lj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(Yq,{})}));export{ks as B,dx as K,ot as a,em as f,Ld as s,Pn as t,ut as u};