@grackle-ai/web 0.106.1 → 0.106.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 +1 @@
1
- import{t as nt,f as rt,b as A,z as it,s as T,h as st,k as X,j as N}from"./dagview-tHPW3Rz3.js";import{u as at,f as ot,s as ct,t as lt,a as ut,B as ft,K as ht}from"./index-cy4uHNRw.js";import"./grpc-DIjMtMRF.js";import"./markdown-Yr3vTPLR.js";function dt(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function gt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function xt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function _t(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function vt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function mt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function pt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function wt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Nt(){return this._root}function bt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function kt(t){var e=[],n,o=this._root,s,r,c,d,y;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function jt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function At(t){return t[0]}function It(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function U(t,e,n){var o=new P(e??At,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function P(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=U.prototype=P.prototype;R.copy=function(){var t=new P(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=gt;R.addAll=xt;R.cover=_t;R.data=yt;R.extent=vt;R.find=mt;R.remove=pt;R.removeAll=wt;R.root=Nt;R.size=bt;R.visit=kt;R.visitAfter=jt;R.x=It;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function Lt(t){return t.x+t.vx}function Rt(t){return t.y+t.vy}function Et(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=U(e,Lt,Rt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,I,C){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||I<h-g||b>p+g||C<p-g}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:O(+i),y(),c):t},c}function Dt(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Bt(t){var e=Dt,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,I,C,k,D,g;m<f;++m)x=t[m],b=x.source,I=x.target,C=I.x+I.vx-b.x-b.vx||S(i),k=I.y+I.vy-b.y-b.vy||S(i),D=Math.sqrt(C*C+k*k),D=(D-r[m])/D*a*o[m],C*=D,k*=D,I.vx-=C*(g=y[m]),I.vy-=k*g,b.vx+=C*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,I)=>[e(b,I,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const zt=1664525,Tt=1013904223,Q=4294967296;function St(){let t=1;return()=>(t=(zt*t+Tt)%Q)/Q}function $t(t){return t.x}function Gt(t){return t.y}var Ot=10,Ft=Math.PI*(3-Math.sqrt(5));function Kt(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=St();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var f=Ot*Math.sqrt(.5+l),m=l*Ft;u.x=f*Math.cos(m),u.y=f*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var f=0,m=t.length,x,b,I,C,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)C=t[f],x=l-C.x,b=a-C.y,I=x*x+b*b,I<u&&(k=C,u=I);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Ht(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=U(t,$t,Gt).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ut="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Xt="_link_13vy2_18",Yt="_node_13vy2_30",Wt="_nodeCard_13vy2_37",Qt="_nodeLabel_13vy2_43",Vt="_selected_13vy2_47",Zt="_dimmed_13vy2_54",Jt="_dimmedLink_13vy2_59",qt="_nodeIndicator_13vy2_71",te="_nodeBadge_13vy2_85",E={graphContainer:Ut,svg:Pt,link:Xt,node:Yt,nodeCard:Wt,nodeLabel:Qt,selected:Vt,dimmed:Zt,dimmedLink:Jt,nodeIndicator:qt,nodeBadge:te},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function ee(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ne({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const I of b)h({width:I.contentRect.width,height:I.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const I=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);I.append("title").text(g=>g.type),y.current=I;const C=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=C,C.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),C.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),C.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),C.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Kt(m).force("link",Bt(b).id(g=>g.id).distance(140)).force("charge",Ht().strength(-400)).force("center",dt(_.width/2,_.height/2)).force("collide",Et($/2+16)).on("tick",()=>{I.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),C.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return C.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=ee(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const re="_panel_1ml6r_1",ie="_header_1ml6r_24",se="_title_1ml6r_32",ae="_closeButton_1ml6r_42",oe="_body_1ml6r_55",ce="_badge_1ml6r_61",le="_section_1ml6r_72",ue="_sectionLabel_1ml6r_76",fe="_content_1ml6r_84",he="_tags_1ml6r_92",de="_tag_1ml6r_92",ge="_viewLink_1ml6r_107",xe="_edgeList_1ml6r_121",_e="_edgeItem_1ml6r_127",ye="_edgeType_1ml6r_136",ve="_edgeNodeLink_1ml6r_142",me="_timestamps_1ml6r_154",M={panel:re,header:ie,title:se,closeButton:ae,body:oe,badge:ce,section:le,sectionLabel:ue,content:fe,tags:he,tag:de,viewLink:ge,edgeList:xe,edgeItem:_e,edgeType:ye,edgeNodeLink:ve,timestamps:me};function pe({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(lt(r.sourceId));break;case"session":s(ct(r.sourceId));break;case"finding":s(ot(r.sourceId));break}}return N.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:M.header,children:[N.jsx("h3",{className:M.title,children:r.label}),N.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:M.body,children:[N.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Content"}),N.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Tags"}),N.jsx("div",{className:M.tags,children:r.tags.map(i=>N.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:M.section,children:N.jsx("button",{className:M.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:M.section,children:[N.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:M.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:M.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const we="_layout_n9vg6_1",Ne="_graphArea_n9vg6_8",be="_empty_n9vg6_15",H={layout:we,graphArea:Ne,empty:be};function Me(){const{knowledge:t}=ut();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ht}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ft,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ne,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(pe,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
1
+ import{t as nt,f as rt,b as A,z as it,s as T,h as st,k as X,j as N}from"./dagview-tHPW3Rz3.js";import{u as at,f as ot,s as ct,t as lt,a as ut,B as ft,K as ht}from"./index-BM6_EZWA.js";import"./grpc-DIjMtMRF.js";import"./markdown-Yr3vTPLR.js";function dt(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function gt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function xt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function _t(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function vt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function mt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function pt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function wt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Nt(){return this._root}function bt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function kt(t){var e=[],n,o=this._root,s,r,c,d,y;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function jt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function At(t){return t[0]}function It(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function U(t,e,n){var o=new P(e??At,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function P(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=U.prototype=P.prototype;R.copy=function(){var t=new P(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=gt;R.addAll=xt;R.cover=_t;R.data=yt;R.extent=vt;R.find=mt;R.remove=pt;R.removeAll=wt;R.root=Nt;R.size=bt;R.visit=kt;R.visitAfter=jt;R.x=It;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function Lt(t){return t.x+t.vx}function Rt(t){return t.y+t.vy}function Et(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=U(e,Lt,Rt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,I,C){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||I<h-g||b>p+g||C<p-g}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:O(+i),y(),c):t},c}function Dt(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Bt(t){var e=Dt,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,I,C,k,D,g;m<f;++m)x=t[m],b=x.source,I=x.target,C=I.x+I.vx-b.x-b.vx||S(i),k=I.y+I.vy-b.y-b.vy||S(i),D=Math.sqrt(C*C+k*k),D=(D-r[m])/D*a*o[m],C*=D,k*=D,I.vx-=C*(g=y[m]),I.vy-=k*g,b.vx+=C*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,I)=>[e(b,I,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const zt=1664525,Tt=1013904223,Q=4294967296;function St(){let t=1;return()=>(t=(zt*t+Tt)%Q)/Q}function $t(t){return t.x}function Gt(t){return t.y}var Ot=10,Ft=Math.PI*(3-Math.sqrt(5));function Kt(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=St();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var f=Ot*Math.sqrt(.5+l),m=l*Ft;u.x=f*Math.cos(m),u.y=f*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var f=0,m=t.length,x,b,I,C,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)C=t[f],x=l-C.x,b=a-C.y,I=x*x+b*b,I<u&&(k=C,u=I);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Ht(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=U(t,$t,Gt).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ut="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Xt="_link_13vy2_18",Yt="_node_13vy2_30",Wt="_nodeCard_13vy2_37",Qt="_nodeLabel_13vy2_43",Vt="_selected_13vy2_47",Zt="_dimmed_13vy2_54",Jt="_dimmedLink_13vy2_59",qt="_nodeIndicator_13vy2_71",te="_nodeBadge_13vy2_85",E={graphContainer:Ut,svg:Pt,link:Xt,node:Yt,nodeCard:Wt,nodeLabel:Qt,selected:Vt,dimmed:Zt,dimmedLink:Jt,nodeIndicator:qt,nodeBadge:te},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function ee(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ne({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const I of b)h({width:I.contentRect.width,height:I.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const I=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);I.append("title").text(g=>g.type),y.current=I;const C=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=C,C.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),C.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),C.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),C.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Kt(m).force("link",Bt(b).id(g=>g.id).distance(140)).force("charge",Ht().strength(-400)).force("center",dt(_.width/2,_.height/2)).force("collide",Et($/2+16)).on("tick",()=>{I.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),C.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return C.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=ee(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const re="_panel_1ml6r_1",ie="_header_1ml6r_24",se="_title_1ml6r_32",ae="_closeButton_1ml6r_42",oe="_body_1ml6r_55",ce="_badge_1ml6r_61",le="_section_1ml6r_72",ue="_sectionLabel_1ml6r_76",fe="_content_1ml6r_84",he="_tags_1ml6r_92",de="_tag_1ml6r_92",ge="_viewLink_1ml6r_107",xe="_edgeList_1ml6r_121",_e="_edgeItem_1ml6r_127",ye="_edgeType_1ml6r_136",ve="_edgeNodeLink_1ml6r_142",me="_timestamps_1ml6r_154",M={panel:re,header:ie,title:se,closeButton:ae,body:oe,badge:ce,section:le,sectionLabel:ue,content:fe,tags:he,tag:de,viewLink:ge,edgeList:xe,edgeItem:_e,edgeType:ye,edgeNodeLink:ve,timestamps:me};function pe({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(lt(r.sourceId));break;case"session":s(ct(r.sourceId));break;case"finding":s(ot(r.sourceId));break}}return N.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:M.header,children:[N.jsx("h3",{className:M.title,children:r.label}),N.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:M.body,children:[N.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Content"}),N.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Tags"}),N.jsx("div",{className:M.tags,children:r.tags.map(i=>N.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:M.section,children:N.jsx("button",{className:M.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:M.section,children:[N.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:M.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:M.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const we="_layout_n9vg6_1",Ne="_graphArea_n9vg6_8",be="_empty_n9vg6_15",H={layout:we,graphArea:Ne,empty:be};function Me(){const{knowledge:t}=ut();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ht}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ft,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ne,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(pe,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-BzbHIYVG.js","assets/dagview-tHPW3Rz3.js","assets/grpc-DIjMtMRF.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-DUXTl4nL.js","assets/dagview-tHPW3Rz3.js","assets/grpc-DIjMtMRF.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
2
  import{r as gT,a as vT,b,j as i,d as oy,H as ry,P as ly,i as yT,B as bT,c as xT,C as _T,M as kT,e as ST}from"./dagview-tHPW3Rz3.js";import{c as TT,a as kd,G as jT,b as wT,d as NT,e as CT,f as ET,M as AT,A as _x,D as kx,W as DT,O as MT,g as RT,C as Ci,h as Sx,i as Tx,w as IT,t as OT,p as Rc,j as BT,R as Or,S as cy}from"./grpc-DIjMtMRF.js";import{v as LT,r as zT,t as Ic,i as $T,f as PT,M as Sd,a as Td}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 Zf={exports:{}},Br={},Kf={exports:{}},Yf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -281,7 +281,7 @@ ${JSON.stringify(u,void 0,2)}
281
281
  \`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
282
282
  ${r.content}`);break}}}return s.join(`
283
283
 
284
- `)}function x6({events:t,formatForClipboard:s}){const[o,r]=b.useState(!1),[c,d]=b.useState(new Set),u=b.useRef(void 0),p=b.useMemo(()=>c.size,[c]),m=b.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=b.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=b.useCallback((S,j)=>{if(j&&u.current!==void 0){const N=Math.min(u.current,S),T=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let B=N;B<=T;B++)B<t.length&&dl(t[B])&&D.add(B);return D})}else d(N=>{const T=new Set(N);return T.has(S)?T.delete(S):T.add(S),T.size===0?(r(!1),u.current=void 0):u.current=S,T})},[t]),x=b.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)dl(t[j])&&S.add(j);d(S)},[t]),y=b.useCallback(()=>{d(new Set)},[]),k=b.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 N=s(j);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:x,deselectAll:y,copySelected:k}}const _6="_wrapper_1cdza_1",k6="_scrollContainer_1cdza_9",S6="_selectingPadding_1cdza_16",T6="_toolbar_1cdza_20",j6="_directionToggle_1cdza_27",w6="_scrollToAnchor_1cdza_65",N6="_scrollToAnchorBottom_1cdza_89",C6="_scrollToAnchorTop_1cdza_93",E6="_eventOverflowWarning_1cdza_97",ea={wrapper:_6,scrollContainer:k6,selectingPadding:S6,toolbar:T6,directionToggle:j6,scrollToAnchor:w6,scrollToAnchorBottom:N6,scrollToAnchorTop:C6,eventOverflowWarning:E6};function A6(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 D1="grackle-stream-direction";function D6(){try{return localStorage.getItem(D1)==="reversed"}catch{return!1}}function M6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:ea.eventOverflowWarning,role:"alert",children:[i.jsx(vm,{size:nn,"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 ch({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=b.useRef(null),[d,u]=b.useState(D6),p=g3(),m=x6({events:t,formatForClipboard:b6}),g=b.useMemo(()=>t.filter(dl).length,[t]),v=b.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:x,scrollToAnchor:y}=g6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),k=()=>{const T=!d;u(T);try{localStorage.setItem(D1,T?"reversed":"default")}catch{}};b.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const S=b.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),j=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:ea.wrapper,children:[i.jsx("div",{className:ea.toolbar,children:i.jsx(zo,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:ea.directionToggle,onClick:k,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(vy,{size:nn,"aria-hidden":"true"}):i.jsx(yy,{size:nn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${ea.scrollContainer} ${m.isSelecting?ea.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(M6,{eventsDropped:s}),i.jsx(gs,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return i.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:j,ease:"easeOut"},children:i.jsx(i6,{copyText:y6(T),isContentBearing:dl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:A6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:B=>{m.toggleEvent(D,B)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(qA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),i.jsx(gs,{children:m.isSelecting&&i.jsx(p6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{S().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(gs,{children:!x&&i.jsxs(Rt.button,{className:`${ea.scrollToAnchor} ${d?ea.scrollToAnchorTop:ea.scrollToAnchorBottom}`,onClick:y,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:[d?i.jsx(yy,{size:nn,"aria-hidden":"true"}):i.jsx(vy,{size:nn,"aria-hidden":"true"})," New events"]})})]})}function dh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=b.useState(""),[x,y]=b.useState(""),k=b.useRef(!1),S=d===c,j=b.useCallback($=>{v($),y("")},[]),N=b.useCallback(()=>{y("")},[]),T=b.useCallback(()=>{k.current=!1,u==null||u(null),v(""),y("")},[u]),C=b.useCallback(()=>{const $=m?g.trim():g;if(r){const U=r(g);if(U){y(U);return}}const L=m?s.trim():s;if($===L){T();return}o($),T()},[g,s,m,r,o,T]),D=b.useCallback(()=>{k.current=!0,u==null||u(c),v(s),y("")},[c,s,u]),B=b.useCallback($=>{if(k.current){k.current=!1;return}$.relatedTarget instanceof HTMLElement&&$.relatedTarget.dataset.editAction===c||C()},[c,C]),E=b.useCallback($=>{$.key==="Escape"?T():$.key==="Enter"&&p&&C()},[T,p,C]),A=(()=>{if(!S)return!1;const $=m?s.trim():s;return(m?g.trim():g)!==$})();return b.useEffect(()=>{!S&&(g!==""||x!=="")&&(v(""),y(""))},[S,g,x]),{isEditing:S,draft:g,error:x,isDirty:A,startEdit:D,cancelEdit:T,save:C,setDraft:j,clearError:N,handleBlur:B,handleKeyDown:E,ignoreInitialBlurRef:k}}const R6="_editFieldWrapper_yuzty_1",I6="_editInput_yuzty_10",O6="_editTextarea_yuzty_42",B6="_editSelect_yuzty_78",L6="_editError_yuzty_111",z6="_editInputInvalid_yuzty_118",$6="_editHint_yuzty_123",P6="_unsavedDot_yuzty_132",U6="_metaValueClickable_yuzty_140",H6="_editButton_yuzty_159",V6="_metaPlaceholder_yuzty_175",q6="_worktreeToggle_yuzty_180",st={editFieldWrapper:R6,editInput:I6,editTextarea:O6,editSelect:B6,editError:L6,editInputInvalid:z6,editHint:$6,unsavedDot:P6,metaValueClickable:U6,editButton:H6,metaPlaceholder:V6,worktreeToggle:q6};function Ft(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:x,ariaLabel:y,"data-testid":k}=t,S=b.useRef(null),j=dh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(b.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=S.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 i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{className:`${st.editInput} ${C?st.editInputInvalid:""}`,value:s,onChange:T,maxLength:x,placeholder:v,"aria-label":y,"data-testid":k?`${k}-input`:void 0}),C&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{ref:S,className:`${st.editInput} ${j.error?st.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:x,placeholder:v,"aria-label":y,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:st.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":y,"data-testid":k?`${k}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function cm(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:x,"data-testid":y}=t,k=b.useRef(null),S=dh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(b.useEffect(()=>{if(S.isEditing){const N=window.setTimeout(()=>{var T;(T=k.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[S.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{className:`${st.editTextarea} ${T?st.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),T&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:T})]})}if(S.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{ref:k,className:`${st.editTextarea} ${S.error?st.editInputInvalid:""}`,value:S.draft,onChange:N=>S.setDraft(N.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:x,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),S.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),S.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:S.error}),i.jsx("span",{className:st.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function yd(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:x,"data-testid":y}=t,k=b.useRef(null),S=dh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});b.useEffect(()=>{if(S.isEditing){const B=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(B)}},[S.isEditing]);const j=b.useCallback(B=>{const E=B.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),N=b.useCallback(B=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return i.jsx("select",{className:st.editSelect,value:s,onChange:B=>m==null?void 0:m(B.target.value),"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});if(S.isEditing)return i.jsx("select",{ref:k,className:st.editSelect,value:S.draft,onChange:j,onBlur:N,title:x,"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});const T=g==null?void 0:g(s),C=(D=c.find(B=>B.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:st.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function G6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:st.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const F6="_nav_1snmp_1",Z6="_searchForm_1snmp_8",K6="_searchInput_1snmp_15",Y6="_searchButton_1snmp_33",J6="_clearButton_1snmp_68",W6="_workspaceSelect_1snmp_85",X6="_listHeader_1snmp_99",Q6="_nodeList_1snmp_108",e5="_nodeItem_1snmp_116",t5="_indicator_1snmp_129",n5="_label_1snmp_136",s5="_badge_1snmp_145",Wn={nav:F6,searchForm:Z6,searchInput:K6,searchButton:Y6,clearButton:J6,workspaceSelect:W6,listHeader:X6,nodeList:Q6,nodeItem:e5,indicator:t5,label:n5,badge:s5};function a5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=b.useState(""),v=b.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),x=b.useCallback(()=>{g(""),d()},[d]),y=b.useCallback(S=>{u(S)},[u]),k=b.useCallback(S=>{g(""),p(S)},[p]);return i.jsxs("div",{className:Wn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Wn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Wn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Wn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Wn.clearButton,onClick:x,children:"Clear search"}),i.jsxs("select",{className:Wn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>i.jsx("option",{value:S.id,children:S.name},S.id))]}),i.jsxs("div",{className:Wn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Wn.nodeList,children:t.map(S=>i.jsxs("li",{className:Wn.nodeItem,onClick:()=>{y(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),y(S.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Wn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Wn.label,children:S.label}),i.jsx("span",{className:Wn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const i5="_container_1mq5u_1",o5="_hamburger_1mq5u_33",r5="_brand_1mq5u_49",l5="_brandLogo_1mq5u_68",c5="_info_1mq5u_75",d5="_connectionLabel_1mq5u_90",u5="_connectionDot_1mq5u_103",f5="_connected_1mq5u_106",p5="_disconnected_1mq5u_110",Xs={container:i5,hamburger:o5,brand:r5,brandLogo:l5,info:c5,connectionLabel:d5,connectionDot:u5,connected:f5,disconnected:p5};function m5({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=mt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Xs.container,children:[r&&i.jsx("button",{type:"button",className:Xs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(X2,{size:Nt,"aria-hidden":"true"})}),i.jsx(zo,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Xs.brand,onClick:()=>d(Di),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Xs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Xs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Xs.connectionDot} ${t?Xs.connected:Xs.disconnected}`,"aria-hidden":"true",children:i.jsx(Va,{size:ym,fill:"currentColor"})})," ",i.jsx("span",{className:Xs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const h5="_nav_13gkc_1",g5="_tab_13gkc_35",v5="_tabIcon_13gkc_68",y5="_tabLabel_13gkc_79",b5="_tabActive_13gkc_84",Ur={nav:h5,tab:g5,tabIcon:v5,tabLabel:y5,tabActive:b5},sd=[{view:"dashboard",label:"Dashboard",icon:i.jsx($2,{size:Nt}),route:Di,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(ej,{size:Nt}),route:jN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(w2,{size:Nt}),route:wN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(nj,{size:Nt}),route:Ro,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(y2,{size:Nt}),route:Wx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(Cx,{size:Nt}),route:Ad,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(pj,{size:Nt}),route:xN,testId:"sidebar-tab-settings"}];function x5(t){return t===Di||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Wx)?"knowledge":t.startsWith(Ad)?"findings":t.startsWith(wi)?"settings":"tasks"}function _5({tabs:t=sd}){const s=Yt(),o=mt(),r=b.useRef(null),c=x5(s.pathname),d=b.useCallback(p=>{o(p.route)},[o]),u=b.useCallback(p=>{var y,k;const m=(y=r.current)==null?void 0:y.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(S=>S===document.activeElement),v=g>=0?g:t.findIndex(S=>S.view===c);let x=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=t.length-1;else return;o(t[x].route),(k=m[x])==null||k.focus()},[c,o,t]);return i.jsx("nav",{className:Ur.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx(zo,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Ur.tab} ${m?Ur.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:Ur.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:Ur.tabLabel,children:p.label})]})},p.view)})})}const k5="_container_pi6ii_1",S5="_content_pi6ii_66",Wb={container:k5,content:S5},T5=320,M1=220,R1=600,I1="grackle-sidebar-width";function j5(){try{const t=localStorage.getItem(I1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=M1&&s<=R1)return s}}catch{}return T5}function w5(t){try{localStorage.setItem(I1,String(t))}catch{}}function N5({content:t}){const[s]=b.useState(j5),o=b.useRef(null);if(b.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>=M1&&m<=R1&&w5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Wb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Wb.content,children:t})})}const C5="_bar_tnfsh_1",E5="_btnPrimary_tnfsh_32",A5="_statusText_tnfsh_85",D5="_statusCompleted_tnfsh_90",M5="_statusFailed_tnfsh_94",R5="_statusBlocked_tnfsh_98",I5="_hintText_tnfsh_103",jt={bar:C5,btnPrimary:E5,statusText:A5,statusCompleted:D5,statusFailed:M5,statusBlocked:R5,hintText:I5};function O5({sessions:t,tasks:s,environments:o}){const r=mt(),c=Yt(),d=Dt("/sessions/:sessionId"),u=Dt("/tasks/:taskId"),p=Dt("/tasks/:taskId/stream"),m=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),x=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),y=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),k=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),S=Dt("/sessions/new"),j=Dt("/environments/:environmentId/workspaces/:workspaceId"),N=Dt("/tasks/new"),T=Dt("/chat"),C=Dt("/"),D=Dt("/settings/*"),B=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)??(x==null?void 0:x.params.taskId)??(y==null?void 0:y.params.taskId)??(k==null?void 0:k.params.taskId),A=v??x??y??k,$=(A==null?void 0:A.params.environmentId)??(j==null?void 0:j.params.environmentId),L=c.pathname.startsWith("/environments")&&!j&&!A,U=!!T,J=!!S,V=!!j&&!v&&!x&&!y&&!k,K=!!N;if(!!C&&!J&&!V&&!K||!!D||(!!g||!!k)||K||L||J)return i.jsx(i.Fragment,{});if(U)return o.find(O=>O.adapterType==="local"&&O.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if(V)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(E){const M=s.find(he=>he.id===E);if(!M)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const O=new Map(s.map(he=>[he.id,he])),X=M.dependsOn.some(he=>{const W=O.get(he);return W!==void 0&&W.status!=="complete"});if(M.status==="not_started"){const he=X?M.dependsOn.map(W=>O.get(W)).filter(W=>W&&W.status!=="complete").map(W=>W.title):[];return i.jsx("div",{className:jt.bar,children:X?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",he.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(M.status==="working"||M.status==="paused"){const he=M.latestSessionId||void 0,W=he?t.find(fe=>fe.id===he):void 0;return W&&W.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(M.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ii(M.workspaceId,void 0,$)),className:jt.btnPrimary,children:"+ New Task"})]});if(M.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(B){const M=t.find(he=>he.id===B),O=(M==null?void 0:M.status)==="stopped";if(M!==void 0&&!O)return i.jsx(i.Fragment,{});if(O)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",M.endReason||M.status]}),i.jsx("button",{onClick:()=>r(Zx(M.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const B5="_nav_14i94_1",L5="_tab_14i94_24",z5="_tabActive_14i94_62",$5="_tabLabel_14i94_75",P5="_statusDot_14i94_81",U5="_pulse_14i94_87",H5="_addButton_14i94_99",V5="_empty_14i94_132",Ba={nav:B5,tab:L5,tabActive:z5,tabLabel:$5,statusDot:P5,pulse:U5,addButton:H5,empty:V5},q5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function G5({environments:t}){const s=mt(),o=b.useRef(null),r=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),d=Dt("/environments/:environmentId/workspaces/:workspaceId"),u=Dt("/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=b.useCallback(y=>{s(Ai(y))},[s]),v=b.useCallback(y=>{var T;const k=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%k.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+k.length)%k.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=k.length-1;else return;N<t.length&&s(Ai(t[N].id)),k[N].focus()},[m,t,s]),x=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ba.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(y=>{const k=y.id===m,S=y.id===x,j=q5[y.status]||"var(--text-tertiary)",N=y.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ba.tab} ${k?Ba.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ba.statusDot} ${N?Ba.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Va,{size:ym,fill:"currentColor"})}),i.jsx("span",{className:Ba.tabLabel,title:y.displayName||y.id,children:y.displayName||y.id})]},y.id)})}),i.jsx("button",{type:"button",className:Ba.addButton,onClick:()=>s(yN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ba.empty,children:"No environments yet."})]})}function $o(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 O1(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 Xb={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 bd(t){return Xb[t]||Xb.general}const F5="_nav_dlm8m_1",Z5="_categoryPills_dlm8m_24",K5="_categoryPill_dlm8m_24",Y5="_tab_dlm8m_42",J5="_tabActive_dlm8m_80",W5="_tabContent_dlm8m_93",X5="_tabLabel_dlm8m_100",Q5="_tabMeta_dlm8m_106",eI="_categoryDot_dlm8m_111",tI="_empty_dlm8m_118",js={nav:F5,categoryPills:Z5,categoryPill:K5,tab:Y5,tabActive:J5,tabContent:W5,tabLabel:X5,tabMeta:Q5,categoryDot:eI,empty:tI};function nI({findings:t,workspaceId:s,environmentId:o}){const r=mt(),c=b.useRef(null),d=Dt("/findings/:findingId"),u=Dt("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=b.useMemo(()=>{const y=new Set(t.map(k=>k.category).filter(Boolean));return Array.from(y).sort()},[t]),g=b.useCallback(y=>{r(qp(y,s,o))},[r,s,o]),v=b.useCallback(y=>{var T;const k=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===p);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%k.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+k.length)%k.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=k.length-1;else return;N<t.length&&r(qp(t[N].id,s,o)),k[N].focus()},[p,t,r,s,o]),x=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:js.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:js.categoryPills,"data-testid":"findings-nav-categories",children:m.map(y=>i.jsx("span",{className:js.categoryPill,style:{color:bd(y).text},children:y},y))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(y=>{const k=y.id===p,S=y.id===x;return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${js.tab} ${k?js.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:js.categoryDot,style:{color:bd(y.category).text},"aria-hidden":"true",children:i.jsx(Va,{size:ym,fill:"currentColor"})}),i.jsxs("span",{className:js.tabContent,children:[i.jsx("span",{className:js.tabLabel,title:y.title,children:y.title}),i.jsx("span",{className:js.tabMeta,title:y.createdAt,children:$o(y.createdAt)})]})]},y.id)})}),t.length===0&&i.jsx("div",{className:js.empty,children:"No findings yet. Agents will post discoveries here."})]})}function sI(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 B1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=sI(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function aI(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 iI(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 kj){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(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=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const oI="_container_z4i38_1",rI="_header_z4i38_5",lI="_headerActions_z4i38_17",cI="_searchInput_z4i38_23",dI="_searchHighlight_z4i38_56",uI="_groupToggle_z4i38_62",fI="_groupToggleActive_z4i38_89",pI="_addButton_z4i38_93",mI="_taskRow_z4i38_120",hI="_selected_z4i38_140",gI="_expandArrow_z4i38_150",vI="_expanded_z4i38_157",yI="_leafSpacer_z4i38_161",bI="_taskStatusIcon_z4i38_166",xI="_taskTitle_z4i38_170",_I="_workspaceBadge_z4i38_177",kI="_childCountBadge_z4i38_195",SI="_dependencyBadge_z4i38_208",TI="_blockedBadge_z4i38_220",jI="_addChildButton_z4i38_225",wI="_emptyState_z4i38_268",NI="_statusGroupHeader_z4i38_275",CI="_statusGroupIcon_z4i38_294",EI="_statusGroupLabel_z4i38_298",AI="_statusGroupCount_z4i38_303",Ze={container:oI,header:rI,headerActions:lI,searchInput:cI,searchHighlight:dI,groupToggle:uI,groupToggleActive:fI,addButton:pI,taskRow:mI,selected:hI,expandArrow:gI,expanded:vI,leafSpacer:yI,taskStatusIcon:bI,taskTitle:xI,workspaceBadge:_I,childCountBadge:kI,dependencyBadge:SI,blockedBadge:TI,addChildButton:jI,emptyState:wI,statusGroupHeader:NI,statusGroupIcon:CI,statusGroupLabel:EI,statusGroupCount:AI},DI=[{name:"title",weight:2},{name:"description",weight:1}],L1=16,MI=16,z1="grackle-task-group-by-status";function Qb(){try{return localStorage.getItem(z1)==="true"}catch{return!1}}function RI(t){try{localStorage.setItem(z1,String(t))}catch{}}function II({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Ze.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Ze.expandArrow} ${s?Ze.expanded:""}`,"aria-hidden":"true",children:i.jsx(la,{size:dt})}),i.jsx("span",{className:Ze.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ze.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ze.statusGroupCount,children:t.tasks.length})]}),i.jsx(gs,{children:s&&i.jsx(Rt.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=qa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(On(p.id)))},className:`${Ze.taskRow} ${g?Ze.selected:""}`,style:{"--task-indent":`${L1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ul(p.status)}`,children:m.icon}),i.jsx("span",{className:Ze.taskTitle,title:p.title,children:i.jsx(B1,{text:p.title,indices:d.get(p.id),highlightClass:Ze.searchHighlight})}),v&&i.jsx("span",{className:Ze.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function $1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=qa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),x=o.has(t.id),y=t.children.length>0,k=c===t.id,S=L1+s*MI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Ze.taskRow} ${k?Ze.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[y&&i.jsx("span",{className:`${Ze.expandArrow} ${x?Ze.expanded:""}`,role:"button",tabIndex:0,"aria-label":x?"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:i.jsx(la,{size:dt,"aria-hidden":"true"})}),!y&&i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ul(t.status)}`,children:g.icon}),i.jsx("span",{className:Ze.taskTitle,title:t.title,children:i.jsx(B1,{text:t.title,indices:p.get(t.id),highlightClass:Ze.searchHighlight})}),N&&i.jsx("span",{className:Ze.workspaceBadge,title:N,children:N}),y&&i.jsxs("span",{className:Ze.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ze.dependencyBadge} ${v?Ze.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<AT&&i.jsx(zo,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ze.addChildButton,children:"+"})})]}),i.jsx(gs,{children:y&&x&&i.jsx(Rt.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=>i.jsx($1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function OI({workspaces:t,tasks:s}){const o=mt(),[r,c]=b.useState(new Set),[d,u]=b.useState(new Set),[p,m]=b.useState(Qb),[g,v]=b.useState(Qb),[x,y]=b.useState(new Map),k=Dt("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=b.useMemo(()=>new Map(s.map(ee=>[ee.id,ee.status])),[s]),N=b.useMemo(()=>new Map(t.map(ee=>[ee.id,ee.name])),[t]),T=()=>{const ee=!p;RI(ee),m(ee),ee&&(v(!0),y(new Map))},C=ee=>{y(ie=>{const M=new Map(ie),O=M.has(ee)?M.get(ee):g;return M.set(ee,!O),M})},D=ee=>x.has(ee)?x.get(ee):g,B=ee=>{c(ie=>{const M=new Set(ie);return M.has(ee)?(M.delete(ee),u(O=>new Set(O).add(ee))):(M.add(ee),u(O=>{const X=new Set(O);return X.delete(ee),X})),M})};b.useEffect(()=>{const ee=new Set(s.filter(ie=>ie.parentTaskId).map(ie=>ie.parentTaskId));ee.size>0&&c(ie=>{const M=new Set(ie);for(const O of ee)d.has(O)||M.add(O);return M})},[s,d]);const[E,A]=b.useState(""),{directMatchTaskIds:$,treeMatchTaskIds:L,titleHighlights:U}=b.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const ee=ET(s,E,DI),ie=new Set(ee.map(he=>he.item.id)),M=new Map;for(const he of ee){const W=he.matches.find(ye=>ye.key==="title");W&&M.set(he.item.id,W.indices)}const O=new Set(ie),X=new Map(s.map(he=>[he.id,he]));for(const he of[...ie]){let W=X.get(he);for(;W!=null&&W.parentTaskId;)O.add(W.parentTaskId),W=X.get(W.parentTaskId)}return{directMatchTaskIds:ie,treeMatchTaskIds:O,titleHighlights:M}},[E,s]),J=$!==null,V=J?p?$:L:null,K=V?s.filter(ee=>V.has(ee.id)):s,de=p?[]:aI(K);return i.jsxs("div",{className:Ze.container,children:[i.jsxs("div",{className:Ze.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ze.headerActions,children:[i.jsx(zo,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ze.groupToggle} ${p?Ze.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:i.jsx(K2,{size:nn})})}),i.jsx(zo,{text:"New task",children:i.jsx("button",{className:Ze.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:ee=>A(ee.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ze.searchInput,"data-testid":"sidebar-search"}),p?iI(K,j).map(ee=>i.jsx(II,{group:ee,isExpanded:D(ee.status),onToggle:()=>C(ee.status),selectedTaskId:S,navigate:o,titleHighlights:U,workspaceNames:N},ee.status)):de.map(ee=>i.jsx($1,{node:ee,depth:0,expandedTasks:r,toggleTask:B,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:U,workspaceNames:N},ee.id)),K.length===0&&!J&&i.jsx("div",{className:Ze.emptyState,children:"No tasks yet. Click + to create one."}),K.length===0&&J&&i.jsx("div",{className:Ze.emptyState,children:"No matching tasks"})]})}const BI="_toast_ed2dk_1",LI="_success_ed2dk_18",zI="_icon_ed2dk_22",$I="_error_ed2dk_25",PI="_warning_ed2dk_32",UI="_info_ed2dk_38",HI="_message_ed2dk_53",VI="_close_ed2dk_60",Hr={toast:BI,success:LI,icon:zI,error:$I,warning:PI,info:UI,message:HI,close:VI},qI={success:i.jsx(Mi,{size:Nt}),error:i.jsx(Za,{size:Nt}),warning:i.jsx(vm,{size:Nt}),info:i.jsx(gm,{size:Nt})};function GI({toast:t,onDismiss:s}){return b.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Rt.div,{className:`${Hr.toast} ${Hr[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:[i.jsx("span",{className:Hr.icon,"aria-hidden":"true",children:qI[t.variant]}),i.jsx("span",{className:Hr.message,children:t.message}),i.jsx("button",{type:"button",className:Hr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Za,{size:nn,"aria-hidden":"true"})})]})}const FI="_container_qqse2_1",ZI={container:FI};function KI({toasts:t,onDismiss:s}){return i.jsx("div",{className:ZI.container,"data-testid":"toast-container",children:i.jsx(gs,{children:t.map(o=>i.jsx(GI,{toast:o,onDismiss:s},o.id))})})}const YI="_callout_e5awm_1",JI="_success_e5awm_11",WI="_icon_e5awm_15",XI="_error_e5awm_18",QI="_warning_e5awm_25",eO="_info_e5awm_32",tO="_content_e5awm_48",nO="_close_e5awm_53",Vr={callout:YI,success:JI,icon:WI,error:XI,warning:QI,info:eO,content:tO,close:nO},sO={success:i.jsx(Mi,{size:Nt}),error:i.jsx(Za,{size:Nt}),warning:i.jsx(vm,{size:Nt}),info:i.jsx(gm,{size:Nt})};function aO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=b.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Vr.callout,Vr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Vr.icon,"aria-hidden":"true",children:sO[t]}),i.jsx("span",{className:Vr.content,children:s}),o&&i.jsx("button",{type:"button",className:Vr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Za,{size:nn,"aria-hidden":"true"})})]})})}function iO({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(aO,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const oO="_container_de44x_1",rO="_emptyState_de44x_8",lO="_card_de44x_14",cO="_cardClickable_de44x_34",dO="_cardHeader_de44x_42",uO="_categoryBadge_de44x_54",fO="_findingTitle_de44x_62",pO="_findingDate_de44x_68",mO="_findingContent_de44x_80",hO="_tags_de44x_86",gO="_tag_de44x_86",fs={container:oO,emptyState:rO,card:lO,cardClickable:cO,cardHeader:dO,categoryBadge:uO,findingTitle:fO,findingDate:pO,findingContent:mO,tags:hO,tag:gO};function P1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:fs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:fs.container,children:t.map((o,r)=>{const c=bd(o.category),d=s?Rt.button:Rt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${fs.card} ${s?fs.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:[i.jsxs("div",{className:fs.cardHeader,children:[i.jsx("span",{className:fs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:fs.findingTitle,children:o.title}),i.jsx("span",{className:fs.findingDate,title:o.createdAt,children:$o(o.createdAt)})]}),i.jsx("div",{className:fs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:fs.tags,children:o.tags.map(u=>i.jsx("span",{className:fs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const vO="_container_1ingb_1",yO="_heading_1ingb_7",bO="_section_1ingb_14",xO="_sectionTitle_1ingb_26",_O="_sectionDescription_1ingb_35",kO="_emptyState_1ingb_41",SO="_tokenList_1ingb_48",TO="_tokenRow_1ingb_55",jO="_tokenBadge_1ingb_68",wO="_tokenName_1ingb_83",NO="_tokenTarget_1ingb_90",CO="_deleteButton_1ingb_99",EO="_addForm_1ingb_113",AO="_formRow_1ingb_119",DO="_input_1ingb_125",MO="_select_1ingb_155",RO="_addButton_1ingb_187",IO="_emptyStateInfo_1ingb_221",OO="_themeOptions_1ingb_229",BO="_themeOption_1ingb_229",LO="_themeOptionSelected_1ingb_254",zO="_themeOptionHeader_1ingb_259",$O="_themeOptionLabel_1ingb_266",PO="_themeOptionDesc_1ingb_273",UO="_variantToggle_1ingb_279",HO="_variantButton_1ingb_286",VO="_variantActive_1ingb_305",qO="_themeSwatches_1ingb_311",GO="_themeSwatch_1ingb_311",FO="_systemToggle_1ingb_325",ZO="_systemToggleHint_1ingb_341",KO="_themeActive_1ingb_348",YO="_aboutGrid_1ingb_354",JO="_aboutItem_1ingb_360",WO="_aboutLabel_1ingb_373",XO="_aboutValue_1ingb_379",QO="_aboutDot_1ingb_387",eB="_aboutDotConnected_1ingb_394",tB="_aboutDotDisconnected_1ingb_398",pe={container:vO,heading:yO,section:bO,sectionTitle:xO,sectionDescription:_O,emptyState:kO,tokenList:SO,tokenRow:TO,tokenBadge:jO,tokenName:wO,tokenTarget:NO,deleteButton:CO,addForm:EO,formRow:AO,input:DO,select:MO,addButton:RO,emptyStateInfo:IO,themeOptions:OO,themeOption:BO,themeOptionSelected:LO,themeOptionHeader:zO,themeOptionLabel:$O,themeOptionDesc:PO,variantToggle:UO,variantButton:HO,variantActive:VO,themeSwatches:qO,themeSwatch:GO,systemToggle:FO,systemToggleHint:ZO,themeActive:KO,aboutGrid:YO,aboutItem:JO,aboutLabel:WO,aboutValue:XO,aboutDot:QO,aboutDotConnected:eB,aboutDotDisconnected:tB},nB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function sB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=b.useState(""),[u,p]=b.useState(""),[m,g]=b.useState("env_var"),[v,x]=b.useState(""),[y,k]=b.useState(null),S=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(""),x("")},j=T=>{k(T)},N=()=>{y&&(o(y),r==null||r("Token deleted","info")),k(null)};return i.jsxs(i.Fragment,{children:[i.jsx(oa,{isOpen:y!==null,title:"Delete Token?",description:y?`"${y}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>k(null)}),i.jsxs("section",{className:pe.section,children:[i.jsx("h3",{className:pe.sectionTitle,children:"Tokens"}),i.jsx("p",{className:pe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:pe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:pe.tokenList,children:t.map(T=>i.jsxs("div",{className:pe.tokenRow,children:[i.jsx("span",{className:pe.tokenBadge,children:T.tokenType}),i.jsx("span",{className:pe.tokenName,children:T.name}),i.jsx("span",{className:pe.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:pe.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Za,{size:nn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:pe.addForm,onSubmit:S,children:[i.jsxs("div",{className:pe.formRow,children:[i.jsx("input",{className:pe.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:pe.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:pe.formRow,children:[i.jsx("select",{className:pe.select,value:m,onChange:T=>g(T.target.value),children:nB.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.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=>x(T.target.value)}),i.jsx("button",{className:pe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Ld=[{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"]}],U1=new Set(Ld.map(t=>t.id)),ex="grackle";function dm(t){return Ld.find(s=>s.id===t)}function aB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:pe.section,children:[i.jsx("h3",{className:pe.sectionTitle,children:"Appearance"}),i.jsx("p",{className:pe.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:pe.themeOptions,children:Ld.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 i.jsxs("button",{type:"button",className:`${pe.themeOption} ${p?pe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:pe.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:pe.themeOptionLabel,children:d.label}),i.jsx("span",{className:pe.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:pe.variantToggle,children:[i.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:"☼"}),i.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&&i.jsx("span",{className:pe.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:pe.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:pe.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:pe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:pe.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function iB({connected: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 i.jsxs("section",{className:pe.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:pe.sectionTitle,children:"About"}),i.jsx("p",{className:pe.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:pe.aboutGrid,children:[i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Connection"}),i.jsxs("span",{className:pe.aboutValue,children:[i.jsx("span",{className:`${pe.aboutDot} ${t?pe.aboutDotConnected:pe.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Environments"}),i.jsxs("span",{className:pe.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:pe.aboutValue,children:d})]}),i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Version"}),i.jsx("span",{className:pe.aboutValue,children:"0.106.0"})]})]})]})}const oB="_container_cddyd_1",rB="_header_cddyd_8",lB="_headerTitle_cddyd_35",cB="_badge_cddyd_44",dB="_headerActions_cddyd_54",uB="_body_cddyd_61",fB="_formContent_cddyd_73",pB="_section_cddyd_85",mB="_label_cddyd_91",hB="_titleInput_cddyd_98",gB="_descriptionTextarea_cddyd_131",vB="_parentContext_cddyd_167",yB="_parentLabel_cddyd_175",bB="_parentName_cddyd_182",xB="_personaSelect_cddyd_186",_B="_depList_cddyd_220",kB="_depItem_cddyd_226",SB="_depItemSelected_cddyd_248",TB="_noDeps_cddyd_252",jB="_btnPrimary_cddyd_258",wB="_btnGhost_cddyd_289",nt={container:oB,header:rB,headerTitle:lB,badge:cB,headerActions:dB,body:uB,formContent:fB,section:pB,label:mB,titleInput:hB,descriptionTextarea:gB,parentContext:vB,parentLabel:yB,parentName:bB,personaSelect:xB,depList:_B,depItem:kB,depItemSelected:SB,noDeps:TB,btnPrimary:jB,btnGhost:wB};function H1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:x}){const y=mt(),k=t==="edit",S=k&&s?d.find(xe=>xe.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[N,T]=b.useState(j),C=j||N,D=u.find(xe=>xe.id===C),B=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,A=k?(S==null?void 0:S.parentTaskId)??"":r??"",$=A?d.find(xe=>xe.id===A):void 0,[L,U]=b.useState((S==null?void 0:S.title)??""),[J,V]=b.useState((S==null?void 0:S.description)??""),[K,de]=b.useState((S==null?void 0:S.dependsOn)??[]),[ee,ie]=b.useState((S==null?void 0:S.defaultPersonaId)??""),[M,O]=b.useState((S==null?void 0:S.canDecompose)??!1),[X,he]=b.useState(!1),W=b.useRef(!1);b.useEffect(()=>{k&&S&&!W.current&&(W.current=!0,U(S.title),V(S.description),de(S.dependsOn),ie(S.defaultPersonaId),O(S.canDecompose))},[k,S]);const ye=d.filter(xe=>xe.workspaceId===C&&(!k||xe.id!==s)&&xe.id!==A),fe=L.trim().length>0&&(!k||S!==void 0)&&C.length>0,Ne=xe=>{de(Be=>Be.includes(xe)?Be.filter(It=>It!==xe):[...Be,xe])},Ue=()=>{!fe||X||k&&S===void 0||(k&&s?(g(s,L.trim(),J,K,ee),x==null||x("Task updated","success"),v?v():y(On(s,void 0,C,B),{replace:!0})):(he(!0),m(C,L.trim(),J,K.length>0?K:void 0,A||void 0,ee,M,()=>{x==null||x("Task created","success"),y(o?Ei(o,B):"/tasks",{replace:!0})},xe=>{x==null||x(xe,"error"),he(!1)})))},ge=()=>{if(v){v();return}y(k&&s?On(s,void 0,C,B):o?Ei(o,B):"/tasks")},ke=k?"edit task":A?"child task":"new task";return i.jsxs("div",{className:nt.container,children:[i.jsxs("div",{className:nt.header,children:[i.jsxs("div",{className:nt.headerTitle,children:[i.jsx("span",{className:nt.badge,children:ke}),$&&i.jsxs("span",{className:nt.parentContext,children:[i.jsx("span",{className:nt.parentLabel,children:"Child of"}),i.jsx("span",{className:nt.parentName,children:$.title})]})]}),i.jsxs("div",{className:nt.headerActions,children:[i.jsx("button",{onClick:Ue,disabled:!fe||X,className:nt.btnPrimary,"data-testid":"task-edit-save",children:X?"Creating…":k?"Save Changes":"Create"}),i.jsx("button",{onClick:ge,className:nt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:nt.body,children:i.jsxs("div",{className:nt.formContent,children:[E&&i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:xe=>T(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:L,onChange:xe=>U(xe.target.value),placeholder:"Task title...",autoFocus:!0,className:nt.titleInput,"data-testid":"task-edit-title",onKeyDown:xe=>{xe.key==="Enter"&&fe&&Ue()}})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:J,onChange:xe=>V(xe.target.value),placeholder:"Describe the task... (markdown supported)",className:nt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:ee,onChange:xe=>ie(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),!k&&i.jsx("div",{className:nt.section,children:i.jsxs("label",{className:nt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:M,onChange:xe=>O(xe.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:nt.section,children:[i.jsx("div",{className:nt.label,children:"Dependencies"}),ye.length===0?i.jsx("div",{className:nt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:nt.depList,children:ye.map(xe=>{const Be=K.includes(xe.id);return i.jsxs("label",{className:`${nt.depItem} ${Be?nt.depItemSelected:""}`,"data-testid":`dep-option-${xe.id}`,children:[i.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ne(xe.id)}),xe.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",xe.status,")"]})]},xe.id)})})]})]})})]})}const NB="_actionButtons_1rjka_1",CB="_btnPrimary_1rjka_8",EB="_btnDanger_1rjka_39",AB="_btnGhost_1rjka_78",Kt={actionButtons:NB,btnPrimary:CB,btnDanger:EB,btnGhost:AB};function DB({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?i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Kt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Kt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Kt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Kt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const MB="_workpadSection_y8nj9_1",RB="_workpadLabel_y8nj9_9",IB="_workpadStatus_y8nj9_17",OB="_workpadSummary_y8nj9_23",BB="_workpadExtra_y8nj9_29",La={workpadSection:MB,workpadLabel:RB,workpadStatus:IB,workpadSummary:OB,workpadExtra:BB};function LB({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 i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),i.jsx("div",{className:La.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:La.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:La.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:La.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const zB="_overviewDashboard_r05qm_1",$B="_overviewHero_r05qm_7",PB="_statusBadge_r05qm_14",UB="_statusPending_r05qm_26",HB="_statusAssigned_r05qm_31",VB="_statusInProgress_r05qm_36",qB="_statusReview_r05qm_41",GB="_statusDone_r05qm_46",FB="_statusFailed_r05qm_51",ZB="_statusWaitingInput_r05qm_56",KB="_overviewBranchPill_r05qm_61",YB="_branchLink_r05qm_76",JB="_overviewSection_r05qm_87",WB="_overviewLabel_r05qm_93",XB="_overviewValue_r05qm_100",QB="_overviewMuted_r05qm_105",eL="_overviewMarkdown_r05qm_111",tL="_envRow_r05qm_180",nL="_envDot_r05qm_186",sL="_envDotGreen_r05qm_193",aL="_envDotYellow_r05qm_197",iL="_envDotRed_r05qm_201",oL="_envDotGray_r05qm_205",rL="_depList_r05qm_209",lL="_depItem_r05qm_215",cL="_depBlocked_r05qm_222",dL="_depDone_r05qm_226",uL="_timeline_r05qm_230",fL="_timelineRow_r05qm_236",pL="_timelineKey_r05qm_243",mL="_timelineValue_r05qm_249",hL="_timelineDelta_r05qm_253",gL="_reviewNotes_r05qm_264",ve={overviewDashboard:zB,overviewHero:$B,statusBadge:PB,statusPending:UB,statusAssigned:HB,statusInProgress:VB,statusReview:qB,statusDone:GB,statusFailed:FB,statusWaitingInput:ZB,overviewBranchPill:KB,branchLink:YB,overviewSection:JB,overviewLabel:WB,overviewValue:XB,overviewMuted:QB,overviewMarkdown:eL,envRow:tL,envDot:nL,envDotGreen:sL,envDotYellow:aL,envDotRed:iL,envDotGray:oL,depList:rL,depItem:lL,depBlocked:cL,depDone:dL,timeline:uL,timelineRow:fL,timelineKey:pL,timelineValue:mL,timelineDelta:hL,reviewNotes:gL};function qc(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 Cp(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 tx(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ve.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ve.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ve.envDotRed:ve.envDotGray}function vL({status:t}){const s=qa(t),o=_j(t);return i.jsx("span",{className:`${ve.statusBadge} ${ve[o]??ve.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function yL({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(S=>S.id===g):void 0,x=r.find(S=>S.id===t.workspaceId),y=o.find(S=>S.id===d),k=t.branch&&(x!=null&&x.repoUrl)?`${x.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:ve.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:ve.overviewHero,children:[i.jsx(vL,{status:t.status}),t.branch&&i.jsx("span",{className:ve.overviewBranchPill,"data-testid":"task-overview-branch",children:k?i.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:ve.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:ve.overviewLabel,children:"Description"}),i.jsx("div",{className:ve.overviewMarkdown,children:i.jsx(Sd,{remarkPlugins:[Td],children:t.description})})]}),t.workpad&&i.jsx(LB,{workpad:t.workpad}),i.jsxs("div",{className:ve.overviewSection,children:[i.jsx("div",{className:ve.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${tx(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:v.displayName})]}):y?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${tx(y.status)}`,title:y.status,"aria-label":`Status: ${y.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:y.displayName}),i.jsx("span",{className:ve.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:ve.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:ve.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:ve.overviewMuted,children:"None"}):i.jsx("div",{className:ve.depList,children:t.dependsOn.map(S=>{const j=s.get(S),N=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${ve.depItem} ${N?ve.depDone:ve.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:ve.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:ve.timeline,children:[t.createdAt&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Created"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Cp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Assigned"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.assignedAt)}),S!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Cp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Started"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.startedAt)}),S!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Cp(t.startedAt,t.completedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Completed"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.completedAt)}),S!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:ve.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:ve.overviewLabel,children:"Usage"}),i.jsxs("div",{className:ve.timeline,children:[i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsx("span",{className:ve.timelineValue,children:Ns(u.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:ve.timelineValue,children:Ns(p.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:ve.overviewLabel,children:"Budget"}),i.jsxs("div",{className:ve.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Tokens"}),i.jsxs("span",{className:ve.timelineValue,children:[Io(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Io(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsxs("span",{className:ve.timelineValue,children:[Ns((u==null?void 0:u.costMillicents)??0)," / ",Ns(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:ve.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:ve.reviewNotes,children:t.reviewNotes})]})]})}function bL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:pe.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:pe.heading,children:"Plugins"}),i.jsxs("div",{className:pe.section,children:[i.jsx("p",{className:pe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:pe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:pe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:pe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{className:pe.tokenName,children:r.name}),r.required&&i.jsx("span",{className:pe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:pe.tokenTarget,children:r.description}),c&&i.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"})]}),i.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:i.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)})]})]})}const xL="_container_legrg_1",_L="_header_legrg_8",kL="_headerTitle_legrg_35",SL="_badge_legrg_44",TL="_headerActions_legrg_54",jL="_body_legrg_61",wL="_formContent_legrg_73",NL="_section_legrg_85",CL="_label_legrg_91",EL="_nameInput_legrg_98",AL="_fieldInput_legrg_131",DL="_adapterSelect_legrg_164",ML="_readOnlyValue_legrg_198",RL="_codespaceSection_legrg_204",IL="_codespaceActions_legrg_210",OL="_creatingHint_legrg_216",BL="_errorHint_legrg_222",LL="_btnPrimary_legrg_235",zL="_btnGhost_legrg_266",le={container:xL,header:_L,headerTitle:kL,badge:SL,headerActions:TL,body:jL,formContent:wL,section:NL,label:CL,nameInput:EL,fieldInput:AL,adapterSelect:DL,readOnlyValue:ML,codespaceSection:RL,codespaceActions:IL,creatingHint:OL,errorHint:BL,btnPrimary:LL,btnGhost:zL},ad=1,id=65535;function Ep(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=ad&&s<=id}function Ap(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function $L({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=b.useState("pick"),[x,y]=b.useState(""),[k,S]=b.useState("");return g==="create"?i.jsxs("div",{className:le.codespaceSection,children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Repository"}),i.jsx("input",{type:"text",value:x,onChange:j=>y(j.target.value),placeholder:"owner/repo",className:le.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:le.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:le.codespaceActions,children:[i.jsx("button",{onClick:()=>{x.trim()&&(m(x.trim(),k.trim()||void 0),v("pick"),y(""),S(""))},disabled:!x.trim(),className:le.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),y(""),S("")},className:le.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:le.codespaceSection,children:i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Codespace"}),!u&&i.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:le.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>i.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:le.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:le.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:le.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:le.errorHint,children:d})]})})}function V1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:x}){const y=mt(),k=t==="edit",S=k&&s?o.find(ge=>ge.id===s):void 0,[j,N]=b.useState(""),[T,C]=b.useState("local"),[D,B]=b.useState(""),[E,A]=b.useState(""),[$,L]=b.useState(""),[U,J]=b.useState(""),[V,K]=b.useState(""),[de,ee]=b.useState(""),[ie,M]=b.useState(""),[O,X]=b.useState(null),he=b.useCallback(()=>{const ge={};if(T==="local"){if(D.trim()&&(ge.host=D.trim()),E.trim()){const ke=Number(E);Number.isInteger(ke)&&(ge.port=ke)}}else if(T==="ssh"){if(ge.host=D.trim(),$.trim()&&(ge.user=$.trim()),E.trim()){const ke=Number(E);Number.isInteger(ke)&&(ge.sshPort=ke)}U.trim()&&(ge.identityFile=U.trim())}else T==="docker"?(V.trim()&&(ge.image=V.trim()),de.trim()&&(ge.repo=de.trim())):T==="codespace"&&(ge.codespaceName=ie.trim());return ge},[T,D,E,$,U,V,de,ie]),W=()=>!(!j.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!ie.trim()||(T==="local"||T==="ssh")&&!Ep(E)),ye=()=>{W()&&(r(j.trim(),T,he()),x==null||x("Environment added successfully","success"),y(Ro,{replace:!0}))},fe=()=>{y(s?Ai(s):Ro)},Ne=b.useCallback((ge,ke)=>{if(!S||!s)return;const xe=Ap(S.adapterConfig),Be=ke.trim();Be?xe[ge]=Be:delete xe[ge],c(s,{adapterConfig:xe})},[S,s,c]),Ue=b.useCallback((ge,ke)=>{if(!S||!s)return;const xe=Ap(S.adapterConfig);if(ke.trim()){const Be=Number(ke);Number.isInteger(Be)&&Be>=ad&&Be<=id&&(xe[ge]=Be)}else delete xe[ge];c(s,{adapterConfig:xe})},[S,s,c]);if(k){if(!S)return i.jsxs("div",{className:le.container,children:[i.jsxs("div",{className:le.header,children:[i.jsx("div",{className:le.headerTitle,children:i.jsx("span",{className:le.badge,children:"edit environment"})}),i.jsx("div",{className:le.headerActions,children:i.jsx("button",{onClick:fe,className:le.btnGhost,children:"Back"})})]}),i.jsx("div",{className:le.body,children:i.jsx("div",{className:le.formContent,children:i.jsx("span",{className:le.readOnlyValue,children:"Environment not found"})})})]});const ge=Ap(S.adapterConfig);return i.jsxs("div",{className:le.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:le.header,children:[i.jsx("div",{className:le.headerTitle,children:i.jsx("span",{className:le.badge,children:"edit environment"})}),i.jsx("div",{className:le.headerActions,children:i.jsx("button",{onClick:fe,className:le.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:le.body,children:i.jsxs("div",{className:le.formContent,children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Name"}),i.jsx(Ft,{value:S.displayName,onSave:ke=>{s&&c(s,{displayName:ke})},validate:ke=>ke.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:O,onActivate:X,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Adapter Type"}),i.jsx("span",{className:le.readOnlyValue,"data-testid":"env-edit-adapter-type",children:S.adapterType})]}),S.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:ke=>Ne("host",ke),mode:"edit",fieldId:"host",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Port"}),i.jsx(Ft,{value:String(ge.port??""),onSave:ke=>Ue("port",ke),validate:ke=>Ep(ke)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),S.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:ke=>Ne("host",ke),validate:ke=>ke.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:O,onActivate:X,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"User"}),i.jsx(Ft,{value:String(ge.user??""),onSave:ke=>Ne("user",ke),mode:"edit",fieldId:"user",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"SSH Port"}),i.jsx(Ft,{value:String(ge.sshPort??""),onSave:ke=>Ue("sshPort",ke),validate:ke=>Ep(ke)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:O,onActivate:X,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Identity File"}),i.jsx(Ft,{value:String(ge.identityFile??""),onSave:ke=>Ne("identityFile",ke),mode:"edit",fieldId:"identityFile",activeFieldId:O,onActivate:X,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),S.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Image"}),i.jsx(Ft,{value:String(ge.image??""),onSave:ke=>Ne("image",ke),mode:"edit",fieldId:"image",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Repo"}),i.jsx(Ft,{value:String(ge.repo??""),onSave:ke=>Ne("repo",ke),mode:"edit",fieldId:"repo",activeFieldId:O,onActivate:X,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),S.adapterType==="codespace"&&i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Codespace Name"}),i.jsx(Ft,{value:String(ge.codespaceName??""),onSave:ke=>Ne("codespaceName",ke),validate:ke=>ke.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:O,onActivate:X,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:le.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:le.header,children:[i.jsx("div",{className:le.headerTitle,children:i.jsx("span",{className:le.badge,children:"new environment"})}),i.jsxs("div",{className:le.headerActions,children:[i.jsx("button",{onClick:ye,disabled:!W(),className:le.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:fe,className:le.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:le.body,children:i.jsxs("div",{className:le.formContent,children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:j,onChange:ge=>N(ge.target.value),placeholder:"Environment name...",autoFocus:!0,className:le.nameInput,"data-testid":"env-create-name",onKeyDown:ge=>{ge.key==="Enter"&&W()&&ye()}})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:ge=>{C(ge.target.value),ge.target.value==="codespace"&&d()},className:le.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ge=>B(ge.target.value),placeholder:"Host (optional)...",className:le.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ad,max:id,value:E,onChange:ge=>A(ge.target.value),placeholder:"Port (optional)...",className:le.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ge=>B(ge.target.value),placeholder:"Host (required)...",className:le.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:$,onChange:ge=>L(ge.target.value),placeholder:"User (optional)...",className:le.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ad,max:id,value:E,onChange:ge=>A(ge.target.value),placeholder:"SSH port (optional)...",className:le.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:U,onChange:ge=>J(ge.target.value),placeholder:"Identity file (optional)...",className:le.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:V,onChange:ge=>K(ge.target.value),placeholder:"Image (optional)...",className:le.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:de,onChange:ge=>ee(ge.target.value),placeholder:"Repo (optional)...",className:le.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx($L,{codespaceName:ie,onCodespaceNameChange:M,envName:j,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const PL="_group_1iprv_1",UL="_groupTitle_1iprv_8",HL="_shortcutList_1iprv_17",VL="_shortcutRow_1iprv_23",qL="_keys_1iprv_36",GL="_kbd_1iprv_43",FL="_description_1iprv_60",ki={group:PL,groupTitle:UL,shortcutList:HL,shortcutRow:VL,keys:qL,kbd:GL,description:FL},ZL=[{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:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function KL(){return i.jsxs("section",{className:pe.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:pe.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:pe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),ZL.map(t=>i.jsxs("div",{className:ki.group,children:[i.jsx("h4",{className:ki.groupTitle,children:t.title}),i.jsx("div",{className:ki.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:ki.shortcutRow,children:[i.jsx("span",{className:ki.keys,children:s.keys.map(o=>i.jsx("kbd",{className:ki.kbd,children:o},o))}),i.jsx("span",{className:ki.description,children:s.description})]},s.description))})]},t.title))]})}const YL=[{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 JL({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:pe.section,children:[i.jsx("h3",{className:pe.sectionTitle,children:"Credential Providers"}),i.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."}),i.jsx("div",{className:pe.tokenList,children:YL.map(r=>i.jsxs("div",{className:pe.tokenRow,children:[i.jsx("span",{className:pe.tokenName,children:r.label}),i.jsx("span",{className:pe.tokenTarget,children:r.description}),i.jsx("select",{className:pe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const WL="_container_10efq_1",XL="_header_10efq_7",QL="_list_10efq_105",e8="_card_10efq_111",t8="_cardHeader_10efq_125",n8="_cardTitle_10efq_135",s8="_defaultBadge_10efq_141",a8="_cardActions_10efq_155",i8="_description_10efq_160",o8="_meta_10efq_166",r8="_empty_10efq_212",l8="_typeBadge_10efq_362",Xn={container:WL,header:XL,list:QL,card:e8,cardHeader:t8,cardTitle:n8,defaultBadge:s8,cardActions:a8,description:i8,meta:o8,empty:r8,typeBadge:l8};function c8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=b.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Xn.container,children:[i.jsxs("div",{className:Xn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Xn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Xn.list,children:t.map(v=>{const x=s===v.id,y=v.type==="script";return i.jsxs("div",{className:Xn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Xn.cardHeader,children:[i.jsxs("span",{className:Xn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Xn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:y?"Script":"Agent"}),x&&i.jsx("span",{className:Xn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Xn.cardActions,onClick:k=>k.stopPropagation(),children:[!x&&i.jsx(tn,{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"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Xn.description,children:v.description}),i.jsxs("div",{className:Xn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(oa,{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 d8="_container_uy08i_1",u8="_header_uy08i_7",f8="_count_uy08i_13",p8="_presets_uy08i_18",m8="_presetButton_uy08i_24",h8="_filterInput_uy08i_41",g8="_groups_uy08i_53",v8="_group_uy08i_53",y8="_groupHeader_uy08i_68",b8="_groupName_uy08i_77",x8="_groupCount_uy08i_81",_8="_toolList_uy08i_87",k8="_toolItem_uy08i_95",S8="_toolName_uy08i_103",gn={container:d8,header:u8,count:f8,presets:p8,presetButton:m8,filterInput:h8,groups:g8,group:v8,groupHeader:y8,groupName:b8,groupCount:x8,toolList:_8,toolItem:k8,toolName:S8},T8=(()=>{const t=new Map;for(const s of _x){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()}))})(),j8=[{name:"default",label:"Default",tools:kx},{name:"worker",label:"Worker",tools:DT},{name:"orchestrator",label:"Orchestrator",tools:MT},{name:"admin",label:"Admin",tools:RT}];function nx({selectedTools:t,onChange:s,disabled:o}){const[r,c]=b.useState(""),d=b.useMemo(()=>new Set(t),[t]),u=b.useCallback(v=>{if(o)return;const x=new Set(d);x.has(v)?x.delete(v):x.add(v),s([...x].sort())},[d,s,o]),p=b.useCallback((v,x)=>{if(o)return;const y=new Set(d);for(const k of v)x?y.delete(k):y.add(k);s([...y].sort())},[d,s,o]),m=b.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:gn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:gn.header,children:i.jsx("span",{className:gn.count,children:t.length===0?`Using default (${kx.length} tools)`:`${t.length} of ${_x.size} tools selected`})}),i.jsxs("div",{className:gn.presets,"data-testid":"mcp-tool-presets",children:[j8.map(v=>i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:gn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:gn.groups,children:T8.map(({group:v,tools:x})=>{const y=g?x.filter(S=>S.toLowerCase().includes(g)):x;if(y.length===0)return null;const k=y.every(S=>d.has(S));return i.jsxs("div",{className:gn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:gn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(y,k),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:gn.groupName,children:v}),i.jsxs("span",{className:gn.groupCount,children:["(",y.filter(S=>d.has(S)).length,"/",y.length,")"]})]}),i.jsx("div",{className:gn.toolList,children:y.map(S=>i.jsxs("label",{className:gn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),i.jsx("span",{className:gn.toolName,children:S})]},S))})]},v)})})]})}const w8="_container_1gfuq_1",N8="_header_1gfuq_7",C8="_list_1gfuq_19",E8="_card_1gfuq_25",A8="_cardHeader_1gfuq_40",D8="_cardTitle_1gfuq_46",M8="_statusBadge_1gfuq_56",R8="_enabled_1gfuq_68",I8="_disabled_1gfuq_71",O8="_cardActions_1gfuq_75",B8="_cardMeta_1gfuq_80",L8="_empty_1gfuq_98",Qn={container:w8,header:N8,list:C8,card:E8,cardHeader:A8,cardTitle:D8,statusBadge:M8,enabled:R8,disabled:I8,cardActions:O8,cardMeta:B8,empty:L8};function z8({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=b.useState(null),m=u?t.find(y=>y.id===u):void 0,g=async y=>{await o(y),p(null)},v=b.useMemo(()=>{const y=new Map;for(const k of s)y.set(k.id,k.name);return y},[s]),x=y=>v.get(y)??y;return i.jsxs("div",{className:Qn.container,children:[i.jsxs("div",{className:Qn.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:Qn.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:Qn.list,children:t.map(y=>i.jsxs("div",{className:Qn.card,"data-testid":`schedule-card-${y.id}`,onClick:()=>d(y.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(y.id))},children:[i.jsxs("div",{className:Qn.cardHeader,children:[i.jsxs("span",{className:Qn.cardTitle,children:[i.jsx("strong",{children:y.title}),i.jsx("span",{className:`${Qn.statusBadge} ${y.enabled?Qn.enabled:Qn.disabled}`,"data-testid":`schedule-status-badge-${y.id}`,children:y.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:Qn.cardActions,onClick:k=>k.stopPropagation(),children:[i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(y.id,{enabled:!y.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${y.id}`,title:y.enabled?"Disable schedule":"Enable schedule",children:y.enabled?"Disable":"Enable"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(y.id),"data-testid":`schedule-edit-${y.id}`,children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(y.id),"data-testid":`schedule-delete-${y.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:Qn.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${y.id}`,children:y.scheduleExpression}),y.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${y.id}`,children:["Persona: ",x(y.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${y.id}`,children:["Last run: ",y.lastRunAt?$o(y.lastRunAt):"Never"]}),y.enabled&&y.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${y.id}`,children:["Next run: ",O1(y.nextRunAt)]}):null,y.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${y.id}`,children:["Runs: ",y.runCount]})]})]},y.id))}),i.jsx(oa,{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 $8="_nav_1bhou_1",P8="_tab_1bhou_24",U8="_tabIcon_1bhou_62",H8="_tabActive_1bhou_68",Gc={nav:$8,tab:P8,tabIcon:U8,tabActive:H8},Qs=[{path:"credentials",label:"Credentials",icon:i.jsx(H2,{size:Nt})},{path:"personas",label:"Personas",icon:i.jsx(yj,{size:Nt})},{path:"schedules",label:"Schedules",icon:i.jsx(x2,{size:Nt})},{path:"appearance",label:"Appearance",icon:i.jsx(aj,{size:Nt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(q2,{size:Nt})},{path:"plugins",label:"Plugins",icon:i.jsx(dj,{size:Nt})},{path:"about",label:"About",icon:i.jsx(gm,{size:Nt})}];function V8(){var u;const t=Yt(),s=mt(),o=b.useRef(null),r=((u=Qs.find(p=>{const m=`${wi}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Qs[0].path,c=b.useCallback(p=>{s(`${wi}/${p}`)},[s]),d=b.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:Qs.findIndex(j=>j.path===r);let x=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%Qs.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+Qs.length)%Qs.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=Qs.length-1;else return;const y=Qs[x].path;s(`${wi}/${y}`),(S=m[x])==null||S.focus()},[r,s]);return i.jsx("nav",{className:Gc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Qs.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Gc.tab} ${m?Gc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Gc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function q8({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(by.map(d=>[d,[]]));for(const d of t){const u=ul(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let x;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?x="Needs input":S==="completed"&&(x="Ready to complete")}const y={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:x},k=c.get(u);k?k.push(y):c.get("not_started").push(y)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return by.map(d=>{const u=qa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const G8="_boardContainer_1c4y1_1",F8="_column_1c4y1_17",Z8="_columnHeader_1c4y1_34",K8="_columnIcon_1c4y1_47",Y8="_columnLabel_1c4y1_52",J8="_columnCount_1c4y1_57",W8="_cardList_1c4y1_67",X8="_emptyPlaceholder_1c4y1_76",Q8="_card_1c4y1_67",e7="_cardHeader_1c4y1_107",t7="_cardStatusIcon_1c4y1_113",n7="_cardTitle_1c4y1_119",s7="_cardBadges_1c4y1_127",a7="_badge_1c4y1_134",i7="_blockedBadge_1c4y1_146",o7="_childBadge_1c4y1_151",r7="_depBadge_1c4y1_155",l7="_parentBadge_1c4y1_159",c7="_pausedSubBadge_1c4y1_166",d7="_personaBadge_1c4y1_170",u7="_envBadge_1c4y1_174",f7="_emptyCta_1c4y1_178",p7="_ctaButton_1c4y1_188",m7="_ctaDescription_1c4y1_204",it={boardContainer:G8,column:F8,columnHeader:Z8,columnIcon:K8,columnLabel:Y8,columnCount:J8,cardList:W8,emptyPlaceholder:X8,card:Q8,cardHeader:e7,cardStatusIcon:t7,cardTitle:n7,cardBadges:s7,badge:a7,blockedBadge:i7,childBadge:o7,depBadge:r7,parentBadge:l7,pausedSubBadge:c7,personaBadge:d7,envBadge:u7,emptyCta:f7,ctaButton:p7,ctaDescription:m7};function h7({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=mt(),p=b.useMemo(()=>o.filter(y=>y.workspaceId===t),[o,t]),m=b.useMemo(()=>new Map(o.map(y=>[y.id,y.status])),[o]),g=b.useMemo(()=>new Map(p.map(y=>[y.id,y])),[p]),v=b.useMemo(()=>{const y=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=y.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const B=k.get(D.personaId);B&&N.set(C.id,B.name)}if(D.environmentId){const B=S.get(D.environmentId);B&&T.set(C.id,B.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),x=b.useMemo(()=>q8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:x.map(y=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${y.status}`,"aria-label":`${y.label}, ${y.tasks.length} ${y.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:y.style.color},children:y.style.icon}),i.jsx("span",{className:it.columnLabel,children:y.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${y.status}`,children:y.tasks.length})]}),i.jsx("div",{className:it.cardList,children:y.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(gs,{mode:"popLayout",children:y.tasks.map(k=>i.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(g7,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(On(k.task.id,void 0,t,s))})},k.task.id))})})]},y.status))})}function g7({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=qa(d.status),x=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[x&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:x.title,children:x.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const v7="_formContent_ymnez_1",y7="_section_ymnez_13",b7="_label_ymnez_19",x7="_titleInput_ymnez_26",_7="_descriptionTextarea_ymnez_58",k7="_selectField_ymnez_94",S7="_checkboxRow_ymnez_128",T7="_checkboxLabel_ymnez_141",j7="_fieldError_ymnez_146",xt={formContent:v7,section:y7,label:b7,titleInput:x7,descriptionTextarea:_7,selectField:k7,checkboxRow:S7,checkboxLabel:T7,fieldError:j7};function w7(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 N7=100;function C7({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:xt.formContent,children:[i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:N7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.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"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.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)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.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:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.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:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.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 q1=b.createContext(void 0),E7=4e3;function A7({children:t}){const[s,o]=b.useState([]),r=b.useRef(0),c=b.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=b.useCallback((u,p="info",m=E7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(q1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=b.useContext(q1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const um="grackle-theme",G1="grackle-prefer-system",F1="(prefers-color-scheme: dark)";let Kr=[],od;function Dp(){od=void 0;for(const t of Kr)t()}function fm(){return typeof window>"u"?!1:window.matchMedia(F1).matches}function el(){if(typeof localStorage>"u")return ex;try{const t=localStorage.getItem(um);if(t!==null&&U1.has(t))return t}catch{}return ex}function xd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(G1)==="true"}catch{return!1}}function pm(t){return Ld.find(s=>s.variantLightId===t||s.variantDarkId===t)}function Z1(t,s){const o=dm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?fm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=pm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return fm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Z1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(el(),xd());function D7(){return od===void 0&&(od={themeId:el(),systemDark:fm(),preferSystem:xd()}),od}function M7(t){return Kr=[...Kr,t],()=>{Kr=Kr.filter(s=>s!==t)}}function R7(){const t=b.useSyncExternalStore(M7,D7),{themeId:s,preferSystem:o}=t,r=Z1(s,o),c=b.useCallback(u=>{if(U1.has(u)){try{localStorage.setItem(um,u)}catch{}No(u,xd(),!0),Dp()}},[]),d=b.useCallback(u=>{try{localStorage.setItem(G1,u?"true":"false")}catch{}if(u){const p=el(),m=dm(p);if(m!=null&&m.hidden){const g=pm(p);if(g)try{localStorage.setItem(um,g.id)}catch{}}}No(el(),u,!0),Dp()},[]);return b.useEffect(()=>{No(s,o)},[s,o]),b.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(F1),p=()=>{const m=el(),g=xd();if(g){const v=dm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const x=pm(m);x!=null&&x.variantDarkId&&x.variantLightId&&No(m,g)}}Dp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const K1=b.createContext(void 0);function I7({children:t}){const s=R7();return i.jsx(K1.Provider,{value:s,children:t})}function Y1(){const t=b.useContext(K1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const J1=b.createContext(void 0),W1=b.createContext(void 0);function O7({children:t}){const[s,o]=b.useState(void 0),r=b.useCallback(c=>{o(c)},[]);return i.jsx(W1.Provider,{value:r,children:i.jsx(J1.Provider,{value:s,children:t})})}function B7(){return b.useContext(J1)}function L7(){const t=b.useContext(W1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const uh=b.createContext(void 0);function ot(){const t=b.useContext(uh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function X1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Q1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function z7(t){return X1(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 $7=new Set(["off","subscription","api_key"]),Fc=new Set(["off","on"]);function P7(t){return X1(t)&&$7.has(t.claude)&&Fc.has(t.github)&&Fc.has(t.copilot)&&Fc.has(t.codex)&&Fc.has(t.goose)}function ek(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 tk(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 wo=5e3;function U7(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 ra={label:"Home",url:Di};function H7(t){return t?[ra,{label:"Settings",url:wi},{label:t,url:void 0}]:[ra,{label:"Settings",url:void 0}]}const fh={label:"Environments",url:Ro};function V7(){return[ra,{label:"Environments",url:void 0}]}function q7(){return[ra,{label:"New Chat",url:void 0}]}function G7(t){return[ra,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function F7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[ra,fh,{label:(d==null?void 0:d.displayName)??"Environment",url:Ai(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function Z7(t,s,o,r,c){const d=U7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,x=[ra];v&&g&&(x.push(fh),x.push({label:v.displayName,url:Ai(g)})),m&&g&&x.push({label:m.name,url:Ei(m.id,g)});for(let k=0;k<d.length-1;k++)x.push({label:d[k].title,url:On(d[k].id,void 0,p,g)});const y=d[d.length-1];return x.push({label:(y==null?void 0:y.title)??t,url:void 0}),x}const K7={label:"Findings",url:Ad};function Y7(){return[ra,{label:"Findings",url:void 0}]}function nk(t,s,o,r,c){const d=[ra];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(fh),p&&d.push({label:p.displayName,url:Ai(o)}),u&&d.push({label:u.name,url:Ei(s,o)}),d.push({label:"Findings",url:NN(s,o)})}else d.push(K7);return d.push({label:t,url:void 0}),d}function ph(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 Zc(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 J7(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 mh(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 x=s.get(v),y=x?Zc(x):void 0;if(y)try{const k=JSON.parse(v.content);o.set(y,{tool:k.tool,args:k.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,x)=>{if(v.eventType!=="tool_result")return v;const y=s.get(v),k=y?J7(y):void 0;if(!k)return v;const S=o.get(k);if(!S)return v;r.add(k),c.add(x);let j;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const x=s.get(d[v]),y=x?Zc(x):void 0;y&&r.has(y)||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 x=p[m];if(x!==v+1)continue;const y=d[v],k=d[x];let S;try{const j=JSON.parse(y.content);S={tool:j.tool,args:j.args}}catch{}if(S){let j;const N=k.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(j=D.detailedContent)}catch{}d[x]={...k,toolUseCtx:{...S,detailedResult:j}},c.add(x);const T=s.get(y),C=T?Zc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(y,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const x=s.get(v);if(!x)return!0;const y=Zc(x);if(y&&r.has(y))return!1;const k=x.__seqId;return!(k&&r.has(k))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let x=!1;for(let y=v+1;y<g.length;y++)if(g[y].eventType!=="tool_use"){x=!0;break}x&&(g[v]={...g[v],settled:!0})}return g}function W7(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=sk(s),d=s.filter(m=>mm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||mm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function sk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function mm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function X7(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=sk(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}):mm(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 Q7(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 ez(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 ws=[{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
284
+ `)}function x6({events:t,formatForClipboard:s}){const[o,r]=b.useState(!1),[c,d]=b.useState(new Set),u=b.useRef(void 0),p=b.useMemo(()=>c.size,[c]),m=b.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=b.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=b.useCallback((S,j)=>{if(j&&u.current!==void 0){const N=Math.min(u.current,S),T=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let B=N;B<=T;B++)B<t.length&&dl(t[B])&&D.add(B);return D})}else d(N=>{const T=new Set(N);return T.has(S)?T.delete(S):T.add(S),T.size===0?(r(!1),u.current=void 0):u.current=S,T})},[t]),x=b.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)dl(t[j])&&S.add(j);d(S)},[t]),y=b.useCallback(()=>{d(new Set)},[]),k=b.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 N=s(j);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:x,deselectAll:y,copySelected:k}}const _6="_wrapper_1cdza_1",k6="_scrollContainer_1cdza_9",S6="_selectingPadding_1cdza_16",T6="_toolbar_1cdza_20",j6="_directionToggle_1cdza_27",w6="_scrollToAnchor_1cdza_65",N6="_scrollToAnchorBottom_1cdza_89",C6="_scrollToAnchorTop_1cdza_93",E6="_eventOverflowWarning_1cdza_97",ea={wrapper:_6,scrollContainer:k6,selectingPadding:S6,toolbar:T6,directionToggle:j6,scrollToAnchor:w6,scrollToAnchorBottom:N6,scrollToAnchorTop:C6,eventOverflowWarning:E6};function A6(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 D1="grackle-stream-direction";function D6(){try{return localStorage.getItem(D1)==="reversed"}catch{return!1}}function M6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:ea.eventOverflowWarning,role:"alert",children:[i.jsx(vm,{size:nn,"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 ch({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=b.useRef(null),[d,u]=b.useState(D6),p=g3(),m=x6({events:t,formatForClipboard:b6}),g=b.useMemo(()=>t.filter(dl).length,[t]),v=b.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:x,scrollToAnchor:y}=g6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),k=()=>{const T=!d;u(T);try{localStorage.setItem(D1,T?"reversed":"default")}catch{}};b.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const S=b.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),j=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:ea.wrapper,children:[i.jsx("div",{className:ea.toolbar,children:i.jsx(zo,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:ea.directionToggle,onClick:k,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(vy,{size:nn,"aria-hidden":"true"}):i.jsx(yy,{size:nn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${ea.scrollContainer} ${m.isSelecting?ea.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(M6,{eventsDropped:s}),i.jsx(gs,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return i.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:j,ease:"easeOut"},children:i.jsx(i6,{copyText:y6(T),isContentBearing:dl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:A6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:B=>{m.toggleEvent(D,B)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(qA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),i.jsx(gs,{children:m.isSelecting&&i.jsx(p6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{S().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(gs,{children:!x&&i.jsxs(Rt.button,{className:`${ea.scrollToAnchor} ${d?ea.scrollToAnchorTop:ea.scrollToAnchorBottom}`,onClick:y,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:[d?i.jsx(yy,{size:nn,"aria-hidden":"true"}):i.jsx(vy,{size:nn,"aria-hidden":"true"})," New events"]})})]})}function dh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=b.useState(""),[x,y]=b.useState(""),k=b.useRef(!1),S=d===c,j=b.useCallback($=>{v($),y("")},[]),N=b.useCallback(()=>{y("")},[]),T=b.useCallback(()=>{k.current=!1,u==null||u(null),v(""),y("")},[u]),C=b.useCallback(()=>{const $=m?g.trim():g;if(r){const U=r(g);if(U){y(U);return}}const L=m?s.trim():s;if($===L){T();return}o($),T()},[g,s,m,r,o,T]),D=b.useCallback(()=>{k.current=!0,u==null||u(c),v(s),y("")},[c,s,u]),B=b.useCallback($=>{if(k.current){k.current=!1;return}$.relatedTarget instanceof HTMLElement&&$.relatedTarget.dataset.editAction===c||C()},[c,C]),E=b.useCallback($=>{$.key==="Escape"?T():$.key==="Enter"&&p&&C()},[T,p,C]),A=(()=>{if(!S)return!1;const $=m?s.trim():s;return(m?g.trim():g)!==$})();return b.useEffect(()=>{!S&&(g!==""||x!=="")&&(v(""),y(""))},[S,g,x]),{isEditing:S,draft:g,error:x,isDirty:A,startEdit:D,cancelEdit:T,save:C,setDraft:j,clearError:N,handleBlur:B,handleKeyDown:E,ignoreInitialBlurRef:k}}const R6="_editFieldWrapper_yuzty_1",I6="_editInput_yuzty_10",O6="_editTextarea_yuzty_42",B6="_editSelect_yuzty_78",L6="_editError_yuzty_111",z6="_editInputInvalid_yuzty_118",$6="_editHint_yuzty_123",P6="_unsavedDot_yuzty_132",U6="_metaValueClickable_yuzty_140",H6="_editButton_yuzty_159",V6="_metaPlaceholder_yuzty_175",q6="_worktreeToggle_yuzty_180",st={editFieldWrapper:R6,editInput:I6,editTextarea:O6,editSelect:B6,editError:L6,editInputInvalid:z6,editHint:$6,unsavedDot:P6,metaValueClickable:U6,editButton:H6,metaPlaceholder:V6,worktreeToggle:q6};function Ft(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:x,ariaLabel:y,"data-testid":k}=t,S=b.useRef(null),j=dh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(b.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=S.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 i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{className:`${st.editInput} ${C?st.editInputInvalid:""}`,value:s,onChange:T,maxLength:x,placeholder:v,"aria-label":y,"data-testid":k?`${k}-input`:void 0}),C&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{ref:S,className:`${st.editInput} ${j.error?st.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:x,placeholder:v,"aria-label":y,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:st.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":y,"data-testid":k?`${k}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function cm(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:x,"data-testid":y}=t,k=b.useRef(null),S=dh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(b.useEffect(()=>{if(S.isEditing){const N=window.setTimeout(()=>{var T;(T=k.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[S.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{className:`${st.editTextarea} ${T?st.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),T&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:T})]})}if(S.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{ref:k,className:`${st.editTextarea} ${S.error?st.editInputInvalid:""}`,value:S.draft,onChange:N=>S.setDraft(N.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:x,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),S.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),S.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:S.error}),i.jsx("span",{className:st.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function yd(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:x,"data-testid":y}=t,k=b.useRef(null),S=dh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});b.useEffect(()=>{if(S.isEditing){const B=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(B)}},[S.isEditing]);const j=b.useCallback(B=>{const E=B.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),N=b.useCallback(B=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return i.jsx("select",{className:st.editSelect,value:s,onChange:B=>m==null?void 0:m(B.target.value),"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});if(S.isEditing)return i.jsx("select",{ref:k,className:st.editSelect,value:S.draft,onChange:j,onBlur:N,title:x,"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});const T=g==null?void 0:g(s),C=(D=c.find(B=>B.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:st.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function G6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:st.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const F6="_nav_1snmp_1",Z6="_searchForm_1snmp_8",K6="_searchInput_1snmp_15",Y6="_searchButton_1snmp_33",J6="_clearButton_1snmp_68",W6="_workspaceSelect_1snmp_85",X6="_listHeader_1snmp_99",Q6="_nodeList_1snmp_108",e5="_nodeItem_1snmp_116",t5="_indicator_1snmp_129",n5="_label_1snmp_136",s5="_badge_1snmp_145",Wn={nav:F6,searchForm:Z6,searchInput:K6,searchButton:Y6,clearButton:J6,workspaceSelect:W6,listHeader:X6,nodeList:Q6,nodeItem:e5,indicator:t5,label:n5,badge:s5};function a5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=b.useState(""),v=b.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),x=b.useCallback(()=>{g(""),d()},[d]),y=b.useCallback(S=>{u(S)},[u]),k=b.useCallback(S=>{g(""),p(S)},[p]);return i.jsxs("div",{className:Wn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Wn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Wn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Wn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Wn.clearButton,onClick:x,children:"Clear search"}),i.jsxs("select",{className:Wn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>i.jsx("option",{value:S.id,children:S.name},S.id))]}),i.jsxs("div",{className:Wn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Wn.nodeList,children:t.map(S=>i.jsxs("li",{className:Wn.nodeItem,onClick:()=>{y(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),y(S.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Wn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Wn.label,children:S.label}),i.jsx("span",{className:Wn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const i5="_container_1mq5u_1",o5="_hamburger_1mq5u_33",r5="_brand_1mq5u_49",l5="_brandLogo_1mq5u_68",c5="_info_1mq5u_75",d5="_connectionLabel_1mq5u_90",u5="_connectionDot_1mq5u_103",f5="_connected_1mq5u_106",p5="_disconnected_1mq5u_110",Xs={container:i5,hamburger:o5,brand:r5,brandLogo:l5,info:c5,connectionLabel:d5,connectionDot:u5,connected:f5,disconnected:p5};function m5({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=mt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Xs.container,children:[r&&i.jsx("button",{type:"button",className:Xs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(X2,{size:Nt,"aria-hidden":"true"})}),i.jsx(zo,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Xs.brand,onClick:()=>d(Di),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Xs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Xs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Xs.connectionDot} ${t?Xs.connected:Xs.disconnected}`,"aria-hidden":"true",children:i.jsx(Va,{size:ym,fill:"currentColor"})})," ",i.jsx("span",{className:Xs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const h5="_nav_13gkc_1",g5="_tab_13gkc_35",v5="_tabIcon_13gkc_68",y5="_tabLabel_13gkc_79",b5="_tabActive_13gkc_84",Ur={nav:h5,tab:g5,tabIcon:v5,tabLabel:y5,tabActive:b5},sd=[{view:"dashboard",label:"Dashboard",icon:i.jsx($2,{size:Nt}),route:Di,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(ej,{size:Nt}),route:jN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(w2,{size:Nt}),route:wN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(nj,{size:Nt}),route:Ro,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(y2,{size:Nt}),route:Wx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(Cx,{size:Nt}),route:Ad,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(pj,{size:Nt}),route:xN,testId:"sidebar-tab-settings"}];function x5(t){return t===Di||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Wx)?"knowledge":t.startsWith(Ad)?"findings":t.startsWith(wi)?"settings":"tasks"}function _5({tabs:t=sd}){const s=Yt(),o=mt(),r=b.useRef(null),c=x5(s.pathname),d=b.useCallback(p=>{o(p.route)},[o]),u=b.useCallback(p=>{var y,k;const m=(y=r.current)==null?void 0:y.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(S=>S===document.activeElement),v=g>=0?g:t.findIndex(S=>S.view===c);let x=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=t.length-1;else return;o(t[x].route),(k=m[x])==null||k.focus()},[c,o,t]);return i.jsx("nav",{className:Ur.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx(zo,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Ur.tab} ${m?Ur.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:Ur.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:Ur.tabLabel,children:p.label})]})},p.view)})})}const k5="_container_pi6ii_1",S5="_content_pi6ii_66",Wb={container:k5,content:S5},T5=320,M1=220,R1=600,I1="grackle-sidebar-width";function j5(){try{const t=localStorage.getItem(I1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=M1&&s<=R1)return s}}catch{}return T5}function w5(t){try{localStorage.setItem(I1,String(t))}catch{}}function N5({content:t}){const[s]=b.useState(j5),o=b.useRef(null);if(b.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>=M1&&m<=R1&&w5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Wb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Wb.content,children:t})})}const C5="_bar_tnfsh_1",E5="_btnPrimary_tnfsh_32",A5="_statusText_tnfsh_85",D5="_statusCompleted_tnfsh_90",M5="_statusFailed_tnfsh_94",R5="_statusBlocked_tnfsh_98",I5="_hintText_tnfsh_103",jt={bar:C5,btnPrimary:E5,statusText:A5,statusCompleted:D5,statusFailed:M5,statusBlocked:R5,hintText:I5};function O5({sessions:t,tasks:s,environments:o}){const r=mt(),c=Yt(),d=Dt("/sessions/:sessionId"),u=Dt("/tasks/:taskId"),p=Dt("/tasks/:taskId/stream"),m=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),x=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),y=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),k=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),S=Dt("/sessions/new"),j=Dt("/environments/:environmentId/workspaces/:workspaceId"),N=Dt("/tasks/new"),T=Dt("/chat"),C=Dt("/"),D=Dt("/settings/*"),B=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)??(x==null?void 0:x.params.taskId)??(y==null?void 0:y.params.taskId)??(k==null?void 0:k.params.taskId),A=v??x??y??k,$=(A==null?void 0:A.params.environmentId)??(j==null?void 0:j.params.environmentId),L=c.pathname.startsWith("/environments")&&!j&&!A,U=!!T,J=!!S,V=!!j&&!v&&!x&&!y&&!k,K=!!N;if(!!C&&!J&&!V&&!K||!!D||(!!g||!!k)||K||L||J)return i.jsx(i.Fragment,{});if(U)return o.find(O=>O.adapterType==="local"&&O.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if(V)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(E){const M=s.find(he=>he.id===E);if(!M)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const O=new Map(s.map(he=>[he.id,he])),X=M.dependsOn.some(he=>{const W=O.get(he);return W!==void 0&&W.status!=="complete"});if(M.status==="not_started"){const he=X?M.dependsOn.map(W=>O.get(W)).filter(W=>W&&W.status!=="complete").map(W=>W.title):[];return i.jsx("div",{className:jt.bar,children:X?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",he.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(M.status==="working"||M.status==="paused"){const he=M.latestSessionId||void 0,W=he?t.find(fe=>fe.id===he):void 0;return W&&W.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(M.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ii(M.workspaceId,void 0,$)),className:jt.btnPrimary,children:"+ New Task"})]});if(M.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(B){const M=t.find(he=>he.id===B),O=(M==null?void 0:M.status)==="stopped";if(M!==void 0&&!O)return i.jsx(i.Fragment,{});if(O)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",M.endReason||M.status]}),i.jsx("button",{onClick:()=>r(Zx(M.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const B5="_nav_14i94_1",L5="_tab_14i94_24",z5="_tabActive_14i94_62",$5="_tabLabel_14i94_75",P5="_statusDot_14i94_81",U5="_pulse_14i94_87",H5="_addButton_14i94_99",V5="_empty_14i94_132",Ba={nav:B5,tab:L5,tabActive:z5,tabLabel:$5,statusDot:P5,pulse:U5,addButton:H5,empty:V5},q5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function G5({environments:t}){const s=mt(),o=b.useRef(null),r=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),d=Dt("/environments/:environmentId/workspaces/:workspaceId"),u=Dt("/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=b.useCallback(y=>{s(Ai(y))},[s]),v=b.useCallback(y=>{var T;const k=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%k.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+k.length)%k.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=k.length-1;else return;N<t.length&&s(Ai(t[N].id)),k[N].focus()},[m,t,s]),x=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ba.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(y=>{const k=y.id===m,S=y.id===x,j=q5[y.status]||"var(--text-tertiary)",N=y.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ba.tab} ${k?Ba.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ba.statusDot} ${N?Ba.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Va,{size:ym,fill:"currentColor"})}),i.jsx("span",{className:Ba.tabLabel,title:y.displayName||y.id,children:y.displayName||y.id})]},y.id)})}),i.jsx("button",{type:"button",className:Ba.addButton,onClick:()=>s(yN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ba.empty,children:"No environments yet."})]})}function $o(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 O1(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 Xb={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 bd(t){return Xb[t]||Xb.general}const F5="_nav_dlm8m_1",Z5="_categoryPills_dlm8m_24",K5="_categoryPill_dlm8m_24",Y5="_tab_dlm8m_42",J5="_tabActive_dlm8m_80",W5="_tabContent_dlm8m_93",X5="_tabLabel_dlm8m_100",Q5="_tabMeta_dlm8m_106",eI="_categoryDot_dlm8m_111",tI="_empty_dlm8m_118",js={nav:F5,categoryPills:Z5,categoryPill:K5,tab:Y5,tabActive:J5,tabContent:W5,tabLabel:X5,tabMeta:Q5,categoryDot:eI,empty:tI};function nI({findings:t,workspaceId:s,environmentId:o}){const r=mt(),c=b.useRef(null),d=Dt("/findings/:findingId"),u=Dt("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=b.useMemo(()=>{const y=new Set(t.map(k=>k.category).filter(Boolean));return Array.from(y).sort()},[t]),g=b.useCallback(y=>{r(qp(y,s,o))},[r,s,o]),v=b.useCallback(y=>{var T;const k=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===p);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%k.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+k.length)%k.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=k.length-1;else return;N<t.length&&r(qp(t[N].id,s,o)),k[N].focus()},[p,t,r,s,o]),x=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:js.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:js.categoryPills,"data-testid":"findings-nav-categories",children:m.map(y=>i.jsx("span",{className:js.categoryPill,style:{color:bd(y).text},children:y},y))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(y=>{const k=y.id===p,S=y.id===x;return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${js.tab} ${k?js.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:js.categoryDot,style:{color:bd(y.category).text},"aria-hidden":"true",children:i.jsx(Va,{size:ym,fill:"currentColor"})}),i.jsxs("span",{className:js.tabContent,children:[i.jsx("span",{className:js.tabLabel,title:y.title,children:y.title}),i.jsx("span",{className:js.tabMeta,title:y.createdAt,children:$o(y.createdAt)})]})]},y.id)})}),t.length===0&&i.jsx("div",{className:js.empty,children:"No findings yet. Agents will post discoveries here."})]})}function sI(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 B1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=sI(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function aI(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 iI(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 kj){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(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=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const oI="_container_z4i38_1",rI="_header_z4i38_5",lI="_headerActions_z4i38_17",cI="_searchInput_z4i38_23",dI="_searchHighlight_z4i38_56",uI="_groupToggle_z4i38_62",fI="_groupToggleActive_z4i38_89",pI="_addButton_z4i38_93",mI="_taskRow_z4i38_120",hI="_selected_z4i38_140",gI="_expandArrow_z4i38_150",vI="_expanded_z4i38_157",yI="_leafSpacer_z4i38_161",bI="_taskStatusIcon_z4i38_166",xI="_taskTitle_z4i38_170",_I="_workspaceBadge_z4i38_177",kI="_childCountBadge_z4i38_195",SI="_dependencyBadge_z4i38_208",TI="_blockedBadge_z4i38_220",jI="_addChildButton_z4i38_225",wI="_emptyState_z4i38_268",NI="_statusGroupHeader_z4i38_275",CI="_statusGroupIcon_z4i38_294",EI="_statusGroupLabel_z4i38_298",AI="_statusGroupCount_z4i38_303",Ze={container:oI,header:rI,headerActions:lI,searchInput:cI,searchHighlight:dI,groupToggle:uI,groupToggleActive:fI,addButton:pI,taskRow:mI,selected:hI,expandArrow:gI,expanded:vI,leafSpacer:yI,taskStatusIcon:bI,taskTitle:xI,workspaceBadge:_I,childCountBadge:kI,dependencyBadge:SI,blockedBadge:TI,addChildButton:jI,emptyState:wI,statusGroupHeader:NI,statusGroupIcon:CI,statusGroupLabel:EI,statusGroupCount:AI},DI=[{name:"title",weight:2},{name:"description",weight:1}],L1=16,MI=16,z1="grackle-task-group-by-status";function Qb(){try{return localStorage.getItem(z1)==="true"}catch{return!1}}function RI(t){try{localStorage.setItem(z1,String(t))}catch{}}function II({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Ze.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Ze.expandArrow} ${s?Ze.expanded:""}`,"aria-hidden":"true",children:i.jsx(la,{size:dt})}),i.jsx("span",{className:Ze.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ze.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ze.statusGroupCount,children:t.tasks.length})]}),i.jsx(gs,{children:s&&i.jsx(Rt.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=qa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(On(p.id)))},className:`${Ze.taskRow} ${g?Ze.selected:""}`,style:{"--task-indent":`${L1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ul(p.status)}`,children:m.icon}),i.jsx("span",{className:Ze.taskTitle,title:p.title,children:i.jsx(B1,{text:p.title,indices:d.get(p.id),highlightClass:Ze.searchHighlight})}),v&&i.jsx("span",{className:Ze.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function $1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=qa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),x=o.has(t.id),y=t.children.length>0,k=c===t.id,S=L1+s*MI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Ze.taskRow} ${k?Ze.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[y&&i.jsx("span",{className:`${Ze.expandArrow} ${x?Ze.expanded:""}`,role:"button",tabIndex:0,"aria-label":x?"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:i.jsx(la,{size:dt,"aria-hidden":"true"})}),!y&&i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ul(t.status)}`,children:g.icon}),i.jsx("span",{className:Ze.taskTitle,title:t.title,children:i.jsx(B1,{text:t.title,indices:p.get(t.id),highlightClass:Ze.searchHighlight})}),N&&i.jsx("span",{className:Ze.workspaceBadge,title:N,children:N}),y&&i.jsxs("span",{className:Ze.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ze.dependencyBadge} ${v?Ze.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<AT&&i.jsx(zo,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ze.addChildButton,children:"+"})})]}),i.jsx(gs,{children:y&&x&&i.jsx(Rt.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=>i.jsx($1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function OI({workspaces:t,tasks:s}){const o=mt(),[r,c]=b.useState(new Set),[d,u]=b.useState(new Set),[p,m]=b.useState(Qb),[g,v]=b.useState(Qb),[x,y]=b.useState(new Map),k=Dt("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=b.useMemo(()=>new Map(s.map(ee=>[ee.id,ee.status])),[s]),N=b.useMemo(()=>new Map(t.map(ee=>[ee.id,ee.name])),[t]),T=()=>{const ee=!p;RI(ee),m(ee),ee&&(v(!0),y(new Map))},C=ee=>{y(ie=>{const M=new Map(ie),O=M.has(ee)?M.get(ee):g;return M.set(ee,!O),M})},D=ee=>x.has(ee)?x.get(ee):g,B=ee=>{c(ie=>{const M=new Set(ie);return M.has(ee)?(M.delete(ee),u(O=>new Set(O).add(ee))):(M.add(ee),u(O=>{const X=new Set(O);return X.delete(ee),X})),M})};b.useEffect(()=>{const ee=new Set(s.filter(ie=>ie.parentTaskId).map(ie=>ie.parentTaskId));ee.size>0&&c(ie=>{const M=new Set(ie);for(const O of ee)d.has(O)||M.add(O);return M})},[s,d]);const[E,A]=b.useState(""),{directMatchTaskIds:$,treeMatchTaskIds:L,titleHighlights:U}=b.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const ee=ET(s,E,DI),ie=new Set(ee.map(he=>he.item.id)),M=new Map;for(const he of ee){const W=he.matches.find(ye=>ye.key==="title");W&&M.set(he.item.id,W.indices)}const O=new Set(ie),X=new Map(s.map(he=>[he.id,he]));for(const he of[...ie]){let W=X.get(he);for(;W!=null&&W.parentTaskId;)O.add(W.parentTaskId),W=X.get(W.parentTaskId)}return{directMatchTaskIds:ie,treeMatchTaskIds:O,titleHighlights:M}},[E,s]),J=$!==null,V=J?p?$:L:null,K=V?s.filter(ee=>V.has(ee.id)):s,de=p?[]:aI(K);return i.jsxs("div",{className:Ze.container,children:[i.jsxs("div",{className:Ze.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ze.headerActions,children:[i.jsx(zo,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ze.groupToggle} ${p?Ze.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:i.jsx(K2,{size:nn})})}),i.jsx(zo,{text:"New task",children:i.jsx("button",{className:Ze.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:ee=>A(ee.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ze.searchInput,"data-testid":"sidebar-search"}),p?iI(K,j).map(ee=>i.jsx(II,{group:ee,isExpanded:D(ee.status),onToggle:()=>C(ee.status),selectedTaskId:S,navigate:o,titleHighlights:U,workspaceNames:N},ee.status)):de.map(ee=>i.jsx($1,{node:ee,depth:0,expandedTasks:r,toggleTask:B,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:U,workspaceNames:N},ee.id)),K.length===0&&!J&&i.jsx("div",{className:Ze.emptyState,children:"No tasks yet. Click + to create one."}),K.length===0&&J&&i.jsx("div",{className:Ze.emptyState,children:"No matching tasks"})]})}const BI="_toast_ed2dk_1",LI="_success_ed2dk_18",zI="_icon_ed2dk_22",$I="_error_ed2dk_25",PI="_warning_ed2dk_32",UI="_info_ed2dk_38",HI="_message_ed2dk_53",VI="_close_ed2dk_60",Hr={toast:BI,success:LI,icon:zI,error:$I,warning:PI,info:UI,message:HI,close:VI},qI={success:i.jsx(Mi,{size:Nt}),error:i.jsx(Za,{size:Nt}),warning:i.jsx(vm,{size:Nt}),info:i.jsx(gm,{size:Nt})};function GI({toast:t,onDismiss:s}){return b.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Rt.div,{className:`${Hr.toast} ${Hr[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:[i.jsx("span",{className:Hr.icon,"aria-hidden":"true",children:qI[t.variant]}),i.jsx("span",{className:Hr.message,children:t.message}),i.jsx("button",{type:"button",className:Hr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Za,{size:nn,"aria-hidden":"true"})})]})}const FI="_container_qqse2_1",ZI={container:FI};function KI({toasts:t,onDismiss:s}){return i.jsx("div",{className:ZI.container,"data-testid":"toast-container",children:i.jsx(gs,{children:t.map(o=>i.jsx(GI,{toast:o,onDismiss:s},o.id))})})}const YI="_callout_e5awm_1",JI="_success_e5awm_11",WI="_icon_e5awm_15",XI="_error_e5awm_18",QI="_warning_e5awm_25",eO="_info_e5awm_32",tO="_content_e5awm_48",nO="_close_e5awm_53",Vr={callout:YI,success:JI,icon:WI,error:XI,warning:QI,info:eO,content:tO,close:nO},sO={success:i.jsx(Mi,{size:Nt}),error:i.jsx(Za,{size:Nt}),warning:i.jsx(vm,{size:Nt}),info:i.jsx(gm,{size:Nt})};function aO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=b.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Vr.callout,Vr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Vr.icon,"aria-hidden":"true",children:sO[t]}),i.jsx("span",{className:Vr.content,children:s}),o&&i.jsx("button",{type:"button",className:Vr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Za,{size:nn,"aria-hidden":"true"})})]})})}function iO({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(aO,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const oO="_container_de44x_1",rO="_emptyState_de44x_8",lO="_card_de44x_14",cO="_cardClickable_de44x_34",dO="_cardHeader_de44x_42",uO="_categoryBadge_de44x_54",fO="_findingTitle_de44x_62",pO="_findingDate_de44x_68",mO="_findingContent_de44x_80",hO="_tags_de44x_86",gO="_tag_de44x_86",fs={container:oO,emptyState:rO,card:lO,cardClickable:cO,cardHeader:dO,categoryBadge:uO,findingTitle:fO,findingDate:pO,findingContent:mO,tags:hO,tag:gO};function P1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:fs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:fs.container,children:t.map((o,r)=>{const c=bd(o.category),d=s?Rt.button:Rt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${fs.card} ${s?fs.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:[i.jsxs("div",{className:fs.cardHeader,children:[i.jsx("span",{className:fs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:fs.findingTitle,children:o.title}),i.jsx("span",{className:fs.findingDate,title:o.createdAt,children:$o(o.createdAt)})]}),i.jsx("div",{className:fs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:fs.tags,children:o.tags.map(u=>i.jsx("span",{className:fs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const vO="_container_1ingb_1",yO="_heading_1ingb_7",bO="_section_1ingb_14",xO="_sectionTitle_1ingb_26",_O="_sectionDescription_1ingb_35",kO="_emptyState_1ingb_41",SO="_tokenList_1ingb_48",TO="_tokenRow_1ingb_55",jO="_tokenBadge_1ingb_68",wO="_tokenName_1ingb_83",NO="_tokenTarget_1ingb_90",CO="_deleteButton_1ingb_99",EO="_addForm_1ingb_113",AO="_formRow_1ingb_119",DO="_input_1ingb_125",MO="_select_1ingb_155",RO="_addButton_1ingb_187",IO="_emptyStateInfo_1ingb_221",OO="_themeOptions_1ingb_229",BO="_themeOption_1ingb_229",LO="_themeOptionSelected_1ingb_254",zO="_themeOptionHeader_1ingb_259",$O="_themeOptionLabel_1ingb_266",PO="_themeOptionDesc_1ingb_273",UO="_variantToggle_1ingb_279",HO="_variantButton_1ingb_286",VO="_variantActive_1ingb_305",qO="_themeSwatches_1ingb_311",GO="_themeSwatch_1ingb_311",FO="_systemToggle_1ingb_325",ZO="_systemToggleHint_1ingb_341",KO="_themeActive_1ingb_348",YO="_aboutGrid_1ingb_354",JO="_aboutItem_1ingb_360",WO="_aboutLabel_1ingb_373",XO="_aboutValue_1ingb_379",QO="_aboutDot_1ingb_387",eB="_aboutDotConnected_1ingb_394",tB="_aboutDotDisconnected_1ingb_398",pe={container:vO,heading:yO,section:bO,sectionTitle:xO,sectionDescription:_O,emptyState:kO,tokenList:SO,tokenRow:TO,tokenBadge:jO,tokenName:wO,tokenTarget:NO,deleteButton:CO,addForm:EO,formRow:AO,input:DO,select:MO,addButton:RO,emptyStateInfo:IO,themeOptions:OO,themeOption:BO,themeOptionSelected:LO,themeOptionHeader:zO,themeOptionLabel:$O,themeOptionDesc:PO,variantToggle:UO,variantButton:HO,variantActive:VO,themeSwatches:qO,themeSwatch:GO,systemToggle:FO,systemToggleHint:ZO,themeActive:KO,aboutGrid:YO,aboutItem:JO,aboutLabel:WO,aboutValue:XO,aboutDot:QO,aboutDotConnected:eB,aboutDotDisconnected:tB},nB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function sB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=b.useState(""),[u,p]=b.useState(""),[m,g]=b.useState("env_var"),[v,x]=b.useState(""),[y,k]=b.useState(null),S=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(""),x("")},j=T=>{k(T)},N=()=>{y&&(o(y),r==null||r("Token deleted","info")),k(null)};return i.jsxs(i.Fragment,{children:[i.jsx(oa,{isOpen:y!==null,title:"Delete Token?",description:y?`"${y}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>k(null)}),i.jsxs("section",{className:pe.section,children:[i.jsx("h3",{className:pe.sectionTitle,children:"Tokens"}),i.jsx("p",{className:pe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:pe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:pe.tokenList,children:t.map(T=>i.jsxs("div",{className:pe.tokenRow,children:[i.jsx("span",{className:pe.tokenBadge,children:T.tokenType}),i.jsx("span",{className:pe.tokenName,children:T.name}),i.jsx("span",{className:pe.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:pe.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Za,{size:nn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:pe.addForm,onSubmit:S,children:[i.jsxs("div",{className:pe.formRow,children:[i.jsx("input",{className:pe.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:pe.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:pe.formRow,children:[i.jsx("select",{className:pe.select,value:m,onChange:T=>g(T.target.value),children:nB.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.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=>x(T.target.value)}),i.jsx("button",{className:pe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Ld=[{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"]}],U1=new Set(Ld.map(t=>t.id)),ex="grackle";function dm(t){return Ld.find(s=>s.id===t)}function aB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:pe.section,children:[i.jsx("h3",{className:pe.sectionTitle,children:"Appearance"}),i.jsx("p",{className:pe.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:pe.themeOptions,children:Ld.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 i.jsxs("button",{type:"button",className:`${pe.themeOption} ${p?pe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:pe.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:pe.themeOptionLabel,children:d.label}),i.jsx("span",{className:pe.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:pe.variantToggle,children:[i.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:"☼"}),i.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&&i.jsx("span",{className:pe.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:pe.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:pe.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:pe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:pe.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function iB({connected: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 i.jsxs("section",{className:pe.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:pe.sectionTitle,children:"About"}),i.jsx("p",{className:pe.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:pe.aboutGrid,children:[i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Connection"}),i.jsxs("span",{className:pe.aboutValue,children:[i.jsx("span",{className:`${pe.aboutDot} ${t?pe.aboutDotConnected:pe.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Environments"}),i.jsxs("span",{className:pe.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:pe.aboutValue,children:d})]}),i.jsxs("div",{className:pe.aboutItem,children:[i.jsx("span",{className:pe.aboutLabel,children:"Version"}),i.jsx("span",{className:pe.aboutValue,children:"0.106.1"})]})]})]})}const oB="_container_cddyd_1",rB="_header_cddyd_8",lB="_headerTitle_cddyd_35",cB="_badge_cddyd_44",dB="_headerActions_cddyd_54",uB="_body_cddyd_61",fB="_formContent_cddyd_73",pB="_section_cddyd_85",mB="_label_cddyd_91",hB="_titleInput_cddyd_98",gB="_descriptionTextarea_cddyd_131",vB="_parentContext_cddyd_167",yB="_parentLabel_cddyd_175",bB="_parentName_cddyd_182",xB="_personaSelect_cddyd_186",_B="_depList_cddyd_220",kB="_depItem_cddyd_226",SB="_depItemSelected_cddyd_248",TB="_noDeps_cddyd_252",jB="_btnPrimary_cddyd_258",wB="_btnGhost_cddyd_289",nt={container:oB,header:rB,headerTitle:lB,badge:cB,headerActions:dB,body:uB,formContent:fB,section:pB,label:mB,titleInput:hB,descriptionTextarea:gB,parentContext:vB,parentLabel:yB,parentName:bB,personaSelect:xB,depList:_B,depItem:kB,depItemSelected:SB,noDeps:TB,btnPrimary:jB,btnGhost:wB};function H1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:x}){const y=mt(),k=t==="edit",S=k&&s?d.find(xe=>xe.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[N,T]=b.useState(j),C=j||N,D=u.find(xe=>xe.id===C),B=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,A=k?(S==null?void 0:S.parentTaskId)??"":r??"",$=A?d.find(xe=>xe.id===A):void 0,[L,U]=b.useState((S==null?void 0:S.title)??""),[J,V]=b.useState((S==null?void 0:S.description)??""),[K,de]=b.useState((S==null?void 0:S.dependsOn)??[]),[ee,ie]=b.useState((S==null?void 0:S.defaultPersonaId)??""),[M,O]=b.useState((S==null?void 0:S.canDecompose)??!1),[X,he]=b.useState(!1),W=b.useRef(!1);b.useEffect(()=>{k&&S&&!W.current&&(W.current=!0,U(S.title),V(S.description),de(S.dependsOn),ie(S.defaultPersonaId),O(S.canDecompose))},[k,S]);const ye=d.filter(xe=>xe.workspaceId===C&&(!k||xe.id!==s)&&xe.id!==A),fe=L.trim().length>0&&(!k||S!==void 0)&&C.length>0,Ne=xe=>{de(Be=>Be.includes(xe)?Be.filter(It=>It!==xe):[...Be,xe])},Ue=()=>{!fe||X||k&&S===void 0||(k&&s?(g(s,L.trim(),J,K,ee),x==null||x("Task updated","success"),v?v():y(On(s,void 0,C,B),{replace:!0})):(he(!0),m(C,L.trim(),J,K.length>0?K:void 0,A||void 0,ee,M,()=>{x==null||x("Task created","success"),y(o?Ei(o,B):"/tasks",{replace:!0})},xe=>{x==null||x(xe,"error"),he(!1)})))},ge=()=>{if(v){v();return}y(k&&s?On(s,void 0,C,B):o?Ei(o,B):"/tasks")},ke=k?"edit task":A?"child task":"new task";return i.jsxs("div",{className:nt.container,children:[i.jsxs("div",{className:nt.header,children:[i.jsxs("div",{className:nt.headerTitle,children:[i.jsx("span",{className:nt.badge,children:ke}),$&&i.jsxs("span",{className:nt.parentContext,children:[i.jsx("span",{className:nt.parentLabel,children:"Child of"}),i.jsx("span",{className:nt.parentName,children:$.title})]})]}),i.jsxs("div",{className:nt.headerActions,children:[i.jsx("button",{onClick:Ue,disabled:!fe||X,className:nt.btnPrimary,"data-testid":"task-edit-save",children:X?"Creating…":k?"Save Changes":"Create"}),i.jsx("button",{onClick:ge,className:nt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:nt.body,children:i.jsxs("div",{className:nt.formContent,children:[E&&i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:xe=>T(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:L,onChange:xe=>U(xe.target.value),placeholder:"Task title...",autoFocus:!0,className:nt.titleInput,"data-testid":"task-edit-title",onKeyDown:xe=>{xe.key==="Enter"&&fe&&Ue()}})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:J,onChange:xe=>V(xe.target.value),placeholder:"Describe the task... (markdown supported)",className:nt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:ee,onChange:xe=>ie(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),!k&&i.jsx("div",{className:nt.section,children:i.jsxs("label",{className:nt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:M,onChange:xe=>O(xe.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:nt.section,children:[i.jsx("div",{className:nt.label,children:"Dependencies"}),ye.length===0?i.jsx("div",{className:nt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:nt.depList,children:ye.map(xe=>{const Be=K.includes(xe.id);return i.jsxs("label",{className:`${nt.depItem} ${Be?nt.depItemSelected:""}`,"data-testid":`dep-option-${xe.id}`,children:[i.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ne(xe.id)}),xe.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",xe.status,")"]})]},xe.id)})})]})]})})]})}const NB="_actionButtons_1rjka_1",CB="_btnPrimary_1rjka_8",EB="_btnDanger_1rjka_39",AB="_btnGhost_1rjka_78",Kt={actionButtons:NB,btnPrimary:CB,btnDanger:EB,btnGhost:AB};function DB({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?i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Kt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Kt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Kt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Kt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const MB="_workpadSection_y8nj9_1",RB="_workpadLabel_y8nj9_9",IB="_workpadStatus_y8nj9_17",OB="_workpadSummary_y8nj9_23",BB="_workpadExtra_y8nj9_29",La={workpadSection:MB,workpadLabel:RB,workpadStatus:IB,workpadSummary:OB,workpadExtra:BB};function LB({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 i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),i.jsx("div",{className:La.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:La.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:La.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:La.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const zB="_overviewDashboard_r05qm_1",$B="_overviewHero_r05qm_7",PB="_statusBadge_r05qm_14",UB="_statusPending_r05qm_26",HB="_statusAssigned_r05qm_31",VB="_statusInProgress_r05qm_36",qB="_statusReview_r05qm_41",GB="_statusDone_r05qm_46",FB="_statusFailed_r05qm_51",ZB="_statusWaitingInput_r05qm_56",KB="_overviewBranchPill_r05qm_61",YB="_branchLink_r05qm_76",JB="_overviewSection_r05qm_87",WB="_overviewLabel_r05qm_93",XB="_overviewValue_r05qm_100",QB="_overviewMuted_r05qm_105",eL="_overviewMarkdown_r05qm_111",tL="_envRow_r05qm_180",nL="_envDot_r05qm_186",sL="_envDotGreen_r05qm_193",aL="_envDotYellow_r05qm_197",iL="_envDotRed_r05qm_201",oL="_envDotGray_r05qm_205",rL="_depList_r05qm_209",lL="_depItem_r05qm_215",cL="_depBlocked_r05qm_222",dL="_depDone_r05qm_226",uL="_timeline_r05qm_230",fL="_timelineRow_r05qm_236",pL="_timelineKey_r05qm_243",mL="_timelineValue_r05qm_249",hL="_timelineDelta_r05qm_253",gL="_reviewNotes_r05qm_264",ve={overviewDashboard:zB,overviewHero:$B,statusBadge:PB,statusPending:UB,statusAssigned:HB,statusInProgress:VB,statusReview:qB,statusDone:GB,statusFailed:FB,statusWaitingInput:ZB,overviewBranchPill:KB,branchLink:YB,overviewSection:JB,overviewLabel:WB,overviewValue:XB,overviewMuted:QB,overviewMarkdown:eL,envRow:tL,envDot:nL,envDotGreen:sL,envDotYellow:aL,envDotRed:iL,envDotGray:oL,depList:rL,depItem:lL,depBlocked:cL,depDone:dL,timeline:uL,timelineRow:fL,timelineKey:pL,timelineValue:mL,timelineDelta:hL,reviewNotes:gL};function qc(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 Cp(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 tx(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ve.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ve.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ve.envDotRed:ve.envDotGray}function vL({status:t}){const s=qa(t),o=_j(t);return i.jsx("span",{className:`${ve.statusBadge} ${ve[o]??ve.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function yL({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(S=>S.id===g):void 0,x=r.find(S=>S.id===t.workspaceId),y=o.find(S=>S.id===d),k=t.branch&&(x!=null&&x.repoUrl)?`${x.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:ve.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:ve.overviewHero,children:[i.jsx(vL,{status:t.status}),t.branch&&i.jsx("span",{className:ve.overviewBranchPill,"data-testid":"task-overview-branch",children:k?i.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:ve.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:ve.overviewLabel,children:"Description"}),i.jsx("div",{className:ve.overviewMarkdown,children:i.jsx(Sd,{remarkPlugins:[Td],children:t.description})})]}),t.workpad&&i.jsx(LB,{workpad:t.workpad}),i.jsxs("div",{className:ve.overviewSection,children:[i.jsx("div",{className:ve.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${tx(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:v.displayName})]}):y?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${tx(y.status)}`,title:y.status,"aria-label":`Status: ${y.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:y.displayName}),i.jsx("span",{className:ve.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:ve.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:ve.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:ve.overviewMuted,children:"None"}):i.jsx("div",{className:ve.depList,children:t.dependsOn.map(S=>{const j=s.get(S),N=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${ve.depItem} ${N?ve.depDone:ve.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:ve.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:ve.timeline,children:[t.createdAt&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Created"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Cp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Assigned"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.assignedAt)}),S!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Cp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Started"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.startedAt)}),S!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Cp(t.startedAt,t.completedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Completed"}),i.jsx("span",{className:ve.timelineValue,children:qc(t.completedAt)}),S!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:ve.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:ve.overviewLabel,children:"Usage"}),i.jsxs("div",{className:ve.timeline,children:[i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsx("span",{className:ve.timelineValue,children:Ns(u.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:ve.timelineValue,children:Ns(p.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:ve.overviewLabel,children:"Budget"}),i.jsxs("div",{className:ve.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Tokens"}),i.jsxs("span",{className:ve.timelineValue,children:[Io(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Io(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsxs("span",{className:ve.timelineValue,children:[Ns((u==null?void 0:u.costMillicents)??0)," / ",Ns(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:ve.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:ve.reviewNotes,children:t.reviewNotes})]})]})}function bL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:pe.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:pe.heading,children:"Plugins"}),i.jsxs("div",{className:pe.section,children:[i.jsx("p",{className:pe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:pe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:pe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:pe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{className:pe.tokenName,children:r.name}),r.required&&i.jsx("span",{className:pe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:pe.tokenTarget,children:r.description}),c&&i.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"})]}),i.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:i.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)})]})]})}const xL="_container_legrg_1",_L="_header_legrg_8",kL="_headerTitle_legrg_35",SL="_badge_legrg_44",TL="_headerActions_legrg_54",jL="_body_legrg_61",wL="_formContent_legrg_73",NL="_section_legrg_85",CL="_label_legrg_91",EL="_nameInput_legrg_98",AL="_fieldInput_legrg_131",DL="_adapterSelect_legrg_164",ML="_readOnlyValue_legrg_198",RL="_codespaceSection_legrg_204",IL="_codespaceActions_legrg_210",OL="_creatingHint_legrg_216",BL="_errorHint_legrg_222",LL="_btnPrimary_legrg_235",zL="_btnGhost_legrg_266",le={container:xL,header:_L,headerTitle:kL,badge:SL,headerActions:TL,body:jL,formContent:wL,section:NL,label:CL,nameInput:EL,fieldInput:AL,adapterSelect:DL,readOnlyValue:ML,codespaceSection:RL,codespaceActions:IL,creatingHint:OL,errorHint:BL,btnPrimary:LL,btnGhost:zL},ad=1,id=65535;function Ep(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=ad&&s<=id}function Ap(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function $L({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=b.useState("pick"),[x,y]=b.useState(""),[k,S]=b.useState("");return g==="create"?i.jsxs("div",{className:le.codespaceSection,children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Repository"}),i.jsx("input",{type:"text",value:x,onChange:j=>y(j.target.value),placeholder:"owner/repo",className:le.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:le.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:le.codespaceActions,children:[i.jsx("button",{onClick:()=>{x.trim()&&(m(x.trim(),k.trim()||void 0),v("pick"),y(""),S(""))},disabled:!x.trim(),className:le.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),y(""),S("")},className:le.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:le.codespaceSection,children:i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Codespace"}),!u&&i.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:le.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>i.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:le.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:le.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:le.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:le.errorHint,children:d})]})})}function V1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:x}){const y=mt(),k=t==="edit",S=k&&s?o.find(ge=>ge.id===s):void 0,[j,N]=b.useState(""),[T,C]=b.useState("local"),[D,B]=b.useState(""),[E,A]=b.useState(""),[$,L]=b.useState(""),[U,J]=b.useState(""),[V,K]=b.useState(""),[de,ee]=b.useState(""),[ie,M]=b.useState(""),[O,X]=b.useState(null),he=b.useCallback(()=>{const ge={};if(T==="local"){if(D.trim()&&(ge.host=D.trim()),E.trim()){const ke=Number(E);Number.isInteger(ke)&&(ge.port=ke)}}else if(T==="ssh"){if(ge.host=D.trim(),$.trim()&&(ge.user=$.trim()),E.trim()){const ke=Number(E);Number.isInteger(ke)&&(ge.sshPort=ke)}U.trim()&&(ge.identityFile=U.trim())}else T==="docker"?(V.trim()&&(ge.image=V.trim()),de.trim()&&(ge.repo=de.trim())):T==="codespace"&&(ge.codespaceName=ie.trim());return ge},[T,D,E,$,U,V,de,ie]),W=()=>!(!j.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!ie.trim()||(T==="local"||T==="ssh")&&!Ep(E)),ye=()=>{W()&&(r(j.trim(),T,he()),x==null||x("Environment added successfully","success"),y(Ro,{replace:!0}))},fe=()=>{y(s?Ai(s):Ro)},Ne=b.useCallback((ge,ke)=>{if(!S||!s)return;const xe=Ap(S.adapterConfig),Be=ke.trim();Be?xe[ge]=Be:delete xe[ge],c(s,{adapterConfig:xe})},[S,s,c]),Ue=b.useCallback((ge,ke)=>{if(!S||!s)return;const xe=Ap(S.adapterConfig);if(ke.trim()){const Be=Number(ke);Number.isInteger(Be)&&Be>=ad&&Be<=id&&(xe[ge]=Be)}else delete xe[ge];c(s,{adapterConfig:xe})},[S,s,c]);if(k){if(!S)return i.jsxs("div",{className:le.container,children:[i.jsxs("div",{className:le.header,children:[i.jsx("div",{className:le.headerTitle,children:i.jsx("span",{className:le.badge,children:"edit environment"})}),i.jsx("div",{className:le.headerActions,children:i.jsx("button",{onClick:fe,className:le.btnGhost,children:"Back"})})]}),i.jsx("div",{className:le.body,children:i.jsx("div",{className:le.formContent,children:i.jsx("span",{className:le.readOnlyValue,children:"Environment not found"})})})]});const ge=Ap(S.adapterConfig);return i.jsxs("div",{className:le.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:le.header,children:[i.jsx("div",{className:le.headerTitle,children:i.jsx("span",{className:le.badge,children:"edit environment"})}),i.jsx("div",{className:le.headerActions,children:i.jsx("button",{onClick:fe,className:le.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:le.body,children:i.jsxs("div",{className:le.formContent,children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Name"}),i.jsx(Ft,{value:S.displayName,onSave:ke=>{s&&c(s,{displayName:ke})},validate:ke=>ke.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:O,onActivate:X,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Adapter Type"}),i.jsx("span",{className:le.readOnlyValue,"data-testid":"env-edit-adapter-type",children:S.adapterType})]}),S.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:ke=>Ne("host",ke),mode:"edit",fieldId:"host",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Port"}),i.jsx(Ft,{value:String(ge.port??""),onSave:ke=>Ue("port",ke),validate:ke=>Ep(ke)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),S.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:ke=>Ne("host",ke),validate:ke=>ke.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:O,onActivate:X,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"User"}),i.jsx(Ft,{value:String(ge.user??""),onSave:ke=>Ne("user",ke),mode:"edit",fieldId:"user",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"SSH Port"}),i.jsx(Ft,{value:String(ge.sshPort??""),onSave:ke=>Ue("sshPort",ke),validate:ke=>Ep(ke)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:O,onActivate:X,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Identity File"}),i.jsx(Ft,{value:String(ge.identityFile??""),onSave:ke=>Ne("identityFile",ke),mode:"edit",fieldId:"identityFile",activeFieldId:O,onActivate:X,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),S.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Image"}),i.jsx(Ft,{value:String(ge.image??""),onSave:ke=>Ne("image",ke),mode:"edit",fieldId:"image",activeFieldId:O,onActivate:X,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Repo"}),i.jsx(Ft,{value:String(ge.repo??""),onSave:ke=>Ne("repo",ke),mode:"edit",fieldId:"repo",activeFieldId:O,onActivate:X,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),S.adapterType==="codespace"&&i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,children:"Codespace Name"}),i.jsx(Ft,{value:String(ge.codespaceName??""),onSave:ke=>Ne("codespaceName",ke),validate:ke=>ke.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:O,onActivate:X,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:le.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:le.header,children:[i.jsx("div",{className:le.headerTitle,children:i.jsx("span",{className:le.badge,children:"new environment"})}),i.jsxs("div",{className:le.headerActions,children:[i.jsx("button",{onClick:ye,disabled:!W(),className:le.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:fe,className:le.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:le.body,children:i.jsxs("div",{className:le.formContent,children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:j,onChange:ge=>N(ge.target.value),placeholder:"Environment name...",autoFocus:!0,className:le.nameInput,"data-testid":"env-create-name",onKeyDown:ge=>{ge.key==="Enter"&&W()&&ye()}})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:ge=>{C(ge.target.value),ge.target.value==="codespace"&&d()},className:le.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ge=>B(ge.target.value),placeholder:"Host (optional)...",className:le.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ad,max:id,value:E,onChange:ge=>A(ge.target.value),placeholder:"Port (optional)...",className:le.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ge=>B(ge.target.value),placeholder:"Host (required)...",className:le.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:$,onChange:ge=>L(ge.target.value),placeholder:"User (optional)...",className:le.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ad,max:id,value:E,onChange:ge=>A(ge.target.value),placeholder:"SSH port (optional)...",className:le.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:U,onChange:ge=>J(ge.target.value),placeholder:"Identity file (optional)...",className:le.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:V,onChange:ge=>K(ge.target.value),placeholder:"Image (optional)...",className:le.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:le.section,children:[i.jsx("label",{className:le.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:de,onChange:ge=>ee(ge.target.value),placeholder:"Repo (optional)...",className:le.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx($L,{codespaceName:ie,onCodespaceNameChange:M,envName:j,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const PL="_group_1iprv_1",UL="_groupTitle_1iprv_8",HL="_shortcutList_1iprv_17",VL="_shortcutRow_1iprv_23",qL="_keys_1iprv_36",GL="_kbd_1iprv_43",FL="_description_1iprv_60",ki={group:PL,groupTitle:UL,shortcutList:HL,shortcutRow:VL,keys:qL,kbd:GL,description:FL},ZL=[{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:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function KL(){return i.jsxs("section",{className:pe.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:pe.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:pe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),ZL.map(t=>i.jsxs("div",{className:ki.group,children:[i.jsx("h4",{className:ki.groupTitle,children:t.title}),i.jsx("div",{className:ki.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:ki.shortcutRow,children:[i.jsx("span",{className:ki.keys,children:s.keys.map(o=>i.jsx("kbd",{className:ki.kbd,children:o},o))}),i.jsx("span",{className:ki.description,children:s.description})]},s.description))})]},t.title))]})}const YL=[{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 JL({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:pe.section,children:[i.jsx("h3",{className:pe.sectionTitle,children:"Credential Providers"}),i.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."}),i.jsx("div",{className:pe.tokenList,children:YL.map(r=>i.jsxs("div",{className:pe.tokenRow,children:[i.jsx("span",{className:pe.tokenName,children:r.label}),i.jsx("span",{className:pe.tokenTarget,children:r.description}),i.jsx("select",{className:pe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const WL="_container_10efq_1",XL="_header_10efq_7",QL="_list_10efq_105",e8="_card_10efq_111",t8="_cardHeader_10efq_125",n8="_cardTitle_10efq_135",s8="_defaultBadge_10efq_141",a8="_cardActions_10efq_155",i8="_description_10efq_160",o8="_meta_10efq_166",r8="_empty_10efq_212",l8="_typeBadge_10efq_362",Xn={container:WL,header:XL,list:QL,card:e8,cardHeader:t8,cardTitle:n8,defaultBadge:s8,cardActions:a8,description:i8,meta:o8,empty:r8,typeBadge:l8};function c8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=b.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Xn.container,children:[i.jsxs("div",{className:Xn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Xn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Xn.list,children:t.map(v=>{const x=s===v.id,y=v.type==="script";return i.jsxs("div",{className:Xn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Xn.cardHeader,children:[i.jsxs("span",{className:Xn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Xn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:y?"Script":"Agent"}),x&&i.jsx("span",{className:Xn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Xn.cardActions,onClick:k=>k.stopPropagation(),children:[!x&&i.jsx(tn,{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"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Xn.description,children:v.description}),i.jsxs("div",{className:Xn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(oa,{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 d8="_container_uy08i_1",u8="_header_uy08i_7",f8="_count_uy08i_13",p8="_presets_uy08i_18",m8="_presetButton_uy08i_24",h8="_filterInput_uy08i_41",g8="_groups_uy08i_53",v8="_group_uy08i_53",y8="_groupHeader_uy08i_68",b8="_groupName_uy08i_77",x8="_groupCount_uy08i_81",_8="_toolList_uy08i_87",k8="_toolItem_uy08i_95",S8="_toolName_uy08i_103",gn={container:d8,header:u8,count:f8,presets:p8,presetButton:m8,filterInput:h8,groups:g8,group:v8,groupHeader:y8,groupName:b8,groupCount:x8,toolList:_8,toolItem:k8,toolName:S8},T8=(()=>{const t=new Map;for(const s of _x){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()}))})(),j8=[{name:"default",label:"Default",tools:kx},{name:"worker",label:"Worker",tools:DT},{name:"orchestrator",label:"Orchestrator",tools:MT},{name:"admin",label:"Admin",tools:RT}];function nx({selectedTools:t,onChange:s,disabled:o}){const[r,c]=b.useState(""),d=b.useMemo(()=>new Set(t),[t]),u=b.useCallback(v=>{if(o)return;const x=new Set(d);x.has(v)?x.delete(v):x.add(v),s([...x].sort())},[d,s,o]),p=b.useCallback((v,x)=>{if(o)return;const y=new Set(d);for(const k of v)x?y.delete(k):y.add(k);s([...y].sort())},[d,s,o]),m=b.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:gn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:gn.header,children:i.jsx("span",{className:gn.count,children:t.length===0?`Using default (${kx.length} tools)`:`${t.length} of ${_x.size} tools selected`})}),i.jsxs("div",{className:gn.presets,"data-testid":"mcp-tool-presets",children:[j8.map(v=>i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:gn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:gn.groups,children:T8.map(({group:v,tools:x})=>{const y=g?x.filter(S=>S.toLowerCase().includes(g)):x;if(y.length===0)return null;const k=y.every(S=>d.has(S));return i.jsxs("div",{className:gn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:gn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(y,k),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:gn.groupName,children:v}),i.jsxs("span",{className:gn.groupCount,children:["(",y.filter(S=>d.has(S)).length,"/",y.length,")"]})]}),i.jsx("div",{className:gn.toolList,children:y.map(S=>i.jsxs("label",{className:gn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),i.jsx("span",{className:gn.toolName,children:S})]},S))})]},v)})})]})}const w8="_container_1gfuq_1",N8="_header_1gfuq_7",C8="_list_1gfuq_19",E8="_card_1gfuq_25",A8="_cardHeader_1gfuq_40",D8="_cardTitle_1gfuq_46",M8="_statusBadge_1gfuq_56",R8="_enabled_1gfuq_68",I8="_disabled_1gfuq_71",O8="_cardActions_1gfuq_75",B8="_cardMeta_1gfuq_80",L8="_empty_1gfuq_98",Qn={container:w8,header:N8,list:C8,card:E8,cardHeader:A8,cardTitle:D8,statusBadge:M8,enabled:R8,disabled:I8,cardActions:O8,cardMeta:B8,empty:L8};function z8({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=b.useState(null),m=u?t.find(y=>y.id===u):void 0,g=async y=>{await o(y),p(null)},v=b.useMemo(()=>{const y=new Map;for(const k of s)y.set(k.id,k.name);return y},[s]),x=y=>v.get(y)??y;return i.jsxs("div",{className:Qn.container,children:[i.jsxs("div",{className:Qn.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:Qn.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:Qn.list,children:t.map(y=>i.jsxs("div",{className:Qn.card,"data-testid":`schedule-card-${y.id}`,onClick:()=>d(y.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(y.id))},children:[i.jsxs("div",{className:Qn.cardHeader,children:[i.jsxs("span",{className:Qn.cardTitle,children:[i.jsx("strong",{children:y.title}),i.jsx("span",{className:`${Qn.statusBadge} ${y.enabled?Qn.enabled:Qn.disabled}`,"data-testid":`schedule-status-badge-${y.id}`,children:y.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:Qn.cardActions,onClick:k=>k.stopPropagation(),children:[i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(y.id,{enabled:!y.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${y.id}`,title:y.enabled?"Disable schedule":"Enable schedule",children:y.enabled?"Disable":"Enable"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(y.id),"data-testid":`schedule-edit-${y.id}`,children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(y.id),"data-testid":`schedule-delete-${y.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:Qn.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${y.id}`,children:y.scheduleExpression}),y.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${y.id}`,children:["Persona: ",x(y.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${y.id}`,children:["Last run: ",y.lastRunAt?$o(y.lastRunAt):"Never"]}),y.enabled&&y.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${y.id}`,children:["Next run: ",O1(y.nextRunAt)]}):null,y.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${y.id}`,children:["Runs: ",y.runCount]})]})]},y.id))}),i.jsx(oa,{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 $8="_nav_1bhou_1",P8="_tab_1bhou_24",U8="_tabIcon_1bhou_62",H8="_tabActive_1bhou_68",Gc={nav:$8,tab:P8,tabIcon:U8,tabActive:H8},Qs=[{path:"credentials",label:"Credentials",icon:i.jsx(H2,{size:Nt})},{path:"personas",label:"Personas",icon:i.jsx(yj,{size:Nt})},{path:"schedules",label:"Schedules",icon:i.jsx(x2,{size:Nt})},{path:"appearance",label:"Appearance",icon:i.jsx(aj,{size:Nt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(q2,{size:Nt})},{path:"plugins",label:"Plugins",icon:i.jsx(dj,{size:Nt})},{path:"about",label:"About",icon:i.jsx(gm,{size:Nt})}];function V8(){var u;const t=Yt(),s=mt(),o=b.useRef(null),r=((u=Qs.find(p=>{const m=`${wi}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Qs[0].path,c=b.useCallback(p=>{s(`${wi}/${p}`)},[s]),d=b.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:Qs.findIndex(j=>j.path===r);let x=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%Qs.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+Qs.length)%Qs.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=Qs.length-1;else return;const y=Qs[x].path;s(`${wi}/${y}`),(S=m[x])==null||S.focus()},[r,s]);return i.jsx("nav",{className:Gc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Qs.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Gc.tab} ${m?Gc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Gc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function q8({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(by.map(d=>[d,[]]));for(const d of t){const u=ul(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let x;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?x="Needs input":S==="completed"&&(x="Ready to complete")}const y={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:x},k=c.get(u);k?k.push(y):c.get("not_started").push(y)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return by.map(d=>{const u=qa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const G8="_boardContainer_1c4y1_1",F8="_column_1c4y1_17",Z8="_columnHeader_1c4y1_34",K8="_columnIcon_1c4y1_47",Y8="_columnLabel_1c4y1_52",J8="_columnCount_1c4y1_57",W8="_cardList_1c4y1_67",X8="_emptyPlaceholder_1c4y1_76",Q8="_card_1c4y1_67",e7="_cardHeader_1c4y1_107",t7="_cardStatusIcon_1c4y1_113",n7="_cardTitle_1c4y1_119",s7="_cardBadges_1c4y1_127",a7="_badge_1c4y1_134",i7="_blockedBadge_1c4y1_146",o7="_childBadge_1c4y1_151",r7="_depBadge_1c4y1_155",l7="_parentBadge_1c4y1_159",c7="_pausedSubBadge_1c4y1_166",d7="_personaBadge_1c4y1_170",u7="_envBadge_1c4y1_174",f7="_emptyCta_1c4y1_178",p7="_ctaButton_1c4y1_188",m7="_ctaDescription_1c4y1_204",it={boardContainer:G8,column:F8,columnHeader:Z8,columnIcon:K8,columnLabel:Y8,columnCount:J8,cardList:W8,emptyPlaceholder:X8,card:Q8,cardHeader:e7,cardStatusIcon:t7,cardTitle:n7,cardBadges:s7,badge:a7,blockedBadge:i7,childBadge:o7,depBadge:r7,parentBadge:l7,pausedSubBadge:c7,personaBadge:d7,envBadge:u7,emptyCta:f7,ctaButton:p7,ctaDescription:m7};function h7({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=mt(),p=b.useMemo(()=>o.filter(y=>y.workspaceId===t),[o,t]),m=b.useMemo(()=>new Map(o.map(y=>[y.id,y.status])),[o]),g=b.useMemo(()=>new Map(p.map(y=>[y.id,y])),[p]),v=b.useMemo(()=>{const y=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=y.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const B=k.get(D.personaId);B&&N.set(C.id,B.name)}if(D.environmentId){const B=S.get(D.environmentId);B&&T.set(C.id,B.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),x=b.useMemo(()=>q8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:x.map(y=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${y.status}`,"aria-label":`${y.label}, ${y.tasks.length} ${y.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:y.style.color},children:y.style.icon}),i.jsx("span",{className:it.columnLabel,children:y.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${y.status}`,children:y.tasks.length})]}),i.jsx("div",{className:it.cardList,children:y.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(gs,{mode:"popLayout",children:y.tasks.map(k=>i.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(g7,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(On(k.task.id,void 0,t,s))})},k.task.id))})})]},y.status))})}function g7({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=qa(d.status),x=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[x&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:x.title,children:x.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const v7="_formContent_ymnez_1",y7="_section_ymnez_13",b7="_label_ymnez_19",x7="_titleInput_ymnez_26",_7="_descriptionTextarea_ymnez_58",k7="_selectField_ymnez_94",S7="_checkboxRow_ymnez_128",T7="_checkboxLabel_ymnez_141",j7="_fieldError_ymnez_146",xt={formContent:v7,section:y7,label:b7,titleInput:x7,descriptionTextarea:_7,selectField:k7,checkboxRow:S7,checkboxLabel:T7,fieldError:j7};function w7(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 N7=100;function C7({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:xt.formContent,children:[i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:N7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.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"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.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)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.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:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.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:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.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 q1=b.createContext(void 0),E7=4e3;function A7({children:t}){const[s,o]=b.useState([]),r=b.useRef(0),c=b.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=b.useCallback((u,p="info",m=E7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(q1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=b.useContext(q1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const um="grackle-theme",G1="grackle-prefer-system",F1="(prefers-color-scheme: dark)";let Kr=[],od;function Dp(){od=void 0;for(const t of Kr)t()}function fm(){return typeof window>"u"?!1:window.matchMedia(F1).matches}function el(){if(typeof localStorage>"u")return ex;try{const t=localStorage.getItem(um);if(t!==null&&U1.has(t))return t}catch{}return ex}function xd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(G1)==="true"}catch{return!1}}function pm(t){return Ld.find(s=>s.variantLightId===t||s.variantDarkId===t)}function Z1(t,s){const o=dm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?fm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=pm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return fm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Z1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(el(),xd());function D7(){return od===void 0&&(od={themeId:el(),systemDark:fm(),preferSystem:xd()}),od}function M7(t){return Kr=[...Kr,t],()=>{Kr=Kr.filter(s=>s!==t)}}function R7(){const t=b.useSyncExternalStore(M7,D7),{themeId:s,preferSystem:o}=t,r=Z1(s,o),c=b.useCallback(u=>{if(U1.has(u)){try{localStorage.setItem(um,u)}catch{}No(u,xd(),!0),Dp()}},[]),d=b.useCallback(u=>{try{localStorage.setItem(G1,u?"true":"false")}catch{}if(u){const p=el(),m=dm(p);if(m!=null&&m.hidden){const g=pm(p);if(g)try{localStorage.setItem(um,g.id)}catch{}}}No(el(),u,!0),Dp()},[]);return b.useEffect(()=>{No(s,o)},[s,o]),b.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(F1),p=()=>{const m=el(),g=xd();if(g){const v=dm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const x=pm(m);x!=null&&x.variantDarkId&&x.variantLightId&&No(m,g)}}Dp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const K1=b.createContext(void 0);function I7({children:t}){const s=R7();return i.jsx(K1.Provider,{value:s,children:t})}function Y1(){const t=b.useContext(K1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const J1=b.createContext(void 0),W1=b.createContext(void 0);function O7({children:t}){const[s,o]=b.useState(void 0),r=b.useCallback(c=>{o(c)},[]);return i.jsx(W1.Provider,{value:r,children:i.jsx(J1.Provider,{value:s,children:t})})}function B7(){return b.useContext(J1)}function L7(){const t=b.useContext(W1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const uh=b.createContext(void 0);function ot(){const t=b.useContext(uh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function X1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Q1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function z7(t){return X1(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 $7=new Set(["off","subscription","api_key"]),Fc=new Set(["off","on"]);function P7(t){return X1(t)&&$7.has(t.claude)&&Fc.has(t.github)&&Fc.has(t.copilot)&&Fc.has(t.codex)&&Fc.has(t.goose)}function ek(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 tk(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 wo=5e3;function U7(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 ra={label:"Home",url:Di};function H7(t){return t?[ra,{label:"Settings",url:wi},{label:t,url:void 0}]:[ra,{label:"Settings",url:void 0}]}const fh={label:"Environments",url:Ro};function V7(){return[ra,{label:"Environments",url:void 0}]}function q7(){return[ra,{label:"New Chat",url:void 0}]}function G7(t){return[ra,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function F7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[ra,fh,{label:(d==null?void 0:d.displayName)??"Environment",url:Ai(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function Z7(t,s,o,r,c){const d=U7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,x=[ra];v&&g&&(x.push(fh),x.push({label:v.displayName,url:Ai(g)})),m&&g&&x.push({label:m.name,url:Ei(m.id,g)});for(let k=0;k<d.length-1;k++)x.push({label:d[k].title,url:On(d[k].id,void 0,p,g)});const y=d[d.length-1];return x.push({label:(y==null?void 0:y.title)??t,url:void 0}),x}const K7={label:"Findings",url:Ad};function Y7(){return[ra,{label:"Findings",url:void 0}]}function nk(t,s,o,r,c){const d=[ra];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(fh),p&&d.push({label:p.displayName,url:Ai(o)}),u&&d.push({label:u.name,url:Ei(s,o)}),d.push({label:"Findings",url:NN(s,o)})}else d.push(K7);return d.push({label:t,url:void 0}),d}function ph(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 Zc(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 J7(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 mh(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 x=s.get(v),y=x?Zc(x):void 0;if(y)try{const k=JSON.parse(v.content);o.set(y,{tool:k.tool,args:k.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,x)=>{if(v.eventType!=="tool_result")return v;const y=s.get(v),k=y?J7(y):void 0;if(!k)return v;const S=o.get(k);if(!S)return v;r.add(k),c.add(x);let j;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const x=s.get(d[v]),y=x?Zc(x):void 0;y&&r.has(y)||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 x=p[m];if(x!==v+1)continue;const y=d[v],k=d[x];let S;try{const j=JSON.parse(y.content);S={tool:j.tool,args:j.args}}catch{}if(S){let j;const N=k.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(j=D.detailedContent)}catch{}d[x]={...k,toolUseCtx:{...S,detailedResult:j}},c.add(x);const T=s.get(y),C=T?Zc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(y,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const x=s.get(v);if(!x)return!0;const y=Zc(x);if(y&&r.has(y))return!1;const k=x.__seqId;return!(k&&r.has(k))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let x=!1;for(let y=v+1;y<g.length;y++)if(g[y].eventType!=="tool_use"){x=!0;break}x&&(g[v]={...g[v],settled:!0})}return g}function W7(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=sk(s),d=s.filter(m=>mm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||mm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function sk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function mm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function X7(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=sk(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}):mm(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 Q7(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 ez(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 ws=[{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
285
285
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
286
286
  const header = req.headers.authorization;
287
287
  if (!header?.startsWith("Bearer ")) {
@@ -722,4 +722,4 @@ const grackle = await host.mcpServer({
722
722
  url: env.vars.GRACKLE_MCP_URL,
723
723
  });
724
724
 
725
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),A==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(nx,{selectedTools:J,onChange:oe=>{V(oe),xe(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,oe),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ne&&!fe&&i.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,i.jsx(oa,{isOpen:K,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:ke,onCancel:()=>de(!1)})]})}function c9(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=pn(),d=mt();return i.jsx(z8,{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(kN),onNavigateToSchedule:u=>d(Yx(u))})}const d9="_container_1g4qh_1",u9="_form_1g4qh_7",f9="_formActions_1g4qh_66",p9="_editableSection_1g4qh_73",m9="_helperText_1g4qh_84",h9="_metaSection_1g4qh_90",g9="_optional_1g4qh_108",v9="_readonlyValue_1g4qh_113",Mn={container:d9,form:u9,formActions:f9,editableSection:p9,helperText:m9,metaSection:h9,optional:g9,readonlyValue:v9};function gx(){const{scheduleId:t}=as(),s=mt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ot(),v=t===void 0,x=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!x)return i.jsx(ts,{to:ep,replace:!0});const y=[{label:"Settings",url:wi},{label:"Schedules",url:ep},{label:v?"New Schedule":(x==null?void 0:x.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:Mn.container,children:[i.jsx(vs,{segments:y}),i.jsx(y9,{existing:x,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(ep)},showToast:o})]})}function y9({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var M;const g=mt(),[v,x]=b.useState((t==null?void 0:t.title)??""),[y,k]=b.useState((t==null?void 0:t.description)??""),[S,j]=b.useState((t==null?void 0:t.scheduleExpression)??""),[N,T]=b.useState((t==null?void 0:t.personaId)??""),[C,D]=b.useState((t==null?void 0:t.workspaceId)??""),[B,E]=b.useState(!1),[A,$]=b.useState(null);b.useEffect(()=>{s||t&&A===null&&(x(t.title),k(t.description),j(t.scheduleExpression),T(t.personaId),D(t.workspaceId))},[s,t,A]);const L=!s&&t===void 0,U=s&&v.trim().length>0&&S.trim().length>0&&N.length>0,J=o.map(O=>({value:O.id,label:O.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(O=>({value:O.id,label:O.name}))],K=O=>{O.preventDefault(),U&&c(v,y,S,N,C||void 0).then(X=>{m("Schedule created","success"),g(Yx(X.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},de=(O,X)=>{t&&d(t.id,{[O]:X}).then(()=>{m("Schedule updated","success"),O==="title"&&x(String(X)),O==="description"&&k(String(X)),O==="scheduleExpression"&&j(String(X)),O==="personaId"&&T(String(X))},()=>{m("Failed to update schedule","error")})},ee=()=>{if(!t)return;const O=!t.enabled;d(t.id,{enabled:O}).then(()=>{m(O?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ie=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[L?i.jsxs("div",{className:Mn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:K,className:Mn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:v,onChange:O=>x(O.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:Mn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:y,onChange:O=>k(O.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:S,onChange:O=>j(O.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:Mn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:N,onChange:O=>T(O.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),J.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))]})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Mn.optional,children:"(optional)"}),i.jsx("select",{value:C,onChange:O=>D(O.target.value),"data-testid":"schedule-detail-workspace",children:V.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))})]}),i.jsxs("div",{className:Mn.formActions,children:[i.jsx(tn,{type:"submit",variant:"primary",size:"md",disabled:!U,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:Mn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:Mn.formActions,children:[i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(tn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:ee,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(tn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:Mn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Ft,{value:v,onSave:O=>{de("title",O)},validate:O=>O.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:A,onActivate:$,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Ft,{value:y,onSave:O=>{de("description",O)},fieldId:"schedule-description",activeFieldId:A,onActivate:$,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Ft,{value:S,onSave:O=>{de("scheduleExpression",O)},validate:O=>O.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:A,onActivate:$,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),i.jsxs("label",{children:["Persona",i.jsx(yd,{value:N,onSave:O=>{de("personaId",O)},options:J,fieldId:"schedule-persona",activeFieldId:A,onActivate:$,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Mn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:Mn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((M=r.find(O=>O.id===t.workspaceId))==null?void 0:M.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:Mn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",$o(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",O1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",$o(t.createdAt)]})]})]}):null,i.jsx(oa,{isOpen:B,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:ie,onCancel:()=>E(!1)})]})}function b9(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=Y1();return i.jsx(aB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function x9(){const[t,s]=b.useState(void 0);return b.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ye.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function _9(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=x9();return i.jsxs(i.Fragment,{children:[r&&i.jsx(iO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(iB,{connected:t,environments:s,sessions:o})]})}function k9(){return i.jsx(KL,{})}function S9(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return i.jsx(bL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const vx=Ii();function T9(){const t=mt();return sa({key:"?"},()=>{t(SN)}),sa({key:"n"},()=>{t(vx)}),sa({key:"N"},()=>{t(vx)}),i.jsx(i.Fragment,{})}function yl(t){const s=L7();b.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function j9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=b.useMemo(()=>i.jsx(OI,{workspaces:t,tasks:s}),[t,s]);return yl(o),i.jsx(Ka,{})}function w9(){const{environments:{environments:t}}=ot(),s=b.useMemo(()=>i.jsx(G5,{environments:t}),[t]);return yl(s),i.jsx(Ka,{})}function N9(){const t=b.useMemo(()=>i.jsx(V8,{}),[]);return yl(t),i.jsx(Ka,{})}function C9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=as();b.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=b.useMemo(()=>i.jsx(nI,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return yl(d),i.jsx(Ka,{})}function E9(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),o=b.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=b.useCallback(()=>{t.clearSearch()},[t]),c=b.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=b.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=b.useMemo(()=>i.jsx(a5,{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 yl(u),i.jsx(Ka,{})}const A9="_container_ce571_1",D9="_title_ce571_6",_d={container:A9,title:D9};function M9(){return i.jsxs("div",{className:_d.container,"aria-hidden":"true",children:[i.jsx("h1",{className:_d.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(vd,{lines:3},s))})]})}function yx(){const{environmentId:t,workspaceId:s}=as(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=mt();b.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=b.useCallback(v=>{p(qp(v,s,t))},[p,s,t]);if(r)return i.jsx(M9,{});const g=s&&t?nk("Findings",s,t,d,u).slice(0,-1):Y7();return i.jsxs("div",{className:_d.container,"data-testid":"findings-list-page",children:[i.jsx(vs,{segments:g}),i.jsx("h1",{className:_d.title,children:"Findings"}),i.jsx(P1,{findings:o,onFindingClick:m})]})}const R9="_container_1wwpb_1",I9="_notFound_1wwpb_6",O9="_header_1wwpb_12",B9="_categoryBadge_1wwpb_19",L9="_title_1wwpb_28",z9="_content_1wwpb_35",$9="_tags_1wwpb_77",P9="_tag_1wwpb_77",U9="_meta_1wwpb_92",H9="_metaTimestamp_1wwpb_100",V9="_metaLink_1wwpb_105",vn={container:R9,notFound:I9,header:O9,categoryBadge:B9,title:L9,content:z9,tags:$9,tag:P9,meta:U9,metaTimestamp:H9,metaLink:V9};function bx(){const{findingId:t,environmentId:s,workspaceId:o}=as(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=mt();if(b.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Finding not found."})});const g=nk(r.title,o,s,u,p),v=bd(r.category);return i.jsxs("div",{className:vn.container,"data-testid":"finding-detail-page",children:[i.jsx(vs,{segments:g}),i.jsxs("div",{className:vn.header,children:[i.jsx("span",{className:vn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:vn.title,children:r.title})]}),r.content&&i.jsx("div",{className:vn.content,children:i.jsx(Sd,{remarkPlugins:[Td],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:vn.tags,children:r.tags.map(x=>i.jsx("span",{className:vn.tag,children:x},x))}),i.jsxs("div",{className:vn.meta,children:[i.jsx("span",{className:vn.metaTimestamp,title:r.createdAt,children:$o(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(Nm(r.sessionId))},children:"View Session"})]})]})}const q9="_wizard_1260s_1",G9="_container_1260s_10",F9="_stepContent_1260s_19",Z9="_logoArea_1260s_28",K9="_logoImage_1260s_32",Y9="_heading_1260s_41",J9="_tagline_1260s_49",W9="_subtitle_1260s_56",X9="_featureList_1260s_64",Q9="_runtimeGrid_1260s_89",eH="_runtimeCard_1260s_101",tH="_runtimeName_1260s_133",nH="_runtimeDescription_1260s_139",sH="_buttonRow_1260s_144",aH="_primaryButton_1260s_151",iH="_ghostButton_1260s_185",oH="_dots_1260s_213",rH="_dot_1260s_213",Ke={wizard:q9,container:G9,stepContent:F9,logoArea:Z9,logoImage:K9,heading:Y9,tagline:J9,subtitle:W9,featureList:X9,runtimeGrid:Q9,runtimeCard:eH,runtimeName:tH,runtimeDescription:nH,buttonRow:sH,primaryButton:aH,ghostButton:iH,dots:oH,dot:rH};function lH({onNext:t}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Ke.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ke.logoImage})}),i.jsx("h1",{className:Ke.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Ke.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function cH({onNext:t,onBack:s}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Ke.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Ke.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const dH=[{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 uH({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=b.useState(t||"claude-code");return b.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Ke.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Ke.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Ke.runtimeGrid,children:dH.map(u=>i.jsxs("button",{type:"button",className:Ke.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:Ke.runtimeName,children:u.name}),i.jsx("span",{className:Ke.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function fH(){return typeof Notification<"u"}function pH({onFinish:t,onBack:s,finishDisabled:o}){const r=fH(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Ke.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Ke.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:Ke.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const mH=4,xx={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function hH(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=pn(),d=mt(),[u,p]=b.useState(0),[m,g]=b.useState("claude-code"),[v,x]=b.useState(!1),y=t.find(j=>j.id==="claude-code"),k=b.useCallback(j=>{g(j),p(3)},[]),S=b.useCallback(()=>{const j=m;x(!0);const N=[];if(y&&j!==y.runtime){const C=xx[j]??"sonnet";N.push(s(y.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===cy);if(T&&j!==T.runtime){const C=xx[j]??"sonnet";N.push(s(cy,void 0,void 0,void 0,j,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),x(!1)})},[m,y,t,s,o,d,c]);return r===!0?i.jsx(ts,{to:"/",replace:!0}):i.jsx("div",{className:Ke.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Ke.container,children:[i.jsx(gs,{mode:"wait",children:i.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(lH,{onNext:()=>p(1)}),u===1&&i.jsx(cH,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(uH,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!y}),u===3&&i.jsx(pH,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Ke.dots,children:Array.from({length:mH},(j,N)=>i.jsx("span",{className:Ke.dot,"data-active":N===u},N))})]})})}const gH="_root_zndgp_1",vH="_body_zndgp_7",yH="_main_zndgp_19",bH="_sidebarWrapper_zndgp_26",xH="_overlay_zndgp_51",Yr={root:gH,body:vH,main:yH,sidebarWrapper:bH,overlay:xH},_H=b.lazy(()=>KT(()=>import("./KnowledgePage-BzbHIYVG.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),ok=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function kH({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=pn(),p=Yt(),m=B7(),g=m!==void 0,[v,x]=b.useState(!1),y=b.useCallback(()=>x(k=>!k),[]);return b.useEffect(()=>{x(!1)},[p.pathname]),b.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&x(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(m5,{connected:s,environments:o,sessions:r,onToggleSidebar:g?y:void 0,sidebarOpen:v}),i.jsx(_5,{tabs:t}),i.jsxs("div",{className:Yr.body,children:[g&&i.jsx("div",{className:Yr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(N5,{content:m})}),g&&v&&i.jsx("div",{className:Yr.overlay,"data-testid":"drawer-overlay",onClick:()=>x(!1)}),i.jsxs("div",{className:Yr.main,children:[i.jsx(Ka,{}),i.jsx(O5,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(KI,{toasts:d,onDismiss:u}),i.jsx(T9,{})]})}function SH(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ot(),{pluginNames:p}=hh(),{showToast:m}=pn();Vz(s,m),Kz(c,m),qz(o,r,m);const g=mt(),v=Yt();if(b.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Nm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ts,{to:"/setup",replace:!0});const x=vz(p);return i.jsx(O7,{children:i.jsxs("div",{className:Yr.root,children:[ok&&i.jsx(QN,{}),i.jsx(kH,{tabs:x})]})})}function $p(){const{workspaceId:t}=as(),{workspaces:{workspaces:s}}=ot(),o=Yt(),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:i.jsx(ts,{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 i.jsx(ts,{to:m,replace:!0})}function TH(){const{pluginNames:t}=hh(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(Lw,{children:[i.jsx(we,{path:"setup",element:i.jsx(hH,{})}),i.jsxs(we,{element:i.jsx(SH,{}),children:[i.jsx(we,{index:!0,element:i.jsx(IP,{})}),i.jsx(we,{path:"chat",element:i.jsx(qP,{})}),i.jsx(we,{path:"sessions/new",element:i.jsx(GP,{})}),i.jsx(we,{path:"sessions/:sessionId",element:i.jsx(YP,{})}),o&&i.jsx(we,{element:i.jsx(E9,{}),children:i.jsx(we,{path:"knowledge",element:i.jsx(b.Suspense,{fallback:i.jsx(E1,{}),children:i.jsx(_H,{})})})}),s&&i.jsxs(we,{element:i.jsx(j9,{}),children:[i.jsx(we,{path:"tasks",element:i.jsx(MP,{})}),i.jsx(we,{path:"tasks/new",element:i.jsx(fx,{})}),i.jsx(we,{path:"tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(we,{path:"tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(we,{path:"tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(we,{path:"tasks/:taskId/findings",element:i.jsx(Pa,{})})]}),s&&i.jsxs(we,{element:i.jsx(C9,{}),children:[i.jsx(we,{path:"findings",element:i.jsx(yx,{})}),i.jsx(we,{path:"findings/:findingId",element:i.jsx(bx,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(yx,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(bx,{})})]}),i.jsxs(we,{element:i.jsx(w9,{}),children:[i.jsx(we,{path:"workspaces",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(we,{path:"workspaces/new",element:i.jsx(dU,{})}),i.jsx(we,{path:"workspaces/:workspaceId",element:i.jsx($p,{})}),i.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx($p,{})}),i.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx($p,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(QP,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(fx,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Pa,{})}),i.jsxs(we,{path:"environments",element:i.jsx(vU,{}),children:[i.jsx(we,{index:!0,element:i.jsx(RP,{})}),i.jsx(we,{path:"new",element:i.jsx(fU,{})}),i.jsx(we,{path:":environmentId",element:i.jsx(ZU,{})}),i.jsx(we,{path:":environmentId/edit",element:i.jsx(pU,{})})]})]}),i.jsx(we,{element:i.jsx(N9,{}),children:i.jsxs(we,{path:"settings",element:i.jsx(JU,{}),children:[i.jsx(we,{index:!0,element:i.jsx(ts,{to:"credentials",replace:!0})}),i.jsx(we,{path:"environments",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(we,{path:"credentials",element:i.jsx(WU,{})}),i.jsx(we,{path:"tokens",element:i.jsx(ts,{to:"../credentials",replace:!0})}),i.jsx(we,{path:"personas",element:i.jsx(XU,{})}),i.jsx(we,{path:"personas/new",element:i.jsx(hx,{})}),i.jsx(we,{path:"personas/:personaId",element:i.jsx(hx,{})}),i.jsx(we,{path:"schedules",element:i.jsx(c9,{})}),i.jsx(we,{path:"schedules/new",element:i.jsx(gx,{})}),i.jsx(we,{path:"schedules/:scheduleId",element:i.jsx(gx,{})}),i.jsx(we,{path:"appearance",element:i.jsx(b9,{})}),i.jsx(we,{path:"shortcuts",element:i.jsx(k9,{})}),i.jsx(we,{path:"plugins",element:i.jsx(S9,{})}),i.jsx(we,{path:"about",element:i.jsx(_9,{})})]})}),i.jsx(we,{path:"*",element:i.jsx(ts,{to:"/",replace:!0})})]})]})}const jH=1e4;function wH(){const{onboardingCompleted:t}=ot(),[s,o]=b.useState(!1);b.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),jH);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(gs,{mode:"wait",children:r?i.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(E1,{})},"splash"):i.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(lN,{basename:"/".replace(/\/$/,""),children:i.jsx(TH,{})})},"app")})}function NH(){const t=ok?dz:Hz;return i.jsx(pz,{children:i.jsx(I7,{children:i.jsx(A7,{children:i.jsx(t,{children:i.jsx(wH,{})})})})})}GT.createRoot(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(NH,{})}));export{vs as B,Wx as K,ot as a,qp as f,Nm as s,On as t,mt as u};
725
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),A==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(nx,{selectedTools:J,onChange:oe=>{V(oe),xe(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,oe),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ne&&!fe&&i.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,i.jsx(oa,{isOpen:K,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:ke,onCancel:()=>de(!1)})]})}function c9(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=pn(),d=mt();return i.jsx(z8,{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(kN),onNavigateToSchedule:u=>d(Yx(u))})}const d9="_container_1g4qh_1",u9="_form_1g4qh_7",f9="_formActions_1g4qh_66",p9="_editableSection_1g4qh_73",m9="_helperText_1g4qh_84",h9="_metaSection_1g4qh_90",g9="_optional_1g4qh_108",v9="_readonlyValue_1g4qh_113",Mn={container:d9,form:u9,formActions:f9,editableSection:p9,helperText:m9,metaSection:h9,optional:g9,readonlyValue:v9};function gx(){const{scheduleId:t}=as(),s=mt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ot(),v=t===void 0,x=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!x)return i.jsx(ts,{to:ep,replace:!0});const y=[{label:"Settings",url:wi},{label:"Schedules",url:ep},{label:v?"New Schedule":(x==null?void 0:x.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:Mn.container,children:[i.jsx(vs,{segments:y}),i.jsx(y9,{existing:x,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(ep)},showToast:o})]})}function y9({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var M;const g=mt(),[v,x]=b.useState((t==null?void 0:t.title)??""),[y,k]=b.useState((t==null?void 0:t.description)??""),[S,j]=b.useState((t==null?void 0:t.scheduleExpression)??""),[N,T]=b.useState((t==null?void 0:t.personaId)??""),[C,D]=b.useState((t==null?void 0:t.workspaceId)??""),[B,E]=b.useState(!1),[A,$]=b.useState(null);b.useEffect(()=>{s||t&&A===null&&(x(t.title),k(t.description),j(t.scheduleExpression),T(t.personaId),D(t.workspaceId))},[s,t,A]);const L=!s&&t===void 0,U=s&&v.trim().length>0&&S.trim().length>0&&N.length>0,J=o.map(O=>({value:O.id,label:O.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(O=>({value:O.id,label:O.name}))],K=O=>{O.preventDefault(),U&&c(v,y,S,N,C||void 0).then(X=>{m("Schedule created","success"),g(Yx(X.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},de=(O,X)=>{t&&d(t.id,{[O]:X}).then(()=>{m("Schedule updated","success"),O==="title"&&x(String(X)),O==="description"&&k(String(X)),O==="scheduleExpression"&&j(String(X)),O==="personaId"&&T(String(X))},()=>{m("Failed to update schedule","error")})},ee=()=>{if(!t)return;const O=!t.enabled;d(t.id,{enabled:O}).then(()=>{m(O?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ie=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[L?i.jsxs("div",{className:Mn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:K,className:Mn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:v,onChange:O=>x(O.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:Mn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:y,onChange:O=>k(O.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:S,onChange:O=>j(O.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:Mn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:N,onChange:O=>T(O.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),J.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))]})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Mn.optional,children:"(optional)"}),i.jsx("select",{value:C,onChange:O=>D(O.target.value),"data-testid":"schedule-detail-workspace",children:V.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))})]}),i.jsxs("div",{className:Mn.formActions,children:[i.jsx(tn,{type:"submit",variant:"primary",size:"md",disabled:!U,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:Mn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:Mn.formActions,children:[i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(tn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:ee,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(tn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:Mn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Ft,{value:v,onSave:O=>{de("title",O)},validate:O=>O.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:A,onActivate:$,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Ft,{value:y,onSave:O=>{de("description",O)},fieldId:"schedule-description",activeFieldId:A,onActivate:$,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Ft,{value:S,onSave:O=>{de("scheduleExpression",O)},validate:O=>O.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:A,onActivate:$,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),i.jsxs("label",{children:["Persona",i.jsx(yd,{value:N,onSave:O=>{de("personaId",O)},options:J,fieldId:"schedule-persona",activeFieldId:A,onActivate:$,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Mn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:Mn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((M=r.find(O=>O.id===t.workspaceId))==null?void 0:M.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:Mn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",$o(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",O1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",$o(t.createdAt)]})]})]}):null,i.jsx(oa,{isOpen:B,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:ie,onCancel:()=>E(!1)})]})}function b9(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=Y1();return i.jsx(aB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function x9(){const[t,s]=b.useState(void 0);return b.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ye.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function _9(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=x9();return i.jsxs(i.Fragment,{children:[r&&i.jsx(iO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(iB,{connected:t,environments:s,sessions:o})]})}function k9(){return i.jsx(KL,{})}function S9(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return i.jsx(bL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const vx=Ii();function T9(){const t=mt();return sa({key:"?"},()=>{t(SN)}),sa({key:"n"},()=>{t(vx)}),sa({key:"N"},()=>{t(vx)}),i.jsx(i.Fragment,{})}function yl(t){const s=L7();b.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function j9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=b.useMemo(()=>i.jsx(OI,{workspaces:t,tasks:s}),[t,s]);return yl(o),i.jsx(Ka,{})}function w9(){const{environments:{environments:t}}=ot(),s=b.useMemo(()=>i.jsx(G5,{environments:t}),[t]);return yl(s),i.jsx(Ka,{})}function N9(){const t=b.useMemo(()=>i.jsx(V8,{}),[]);return yl(t),i.jsx(Ka,{})}function C9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=as();b.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=b.useMemo(()=>i.jsx(nI,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return yl(d),i.jsx(Ka,{})}function E9(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),o=b.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=b.useCallback(()=>{t.clearSearch()},[t]),c=b.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=b.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=b.useMemo(()=>i.jsx(a5,{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 yl(u),i.jsx(Ka,{})}const A9="_container_ce571_1",D9="_title_ce571_6",_d={container:A9,title:D9};function M9(){return i.jsxs("div",{className:_d.container,"aria-hidden":"true",children:[i.jsx("h1",{className:_d.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(vd,{lines:3},s))})]})}function yx(){const{environmentId:t,workspaceId:s}=as(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=mt();b.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=b.useCallback(v=>{p(qp(v,s,t))},[p,s,t]);if(r)return i.jsx(M9,{});const g=s&&t?nk("Findings",s,t,d,u).slice(0,-1):Y7();return i.jsxs("div",{className:_d.container,"data-testid":"findings-list-page",children:[i.jsx(vs,{segments:g}),i.jsx("h1",{className:_d.title,children:"Findings"}),i.jsx(P1,{findings:o,onFindingClick:m})]})}const R9="_container_1wwpb_1",I9="_notFound_1wwpb_6",O9="_header_1wwpb_12",B9="_categoryBadge_1wwpb_19",L9="_title_1wwpb_28",z9="_content_1wwpb_35",$9="_tags_1wwpb_77",P9="_tag_1wwpb_77",U9="_meta_1wwpb_92",H9="_metaTimestamp_1wwpb_100",V9="_metaLink_1wwpb_105",vn={container:R9,notFound:I9,header:O9,categoryBadge:B9,title:L9,content:z9,tags:$9,tag:P9,meta:U9,metaTimestamp:H9,metaLink:V9};function bx(){const{findingId:t,environmentId:s,workspaceId:o}=as(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=mt();if(b.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Finding not found."})});const g=nk(r.title,o,s,u,p),v=bd(r.category);return i.jsxs("div",{className:vn.container,"data-testid":"finding-detail-page",children:[i.jsx(vs,{segments:g}),i.jsxs("div",{className:vn.header,children:[i.jsx("span",{className:vn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:vn.title,children:r.title})]}),r.content&&i.jsx("div",{className:vn.content,children:i.jsx(Sd,{remarkPlugins:[Td],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:vn.tags,children:r.tags.map(x=>i.jsx("span",{className:vn.tag,children:x},x))}),i.jsxs("div",{className:vn.meta,children:[i.jsx("span",{className:vn.metaTimestamp,title:r.createdAt,children:$o(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(Nm(r.sessionId))},children:"View Session"})]})]})}const q9="_wizard_1260s_1",G9="_container_1260s_10",F9="_stepContent_1260s_19",Z9="_logoArea_1260s_28",K9="_logoImage_1260s_32",Y9="_heading_1260s_41",J9="_tagline_1260s_49",W9="_subtitle_1260s_56",X9="_featureList_1260s_64",Q9="_runtimeGrid_1260s_89",eH="_runtimeCard_1260s_101",tH="_runtimeName_1260s_133",nH="_runtimeDescription_1260s_139",sH="_buttonRow_1260s_144",aH="_primaryButton_1260s_151",iH="_ghostButton_1260s_185",oH="_dots_1260s_213",rH="_dot_1260s_213",Ke={wizard:q9,container:G9,stepContent:F9,logoArea:Z9,logoImage:K9,heading:Y9,tagline:J9,subtitle:W9,featureList:X9,runtimeGrid:Q9,runtimeCard:eH,runtimeName:tH,runtimeDescription:nH,buttonRow:sH,primaryButton:aH,ghostButton:iH,dots:oH,dot:rH};function lH({onNext:t}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Ke.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ke.logoImage})}),i.jsx("h1",{className:Ke.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Ke.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function cH({onNext:t,onBack:s}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Ke.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Ke.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const dH=[{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 uH({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=b.useState(t||"claude-code");return b.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Ke.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Ke.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Ke.runtimeGrid,children:dH.map(u=>i.jsxs("button",{type:"button",className:Ke.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:Ke.runtimeName,children:u.name}),i.jsx("span",{className:Ke.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function fH(){return typeof Notification<"u"}function pH({onFinish:t,onBack:s,finishDisabled:o}){const r=fH(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Ke.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Ke.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:Ke.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const mH=4,xx={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function hH(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=pn(),d=mt(),[u,p]=b.useState(0),[m,g]=b.useState("claude-code"),[v,x]=b.useState(!1),y=t.find(j=>j.id==="claude-code"),k=b.useCallback(j=>{g(j),p(3)},[]),S=b.useCallback(()=>{const j=m;x(!0);const N=[];if(y&&j!==y.runtime){const C=xx[j]??"sonnet";N.push(s(y.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===cy);if(T&&j!==T.runtime){const C=xx[j]??"sonnet";N.push(s(cy,void 0,void 0,void 0,j,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),x(!1)})},[m,y,t,s,o,d,c]);return r===!0?i.jsx(ts,{to:"/",replace:!0}):i.jsx("div",{className:Ke.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Ke.container,children:[i.jsx(gs,{mode:"wait",children:i.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(lH,{onNext:()=>p(1)}),u===1&&i.jsx(cH,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(uH,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!y}),u===3&&i.jsx(pH,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Ke.dots,children:Array.from({length:mH},(j,N)=>i.jsx("span",{className:Ke.dot,"data-active":N===u},N))})]})})}const gH="_root_zndgp_1",vH="_body_zndgp_7",yH="_main_zndgp_19",bH="_sidebarWrapper_zndgp_26",xH="_overlay_zndgp_51",Yr={root:gH,body:vH,main:yH,sidebarWrapper:bH,overlay:xH},_H=b.lazy(()=>KT(()=>import("./KnowledgePage-DUXTl4nL.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),ok=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function kH({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=pn(),p=Yt(),m=B7(),g=m!==void 0,[v,x]=b.useState(!1),y=b.useCallback(()=>x(k=>!k),[]);return b.useEffect(()=>{x(!1)},[p.pathname]),b.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&x(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(m5,{connected:s,environments:o,sessions:r,onToggleSidebar:g?y:void 0,sidebarOpen:v}),i.jsx(_5,{tabs:t}),i.jsxs("div",{className:Yr.body,children:[g&&i.jsx("div",{className:Yr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(N5,{content:m})}),g&&v&&i.jsx("div",{className:Yr.overlay,"data-testid":"drawer-overlay",onClick:()=>x(!1)}),i.jsxs("div",{className:Yr.main,children:[i.jsx(Ka,{}),i.jsx(O5,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(KI,{toasts:d,onDismiss:u}),i.jsx(T9,{})]})}function SH(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ot(),{pluginNames:p}=hh(),{showToast:m}=pn();Vz(s,m),Kz(c,m),qz(o,r,m);const g=mt(),v=Yt();if(b.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Nm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ts,{to:"/setup",replace:!0});const x=vz(p);return i.jsx(O7,{children:i.jsxs("div",{className:Yr.root,children:[ok&&i.jsx(QN,{}),i.jsx(kH,{tabs:x})]})})}function $p(){const{workspaceId:t}=as(),{workspaces:{workspaces:s}}=ot(),o=Yt(),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:i.jsx(ts,{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 i.jsx(ts,{to:m,replace:!0})}function TH(){const{pluginNames:t}=hh(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(Lw,{children:[i.jsx(we,{path:"setup",element:i.jsx(hH,{})}),i.jsxs(we,{element:i.jsx(SH,{}),children:[i.jsx(we,{index:!0,element:i.jsx(IP,{})}),i.jsx(we,{path:"chat",element:i.jsx(qP,{})}),i.jsx(we,{path:"sessions/new",element:i.jsx(GP,{})}),i.jsx(we,{path:"sessions/:sessionId",element:i.jsx(YP,{})}),o&&i.jsx(we,{element:i.jsx(E9,{}),children:i.jsx(we,{path:"knowledge",element:i.jsx(b.Suspense,{fallback:i.jsx(E1,{}),children:i.jsx(_H,{})})})}),s&&i.jsxs(we,{element:i.jsx(j9,{}),children:[i.jsx(we,{path:"tasks",element:i.jsx(MP,{})}),i.jsx(we,{path:"tasks/new",element:i.jsx(fx,{})}),i.jsx(we,{path:"tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(we,{path:"tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(we,{path:"tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(we,{path:"tasks/:taskId/findings",element:i.jsx(Pa,{})})]}),s&&i.jsxs(we,{element:i.jsx(C9,{}),children:[i.jsx(we,{path:"findings",element:i.jsx(yx,{})}),i.jsx(we,{path:"findings/:findingId",element:i.jsx(bx,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(yx,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(bx,{})})]}),i.jsxs(we,{element:i.jsx(w9,{}),children:[i.jsx(we,{path:"workspaces",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(we,{path:"workspaces/new",element:i.jsx(dU,{})}),i.jsx(we,{path:"workspaces/:workspaceId",element:i.jsx($p,{})}),i.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx($p,{})}),i.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx($p,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(QP,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(fx,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Pa,{})}),i.jsxs(we,{path:"environments",element:i.jsx(vU,{}),children:[i.jsx(we,{index:!0,element:i.jsx(RP,{})}),i.jsx(we,{path:"new",element:i.jsx(fU,{})}),i.jsx(we,{path:":environmentId",element:i.jsx(ZU,{})}),i.jsx(we,{path:":environmentId/edit",element:i.jsx(pU,{})})]})]}),i.jsx(we,{element:i.jsx(N9,{}),children:i.jsxs(we,{path:"settings",element:i.jsx(JU,{}),children:[i.jsx(we,{index:!0,element:i.jsx(ts,{to:"credentials",replace:!0})}),i.jsx(we,{path:"environments",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(we,{path:"credentials",element:i.jsx(WU,{})}),i.jsx(we,{path:"tokens",element:i.jsx(ts,{to:"../credentials",replace:!0})}),i.jsx(we,{path:"personas",element:i.jsx(XU,{})}),i.jsx(we,{path:"personas/new",element:i.jsx(hx,{})}),i.jsx(we,{path:"personas/:personaId",element:i.jsx(hx,{})}),i.jsx(we,{path:"schedules",element:i.jsx(c9,{})}),i.jsx(we,{path:"schedules/new",element:i.jsx(gx,{})}),i.jsx(we,{path:"schedules/:scheduleId",element:i.jsx(gx,{})}),i.jsx(we,{path:"appearance",element:i.jsx(b9,{})}),i.jsx(we,{path:"shortcuts",element:i.jsx(k9,{})}),i.jsx(we,{path:"plugins",element:i.jsx(S9,{})}),i.jsx(we,{path:"about",element:i.jsx(_9,{})})]})}),i.jsx(we,{path:"*",element:i.jsx(ts,{to:"/",replace:!0})})]})]})}const jH=1e4;function wH(){const{onboardingCompleted:t}=ot(),[s,o]=b.useState(!1);b.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),jH);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(gs,{mode:"wait",children:r?i.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(E1,{})},"splash"):i.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(lN,{basename:"/".replace(/\/$/,""),children:i.jsx(TH,{})})},"app")})}function NH(){const t=ok?dz:Hz;return i.jsx(pz,{children:i.jsx(I7,{children:i.jsx(A7,{children:i.jsx(t,{children:i.jsx(wH,{})})})})})}GT.createRoot(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(NH,{})}));export{vs as B,Wx as K,ot as a,qp as f,Nm as s,On as t,mt as u};
package/dist/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
12
12
  <link rel="manifest" href="/manifest.json" />
13
- <script type="module" crossorigin src="/assets/index-cy4uHNRw.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-BM6_EZWA.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-tHPW3Rz3.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/grpc-DIjMtMRF.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/markdown-Yr3vTPLR.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.106.1",
3
+ "version": "0.106.2",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "rehype-prism-plus": "^2.0.0",
39
39
  "remark-gfm": "^4.0.0",
40
40
  "react-router": "^7.0.0",
41
- "@grackle-ai/common": "0.106.1",
41
+ "@grackle-ai/common": "0.106.2",
42
42
  "@grackle-ai/web-components": "0.83.2"
43
43
  },
44
44
  "devDependencies": {