@grackle-ai/web 0.96.3 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-D_SccLJc.js";import"./grpc-CkqXCGns.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-CSO6PNIo.js";import"./grpc-CkqXCGns.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-BJrUmsbY.js","assets/dagview-tHPW3Rz3.js","assets/grpc-CkqXCGns.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-DzeT3FFx.js","assets/dagview-tHPW3Rz3.js","assets/grpc-CkqXCGns.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
2
  import{r as tT,a as nT,b as y,j as i,d as K0,H as Y0,P as J0,i as sT,B as aT,c as iT,C as oT,M as rT,e as lT}from"./dagview-tHPW3Rz3.js";import{c as cT,a as dT,G as uT,f as fT,M as pT,A as lx,D as cx,W as mT,O as hT,b as gT,C as ji,d as dx,e as ux,w as vT,t as yT,p as Ec,g as bT,R as Mr,S as W0}from"./grpc-CkqXCGns.js";import{v as xT,r as _T,t as Ac,i as kT,f as ST,M as hd,a as gd}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:{}},Ir={},$f={exports:{}},Uf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -271,7 +271,7 @@ ${JSON.stringify(u,void 0,2)}
271
271
  \`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
272
272
  ${r.content}`);break}}}return s.join(`
273
273
 
274
- `)}function Q3({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let O=N;O<=T;O++)O<t.length&&ll(t[O])&&D.add(O);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)ll(t[w])&&k.add(w);d(k)},[t]),x=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);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:b,deselectAll:x,copySelected:S}}const e6="_wrapper_1cdza_1",t6="_scrollContainer_1cdza_9",n6="_selectingPadding_1cdza_16",s6="_toolbar_1cdza_20",a6="_directionToggle_1cdza_27",i6="_scrollToAnchor_1cdza_65",o6="_scrollToAnchorBottom_1cdza_89",r6="_scrollToAnchorTop_1cdza_93",l6="_eventOverflowWarning_1cdza_97",Ys={wrapper:e6,scrollContainer:t6,selectingPadding:n6,toolbar:s6,directionToggle:a6,scrollToAnchor:i6,scrollToAnchorBottom:o6,scrollToAnchorTop:r6,eventOverflowWarning:l6};function c6(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 v1="grackle-stream-direction";function d6(){try{return localStorage.getItem(v1)==="reversed"}catch{return!1}}function u6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[i.jsx(im,{size:tn,"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 Wm({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(d6),p=Y4(),m=Q3({events:t,formatForClipboard:X3}),g=y.useMemo(()=>t.filter(ll).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:x}=Y3({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(v1,T?"reversed":"default")}catch{}};y.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 k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:Ys.wrapper,children:[i.jsx("div",{className:Ys.toolbar,children:i.jsx(zo,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(iy,{size:tn,"aria-hidden":"true"}):i.jsx(oy,{size:tn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(u6,{eventsDropped:s}),i.jsx(us,{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:w,ease:"easeOut"},children:i.jsx(z3,{copyText:W3(T),isContentBearing:ll(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:c6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:O=>{m.toggleEvent(D,O)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(SA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),i.jsx(us,{children:m.isSelecting&&i.jsx(F3,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(us,{children:!b&&i.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:x,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(oy,{size:tn,"aria-hidden":"true"}):i.jsx(iy,{size:tn,"aria-hidden":"true"})," New events"]})})]})}function Xm(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,x]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(P=>{v(P),x("")},[]),N=y.useCallback(()=>{x("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),x("")},[u]),C=y.useCallback(()=>{const P=m?g.trim():g;if(r){const U=r(g);if(U){x(U);return}}const I=m?s.trim():s;if(P===I){T();return}o(P),T()},[g,s,m,r,o,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),x("")},[c,s,u]),O=y.useCallback(P=>{if(S.current){S.current=!1;return}P.relatedTarget instanceof HTMLElement&&P.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(P=>{P.key==="Escape"?T():P.key==="Enter"&&p&&C()},[T,p,C]),A=(()=>{if(!k)return!1;const P=m?s.trim():s;return(m?g.trim():g)!==P})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),x(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:A,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:O,handleKeyDown:E,ignoreInitialBlurRef:S}}const f6="_editFieldWrapper_yuzty_1",p6="_editInput_yuzty_10",m6="_editTextarea_yuzty_42",h6="_editSelect_yuzty_78",g6="_editError_yuzty_111",v6="_editInputInvalid_yuzty_118",y6="_editHint_yuzty_123",b6="_unsavedDot_yuzty_132",x6="_metaValueClickable_yuzty_140",_6="_editButton_yuzty_159",k6="_metaPlaceholder_yuzty_175",S6="_worktreeToggle_yuzty_180",nt={editFieldWrapper:f6,editInput:p6,editTextarea:m6,editSelect:h6,editError:g6,editInputInvalid:v6,editHint:y6,unsavedDot:b6,metaValueClickable:x6,editButton:_6,metaPlaceholder:k6,worktreeToggle:S6};function ln(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:b,ariaLabel:x,"data-testid":S}=t,k=y.useRef(null),w=Xm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{className:`${nt.editInput} ${C?nt.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${nt.editInput} ${w.error?nt.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),w.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:w.error}),i.jsx("span",{className:nt.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:nt.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":x,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function Xp(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:b,"data-testid":x}=t,S=y.useRef(null),k=Xm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{className:`${nt.editTextarea} ${T?nt.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),T&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${nt.editTextarea} ${k.error?nt.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),k.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:nt.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:nt.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function ud(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:b,"data-testid":x}=t,S=y.useRef(null),k=Xm({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const O=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(O)}},[k.isEditing]);const w=y.useCallback(O=>{const E=O.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=y.useCallback(O=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:nt.editSelect,value:s,onChange:O=>m==null?void 0:m(O.target.value),"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:nt.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});const T=g==null?void 0:g(s),C=(D=c.find(O=>O.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:nt.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function T6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:nt.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 w6="_envRow_1e1r5_1",j6="_envDot_1e1r5_7",N6="_envDotGreen_1e1r5_14",C6="_envDotYellow_1e1r5_18",E6="_envDotRed_1e1r5_22",A6="_envDotGray_1e1r5_26",Do={envRow:w6,envDot:j6,envDotGreen:N6,envDotYellow:C6,envDotRed:E6,envDotGray:A6};function D6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Do.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Do.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Do.envDotRed:Do.envDotGray}function R6(t){const{value:s,onSave:o,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),x=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return i.jsxs("span",{className:Do.envRow,children:[i.jsx("span",{className:`${Do.envDot} ${D6(b.status)}`}),b.displayName]})};return i.jsx(ud,{value:s,onSave:o,options:x,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const M6="_nav_1snmp_1",I6="_searchForm_1snmp_8",O6="_searchInput_1snmp_15",B6="_searchButton_1snmp_33",L6="_clearButton_1snmp_68",z6="_workspaceSelect_1snmp_85",$6="_listHeader_1snmp_99",U6="_nodeList_1snmp_108",P6="_nodeItem_1snmp_116",H6="_indicator_1snmp_129",V6="_label_1snmp_136",q6="_badge_1snmp_145",Yn={nav:M6,searchForm:I6,searchInput:O6,searchButton:B6,clearButton:L6,workspaceSelect:z6,listHeader:$6,nodeList:U6,nodeItem:P6,indicator:H6,label:V6,badge:q6};function G6({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),x=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Yn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Yn.nodeList,children:t.map(k=>i.jsxs("li",{className:Yn.nodeItem,onClick:()=>{x(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Yn.label,children:k.label}),i.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const F6="_container_1mq5u_1",Z6="_hamburger_1mq5u_33",K6="_brand_1mq5u_49",Y6="_brandLogo_1mq5u_68",J6="_info_1mq5u_75",W6="_connectionLabel_1mq5u_90",X6="_connectionDot_1mq5u_103",Q6="_connected_1mq5u_106",e5="_disconnected_1mq5u_110",Zs={container:F6,hamburger:Z6,brand:K6,brandLogo:Y6,info:J6,connectionLabel:W6,connectionDot:X6,connected:Q6,disconnected:e5};function t5({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=kt(),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:Zs.container,children:[r&&i.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(I2,{size:zt,"aria-hidden":"true"})}),i.jsx(zo,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ci),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Zs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:i.jsx(La,{size:om,fill:"currentColor"})})," ",i.jsx("span",{className:Zs.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 n5="_nav_13gkc_1",s5="_tab_13gkc_35",a5="_tabIcon_13gkc_68",i5="_tabLabel_13gkc_79",o5="_tabActive_13gkc_84",$r={nav:n5,tab:s5,tabIcon:a5,tabLabel:i5,tabActive:o5},xi=[{view:"dashboard",label:"Dashboard",icon:i.jsx(_2,{size:zt}),route:Ci,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(B2,{size:zt}),route:aN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(l2,{size:zt}),route:iN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(z2,{size:zt}),route:Mo,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(n2,{size:zt}),route:Lx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(hx,{size:zt}),route:_d,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(Z2,{size:zt}),route:eN,testId:"sidebar-tab-settings"}];function r5(t){return t===Ci||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Lx)?"knowledge":t.startsWith(_d)?"findings":t.startsWith(Ro)?"settings":"tasks"}function l5(){const t=Zt(),s=kt(),o=y.useRef(null),r=r5(t.pathname),c=y.useCallback(u=>{s(u.route)},[s]),d=y.useCallback(u=>{var b,x;const p=(b=o.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!p)return;const m=Array.from(p).findIndex(S=>S===document.activeElement),g=m>=0?m:xi.findIndex(S=>S.view===r);let v=g;if(u.key==="ArrowRight"||u.key==="j"||u.key==="J")u.preventDefault(),v=(g+1)%xi.length;else if(u.key==="ArrowLeft"||u.key==="k"||u.key==="K")u.preventDefault(),v=(g-1+xi.length)%xi.length;else if(u.key==="Home")u.preventDefault(),v=0;else if(u.key==="End")u.preventDefault(),v=xi.length-1;else return;s(xi[v].route),(x=p[v])==null||x.focus()},[r,s]);return i.jsx("nav",{className:$r.nav,ref:o,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:d,"data-testid":"sidebar-nav",children:xi.map(u=>{const p=u.view===r;return i.jsx(zo,{text:u.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${$r.tab} ${p?$r.tabActive:""}`,onClick:()=>c(u),"data-testid":u.testId,"aria-label":u.label,children:[i.jsx("span",{className:$r.tabIcon,"aria-hidden":"true",children:u.icon}),i.jsx("span",{className:$r.tabLabel,children:u.label})]})},u.view)})})}const c5="_container_pi6ii_1",d5="_content_pi6ii_66",$b={container:c5,content:d5},u5=320,y1=220,b1=600,x1="grackle-sidebar-width";function f5(){try{const t=localStorage.getItem(x1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=y1&&s<=b1)return s}}catch{}return u5}function p5(t){try{localStorage.setItem(x1,String(t))}catch{}}function m5({content:t}){const[s]=y.useState(f5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=y1&&m<=b1&&p5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:$b.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:$b.content,children:t})})}const h5="_bar_tnfsh_1",g5="_btnPrimary_tnfsh_32",v5="_statusText_tnfsh_85",y5="_statusCompleted_tnfsh_90",b5="_statusFailed_tnfsh_94",x5="_statusBlocked_tnfsh_98",_5="_hintText_tnfsh_103",wt={bar:h5,btnPrimary:g5,statusText:v5,statusCompleted:y5,statusFailed:b5,statusBlocked:x5,hintText:_5};function k5({sessions:t,tasks:s,environments:o}){const r=kt(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),x=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),O=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId)??(S==null?void 0:S.params.taskId),A=v??b??x??S,P=(A==null?void 0:A.params.environmentId)??(w==null?void 0:w.params.environmentId),I=c.pathname.startsWith("/environments")&&!w&&!A,U=!!T,Q=!!k,$=!!w&&!v&&!b&&!x&&!S,H=!!N;if(!!C&&!Q&&!$&&!H||!!D||(!!g||!!S)||H||I||Q)return i.jsx(i.Fragment,{});if(U)return o.find(Z=>Z.adapterType==="local"&&Z.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Select a task or click + to create one"})});if(E){const L=s.find(ce=>ce.id===E);if(!L)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})});const Z=new Map(s.map(ce=>[ce.id,ce])),J=L.dependsOn.some(ce=>{const X=Z.get(ce);return X!==void 0&&X.status!=="complete"});if(L.status==="not_started"){const ce=J?L.dependsOn.map(X=>Z.get(X)).filter(X=>X&&X.status!=="complete").map(X=>X.title):[];return i.jsx("div",{className:wt.bar,children:J?i.jsxs("span",{className:wt.statusBlocked,children:["Blocked by: ",ce.join(", ")]}):i.jsx("span",{className:wt.hintText,children:"Use the buttons above to start or manage this task"})})}if(L.status==="working"||L.status==="paused"){const ce=L.latestSessionId||void 0,X=ce?t.find(pe=>pe.id===ce):void 0;return X&&X.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Waiting for agent..."})})}if(L.status==="complete")return i.jsxs("div",{className:wt.bar,children:[i.jsx("span",{className:`${wt.statusText} ${wt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ri(L.workspaceId,void 0,P)),className:wt.btnPrimary,children:"+ New Task"})]});if(L.status==="failed")return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:`${wt.statusText} ${wt.statusFailed}`,children:"Task failed"})})}if(O){const L=t.find(ce=>ce.id===O),Z=(L==null?void 0:L.status)==="stopped";if(L!==void 0&&!Z)return i.jsx(i.Fragment,{});if(Z)return i.jsxs("div",{className:wt.bar,children:[i.jsxs("span",{className:`${wt.statusText} ${wt.hintText}`,children:["Session ",L.endReason||L.status]}),i.jsx("button",{onClick:()=>r(Ix(L.environmentId)),className:wt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})})}const S5="_nav_14i94_1",T5="_tab_14i94_24",w5="_tabActive_14i94_62",j5="_tabLabel_14i94_75",N5="_statusDot_14i94_81",C5="_pulse_14i94_87",E5="_addButton_14i94_99",A5="_empty_14i94_132",Aa={nav:S5,tab:T5,tabActive:w5,tabLabel:j5,statusDot:N5,pulse:C5,addButton:E5,empty:A5},D5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function R5({environments:t}){const s=kt(),o=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(x=>{s(Ni(x))},[s]),v=y.useCallback(x=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&s(Ni(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(x=>{const S=x.id===m,k=x.id===b,w=D5[x.status]||"var(--text-tertiary)",N=x.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:i.jsx(La,{size:om,fill:"currentColor"})}),i.jsx("span",{className:Aa.tabLabel,title:x.displayName||x.id,children:x.displayName||x.id})]},x.id)})}),i.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(Xj),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function Qm(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()}`}const Ub={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 fd(t){return Ub[t]||Ub.general}const M5="_nav_dlm8m_1",I5="_categoryPills_dlm8m_24",O5="_categoryPill_dlm8m_24",B5="_tab_dlm8m_42",L5="_tabActive_dlm8m_80",z5="_tabContent_dlm8m_93",$5="_tabLabel_dlm8m_100",U5="_tabMeta_dlm8m_106",P5="_categoryDot_dlm8m_111",H5="_empty_dlm8m_118",xs={nav:M5,categoryPills:I5,categoryPill:O5,tab:B5,tabActive:L5,tabContent:z5,tabLabel:$5,tabMeta:U5,categoryDot:P5,empty:H5};function V5({findings:t,workspaceId:s,environmentId:o}){const r=kt(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const x=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(x).sort()},[t]),g=y.useCallback(x=>{r(Mp(x,s,o))},[r,s,o]),v=y.useCallback(x=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&r(Mp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),b=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:xs.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:xs.categoryPills,"data-testid":"findings-nav-categories",children:m.map(x=>i.jsx("span",{className:xs.categoryPill,style:{color:fd(x).text},children:x},x))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(x=>{const S=x.id===p,k=x.id===b;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${xs.tab} ${S?xs.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:xs.categoryDot,style:{color:fd(x.category).text},"aria-hidden":"true",children:i.jsx(La,{size:om,fill:"currentColor"})}),i.jsxs("span",{className:xs.tabContent,children:[i.jsx("span",{className:xs.tabLabel,title:x.title,children:x.title}),i.jsx("span",{className:xs.tabMeta,title:x.createdAt,children:Qm(x.createdAt)})]})]},x.id)})}),t.length===0&&i.jsx("div",{className:xs.empty,children:"No findings yet. Agents will post discoveries here."})]})}function q5(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 _1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=q5(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 G5(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 F5(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 nw){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(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=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const Z5="_container_z4i38_1",K5="_header_z4i38_5",Y5="_headerActions_z4i38_17",J5="_searchInput_z4i38_23",W5="_searchHighlight_z4i38_56",X5="_groupToggle_z4i38_62",Q5="_groupToggleActive_z4i38_89",eI="_addButton_z4i38_93",tI="_taskRow_z4i38_120",nI="_selected_z4i38_140",sI="_expandArrow_z4i38_150",aI="_expanded_z4i38_157",iI="_leafSpacer_z4i38_161",oI="_taskStatusIcon_z4i38_166",rI="_taskTitle_z4i38_170",lI="_workspaceBadge_z4i38_177",cI="_childCountBadge_z4i38_195",dI="_dependencyBadge_z4i38_208",uI="_blockedBadge_z4i38_220",fI="_addChildButton_z4i38_225",pI="_emptyState_z4i38_268",mI="_statusGroupHeader_z4i38_275",hI="_statusGroupIcon_z4i38_294",gI="_statusGroupLabel_z4i38_298",vI="_statusGroupCount_z4i38_303",Ge={container:Z5,header:K5,headerActions:Y5,searchInput:J5,searchHighlight:W5,groupToggle:X5,groupToggleActive:Q5,addButton:eI,taskRow:tI,selected:nI,expandArrow:sI,expanded:aI,leafSpacer:iI,taskStatusIcon:oI,taskTitle:rI,workspaceBadge:lI,childCountBadge:cI,dependencyBadge:dI,blockedBadge:uI,addChildButton:fI,emptyState:pI,statusGroupHeader:mI,statusGroupIcon:hI,statusGroupLabel:gI,statusGroupCount:vI},yI=[{name:"title",weight:2},{name:"description",weight:1}],k1=16,bI=16,S1="grackle-task-group-by-status";function Pb(){try{return localStorage.getItem(S1)==="true"}catch{return!1}}function xI(t){try{localStorage.setItem(S1,String(t))}catch{}}function _I({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:Ge.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:`${Ge.expandArrow} ${s?Ge.expanded:""}`,"aria-hidden":"true",children:i.jsx(sa,{size:lt})}),i.jsx("span",{className:Ge.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ge.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ge.statusGroupCount,children:t.tasks.length})]}),i.jsx(us,{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=za(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:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(On(p.id)))},className:`${Ge.taskRow} ${g?Ge.selected:""}`,style:{"--task-indent":`${k1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${cl(p.status)}`,children:m.icon}),i.jsx("span",{className:Ge.taskTitle,title:p.title,children:i.jsx(_1,{text:p.title,indices:d.get(p.id),highlightClass:Ge.searchHighlight})}),v&&i.jsx("span",{className:Ge.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function T1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=o.has(t.id),x=t.children.length>0,S=c===t.id,k=k1+s*bI,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:`${Ge.taskRow} ${S?Ge.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[x&&i.jsx("span",{className:`${Ge.expandArrow} ${b?Ge.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"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(sa,{size:lt,"aria-hidden":"true"})}),!x&&i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${cl(t.status)}`,children:g.icon}),i.jsx("span",{className:Ge.taskTitle,title:t.title,children:i.jsx(_1,{text:t.title,indices:p.get(t.id),highlightClass:Ge.searchHighlight})}),N&&i.jsx("span",{className:Ge.workspaceBadge,title:N,children:N}),x&&i.jsxs("span",{className:Ge.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ge.dependencyBadge} ${v?Ge.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<pT&&i.jsx(zo,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ri(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ge.addChildButton,children:"+"})})]}),i.jsx(us,{children:x&&b&&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(T1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function kI({workspaces:t,tasks:s}){const o=kt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Pb),[g,v]=y.useState(Pb),[b,x]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(W=>[W.id,W.status])),[s]),N=y.useMemo(()=>new Map(t.map(W=>[W.id,W.name])),[t]),T=()=>{const W=!p;xI(W),m(W),W&&(v(!0),x(new Map))},C=W=>{x(oe=>{const L=new Map(oe),Z=L.has(W)?L.get(W):g;return L.set(W,!Z),L})},D=W=>b.has(W)?b.get(W):g,O=W=>{c(oe=>{const L=new Set(oe);return L.has(W)?(L.delete(W),u(Z=>new Set(Z).add(W))):(L.add(W),u(Z=>{const J=new Set(Z);return J.delete(W),J})),L})};y.useEffect(()=>{const W=new Set(s.filter(oe=>oe.parentTaskId).map(oe=>oe.parentTaskId));W.size>0&&c(oe=>{const L=new Set(oe);for(const Z of W)d.has(Z)||L.add(Z);return L})},[s,d]);const[E,A]=y.useState(""),{directMatchTaskIds:P,treeMatchTaskIds:I,titleHighlights:U}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const W=fT(s,E,yI),oe=new Set(W.map(ce=>ce.item.id)),L=new Map;for(const ce of W){const X=ce.matches.find(ge=>ge.key==="title");X&&L.set(ce.item.id,X.indices)}const Z=new Set(oe),J=new Map(s.map(ce=>[ce.id,ce]));for(const ce of[...oe]){let X=J.get(ce);for(;X!=null&&X.parentTaskId;)Z.add(X.parentTaskId),X=J.get(X.parentTaskId)}return{directMatchTaskIds:oe,treeMatchTaskIds:Z,titleHighlights:L}},[E,s]),Q=P!==null,$=Q?p?P:I:null,H=$?s.filter(W=>$.has(W.id)):s,ue=p?[]:G5(H);return i.jsxs("div",{className:Ge.container,children:[i.jsxs("div",{className:Ge.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ge.headerActions,children:[i.jsx(zo,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ge.groupToggle} ${p?Ge.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(A2,{size:tn})})}),i.jsx(zo,{text:"New task",children:i.jsx("button",{className:Ge.addButton,onClick:()=>o(Ri()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:W=>A(W.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ge.searchInput,"data-testid":"sidebar-search"}),p?F5(H,w).map(W=>i.jsx(_I,{group:W,isExpanded:D(W.status),onToggle:()=>C(W.status),selectedTaskId:k,navigate:o,titleHighlights:U,workspaceNames:N},W.status)):ue.map(W=>i.jsx(T1,{node:W,depth:0,expandedTasks:r,toggleTask:O,selectedTaskId:k,navigate:o,taskStatusById:w,titleHighlights:U,workspaceNames:N},W.id)),H.length===0&&!Q&&i.jsx("div",{className:Ge.emptyState,children:"No tasks yet. Click + to create one."}),H.length===0&&Q&&i.jsx("div",{className:Ge.emptyState,children:"No matching tasks"})]})}const SI="_toast_ed2dk_1",TI="_success_ed2dk_18",wI="_icon_ed2dk_22",jI="_error_ed2dk_25",NI="_warning_ed2dk_32",CI="_info_ed2dk_38",EI="_message_ed2dk_53",AI="_close_ed2dk_60",Ur={toast:SI,success:TI,icon:wI,error:jI,warning:NI,info:CI,message:EI,close:AI},DI={success:i.jsx(Ai,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(im,{size:zt}),info:i.jsx(am,{size:zt})};function RI({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Rt.div,{className:`${Ur.toast} ${Ur[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:Ur.icon,"aria-hidden":"true",children:DI[t.variant]}),i.jsx("span",{className:Ur.message,children:t.message}),i.jsx("button",{type:"button",className:Ur.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})}const MI="_container_qqse2_1",II={container:MI};function OI({toasts:t,onDismiss:s}){return i.jsx("div",{className:II.container,"data-testid":"toast-container",children:i.jsx(us,{children:t.map(o=>i.jsx(RI,{toast:o,onDismiss:s},o.id))})})}const BI="_callout_e5awm_1",LI="_success_e5awm_11",zI="_icon_e5awm_15",$I="_error_e5awm_18",UI="_warning_e5awm_25",PI="_info_e5awm_32",HI="_content_e5awm_48",VI="_close_e5awm_53",Pr={callout:BI,success:LI,icon:zI,error:$I,warning:UI,info:PI,content:HI,close:VI},qI={success:i.jsx(Ai,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(im,{size:zt}),info:i.jsx(am,{size:zt})};function GI({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Pr.callout,Pr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Pr.icon,"aria-hidden":"true",children:qI[t]}),i.jsx("span",{className:Pr.content,children:s}),o&&i.jsx("button",{type:"button",className:Pr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})})}function FI({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(GI,{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 ZI="_container_de44x_1",KI="_emptyState_de44x_8",YI="_card_de44x_14",JI="_cardClickable_de44x_34",WI="_cardHeader_de44x_42",XI="_categoryBadge_de44x_54",QI="_findingTitle_de44x_62",eO="_findingDate_de44x_68",tO="_findingContent_de44x_80",nO="_tags_de44x_86",sO="_tag_de44x_86",rs={container:ZI,emptyState:KI,card:YI,cardClickable:JI,cardHeader:WI,categoryBadge:XI,findingTitle:QI,findingDate:eO,findingContent:tO,tags:nO,tag:sO};function w1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:rs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:rs.container,children:t.map((o,r)=>{const c=fd(o.category),d=s?Rt.button:Rt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${rs.card} ${s?rs.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:rs.cardHeader,children:[i.jsx("span",{className:rs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:rs.findingTitle,children:o.title}),i.jsx("span",{className:rs.findingDate,title:o.createdAt,children:Qm(o.createdAt)})]}),i.jsx("div",{className:rs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:rs.tags,children:o.tags.map(u=>i.jsx("span",{className:rs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const aO="_section_1ingb_14",iO="_sectionTitle_1ingb_26",oO="_sectionDescription_1ingb_35",rO="_tokenList_1ingb_48",lO="_tokenRow_1ingb_55",cO="_tokenBadge_1ingb_68",dO="_tokenName_1ingb_83",uO="_tokenTarget_1ingb_90",fO="_deleteButton_1ingb_99",pO="_addForm_1ingb_113",mO="_formRow_1ingb_119",hO="_input_1ingb_125",gO="_select_1ingb_155",vO="_addButton_1ingb_187",yO="_emptyStateInfo_1ingb_221",bO="_themeOptions_1ingb_229",xO="_themeOption_1ingb_229",_O="_themeOptionSelected_1ingb_254",kO="_themeOptionHeader_1ingb_259",SO="_themeOptionLabel_1ingb_266",TO="_themeOptionDesc_1ingb_273",wO="_variantToggle_1ingb_279",jO="_variantButton_1ingb_286",NO="_variantActive_1ingb_305",CO="_themeSwatches_1ingb_311",EO="_themeSwatch_1ingb_311",AO="_systemToggle_1ingb_325",DO="_systemToggleHint_1ingb_341",RO="_themeActive_1ingb_348",MO="_aboutGrid_1ingb_354",IO="_aboutItem_1ingb_360",OO="_aboutLabel_1ingb_373",BO="_aboutValue_1ingb_379",LO="_aboutDot_1ingb_387",zO="_aboutDotConnected_1ingb_394",$O="_aboutDotDisconnected_1ingb_398",be={section:aO,sectionTitle:iO,sectionDescription:oO,tokenList:rO,tokenRow:lO,tokenBadge:cO,tokenName:dO,tokenTarget:uO,deleteButton:fO,addForm:pO,formRow:mO,input:hO,select:gO,addButton:vO,emptyStateInfo:yO,themeOptions:bO,themeOption:xO,themeOptionSelected:_O,themeOptionHeader:kO,themeOptionLabel:SO,themeOptionDesc:TO,variantToggle:wO,variantButton:jO,variantActive:NO,themeSwatches:CO,themeSwatch:EO,systemToggle:AO,systemToggleHint:DO,themeActive:RO,aboutGrid:MO,aboutItem:IO,aboutLabel:OO,aboutValue:BO,aboutDot:LO,aboutDotConnected:zO,aboutDotDisconnected:$O},UO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function PO({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[x,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{x&&(o(x),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(Ei,{isOpen:x!==null,title:"Delete Token?",description:x?`"${x}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Tokens"}),i.jsx("p",{className:be.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:be.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:be.tokenList,children:t.map(T=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenBadge,children:T.tokenType}),i.jsx("span",{className:be.tokenName,children:T.name}),i.jsx("span",{className:be.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:be.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:be.addForm,onSubmit:k,children:[i.jsxs("div",{className:be.formRow,children:[i.jsx("input",{className:be.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:be.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:be.formRow,children:[i.jsx("select",{className:be.select,value:m,onChange:T=>g(T.target.value),children:UO.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:be.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=>b(T.target.value)}),i.jsx("button",{className:be.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Cd=[{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"]}],j1=new Set(Cd.map(t=>t.id)),Hb="grackle";function Qp(t){return Cd.find(s=>s.id===t)}function HO({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Appearance"}),i.jsx("p",{className:be.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:be.themeOptions,children:Cd.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:`${be.themeOption} ${p?be.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:be.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:be.themeOptionLabel,children:d.label}),i.jsx("span",{className:be.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:be.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${be.variantButton} ${p&&m?be.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:`${be.variantButton} ${p&&!m?be.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:be.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:be.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:be.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:be.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:be.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function VO({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:be.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"About"}),i.jsx("p",{className:be.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:be.aboutGrid,children:[i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Connection"}),i.jsxs("span",{className:be.aboutValue,children:[i.jsx("span",{className:`${be.aboutDot} ${t?be.aboutDotConnected:be.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Environments"}),i.jsxs("span",{className:be.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:be.aboutValue,children:d})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Version"}),i.jsx("span",{className:be.aboutValue,children:"0.96.2"})]})]})]})}const qO="_container_cddyd_1",GO="_header_cddyd_8",FO="_headerTitle_cddyd_35",ZO="_badge_cddyd_44",KO="_headerActions_cddyd_54",YO="_body_cddyd_61",JO="_formContent_cddyd_73",WO="_section_cddyd_85",XO="_label_cddyd_91",QO="_titleInput_cddyd_98",eB="_descriptionTextarea_cddyd_131",tB="_parentContext_cddyd_167",nB="_parentLabel_cddyd_175",sB="_parentName_cddyd_182",aB="_personaSelect_cddyd_186",iB="_depList_cddyd_220",oB="_depItem_cddyd_226",rB="_depItemSelected_cddyd_248",lB="_noDeps_cddyd_252",cB="_btnPrimary_cddyd_258",dB="_btnGhost_cddyd_289",tt={container:qO,header:GO,headerTitle:FO,badge:ZO,headerActions:KO,body:YO,formContent:JO,section:WO,label:XO,titleInput:QO,descriptionTextarea:eB,parentContext:tB,parentLabel:nB,parentName:sB,personaSelect:aB,depList:iB,depItem:oB,depItemSelected:rB,noDeps:lB,btnPrimary:cB,btnGhost:dB};function N1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?d.find(ve=>ve.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=y.useState(w),C=w||N,D=u.find(ve=>ve.id===C),O=c??(D==null?void 0:D.environmentId),E=!S&&!o,A=S?(k==null?void 0:k.parentTaskId)??"":r??"",P=A?d.find(ve=>ve.id===A):void 0,[I,U]=y.useState((k==null?void 0:k.title)??""),[Q,$]=y.useState((k==null?void 0:k.description)??""),[H,ue]=y.useState((k==null?void 0:k.dependsOn)??[]),[W,oe]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[L,Z]=y.useState((k==null?void 0:k.canDecompose)??!1),[J,ce]=y.useState(!1),X=y.useRef(!1);y.useEffect(()=>{S&&k&&!X.current&&(X.current=!0,U(k.title),$(k.description),ue(k.dependsOn),oe(k.defaultPersonaId),Z(k.canDecompose))},[S,k]);const ge=d.filter(ve=>ve.workspaceId===C&&(!S||ve.id!==s)&&ve.id!==A),pe=I.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=ve=>{ue(Le=>Le.includes(ve)?Le.filter(Mt=>Mt!==ve):[...Le,ve])},Ze=()=>{!pe||J||S&&k===void 0||(S&&s?(g(s,I.trim(),Q,H,W),b==null||b("Task updated","success"),v?v():x(On(s,void 0,C,O),{replace:!0})):(ce(!0),m(C,I.trim(),Q,H.length>0?H:void 0,A||void 0,W,L,()=>{b==null||b("Task created","success"),x(o?$a(o,O):"/tasks",{replace:!0})},ve=>{b==null||b(ve,"error"),ce(!1)})))},me=()=>{if(v){v();return}x(S&&s?On(s,void 0,C,O):o?$a(o,O):"/tasks")},_e=S?"edit task":A?"child task":"new task";return i.jsxs("div",{className:tt.container,children:[i.jsxs("div",{className:tt.header,children:[i.jsxs("div",{className:tt.headerTitle,children:[i.jsx("span",{className:tt.badge,children:_e}),P&&i.jsxs("span",{className:tt.parentContext,children:[i.jsx("span",{className:tt.parentLabel,children:"Child of"}),i.jsx("span",{className:tt.parentName,children:P.title})]})]}),i.jsxs("div",{className:tt.headerActions,children:[i.jsx("button",{onClick:Ze,disabled:!pe||J,className:tt.btnPrimary,"data-testid":"task-edit-save",children:J?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:me,className:tt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:tt.body,children:i.jsxs("div",{className:tt.formContent,children:[E&&i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:ve=>T(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:I,onChange:ve=>U(ve.target.value),placeholder:"Task title...",autoFocus:!0,className:tt.titleInput,"data-testid":"task-edit-title",onKeyDown:ve=>{ve.key==="Enter"&&pe&&Ze()}})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Q,onChange:ve=>$(ve.target.value),placeholder:"Describe the task... (markdown supported)",className:tt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:W,onChange:ve=>oe(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),!S&&i.jsx("div",{className:tt.section,children:i.jsxs("label",{className:tt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:L,onChange:ve=>Z(ve.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:tt.section,children:[i.jsx("div",{className:tt.label,children:"Dependencies"}),ge.length===0?i.jsx("div",{className:tt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:tt.depList,children:ge.map(ve=>{const Le=H.includes(ve.id);return i.jsxs("label",{className:`${tt.depItem} ${Le?tt.depItemSelected:""}`,"data-testid":`dep-option-${ve.id}`,children:[i.jsx("input",{type:"checkbox",checked:Le,onChange:()=>Ce(ve.id)}),ve.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ve.status,")"]})]},ve.id)})})]})]})})]})}const uB="_actionButtons_1rjka_1",fB="_btnPrimary_1rjka_8",pB="_btnDanger_1rjka_39",mB="_btnGhost_1rjka_78",Ft={actionButtons:uB,btnPrimary:fB,btnDanger:pB,btnGhost:mB};function hB({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:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const gB="_workpadSection_y8nj9_1",vB="_workpadLabel_y8nj9_9",yB="_workpadStatus_y8nj9_17",bB="_workpadSummary_y8nj9_23",xB="_workpadExtra_y8nj9_29",Da={workpadSection:gB,workpadLabel:vB,workpadStatus:yB,workpadSummary:bB,workpadExtra:xB};function _B({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:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const kB="_overviewDashboard_r05qm_1",SB="_overviewHero_r05qm_7",TB="_statusBadge_r05qm_14",wB="_statusPending_r05qm_26",jB="_statusAssigned_r05qm_31",NB="_statusInProgress_r05qm_36",CB="_statusReview_r05qm_41",EB="_statusDone_r05qm_46",AB="_statusFailed_r05qm_51",DB="_statusWaitingInput_r05qm_56",RB="_overviewBranchPill_r05qm_61",MB="_branchLink_r05qm_76",IB="_overviewSection_r05qm_87",OB="_overviewLabel_r05qm_93",BB="_overviewValue_r05qm_100",LB="_overviewMuted_r05qm_105",zB="_overviewMarkdown_r05qm_111",$B="_envRow_r05qm_180",UB="_envDot_r05qm_186",PB="_envDotGreen_r05qm_193",HB="_envDotYellow_r05qm_197",VB="_envDotRed_r05qm_201",qB="_envDotGray_r05qm_205",GB="_depList_r05qm_209",FB="_depItem_r05qm_215",ZB="_depBlocked_r05qm_222",KB="_depDone_r05qm_226",YB="_timeline_r05qm_230",JB="_timelineRow_r05qm_236",WB="_timelineKey_r05qm_243",XB="_timelineValue_r05qm_249",QB="_timelineDelta_r05qm_253",eL="_reviewNotes_r05qm_264",he={overviewDashboard:kB,overviewHero:SB,statusBadge:TB,statusPending:wB,statusAssigned:jB,statusInProgress:NB,statusReview:CB,statusDone:EB,statusFailed:AB,statusWaitingInput:DB,overviewBranchPill:RB,branchLink:MB,overviewSection:IB,overviewLabel:OB,overviewValue:BB,overviewMuted:LB,overviewMarkdown:zB,envRow:$B,envDot:UB,envDotGreen:PB,envDotYellow:HB,envDotRed:VB,envDotGray:qB,depList:GB,depItem:FB,depBlocked:ZB,depDone:KB,timeline:YB,timelineRow:JB,timelineKey:WB,timelineValue:XB,timelineDelta:QB,reviewNotes:eL};function zc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function yp(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 Vb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?he.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?he.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?he.envDotRed:he.envDotGray}function tL({status:t}){const s=za(t),o=tw(t);return i.jsx("span",{className:`${he.statusBadge} ${he[o]??he.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function nL({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),x=o.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:he.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:he.overviewHero,children:[i.jsx(tL,{status:t.status}),t.branch&&i.jsx("span",{className:he.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:he.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:he.overviewLabel,children:"Description"}),i.jsx("div",{className:he.overviewMarkdown,children:i.jsx(hd,{remarkPlugins:[gd],children:t.description})})]}),t.workpad&&i.jsx(_B,{workpad:t.workpad}),i.jsxs("div",{className:he.overviewSection,children:[i.jsx("div",{className:he.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Vb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:v.displayName})]}):x?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Vb(x.status)}`,title:x.status,"aria-label":`Status: ${x.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:x.displayName}),i.jsx("span",{className:he.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:he.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:he.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:he.overviewMuted,children:"None"}):i.jsx("div",{className:he.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return i.jsxs("div",{className:`${he.depItem} ${N?he.depDone:he.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:he.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:he.timeline,children:[t.createdAt&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Created"}),i.jsx("span",{className:he.timelineValue,children:zc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=yp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Assigned"}),i.jsx("span",{className:he.timelineValue,children:zc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=yp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Started"}),i.jsx("span",{className:he.timelineValue,children:zc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=yp(t.startedAt,t.completedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Completed"}),i.jsx("span",{className:he.timelineValue,children:zc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:he.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:he.overviewLabel,children:"Usage"}),i.jsxs("div",{className:he.timeline,children:[i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsx("span",{className:he.timelineValue,children:Ss(u.costUsd)}),i.jsxs("span",{className:he.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:he.timelineValue,children:Ss(p.costUsd)}),i.jsxs("span",{className:he.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:he.overviewLabel,children:"Budget"}),i.jsxs("div",{className:he.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Tokens"}),i.jsxs("span",{className:he.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:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsxs("span",{className:he.timelineValue,children:[Ss((u==null?void 0:u.costUsd)??0)," / ",Ss(t.costBudgetMillicents/1e5)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:he.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:he.reviewNotes,children:t.reviewNotes})]})]})}const sL="_container_legrg_1",aL="_header_legrg_8",iL="_headerTitle_legrg_35",oL="_badge_legrg_44",rL="_headerActions_legrg_54",lL="_body_legrg_61",cL="_formContent_legrg_73",dL="_section_legrg_85",uL="_label_legrg_91",fL="_nameInput_legrg_98",pL="_fieldInput_legrg_131",mL="_adapterSelect_legrg_164",hL="_readOnlyValue_legrg_198",gL="_codespaceSection_legrg_204",vL="_codespaceActions_legrg_210",yL="_creatingHint_legrg_216",bL="_errorHint_legrg_222",xL="_btnPrimary_legrg_235",_L="_btnGhost_legrg_266",re={container:sL,header:aL,headerTitle:iL,badge:oL,headerActions:rL,body:lL,formContent:cL,section:dL,label:uL,nameInput:fL,fieldInput:pL,adapterSelect:mL,readOnlyValue:hL,codespaceSection:gL,codespaceActions:vL,creatingHint:yL,errorHint:bL,btnPrimary:xL,btnGhost:_L},Wc=1,Xc=65535;function bp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Wc&&s<=Xc}function xp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function kL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,x]=y.useState(""),[S,k]=y.useState("");return g==="create"?i.jsxs("div",{className:re.codespaceSection,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:w=>x(w.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:re.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),x(""),k(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),x(""),k("")},className:re.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:re.codespaceSection,children:i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!o.trim()&&r(w.target.value))},disabled:p,className:re.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>i.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:re.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:re.errorHint,children:d})]})})}function C1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?o.find(me=>me.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,O]=y.useState(""),[E,A]=y.useState(""),[P,I]=y.useState(""),[U,Q]=y.useState(""),[$,H]=y.useState(""),[ue,W]=y.useState(""),[oe,L]=y.useState(""),[Z,J]=y.useState(null),ce=y.useCallback(()=>{const me={};if(T==="local"){if(D.trim()&&(me.host=D.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.port=_e)}}else if(T==="ssh"){if(me.host=D.trim(),P.trim()&&(me.user=P.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.sshPort=_e)}U.trim()&&(me.identityFile=U.trim())}else T==="docker"?($.trim()&&(me.image=$.trim()),ue.trim()&&(me.repo=ue.trim())):T==="codespace"&&(me.codespaceName=oe.trim());return me},[T,D,E,P,U,$,ue,oe]),X=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!oe.trim()||(T==="local"||T==="ssh")&&!bp(E)),ge=()=>{X()&&(r(w.trim(),T,ce()),b==null||b("Environment added successfully","success"),x(Mo,{replace:!0}))},pe=()=>{x(s?Ni(s):Mo)},Ce=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig),Le=_e.trim();Le?ve[me]=Le:delete ve[me],c(s,{adapterConfig:ve})},[k,s,c]),Ze=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig);if(_e.trim()){const Le=Number(_e);Number.isInteger(Le)&&Le>=Wc&&Le<=Xc&&(ve[me]=Le)}else delete ve[me];c(s,{adapterConfig:ve})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:re.container,children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:pe,className:re.btnGhost,children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsx("div",{className:re.formContent,children:i.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const me=xp(k.adapterConfig);return i.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:pe,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Name"}),i.jsx(ln,{value:k.displayName,onSave:_e=>{s&&c(s,{displayName:_e})},validate:_e=>_e.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:Z,onActivate:J,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Adapter Type"}),i.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Port"}),i.jsx(ln,{value:String(me.port??""),onSave:_e=>Ze("port",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),validate:_e=>_e.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"User"}),i.jsx(ln,{value:String(me.user??""),onSave:_e=>Ce("user",_e),mode:"edit",fieldId:"user",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"SSH Port"}),i.jsx(ln,{value:String(me.sshPort??""),onSave:_e=>Ze("sshPort",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:Z,onActivate:J,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Identity File"}),i.jsx(ln,{value:String(me.identityFile??""),onSave:_e=>Ce("identityFile",_e),mode:"edit",fieldId:"identityFile",activeFieldId:Z,onActivate:J,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Image"}),i.jsx(ln,{value:String(me.image??""),onSave:_e=>Ce("image",_e),mode:"edit",fieldId:"image",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repo"}),i.jsx(ln,{value:String(me.repo??""),onSave:_e=>Ce("repo",_e),mode:"edit",fieldId:"repo",activeFieldId:Z,onActivate:J,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace Name"}),i.jsx(ln,{value:String(me.codespaceName??""),onSave:_e=>Ce("codespaceName",_e),validate:_e=>_e.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:Z,onActivate:J,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"new environment"})}),i.jsxs("div",{className:re.headerActions,children:[i.jsx("button",{onClick:ge,disabled:!X(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:pe,className:re.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:me=>N(me.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:me=>{me.key==="Enter"&&X()&&ge()}})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:me=>{C(me.target.value),me.target.value==="codespace"&&d()},className:re.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:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>O(me.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>O(me.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:P,onChange:me=>I(me.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:U,onChange:me=>Q(me.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:me=>H(me.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:ue,onChange:me=>W(me.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(kL,{codespaceName:oe,onCodespaceNameChange:L,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const SL="_group_1iprv_1",TL="_groupTitle_1iprv_8",wL="_shortcutList_1iprv_17",jL="_shortcutRow_1iprv_23",NL="_keys_1iprv_36",CL="_kbd_1iprv_43",EL="_description_1iprv_60",_i={group:SL,groupTitle:TL,shortcutList:wL,shortcutRow:jL,keys:NL,kbd:CL,description:EL},AL=[{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 DL(){return i.jsxs("section",{className:be.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:be.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),AL.map(t=>i.jsxs("div",{className:_i.group,children:[i.jsx("h4",{className:_i.groupTitle,children:t.title}),i.jsx("div",{className:_i.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:_i.shortcutRow,children:[i.jsx("span",{className:_i.keys,children:s.keys.map(o=>i.jsx("kbd",{className:_i.kbd,children:o},o))}),i.jsx("span",{className:_i.description,children:s.description})]},s.description))})]},t.title))]})}const RL=[{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 ML({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:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:be.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:be.tokenList,children:RL.map(r=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenName,children:r.label}),i.jsx("span",{className:be.tokenTarget,children:r.description}),i.jsx("select",{className:be.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 IL="_container_10efq_1",OL="_header_10efq_7",BL="_list_10efq_105",LL="_card_10efq_111",zL="_cardHeader_10efq_125",$L="_cardTitle_10efq_135",UL="_defaultBadge_10efq_141",PL="_cardActions_10efq_155",HL="_description_10efq_160",VL="_meta_10efq_166",qL="_empty_10efq_212",GL="_typeBadge_10efq_362",Jn={container:IL,header:OL,list:BL,card:LL,cardHeader:zL,cardTitle:$L,defaultBadge:UL,cardActions:PL,description:HL,meta:VL,empty:qL,typeBadge:GL};function FL({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Jn.container,children:[i.jsxs("div",{className:Jn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,x=v.type==="script";return i.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Jn.cardHeader,children:[i.jsxs("span",{className:Jn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:x?"Script":"Agent"}),b&&i.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&i.jsx(Js,{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(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Jn.description,children:v.description}),i.jsxs("div",{className:Jn.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(Ei,{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 ZL="_container_uy08i_1",KL="_header_uy08i_7",YL="_count_uy08i_13",JL="_presets_uy08i_18",WL="_presetButton_uy08i_24",XL="_filterInput_uy08i_41",QL="_groups_uy08i_53",e8="_group_uy08i_53",t8="_groupHeader_uy08i_68",n8="_groupName_uy08i_77",s8="_groupCount_uy08i_81",a8="_toolList_uy08i_87",i8="_toolItem_uy08i_95",o8="_toolName_uy08i_103",pn={container:ZL,header:KL,count:YL,presets:JL,presetButton:WL,filterInput:XL,groups:QL,group:e8,groupHeader:t8,groupName:n8,groupCount:s8,toolList:a8,toolItem:i8,toolName:o8},r8=(()=>{const t=new Map;for(const s of lx){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()}))})(),l8=[{name:"default",label:"Default",tools:cx},{name:"worker",label:"Worker",tools:mT},{name:"orchestrator",label:"Orchestrator",tools:hT},{name:"admin",label:"Admin",tools:gT}];function qb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const x=new Set(d);for(const S of v)b?x.delete(S):x.add(S);s([...x].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:pn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:pn.header,children:i.jsx("span",{className:pn.count,children:t.length===0?`Using default (${cx.length} tools)`:`${t.length} of ${lx.size} tools selected`})}),i.jsxs("div",{className:pn.presets,"data-testid":"mcp-tool-presets",children:[l8.map(v=>i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:pn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:pn.groups,children:r8.map(({group:v,tools:b})=>{const x=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(x.length===0)return null;const S=x.every(k=>d.has(k));return i.jsxs("div",{className:pn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:pn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(x,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:pn.groupName,children:v}),i.jsxs("span",{className:pn.groupCount,children:["(",x.filter(k=>d.has(k)).length,"/",x.length,")"]})]}),i.jsx("div",{className:pn.toolList,children:x.map(k=>i.jsxs("label",{className:pn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:pn.toolName,children:k})]},k))})]},v)})})]})}const c8="_nav_1bhou_1",d8="_tab_1bhou_24",u8="_tabIcon_1bhou_62",f8="_tabActive_1bhou_68",$c={nav:c8,tab:d8,tabIcon:u8,tabActive:f8},Ks=[{path:"credentials",label:"Credentials",icon:i.jsx(T2,{size:zt})},{path:"personas",label:"Personas",icon:i.jsx(X2,{size:zt})},{path:"appearance",label:"Appearance",icon:i.jsx(U2,{size:zt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(j2,{size:zt})},{path:"about",label:"About",icon:i.jsx(am,{size:zt})}];function p8(){var u;const t=Zt(),s=kt(),o=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Ro}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Ro}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const x=Ks[b].path;s(`${Ro}/${x}`),(k=m[b])==null||k.focus()},[r,s]);return i.jsx("nav",{className:$c.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${$c.tab} ${m?$c.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:$c.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function m8({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(ry.map(d=>[d,[]]));for(const d of t){const u=cl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const x={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(x):c.get("not_started").push(x)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return ry.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const h8="_boardContainer_1c4y1_1",g8="_column_1c4y1_17",v8="_columnHeader_1c4y1_34",y8="_columnIcon_1c4y1_47",b8="_columnLabel_1c4y1_52",x8="_columnCount_1c4y1_57",_8="_cardList_1c4y1_67",k8="_emptyPlaceholder_1c4y1_76",S8="_card_1c4y1_67",T8="_cardHeader_1c4y1_107",w8="_cardStatusIcon_1c4y1_113",j8="_cardTitle_1c4y1_119",N8="_cardBadges_1c4y1_127",C8="_badge_1c4y1_134",E8="_blockedBadge_1c4y1_146",A8="_childBadge_1c4y1_151",D8="_depBadge_1c4y1_155",R8="_parentBadge_1c4y1_159",M8="_pausedSubBadge_1c4y1_166",I8="_personaBadge_1c4y1_170",O8="_envBadge_1c4y1_174",B8="_emptyCta_1c4y1_178",L8="_ctaButton_1c4y1_188",z8="_ctaDescription_1c4y1_204",it={boardContainer:h8,column:g8,columnHeader:v8,columnIcon:y8,columnLabel:b8,columnCount:x8,cardList:_8,emptyPlaceholder:k8,card:S8,cardHeader:T8,cardStatusIcon:w8,cardTitle:j8,cardBadges:N8,badge:C8,blockedBadge:E8,childBadge:A8,depBadge:D8,parentBadge:R8,pausedSubBadge:M8,personaBadge:I8,envBadge:O8,emptyCta:B8,ctaButton:L8,ctaDescription:z8};function $8({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=kt(),p=y.useMemo(()=>o.filter(x=>x.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(x=>[x.id,x.status])),[o]),g=y.useMemo(()=>new Map(p.map(x=>[x.id,x])),[p]),v=y.useMemo(()=>{const x=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=x.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const O=S.get(D.personaId);O&&N.set(C.id,O.name)}if(D.environmentId){const O=k.get(D.environmentId);O&&T.set(C.id,O.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>m8({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(Ri(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:b.map(x=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${x.status}`,"aria-label":`${x.label}, ${x.tasks.length} ${x.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:x.style.color},children:x.style.icon}),i.jsx("span",{className:it.columnLabel,children:x.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${x.status}`,children:x.tasks.length})]}),i.jsx("div",{className:it.cardList,children:x.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(us,{mode:"popLayout",children:x.tasks.map(S=>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(U8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},x.status))})}function U8({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=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:x=>{(x.key==="Enter"||x.key===" ")&&(x.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:[b&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:b.title,children:b.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 P8="_formContent_ymnez_1",H8="_section_ymnez_13",V8="_label_ymnez_19",q8="_titleInput_ymnez_26",G8="_descriptionTextarea_ymnez_58",F8="_selectField_ymnez_94",Z8="_checkboxRow_ymnez_128",K8="_checkboxLabel_ymnez_141",Y8="_fieldError_ymnez_146",bt={formContent:P8,section:H8,label:V8,titleInput:q8,descriptionTextarea:G8,selectField:F8,checkboxRow:Z8,checkboxLabel:K8,fieldError:Y8};function J8(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.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const W8=100;function X8({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:bt.formContent,children:[i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:bt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:W8,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:bt.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:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:bt.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:bt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:bt.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:bt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:bt.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:bt.section,children:i.jsxs("label",{className:bt.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:bt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:bt.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 E1=y.createContext(void 0),Q8=4e3;function e7({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=Q8)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(E1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Sn(){const t=y.useContext(E1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const em="grackle-theme",A1="grackle-prefer-system",D1="(prefers-color-scheme: dark)";let Fr=[],Qc;function _p(){Qc=void 0;for(const t of Fr)t()}function tm(){return typeof window>"u"?!1:window.matchMedia(D1).matches}function Xr(){if(typeof localStorage>"u")return Hb;try{const t=localStorage.getItem(em);if(t!==null&&j1.has(t))return t}catch{}return Hb}function pd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(A1)==="true"}catch{return!1}}function nm(t){return Cd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function R1(t,s){const o=Qp(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?tm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=nm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return tm()?r.variantDarkId:r.variantLightId}return t}function wo(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=R1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&wo(Xr(),pd());function t7(){return Qc===void 0&&(Qc={themeId:Xr(),systemDark:tm(),preferSystem:pd()}),Qc}function n7(t){return Fr=[...Fr,t],()=>{Fr=Fr.filter(s=>s!==t)}}function s7(){const t=y.useSyncExternalStore(n7,t7),{themeId:s,preferSystem:o}=t,r=R1(s,o),c=y.useCallback(u=>{if(j1.has(u)){try{localStorage.setItem(em,u)}catch{}wo(u,pd(),!0),_p()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(A1,u?"true":"false")}catch{}if(u){const p=Xr(),m=Qp(p);if(m!=null&&m.hidden){const g=nm(p);if(g)try{localStorage.setItem(em,g.id)}catch{}}}wo(Xr(),u,!0),_p()},[]);return y.useEffect(()=>{wo(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(D1),p=()=>{const m=Xr(),g=pd();if(g){const v=Qp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&wo(m,g),v!=null&&v.hidden){const b=nm(m);b!=null&&b.variantDarkId&&b.variantLightId&&wo(m,g)}}_p()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const M1=y.createContext(void 0);function a7({children:t}){const s=s7();return i.jsx(M1.Provider,{value:s,children:t})}function I1(){const t=y.useContext(M1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const O1=y.createContext(void 0),B1=y.createContext(void 0);function i7({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(B1.Provider,{value:r,children:i.jsx(O1.Provider,{value:s,children:t})})}function o7(){return y.useContext(O1)}function r7(){const t=y.useContext(B1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const eh=y.createContext(void 0);function mt(){const t=y.useContext(eh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function L1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function z1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function l7(t){return L1(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 c7=new Set(["off","subscription","api_key"]),Uc=new Set(["off","on"]);function d7(t){return L1(t)&&c7.has(t.claude)&&Uc.has(t.github)&&Uc.has(t.copilot)&&Uc.has(t.codex)&&Uc.has(t.goose)}function $1(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 U1(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 To=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 na={label:"Home",url:Ci};function f7(t){return t?[na,{label:"Settings",url:Ro},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const th={label:"Environments",url:Mo};function p7(){return[na,{label:"Environments",url:void 0}]}function m7(){return[na,{label:"New Chat",url:void 0}]}function h7(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function g7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,th,{label:(d==null?void 0:d.displayName)??"Environment",url:Ni(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function v7(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(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(th),b.push({label:v.displayName,url:Ni(g)})),m&&g&&b.push({label:m.name,url:$a(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const x=d[d.length-1];return b.push({label:(x==null?void 0:x.title)??t,url:void 0}),b}const y7={label:"Findings",url:_d};function b7(){return[na,{label:"Findings",url:void 0}]}function P1(t,s,o,r,c){const d=[na];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(th),p&&d.push({label:p.displayName,url:Ni(o)}),u&&d.push({label:u.name,url:$a(s,o)}),d.push({label:"Findings",url:oN(s,o)})}else d.push(y7);return d.push({label:t,url:void 0}),d}function nh(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 Pc(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 x7(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function sh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),x=b?Pc(b):void 0;if(x)try{const S=JSON.parse(v.content);o.set(x,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const x=s.get(v),S=x?x7(x):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),x=b?Pc(b):void 0;x&&r.has(x)||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 b=p[m];if(b!==v+1)continue;const x=d[v],S=d[b];let k;try{const w=JSON.parse(x.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(x),C=T?Pc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(x,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const x=Pc(b);if(x&&r.has(x))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let x=v+1;x<g.length;x++)if(g[x].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function _7(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=H1(s),d=s.filter(m=>sm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||sm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function H1(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function sm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function k7(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=H1(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}):sm(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 S7(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 T7(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 ks=[{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
274
+ `)}function Q3({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let O=N;O<=T;O++)O<t.length&&ll(t[O])&&D.add(O);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)ll(t[w])&&k.add(w);d(k)},[t]),x=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);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:b,deselectAll:x,copySelected:S}}const e6="_wrapper_1cdza_1",t6="_scrollContainer_1cdza_9",n6="_selectingPadding_1cdza_16",s6="_toolbar_1cdza_20",a6="_directionToggle_1cdza_27",i6="_scrollToAnchor_1cdza_65",o6="_scrollToAnchorBottom_1cdza_89",r6="_scrollToAnchorTop_1cdza_93",l6="_eventOverflowWarning_1cdza_97",Ys={wrapper:e6,scrollContainer:t6,selectingPadding:n6,toolbar:s6,directionToggle:a6,scrollToAnchor:i6,scrollToAnchorBottom:o6,scrollToAnchorTop:r6,eventOverflowWarning:l6};function c6(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 v1="grackle-stream-direction";function d6(){try{return localStorage.getItem(v1)==="reversed"}catch{return!1}}function u6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[i.jsx(im,{size:tn,"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 Wm({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(d6),p=Y4(),m=Q3({events:t,formatForClipboard:X3}),g=y.useMemo(()=>t.filter(ll).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:x}=Y3({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(v1,T?"reversed":"default")}catch{}};y.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 k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:Ys.wrapper,children:[i.jsx("div",{className:Ys.toolbar,children:i.jsx(zo,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(iy,{size:tn,"aria-hidden":"true"}):i.jsx(oy,{size:tn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(u6,{eventsDropped:s}),i.jsx(us,{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:w,ease:"easeOut"},children:i.jsx(z3,{copyText:W3(T),isContentBearing:ll(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:c6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:O=>{m.toggleEvent(D,O)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(SA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),i.jsx(us,{children:m.isSelecting&&i.jsx(F3,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(us,{children:!b&&i.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:x,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(oy,{size:tn,"aria-hidden":"true"}):i.jsx(iy,{size:tn,"aria-hidden":"true"})," New events"]})})]})}function Xm(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,x]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(P=>{v(P),x("")},[]),N=y.useCallback(()=>{x("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),x("")},[u]),C=y.useCallback(()=>{const P=m?g.trim():g;if(r){const U=r(g);if(U){x(U);return}}const I=m?s.trim():s;if(P===I){T();return}o(P),T()},[g,s,m,r,o,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),x("")},[c,s,u]),O=y.useCallback(P=>{if(S.current){S.current=!1;return}P.relatedTarget instanceof HTMLElement&&P.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(P=>{P.key==="Escape"?T():P.key==="Enter"&&p&&C()},[T,p,C]),A=(()=>{if(!k)return!1;const P=m?s.trim():s;return(m?g.trim():g)!==P})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),x(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:A,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:O,handleKeyDown:E,ignoreInitialBlurRef:S}}const f6="_editFieldWrapper_yuzty_1",p6="_editInput_yuzty_10",m6="_editTextarea_yuzty_42",h6="_editSelect_yuzty_78",g6="_editError_yuzty_111",v6="_editInputInvalid_yuzty_118",y6="_editHint_yuzty_123",b6="_unsavedDot_yuzty_132",x6="_metaValueClickable_yuzty_140",_6="_editButton_yuzty_159",k6="_metaPlaceholder_yuzty_175",S6="_worktreeToggle_yuzty_180",nt={editFieldWrapper:f6,editInput:p6,editTextarea:m6,editSelect:h6,editError:g6,editInputInvalid:v6,editHint:y6,unsavedDot:b6,metaValueClickable:x6,editButton:_6,metaPlaceholder:k6,worktreeToggle:S6};function ln(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:b,ariaLabel:x,"data-testid":S}=t,k=y.useRef(null),w=Xm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{className:`${nt.editInput} ${C?nt.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${nt.editInput} ${w.error?nt.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),w.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:w.error}),i.jsx("span",{className:nt.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:nt.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":x,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function Xp(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:b,"data-testid":x}=t,S=y.useRef(null),k=Xm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{className:`${nt.editTextarea} ${T?nt.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),T&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${nt.editTextarea} ${k.error?nt.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),k.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:nt.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:nt.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function ud(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:b,"data-testid":x}=t,S=y.useRef(null),k=Xm({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const O=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(O)}},[k.isEditing]);const w=y.useCallback(O=>{const E=O.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=y.useCallback(O=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:nt.editSelect,value:s,onChange:O=>m==null?void 0:m(O.target.value),"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:nt.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});const T=g==null?void 0:g(s),C=(D=c.find(O=>O.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:nt.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function T6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:nt.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 w6="_envRow_1e1r5_1",j6="_envDot_1e1r5_7",N6="_envDotGreen_1e1r5_14",C6="_envDotYellow_1e1r5_18",E6="_envDotRed_1e1r5_22",A6="_envDotGray_1e1r5_26",Do={envRow:w6,envDot:j6,envDotGreen:N6,envDotYellow:C6,envDotRed:E6,envDotGray:A6};function D6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Do.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Do.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Do.envDotRed:Do.envDotGray}function R6(t){const{value:s,onSave:o,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),x=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return i.jsxs("span",{className:Do.envRow,children:[i.jsx("span",{className:`${Do.envDot} ${D6(b.status)}`}),b.displayName]})};return i.jsx(ud,{value:s,onSave:o,options:x,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const M6="_nav_1snmp_1",I6="_searchForm_1snmp_8",O6="_searchInput_1snmp_15",B6="_searchButton_1snmp_33",L6="_clearButton_1snmp_68",z6="_workspaceSelect_1snmp_85",$6="_listHeader_1snmp_99",U6="_nodeList_1snmp_108",P6="_nodeItem_1snmp_116",H6="_indicator_1snmp_129",V6="_label_1snmp_136",q6="_badge_1snmp_145",Yn={nav:M6,searchForm:I6,searchInput:O6,searchButton:B6,clearButton:L6,workspaceSelect:z6,listHeader:$6,nodeList:U6,nodeItem:P6,indicator:H6,label:V6,badge:q6};function G6({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),x=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Yn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Yn.nodeList,children:t.map(k=>i.jsxs("li",{className:Yn.nodeItem,onClick:()=>{x(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Yn.label,children:k.label}),i.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const F6="_container_1mq5u_1",Z6="_hamburger_1mq5u_33",K6="_brand_1mq5u_49",Y6="_brandLogo_1mq5u_68",J6="_info_1mq5u_75",W6="_connectionLabel_1mq5u_90",X6="_connectionDot_1mq5u_103",Q6="_connected_1mq5u_106",e5="_disconnected_1mq5u_110",Zs={container:F6,hamburger:Z6,brand:K6,brandLogo:Y6,info:J6,connectionLabel:W6,connectionDot:X6,connected:Q6,disconnected:e5};function t5({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=kt(),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:Zs.container,children:[r&&i.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(I2,{size:zt,"aria-hidden":"true"})}),i.jsx(zo,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ci),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Zs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:i.jsx(La,{size:om,fill:"currentColor"})})," ",i.jsx("span",{className:Zs.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 n5="_nav_13gkc_1",s5="_tab_13gkc_35",a5="_tabIcon_13gkc_68",i5="_tabLabel_13gkc_79",o5="_tabActive_13gkc_84",$r={nav:n5,tab:s5,tabIcon:a5,tabLabel:i5,tabActive:o5},xi=[{view:"dashboard",label:"Dashboard",icon:i.jsx(_2,{size:zt}),route:Ci,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(B2,{size:zt}),route:aN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(l2,{size:zt}),route:iN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(z2,{size:zt}),route:Mo,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(n2,{size:zt}),route:Lx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(hx,{size:zt}),route:_d,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(Z2,{size:zt}),route:eN,testId:"sidebar-tab-settings"}];function r5(t){return t===Ci||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Lx)?"knowledge":t.startsWith(_d)?"findings":t.startsWith(Ro)?"settings":"tasks"}function l5(){const t=Zt(),s=kt(),o=y.useRef(null),r=r5(t.pathname),c=y.useCallback(u=>{s(u.route)},[s]),d=y.useCallback(u=>{var b,x;const p=(b=o.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!p)return;const m=Array.from(p).findIndex(S=>S===document.activeElement),g=m>=0?m:xi.findIndex(S=>S.view===r);let v=g;if(u.key==="ArrowRight"||u.key==="j"||u.key==="J")u.preventDefault(),v=(g+1)%xi.length;else if(u.key==="ArrowLeft"||u.key==="k"||u.key==="K")u.preventDefault(),v=(g-1+xi.length)%xi.length;else if(u.key==="Home")u.preventDefault(),v=0;else if(u.key==="End")u.preventDefault(),v=xi.length-1;else return;s(xi[v].route),(x=p[v])==null||x.focus()},[r,s]);return i.jsx("nav",{className:$r.nav,ref:o,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:d,"data-testid":"sidebar-nav",children:xi.map(u=>{const p=u.view===r;return i.jsx(zo,{text:u.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${$r.tab} ${p?$r.tabActive:""}`,onClick:()=>c(u),"data-testid":u.testId,"aria-label":u.label,children:[i.jsx("span",{className:$r.tabIcon,"aria-hidden":"true",children:u.icon}),i.jsx("span",{className:$r.tabLabel,children:u.label})]})},u.view)})})}const c5="_container_pi6ii_1",d5="_content_pi6ii_66",$b={container:c5,content:d5},u5=320,y1=220,b1=600,x1="grackle-sidebar-width";function f5(){try{const t=localStorage.getItem(x1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=y1&&s<=b1)return s}}catch{}return u5}function p5(t){try{localStorage.setItem(x1,String(t))}catch{}}function m5({content:t}){const[s]=y.useState(f5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=y1&&m<=b1&&p5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:$b.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:$b.content,children:t})})}const h5="_bar_tnfsh_1",g5="_btnPrimary_tnfsh_32",v5="_statusText_tnfsh_85",y5="_statusCompleted_tnfsh_90",b5="_statusFailed_tnfsh_94",x5="_statusBlocked_tnfsh_98",_5="_hintText_tnfsh_103",wt={bar:h5,btnPrimary:g5,statusText:v5,statusCompleted:y5,statusFailed:b5,statusBlocked:x5,hintText:_5};function k5({sessions:t,tasks:s,environments:o}){const r=kt(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),x=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),O=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId)??(S==null?void 0:S.params.taskId),A=v??b??x??S,P=(A==null?void 0:A.params.environmentId)??(w==null?void 0:w.params.environmentId),I=c.pathname.startsWith("/environments")&&!w&&!A,U=!!T,Q=!!k,$=!!w&&!v&&!b&&!x&&!S,H=!!N;if(!!C&&!Q&&!$&&!H||!!D||(!!g||!!S)||H||I||Q)return i.jsx(i.Fragment,{});if(U)return o.find(Z=>Z.adapterType==="local"&&Z.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Select a task or click + to create one"})});if(E){const L=s.find(ce=>ce.id===E);if(!L)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})});const Z=new Map(s.map(ce=>[ce.id,ce])),J=L.dependsOn.some(ce=>{const X=Z.get(ce);return X!==void 0&&X.status!=="complete"});if(L.status==="not_started"){const ce=J?L.dependsOn.map(X=>Z.get(X)).filter(X=>X&&X.status!=="complete").map(X=>X.title):[];return i.jsx("div",{className:wt.bar,children:J?i.jsxs("span",{className:wt.statusBlocked,children:["Blocked by: ",ce.join(", ")]}):i.jsx("span",{className:wt.hintText,children:"Use the buttons above to start or manage this task"})})}if(L.status==="working"||L.status==="paused"){const ce=L.latestSessionId||void 0,X=ce?t.find(pe=>pe.id===ce):void 0;return X&&X.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Waiting for agent..."})})}if(L.status==="complete")return i.jsxs("div",{className:wt.bar,children:[i.jsx("span",{className:`${wt.statusText} ${wt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ri(L.workspaceId,void 0,P)),className:wt.btnPrimary,children:"+ New Task"})]});if(L.status==="failed")return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:`${wt.statusText} ${wt.statusFailed}`,children:"Task failed"})})}if(O){const L=t.find(ce=>ce.id===O),Z=(L==null?void 0:L.status)==="stopped";if(L!==void 0&&!Z)return i.jsx(i.Fragment,{});if(Z)return i.jsxs("div",{className:wt.bar,children:[i.jsxs("span",{className:`${wt.statusText} ${wt.hintText}`,children:["Session ",L.endReason||L.status]}),i.jsx("button",{onClick:()=>r(Ix(L.environmentId)),className:wt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})})}const S5="_nav_14i94_1",T5="_tab_14i94_24",w5="_tabActive_14i94_62",j5="_tabLabel_14i94_75",N5="_statusDot_14i94_81",C5="_pulse_14i94_87",E5="_addButton_14i94_99",A5="_empty_14i94_132",Aa={nav:S5,tab:T5,tabActive:w5,tabLabel:j5,statusDot:N5,pulse:C5,addButton:E5,empty:A5},D5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function R5({environments:t}){const s=kt(),o=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(x=>{s(Ni(x))},[s]),v=y.useCallback(x=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&s(Ni(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(x=>{const S=x.id===m,k=x.id===b,w=D5[x.status]||"var(--text-tertiary)",N=x.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:i.jsx(La,{size:om,fill:"currentColor"})}),i.jsx("span",{className:Aa.tabLabel,title:x.displayName||x.id,children:x.displayName||x.id})]},x.id)})}),i.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(Xj),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function Qm(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()}`}const Ub={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 fd(t){return Ub[t]||Ub.general}const M5="_nav_dlm8m_1",I5="_categoryPills_dlm8m_24",O5="_categoryPill_dlm8m_24",B5="_tab_dlm8m_42",L5="_tabActive_dlm8m_80",z5="_tabContent_dlm8m_93",$5="_tabLabel_dlm8m_100",U5="_tabMeta_dlm8m_106",P5="_categoryDot_dlm8m_111",H5="_empty_dlm8m_118",xs={nav:M5,categoryPills:I5,categoryPill:O5,tab:B5,tabActive:L5,tabContent:z5,tabLabel:$5,tabMeta:U5,categoryDot:P5,empty:H5};function V5({findings:t,workspaceId:s,environmentId:o}){const r=kt(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const x=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(x).sort()},[t]),g=y.useCallback(x=>{r(Mp(x,s,o))},[r,s,o]),v=y.useCallback(x=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&r(Mp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),b=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:xs.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:xs.categoryPills,"data-testid":"findings-nav-categories",children:m.map(x=>i.jsx("span",{className:xs.categoryPill,style:{color:fd(x).text},children:x},x))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(x=>{const S=x.id===p,k=x.id===b;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${xs.tab} ${S?xs.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:xs.categoryDot,style:{color:fd(x.category).text},"aria-hidden":"true",children:i.jsx(La,{size:om,fill:"currentColor"})}),i.jsxs("span",{className:xs.tabContent,children:[i.jsx("span",{className:xs.tabLabel,title:x.title,children:x.title}),i.jsx("span",{className:xs.tabMeta,title:x.createdAt,children:Qm(x.createdAt)})]})]},x.id)})}),t.length===0&&i.jsx("div",{className:xs.empty,children:"No findings yet. Agents will post discoveries here."})]})}function q5(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 _1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=q5(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 G5(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 F5(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 nw){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(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=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const Z5="_container_z4i38_1",K5="_header_z4i38_5",Y5="_headerActions_z4i38_17",J5="_searchInput_z4i38_23",W5="_searchHighlight_z4i38_56",X5="_groupToggle_z4i38_62",Q5="_groupToggleActive_z4i38_89",eI="_addButton_z4i38_93",tI="_taskRow_z4i38_120",nI="_selected_z4i38_140",sI="_expandArrow_z4i38_150",aI="_expanded_z4i38_157",iI="_leafSpacer_z4i38_161",oI="_taskStatusIcon_z4i38_166",rI="_taskTitle_z4i38_170",lI="_workspaceBadge_z4i38_177",cI="_childCountBadge_z4i38_195",dI="_dependencyBadge_z4i38_208",uI="_blockedBadge_z4i38_220",fI="_addChildButton_z4i38_225",pI="_emptyState_z4i38_268",mI="_statusGroupHeader_z4i38_275",hI="_statusGroupIcon_z4i38_294",gI="_statusGroupLabel_z4i38_298",vI="_statusGroupCount_z4i38_303",Ge={container:Z5,header:K5,headerActions:Y5,searchInput:J5,searchHighlight:W5,groupToggle:X5,groupToggleActive:Q5,addButton:eI,taskRow:tI,selected:nI,expandArrow:sI,expanded:aI,leafSpacer:iI,taskStatusIcon:oI,taskTitle:rI,workspaceBadge:lI,childCountBadge:cI,dependencyBadge:dI,blockedBadge:uI,addChildButton:fI,emptyState:pI,statusGroupHeader:mI,statusGroupIcon:hI,statusGroupLabel:gI,statusGroupCount:vI},yI=[{name:"title",weight:2},{name:"description",weight:1}],k1=16,bI=16,S1="grackle-task-group-by-status";function Pb(){try{return localStorage.getItem(S1)==="true"}catch{return!1}}function xI(t){try{localStorage.setItem(S1,String(t))}catch{}}function _I({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:Ge.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:`${Ge.expandArrow} ${s?Ge.expanded:""}`,"aria-hidden":"true",children:i.jsx(sa,{size:lt})}),i.jsx("span",{className:Ge.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ge.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ge.statusGroupCount,children:t.tasks.length})]}),i.jsx(us,{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=za(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:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(On(p.id)))},className:`${Ge.taskRow} ${g?Ge.selected:""}`,style:{"--task-indent":`${k1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${cl(p.status)}`,children:m.icon}),i.jsx("span",{className:Ge.taskTitle,title:p.title,children:i.jsx(_1,{text:p.title,indices:d.get(p.id),highlightClass:Ge.searchHighlight})}),v&&i.jsx("span",{className:Ge.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function T1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=o.has(t.id),x=t.children.length>0,S=c===t.id,k=k1+s*bI,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:`${Ge.taskRow} ${S?Ge.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[x&&i.jsx("span",{className:`${Ge.expandArrow} ${b?Ge.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"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(sa,{size:lt,"aria-hidden":"true"})}),!x&&i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${cl(t.status)}`,children:g.icon}),i.jsx("span",{className:Ge.taskTitle,title:t.title,children:i.jsx(_1,{text:t.title,indices:p.get(t.id),highlightClass:Ge.searchHighlight})}),N&&i.jsx("span",{className:Ge.workspaceBadge,title:N,children:N}),x&&i.jsxs("span",{className:Ge.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ge.dependencyBadge} ${v?Ge.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<pT&&i.jsx(zo,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ri(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ge.addChildButton,children:"+"})})]}),i.jsx(us,{children:x&&b&&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(T1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function kI({workspaces:t,tasks:s}){const o=kt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Pb),[g,v]=y.useState(Pb),[b,x]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(W=>[W.id,W.status])),[s]),N=y.useMemo(()=>new Map(t.map(W=>[W.id,W.name])),[t]),T=()=>{const W=!p;xI(W),m(W),W&&(v(!0),x(new Map))},C=W=>{x(oe=>{const L=new Map(oe),Z=L.has(W)?L.get(W):g;return L.set(W,!Z),L})},D=W=>b.has(W)?b.get(W):g,O=W=>{c(oe=>{const L=new Set(oe);return L.has(W)?(L.delete(W),u(Z=>new Set(Z).add(W))):(L.add(W),u(Z=>{const J=new Set(Z);return J.delete(W),J})),L})};y.useEffect(()=>{const W=new Set(s.filter(oe=>oe.parentTaskId).map(oe=>oe.parentTaskId));W.size>0&&c(oe=>{const L=new Set(oe);for(const Z of W)d.has(Z)||L.add(Z);return L})},[s,d]);const[E,A]=y.useState(""),{directMatchTaskIds:P,treeMatchTaskIds:I,titleHighlights:U}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const W=fT(s,E,yI),oe=new Set(W.map(ce=>ce.item.id)),L=new Map;for(const ce of W){const X=ce.matches.find(ge=>ge.key==="title");X&&L.set(ce.item.id,X.indices)}const Z=new Set(oe),J=new Map(s.map(ce=>[ce.id,ce]));for(const ce of[...oe]){let X=J.get(ce);for(;X!=null&&X.parentTaskId;)Z.add(X.parentTaskId),X=J.get(X.parentTaskId)}return{directMatchTaskIds:oe,treeMatchTaskIds:Z,titleHighlights:L}},[E,s]),Q=P!==null,$=Q?p?P:I:null,H=$?s.filter(W=>$.has(W.id)):s,ue=p?[]:G5(H);return i.jsxs("div",{className:Ge.container,children:[i.jsxs("div",{className:Ge.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ge.headerActions,children:[i.jsx(zo,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ge.groupToggle} ${p?Ge.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(A2,{size:tn})})}),i.jsx(zo,{text:"New task",children:i.jsx("button",{className:Ge.addButton,onClick:()=>o(Ri()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:W=>A(W.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ge.searchInput,"data-testid":"sidebar-search"}),p?F5(H,w).map(W=>i.jsx(_I,{group:W,isExpanded:D(W.status),onToggle:()=>C(W.status),selectedTaskId:k,navigate:o,titleHighlights:U,workspaceNames:N},W.status)):ue.map(W=>i.jsx(T1,{node:W,depth:0,expandedTasks:r,toggleTask:O,selectedTaskId:k,navigate:o,taskStatusById:w,titleHighlights:U,workspaceNames:N},W.id)),H.length===0&&!Q&&i.jsx("div",{className:Ge.emptyState,children:"No tasks yet. Click + to create one."}),H.length===0&&Q&&i.jsx("div",{className:Ge.emptyState,children:"No matching tasks"})]})}const SI="_toast_ed2dk_1",TI="_success_ed2dk_18",wI="_icon_ed2dk_22",jI="_error_ed2dk_25",NI="_warning_ed2dk_32",CI="_info_ed2dk_38",EI="_message_ed2dk_53",AI="_close_ed2dk_60",Ur={toast:SI,success:TI,icon:wI,error:jI,warning:NI,info:CI,message:EI,close:AI},DI={success:i.jsx(Ai,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(im,{size:zt}),info:i.jsx(am,{size:zt})};function RI({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Rt.div,{className:`${Ur.toast} ${Ur[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:Ur.icon,"aria-hidden":"true",children:DI[t.variant]}),i.jsx("span",{className:Ur.message,children:t.message}),i.jsx("button",{type:"button",className:Ur.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})}const MI="_container_qqse2_1",II={container:MI};function OI({toasts:t,onDismiss:s}){return i.jsx("div",{className:II.container,"data-testid":"toast-container",children:i.jsx(us,{children:t.map(o=>i.jsx(RI,{toast:o,onDismiss:s},o.id))})})}const BI="_callout_e5awm_1",LI="_success_e5awm_11",zI="_icon_e5awm_15",$I="_error_e5awm_18",UI="_warning_e5awm_25",PI="_info_e5awm_32",HI="_content_e5awm_48",VI="_close_e5awm_53",Pr={callout:BI,success:LI,icon:zI,error:$I,warning:UI,info:PI,content:HI,close:VI},qI={success:i.jsx(Ai,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(im,{size:zt}),info:i.jsx(am,{size:zt})};function GI({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Pr.callout,Pr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Pr.icon,"aria-hidden":"true",children:qI[t]}),i.jsx("span",{className:Pr.content,children:s}),o&&i.jsx("button",{type:"button",className:Pr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})})}function FI({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(GI,{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 ZI="_container_de44x_1",KI="_emptyState_de44x_8",YI="_card_de44x_14",JI="_cardClickable_de44x_34",WI="_cardHeader_de44x_42",XI="_categoryBadge_de44x_54",QI="_findingTitle_de44x_62",eO="_findingDate_de44x_68",tO="_findingContent_de44x_80",nO="_tags_de44x_86",sO="_tag_de44x_86",rs={container:ZI,emptyState:KI,card:YI,cardClickable:JI,cardHeader:WI,categoryBadge:XI,findingTitle:QI,findingDate:eO,findingContent:tO,tags:nO,tag:sO};function w1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:rs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:rs.container,children:t.map((o,r)=>{const c=fd(o.category),d=s?Rt.button:Rt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${rs.card} ${s?rs.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:rs.cardHeader,children:[i.jsx("span",{className:rs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:rs.findingTitle,children:o.title}),i.jsx("span",{className:rs.findingDate,title:o.createdAt,children:Qm(o.createdAt)})]}),i.jsx("div",{className:rs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:rs.tags,children:o.tags.map(u=>i.jsx("span",{className:rs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const aO="_section_1ingb_14",iO="_sectionTitle_1ingb_26",oO="_sectionDescription_1ingb_35",rO="_tokenList_1ingb_48",lO="_tokenRow_1ingb_55",cO="_tokenBadge_1ingb_68",dO="_tokenName_1ingb_83",uO="_tokenTarget_1ingb_90",fO="_deleteButton_1ingb_99",pO="_addForm_1ingb_113",mO="_formRow_1ingb_119",hO="_input_1ingb_125",gO="_select_1ingb_155",vO="_addButton_1ingb_187",yO="_emptyStateInfo_1ingb_221",bO="_themeOptions_1ingb_229",xO="_themeOption_1ingb_229",_O="_themeOptionSelected_1ingb_254",kO="_themeOptionHeader_1ingb_259",SO="_themeOptionLabel_1ingb_266",TO="_themeOptionDesc_1ingb_273",wO="_variantToggle_1ingb_279",jO="_variantButton_1ingb_286",NO="_variantActive_1ingb_305",CO="_themeSwatches_1ingb_311",EO="_themeSwatch_1ingb_311",AO="_systemToggle_1ingb_325",DO="_systemToggleHint_1ingb_341",RO="_themeActive_1ingb_348",MO="_aboutGrid_1ingb_354",IO="_aboutItem_1ingb_360",OO="_aboutLabel_1ingb_373",BO="_aboutValue_1ingb_379",LO="_aboutDot_1ingb_387",zO="_aboutDotConnected_1ingb_394",$O="_aboutDotDisconnected_1ingb_398",be={section:aO,sectionTitle:iO,sectionDescription:oO,tokenList:rO,tokenRow:lO,tokenBadge:cO,tokenName:dO,tokenTarget:uO,deleteButton:fO,addForm:pO,formRow:mO,input:hO,select:gO,addButton:vO,emptyStateInfo:yO,themeOptions:bO,themeOption:xO,themeOptionSelected:_O,themeOptionHeader:kO,themeOptionLabel:SO,themeOptionDesc:TO,variantToggle:wO,variantButton:jO,variantActive:NO,themeSwatches:CO,themeSwatch:EO,systemToggle:AO,systemToggleHint:DO,themeActive:RO,aboutGrid:MO,aboutItem:IO,aboutLabel:OO,aboutValue:BO,aboutDot:LO,aboutDotConnected:zO,aboutDotDisconnected:$O},UO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function PO({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[x,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{x&&(o(x),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(Ei,{isOpen:x!==null,title:"Delete Token?",description:x?`"${x}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Tokens"}),i.jsx("p",{className:be.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:be.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:be.tokenList,children:t.map(T=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenBadge,children:T.tokenType}),i.jsx("span",{className:be.tokenName,children:T.name}),i.jsx("span",{className:be.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:be.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:be.addForm,onSubmit:k,children:[i.jsxs("div",{className:be.formRow,children:[i.jsx("input",{className:be.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:be.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:be.formRow,children:[i.jsx("select",{className:be.select,value:m,onChange:T=>g(T.target.value),children:UO.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:be.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=>b(T.target.value)}),i.jsx("button",{className:be.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Cd=[{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"]}],j1=new Set(Cd.map(t=>t.id)),Hb="grackle";function Qp(t){return Cd.find(s=>s.id===t)}function HO({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Appearance"}),i.jsx("p",{className:be.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:be.themeOptions,children:Cd.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:`${be.themeOption} ${p?be.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:be.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:be.themeOptionLabel,children:d.label}),i.jsx("span",{className:be.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:be.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${be.variantButton} ${p&&m?be.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:`${be.variantButton} ${p&&!m?be.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:be.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:be.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:be.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:be.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:be.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function VO({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:be.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"About"}),i.jsx("p",{className:be.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:be.aboutGrid,children:[i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Connection"}),i.jsxs("span",{className:be.aboutValue,children:[i.jsx("span",{className:`${be.aboutDot} ${t?be.aboutDotConnected:be.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Environments"}),i.jsxs("span",{className:be.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:be.aboutValue,children:d})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Version"}),i.jsx("span",{className:be.aboutValue,children:"0.97.0"})]})]})]})}const qO="_container_cddyd_1",GO="_header_cddyd_8",FO="_headerTitle_cddyd_35",ZO="_badge_cddyd_44",KO="_headerActions_cddyd_54",YO="_body_cddyd_61",JO="_formContent_cddyd_73",WO="_section_cddyd_85",XO="_label_cddyd_91",QO="_titleInput_cddyd_98",eB="_descriptionTextarea_cddyd_131",tB="_parentContext_cddyd_167",nB="_parentLabel_cddyd_175",sB="_parentName_cddyd_182",aB="_personaSelect_cddyd_186",iB="_depList_cddyd_220",oB="_depItem_cddyd_226",rB="_depItemSelected_cddyd_248",lB="_noDeps_cddyd_252",cB="_btnPrimary_cddyd_258",dB="_btnGhost_cddyd_289",tt={container:qO,header:GO,headerTitle:FO,badge:ZO,headerActions:KO,body:YO,formContent:JO,section:WO,label:XO,titleInput:QO,descriptionTextarea:eB,parentContext:tB,parentLabel:nB,parentName:sB,personaSelect:aB,depList:iB,depItem:oB,depItemSelected:rB,noDeps:lB,btnPrimary:cB,btnGhost:dB};function N1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?d.find(ve=>ve.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=y.useState(w),C=w||N,D=u.find(ve=>ve.id===C),O=c??(D==null?void 0:D.environmentId),E=!S&&!o,A=S?(k==null?void 0:k.parentTaskId)??"":r??"",P=A?d.find(ve=>ve.id===A):void 0,[I,U]=y.useState((k==null?void 0:k.title)??""),[Q,$]=y.useState((k==null?void 0:k.description)??""),[H,ue]=y.useState((k==null?void 0:k.dependsOn)??[]),[W,oe]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[L,Z]=y.useState((k==null?void 0:k.canDecompose)??!1),[J,ce]=y.useState(!1),X=y.useRef(!1);y.useEffect(()=>{S&&k&&!X.current&&(X.current=!0,U(k.title),$(k.description),ue(k.dependsOn),oe(k.defaultPersonaId),Z(k.canDecompose))},[S,k]);const ge=d.filter(ve=>ve.workspaceId===C&&(!S||ve.id!==s)&&ve.id!==A),pe=I.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=ve=>{ue(Le=>Le.includes(ve)?Le.filter(Mt=>Mt!==ve):[...Le,ve])},Ze=()=>{!pe||J||S&&k===void 0||(S&&s?(g(s,I.trim(),Q,H,W),b==null||b("Task updated","success"),v?v():x(On(s,void 0,C,O),{replace:!0})):(ce(!0),m(C,I.trim(),Q,H.length>0?H:void 0,A||void 0,W,L,()=>{b==null||b("Task created","success"),x(o?$a(o,O):"/tasks",{replace:!0})},ve=>{b==null||b(ve,"error"),ce(!1)})))},me=()=>{if(v){v();return}x(S&&s?On(s,void 0,C,O):o?$a(o,O):"/tasks")},_e=S?"edit task":A?"child task":"new task";return i.jsxs("div",{className:tt.container,children:[i.jsxs("div",{className:tt.header,children:[i.jsxs("div",{className:tt.headerTitle,children:[i.jsx("span",{className:tt.badge,children:_e}),P&&i.jsxs("span",{className:tt.parentContext,children:[i.jsx("span",{className:tt.parentLabel,children:"Child of"}),i.jsx("span",{className:tt.parentName,children:P.title})]})]}),i.jsxs("div",{className:tt.headerActions,children:[i.jsx("button",{onClick:Ze,disabled:!pe||J,className:tt.btnPrimary,"data-testid":"task-edit-save",children:J?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:me,className:tt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:tt.body,children:i.jsxs("div",{className:tt.formContent,children:[E&&i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:ve=>T(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:I,onChange:ve=>U(ve.target.value),placeholder:"Task title...",autoFocus:!0,className:tt.titleInput,"data-testid":"task-edit-title",onKeyDown:ve=>{ve.key==="Enter"&&pe&&Ze()}})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Q,onChange:ve=>$(ve.target.value),placeholder:"Describe the task... (markdown supported)",className:tt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:W,onChange:ve=>oe(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),!S&&i.jsx("div",{className:tt.section,children:i.jsxs("label",{className:tt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:L,onChange:ve=>Z(ve.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:tt.section,children:[i.jsx("div",{className:tt.label,children:"Dependencies"}),ge.length===0?i.jsx("div",{className:tt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:tt.depList,children:ge.map(ve=>{const Le=H.includes(ve.id);return i.jsxs("label",{className:`${tt.depItem} ${Le?tt.depItemSelected:""}`,"data-testid":`dep-option-${ve.id}`,children:[i.jsx("input",{type:"checkbox",checked:Le,onChange:()=>Ce(ve.id)}),ve.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ve.status,")"]})]},ve.id)})})]})]})})]})}const uB="_actionButtons_1rjka_1",fB="_btnPrimary_1rjka_8",pB="_btnDanger_1rjka_39",mB="_btnGhost_1rjka_78",Ft={actionButtons:uB,btnPrimary:fB,btnDanger:pB,btnGhost:mB};function hB({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:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const gB="_workpadSection_y8nj9_1",vB="_workpadLabel_y8nj9_9",yB="_workpadStatus_y8nj9_17",bB="_workpadSummary_y8nj9_23",xB="_workpadExtra_y8nj9_29",Da={workpadSection:gB,workpadLabel:vB,workpadStatus:yB,workpadSummary:bB,workpadExtra:xB};function _B({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:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const kB="_overviewDashboard_r05qm_1",SB="_overviewHero_r05qm_7",TB="_statusBadge_r05qm_14",wB="_statusPending_r05qm_26",jB="_statusAssigned_r05qm_31",NB="_statusInProgress_r05qm_36",CB="_statusReview_r05qm_41",EB="_statusDone_r05qm_46",AB="_statusFailed_r05qm_51",DB="_statusWaitingInput_r05qm_56",RB="_overviewBranchPill_r05qm_61",MB="_branchLink_r05qm_76",IB="_overviewSection_r05qm_87",OB="_overviewLabel_r05qm_93",BB="_overviewValue_r05qm_100",LB="_overviewMuted_r05qm_105",zB="_overviewMarkdown_r05qm_111",$B="_envRow_r05qm_180",UB="_envDot_r05qm_186",PB="_envDotGreen_r05qm_193",HB="_envDotYellow_r05qm_197",VB="_envDotRed_r05qm_201",qB="_envDotGray_r05qm_205",GB="_depList_r05qm_209",FB="_depItem_r05qm_215",ZB="_depBlocked_r05qm_222",KB="_depDone_r05qm_226",YB="_timeline_r05qm_230",JB="_timelineRow_r05qm_236",WB="_timelineKey_r05qm_243",XB="_timelineValue_r05qm_249",QB="_timelineDelta_r05qm_253",eL="_reviewNotes_r05qm_264",he={overviewDashboard:kB,overviewHero:SB,statusBadge:TB,statusPending:wB,statusAssigned:jB,statusInProgress:NB,statusReview:CB,statusDone:EB,statusFailed:AB,statusWaitingInput:DB,overviewBranchPill:RB,branchLink:MB,overviewSection:IB,overviewLabel:OB,overviewValue:BB,overviewMuted:LB,overviewMarkdown:zB,envRow:$B,envDot:UB,envDotGreen:PB,envDotYellow:HB,envDotRed:VB,envDotGray:qB,depList:GB,depItem:FB,depBlocked:ZB,depDone:KB,timeline:YB,timelineRow:JB,timelineKey:WB,timelineValue:XB,timelineDelta:QB,reviewNotes:eL};function zc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function yp(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 Vb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?he.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?he.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?he.envDotRed:he.envDotGray}function tL({status:t}){const s=za(t),o=tw(t);return i.jsx("span",{className:`${he.statusBadge} ${he[o]??he.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function nL({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),x=o.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:he.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:he.overviewHero,children:[i.jsx(tL,{status:t.status}),t.branch&&i.jsx("span",{className:he.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:he.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:he.overviewLabel,children:"Description"}),i.jsx("div",{className:he.overviewMarkdown,children:i.jsx(hd,{remarkPlugins:[gd],children:t.description})})]}),t.workpad&&i.jsx(_B,{workpad:t.workpad}),i.jsxs("div",{className:he.overviewSection,children:[i.jsx("div",{className:he.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Vb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:v.displayName})]}):x?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Vb(x.status)}`,title:x.status,"aria-label":`Status: ${x.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:x.displayName}),i.jsx("span",{className:he.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:he.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:he.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:he.overviewMuted,children:"None"}):i.jsx("div",{className:he.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return i.jsxs("div",{className:`${he.depItem} ${N?he.depDone:he.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:he.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:he.timeline,children:[t.createdAt&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Created"}),i.jsx("span",{className:he.timelineValue,children:zc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=yp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Assigned"}),i.jsx("span",{className:he.timelineValue,children:zc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=yp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Started"}),i.jsx("span",{className:he.timelineValue,children:zc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=yp(t.startedAt,t.completedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Completed"}),i.jsx("span",{className:he.timelineValue,children:zc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:he.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:he.overviewLabel,children:"Usage"}),i.jsxs("div",{className:he.timeline,children:[i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsx("span",{className:he.timelineValue,children:Ss(u.costUsd)}),i.jsxs("span",{className:he.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:he.timelineValue,children:Ss(p.costUsd)}),i.jsxs("span",{className:he.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:he.overviewLabel,children:"Budget"}),i.jsxs("div",{className:he.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Tokens"}),i.jsxs("span",{className:he.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:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsxs("span",{className:he.timelineValue,children:[Ss((u==null?void 0:u.costUsd)??0)," / ",Ss(t.costBudgetMillicents/1e5)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:he.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:he.reviewNotes,children:t.reviewNotes})]})]})}const sL="_container_legrg_1",aL="_header_legrg_8",iL="_headerTitle_legrg_35",oL="_badge_legrg_44",rL="_headerActions_legrg_54",lL="_body_legrg_61",cL="_formContent_legrg_73",dL="_section_legrg_85",uL="_label_legrg_91",fL="_nameInput_legrg_98",pL="_fieldInput_legrg_131",mL="_adapterSelect_legrg_164",hL="_readOnlyValue_legrg_198",gL="_codespaceSection_legrg_204",vL="_codespaceActions_legrg_210",yL="_creatingHint_legrg_216",bL="_errorHint_legrg_222",xL="_btnPrimary_legrg_235",_L="_btnGhost_legrg_266",re={container:sL,header:aL,headerTitle:iL,badge:oL,headerActions:rL,body:lL,formContent:cL,section:dL,label:uL,nameInput:fL,fieldInput:pL,adapterSelect:mL,readOnlyValue:hL,codespaceSection:gL,codespaceActions:vL,creatingHint:yL,errorHint:bL,btnPrimary:xL,btnGhost:_L},Wc=1,Xc=65535;function bp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Wc&&s<=Xc}function xp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function kL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,x]=y.useState(""),[S,k]=y.useState("");return g==="create"?i.jsxs("div",{className:re.codespaceSection,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:w=>x(w.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:re.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),x(""),k(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),x(""),k("")},className:re.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:re.codespaceSection,children:i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!o.trim()&&r(w.target.value))},disabled:p,className:re.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>i.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:re.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:re.errorHint,children:d})]})})}function C1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?o.find(me=>me.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,O]=y.useState(""),[E,A]=y.useState(""),[P,I]=y.useState(""),[U,Q]=y.useState(""),[$,H]=y.useState(""),[ue,W]=y.useState(""),[oe,L]=y.useState(""),[Z,J]=y.useState(null),ce=y.useCallback(()=>{const me={};if(T==="local"){if(D.trim()&&(me.host=D.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.port=_e)}}else if(T==="ssh"){if(me.host=D.trim(),P.trim()&&(me.user=P.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.sshPort=_e)}U.trim()&&(me.identityFile=U.trim())}else T==="docker"?($.trim()&&(me.image=$.trim()),ue.trim()&&(me.repo=ue.trim())):T==="codespace"&&(me.codespaceName=oe.trim());return me},[T,D,E,P,U,$,ue,oe]),X=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!oe.trim()||(T==="local"||T==="ssh")&&!bp(E)),ge=()=>{X()&&(r(w.trim(),T,ce()),b==null||b("Environment added successfully","success"),x(Mo,{replace:!0}))},pe=()=>{x(s?Ni(s):Mo)},Ce=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig),Le=_e.trim();Le?ve[me]=Le:delete ve[me],c(s,{adapterConfig:ve})},[k,s,c]),Ze=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig);if(_e.trim()){const Le=Number(_e);Number.isInteger(Le)&&Le>=Wc&&Le<=Xc&&(ve[me]=Le)}else delete ve[me];c(s,{adapterConfig:ve})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:re.container,children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:pe,className:re.btnGhost,children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsx("div",{className:re.formContent,children:i.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const me=xp(k.adapterConfig);return i.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:pe,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Name"}),i.jsx(ln,{value:k.displayName,onSave:_e=>{s&&c(s,{displayName:_e})},validate:_e=>_e.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:Z,onActivate:J,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Adapter Type"}),i.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Port"}),i.jsx(ln,{value:String(me.port??""),onSave:_e=>Ze("port",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),validate:_e=>_e.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"User"}),i.jsx(ln,{value:String(me.user??""),onSave:_e=>Ce("user",_e),mode:"edit",fieldId:"user",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"SSH Port"}),i.jsx(ln,{value:String(me.sshPort??""),onSave:_e=>Ze("sshPort",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:Z,onActivate:J,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Identity File"}),i.jsx(ln,{value:String(me.identityFile??""),onSave:_e=>Ce("identityFile",_e),mode:"edit",fieldId:"identityFile",activeFieldId:Z,onActivate:J,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Image"}),i.jsx(ln,{value:String(me.image??""),onSave:_e=>Ce("image",_e),mode:"edit",fieldId:"image",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repo"}),i.jsx(ln,{value:String(me.repo??""),onSave:_e=>Ce("repo",_e),mode:"edit",fieldId:"repo",activeFieldId:Z,onActivate:J,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace Name"}),i.jsx(ln,{value:String(me.codespaceName??""),onSave:_e=>Ce("codespaceName",_e),validate:_e=>_e.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:Z,onActivate:J,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"new environment"})}),i.jsxs("div",{className:re.headerActions,children:[i.jsx("button",{onClick:ge,disabled:!X(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:pe,className:re.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:me=>N(me.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:me=>{me.key==="Enter"&&X()&&ge()}})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:me=>{C(me.target.value),me.target.value==="codespace"&&d()},className:re.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:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>O(me.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>O(me.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:P,onChange:me=>I(me.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:U,onChange:me=>Q(me.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:me=>H(me.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:ue,onChange:me=>W(me.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(kL,{codespaceName:oe,onCodespaceNameChange:L,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const SL="_group_1iprv_1",TL="_groupTitle_1iprv_8",wL="_shortcutList_1iprv_17",jL="_shortcutRow_1iprv_23",NL="_keys_1iprv_36",CL="_kbd_1iprv_43",EL="_description_1iprv_60",_i={group:SL,groupTitle:TL,shortcutList:wL,shortcutRow:jL,keys:NL,kbd:CL,description:EL},AL=[{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 DL(){return i.jsxs("section",{className:be.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:be.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),AL.map(t=>i.jsxs("div",{className:_i.group,children:[i.jsx("h4",{className:_i.groupTitle,children:t.title}),i.jsx("div",{className:_i.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:_i.shortcutRow,children:[i.jsx("span",{className:_i.keys,children:s.keys.map(o=>i.jsx("kbd",{className:_i.kbd,children:o},o))}),i.jsx("span",{className:_i.description,children:s.description})]},s.description))})]},t.title))]})}const RL=[{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 ML({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:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:be.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:be.tokenList,children:RL.map(r=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenName,children:r.label}),i.jsx("span",{className:be.tokenTarget,children:r.description}),i.jsx("select",{className:be.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 IL="_container_10efq_1",OL="_header_10efq_7",BL="_list_10efq_105",LL="_card_10efq_111",zL="_cardHeader_10efq_125",$L="_cardTitle_10efq_135",UL="_defaultBadge_10efq_141",PL="_cardActions_10efq_155",HL="_description_10efq_160",VL="_meta_10efq_166",qL="_empty_10efq_212",GL="_typeBadge_10efq_362",Jn={container:IL,header:OL,list:BL,card:LL,cardHeader:zL,cardTitle:$L,defaultBadge:UL,cardActions:PL,description:HL,meta:VL,empty:qL,typeBadge:GL};function FL({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Jn.container,children:[i.jsxs("div",{className:Jn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,x=v.type==="script";return i.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Jn.cardHeader,children:[i.jsxs("span",{className:Jn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:x?"Script":"Agent"}),b&&i.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&i.jsx(Js,{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(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Jn.description,children:v.description}),i.jsxs("div",{className:Jn.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(Ei,{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 ZL="_container_uy08i_1",KL="_header_uy08i_7",YL="_count_uy08i_13",JL="_presets_uy08i_18",WL="_presetButton_uy08i_24",XL="_filterInput_uy08i_41",QL="_groups_uy08i_53",e8="_group_uy08i_53",t8="_groupHeader_uy08i_68",n8="_groupName_uy08i_77",s8="_groupCount_uy08i_81",a8="_toolList_uy08i_87",i8="_toolItem_uy08i_95",o8="_toolName_uy08i_103",pn={container:ZL,header:KL,count:YL,presets:JL,presetButton:WL,filterInput:XL,groups:QL,group:e8,groupHeader:t8,groupName:n8,groupCount:s8,toolList:a8,toolItem:i8,toolName:o8},r8=(()=>{const t=new Map;for(const s of lx){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()}))})(),l8=[{name:"default",label:"Default",tools:cx},{name:"worker",label:"Worker",tools:mT},{name:"orchestrator",label:"Orchestrator",tools:hT},{name:"admin",label:"Admin",tools:gT}];function qb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const x=new Set(d);for(const S of v)b?x.delete(S):x.add(S);s([...x].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:pn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:pn.header,children:i.jsx("span",{className:pn.count,children:t.length===0?`Using default (${cx.length} tools)`:`${t.length} of ${lx.size} tools selected`})}),i.jsxs("div",{className:pn.presets,"data-testid":"mcp-tool-presets",children:[l8.map(v=>i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:pn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:pn.groups,children:r8.map(({group:v,tools:b})=>{const x=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(x.length===0)return null;const S=x.every(k=>d.has(k));return i.jsxs("div",{className:pn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:pn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(x,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:pn.groupName,children:v}),i.jsxs("span",{className:pn.groupCount,children:["(",x.filter(k=>d.has(k)).length,"/",x.length,")"]})]}),i.jsx("div",{className:pn.toolList,children:x.map(k=>i.jsxs("label",{className:pn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:pn.toolName,children:k})]},k))})]},v)})})]})}const c8="_nav_1bhou_1",d8="_tab_1bhou_24",u8="_tabIcon_1bhou_62",f8="_tabActive_1bhou_68",$c={nav:c8,tab:d8,tabIcon:u8,tabActive:f8},Ks=[{path:"credentials",label:"Credentials",icon:i.jsx(T2,{size:zt})},{path:"personas",label:"Personas",icon:i.jsx(X2,{size:zt})},{path:"appearance",label:"Appearance",icon:i.jsx(U2,{size:zt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(j2,{size:zt})},{path:"about",label:"About",icon:i.jsx(am,{size:zt})}];function p8(){var u;const t=Zt(),s=kt(),o=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Ro}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Ro}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const x=Ks[b].path;s(`${Ro}/${x}`),(k=m[b])==null||k.focus()},[r,s]);return i.jsx("nav",{className:$c.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${$c.tab} ${m?$c.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:$c.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function m8({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(ry.map(d=>[d,[]]));for(const d of t){const u=cl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const x={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(x):c.get("not_started").push(x)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return ry.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const h8="_boardContainer_1c4y1_1",g8="_column_1c4y1_17",v8="_columnHeader_1c4y1_34",y8="_columnIcon_1c4y1_47",b8="_columnLabel_1c4y1_52",x8="_columnCount_1c4y1_57",_8="_cardList_1c4y1_67",k8="_emptyPlaceholder_1c4y1_76",S8="_card_1c4y1_67",T8="_cardHeader_1c4y1_107",w8="_cardStatusIcon_1c4y1_113",j8="_cardTitle_1c4y1_119",N8="_cardBadges_1c4y1_127",C8="_badge_1c4y1_134",E8="_blockedBadge_1c4y1_146",A8="_childBadge_1c4y1_151",D8="_depBadge_1c4y1_155",R8="_parentBadge_1c4y1_159",M8="_pausedSubBadge_1c4y1_166",I8="_personaBadge_1c4y1_170",O8="_envBadge_1c4y1_174",B8="_emptyCta_1c4y1_178",L8="_ctaButton_1c4y1_188",z8="_ctaDescription_1c4y1_204",it={boardContainer:h8,column:g8,columnHeader:v8,columnIcon:y8,columnLabel:b8,columnCount:x8,cardList:_8,emptyPlaceholder:k8,card:S8,cardHeader:T8,cardStatusIcon:w8,cardTitle:j8,cardBadges:N8,badge:C8,blockedBadge:E8,childBadge:A8,depBadge:D8,parentBadge:R8,pausedSubBadge:M8,personaBadge:I8,envBadge:O8,emptyCta:B8,ctaButton:L8,ctaDescription:z8};function $8({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=kt(),p=y.useMemo(()=>o.filter(x=>x.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(x=>[x.id,x.status])),[o]),g=y.useMemo(()=>new Map(p.map(x=>[x.id,x])),[p]),v=y.useMemo(()=>{const x=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=x.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const O=S.get(D.personaId);O&&N.set(C.id,O.name)}if(D.environmentId){const O=k.get(D.environmentId);O&&T.set(C.id,O.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>m8({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(Ri(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:b.map(x=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${x.status}`,"aria-label":`${x.label}, ${x.tasks.length} ${x.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:x.style.color},children:x.style.icon}),i.jsx("span",{className:it.columnLabel,children:x.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${x.status}`,children:x.tasks.length})]}),i.jsx("div",{className:it.cardList,children:x.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(us,{mode:"popLayout",children:x.tasks.map(S=>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(U8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},x.status))})}function U8({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=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:x=>{(x.key==="Enter"||x.key===" ")&&(x.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:[b&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:b.title,children:b.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 P8="_formContent_ymnez_1",H8="_section_ymnez_13",V8="_label_ymnez_19",q8="_titleInput_ymnez_26",G8="_descriptionTextarea_ymnez_58",F8="_selectField_ymnez_94",Z8="_checkboxRow_ymnez_128",K8="_checkboxLabel_ymnez_141",Y8="_fieldError_ymnez_146",bt={formContent:P8,section:H8,label:V8,titleInput:q8,descriptionTextarea:G8,selectField:F8,checkboxRow:Z8,checkboxLabel:K8,fieldError:Y8};function J8(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.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const W8=100;function X8({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:bt.formContent,children:[i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:bt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:W8,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:bt.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:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:bt.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:bt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:bt.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:bt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:bt.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:bt.section,children:i.jsxs("label",{className:bt.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:bt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:bt.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 E1=y.createContext(void 0),Q8=4e3;function e7({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=Q8)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(E1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Sn(){const t=y.useContext(E1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const em="grackle-theme",A1="grackle-prefer-system",D1="(prefers-color-scheme: dark)";let Fr=[],Qc;function _p(){Qc=void 0;for(const t of Fr)t()}function tm(){return typeof window>"u"?!1:window.matchMedia(D1).matches}function Xr(){if(typeof localStorage>"u")return Hb;try{const t=localStorage.getItem(em);if(t!==null&&j1.has(t))return t}catch{}return Hb}function pd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(A1)==="true"}catch{return!1}}function nm(t){return Cd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function R1(t,s){const o=Qp(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?tm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=nm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return tm()?r.variantDarkId:r.variantLightId}return t}function wo(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=R1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&wo(Xr(),pd());function t7(){return Qc===void 0&&(Qc={themeId:Xr(),systemDark:tm(),preferSystem:pd()}),Qc}function n7(t){return Fr=[...Fr,t],()=>{Fr=Fr.filter(s=>s!==t)}}function s7(){const t=y.useSyncExternalStore(n7,t7),{themeId:s,preferSystem:o}=t,r=R1(s,o),c=y.useCallback(u=>{if(j1.has(u)){try{localStorage.setItem(em,u)}catch{}wo(u,pd(),!0),_p()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(A1,u?"true":"false")}catch{}if(u){const p=Xr(),m=Qp(p);if(m!=null&&m.hidden){const g=nm(p);if(g)try{localStorage.setItem(em,g.id)}catch{}}}wo(Xr(),u,!0),_p()},[]);return y.useEffect(()=>{wo(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(D1),p=()=>{const m=Xr(),g=pd();if(g){const v=Qp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&wo(m,g),v!=null&&v.hidden){const b=nm(m);b!=null&&b.variantDarkId&&b.variantLightId&&wo(m,g)}}_p()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const M1=y.createContext(void 0);function a7({children:t}){const s=s7();return i.jsx(M1.Provider,{value:s,children:t})}function I1(){const t=y.useContext(M1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const O1=y.createContext(void 0),B1=y.createContext(void 0);function i7({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(B1.Provider,{value:r,children:i.jsx(O1.Provider,{value:s,children:t})})}function o7(){return y.useContext(O1)}function r7(){const t=y.useContext(B1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const eh=y.createContext(void 0);function mt(){const t=y.useContext(eh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function L1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function z1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function l7(t){return L1(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 c7=new Set(["off","subscription","api_key"]),Uc=new Set(["off","on"]);function d7(t){return L1(t)&&c7.has(t.claude)&&Uc.has(t.github)&&Uc.has(t.copilot)&&Uc.has(t.codex)&&Uc.has(t.goose)}function $1(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 U1(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 To=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 na={label:"Home",url:Ci};function f7(t){return t?[na,{label:"Settings",url:Ro},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const th={label:"Environments",url:Mo};function p7(){return[na,{label:"Environments",url:void 0}]}function m7(){return[na,{label:"New Chat",url:void 0}]}function h7(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function g7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,th,{label:(d==null?void 0:d.displayName)??"Environment",url:Ni(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function v7(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(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(th),b.push({label:v.displayName,url:Ni(g)})),m&&g&&b.push({label:m.name,url:$a(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const x=d[d.length-1];return b.push({label:(x==null?void 0:x.title)??t,url:void 0}),b}const y7={label:"Findings",url:_d};function b7(){return[na,{label:"Findings",url:void 0}]}function P1(t,s,o,r,c){const d=[na];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(th),p&&d.push({label:p.displayName,url:Ni(o)}),u&&d.push({label:u.name,url:$a(s,o)}),d.push({label:"Findings",url:oN(s,o)})}else d.push(y7);return d.push({label:t,url:void 0}),d}function nh(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 Pc(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 x7(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function sh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),x=b?Pc(b):void 0;if(x)try{const S=JSON.parse(v.content);o.set(x,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const x=s.get(v),S=x?x7(x):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),x=b?Pc(b):void 0;x&&r.has(x)||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 b=p[m];if(b!==v+1)continue;const x=d[v],S=d[b];let k;try{const w=JSON.parse(x.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(x),C=T?Pc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(x,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const x=Pc(b);if(x&&r.has(x))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let x=v+1;x<g.length;x++)if(g[x].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function _7(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=H1(s),d=s.filter(m=>sm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||sm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function H1(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function sm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function k7(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=H1(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}):sm(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 S7(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 T7(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 ks=[{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
275
275
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
276
276
  const header = req.headers.authorization;
277
277
  if (!header?.startsWith("Bearer ")) {
@@ -712,4 +712,4 @@ const grackle = await host.mcpServer({
712
712
  url: env.vars.GRACKLE_MCP_URL,
713
713
  });
714
714
 
715
- $\`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(qb,{selectedTools:Q,onChange:ie=>{$(ie),ve(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ie),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!pe&&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(Ei,{isOpen:H,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:_e,onCancel:()=>ue(!1)})]})}function wP(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=I1();return i.jsx(HO,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function jP(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ne.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function NP(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=mt(),r=jP();return i.jsxs(i.Fragment,{children:[r&&i.jsx(FI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(VO,{connected:t,environments:s,sessions:o})]})}function CP(){return i.jsx(DL,{})}const ax=Ri();function EP(){const t=kt();return Qs({key:"?"},()=>{t(nN)}),Qs({key:"n"},()=>{t(ax)}),Qs({key:"N"},()=>{t(ax)}),i.jsx(i.Fragment,{})}function gl(t){const s=r7();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function AP(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=mt(),o=y.useMemo(()=>i.jsx(kI,{workspaces:t,tasks:s}),[t,s]);return gl(o),i.jsx(Va,{})}function DP(){const{environments:{environments:t}}=mt(),s=y.useMemo(()=>i.jsx(R5,{environments:t}),[t]);return gl(s),i.jsx(Va,{})}function RP(){const t=y.useMemo(()=>i.jsx(p8,{}),[]);return gl(t),i.jsx(Va,{})}function MP(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=mt(),{workspaceId:r,environmentId:c}=fs();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>i.jsx(V5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return gl(d),i.jsx(Va,{})}function IP(){const{knowledge:t,workspaces:{workspaces:s}}=mt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(G6,{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 gl(u),i.jsx(Va,{})}const OP="_container_ce571_1",BP="_title_ce571_6",md={container:OP,title:BP};function LP(){return i.jsxs("div",{className:md.container,"aria-hidden":"true",children:[i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(dd,{lines:3},s))})]})}function ix(){const{environmentId:t,workspaceId:s}=fs(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=mt(),p=kt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Mp(v,s,t))},[p,s,t]);if(r)return i.jsx(LP,{});const g=s&&t?P1("Findings",s,t,d,u).slice(0,-1):b7();return i.jsxs("div",{className:md.container,"data-testid":"findings-list-page",children:[i.jsx(Ns,{segments:g}),i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx(w1,{findings:o,onFindingClick:m})]})}const zP="_container_1wwpb_1",$P="_notFound_1wwpb_6",UP="_header_1wwpb_12",PP="_categoryBadge_1wwpb_19",HP="_title_1wwpb_28",VP="_content_1wwpb_35",qP="_tags_1wwpb_77",GP="_tag_1wwpb_77",FP="_meta_1wwpb_92",ZP="_metaTimestamp_1wwpb_100",KP="_metaLink_1wwpb_105",mn={container:zP,notFound:$P,header:UP,categoryBadge:PP,title:HP,content:VP,tags:qP,tag:GP,meta:FP,metaTimestamp:ZP,metaLink:KP};function ox(){const{findingId:t,environmentId:s,workspaceId:o}=fs(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=mt(),m=kt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Finding not found."})});const g=P1(r.title,o,s,u,p),v=fd(r.category);return i.jsxs("div",{className:mn.container,"data-testid":"finding-detail-page",children:[i.jsx(Ns,{segments:g}),i.jsxs("div",{className:mn.header,children:[i.jsx("span",{className:mn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:mn.title,children:r.title})]}),r.content&&i.jsx("div",{className:mn.content,children:i.jsx(hd,{remarkPlugins:[gd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:mn.tags,children:r.tags.map(b=>i.jsx("span",{className:mn.tag,children:b},b))}),i.jsxs("div",{className:mn.meta,children:[i.jsx("span",{className:mn.metaTimestamp,title:r.createdAt,children:Qm(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(hm(r.sessionId))},children:"View Session"})]})]})}const YP="_wizard_1260s_1",JP="_container_1260s_10",WP="_stepContent_1260s_19",XP="_logoArea_1260s_28",QP="_logoImage_1260s_32",e9="_heading_1260s_41",t9="_tagline_1260s_49",n9="_subtitle_1260s_56",s9="_featureList_1260s_64",a9="_runtimeGrid_1260s_89",i9="_runtimeCard_1260s_101",o9="_runtimeName_1260s_133",r9="_runtimeDescription_1260s_139",l9="_buttonRow_1260s_144",c9="_primaryButton_1260s_151",d9="_ghostButton_1260s_185",u9="_dots_1260s_213",f9="_dot_1260s_213",Fe={wizard:YP,container:JP,stepContent:WP,logoArea:XP,logoImage:QP,heading:e9,tagline:t9,subtitle:n9,featureList:s9,runtimeGrid:a9,runtimeCard:i9,runtimeName:o9,runtimeDescription:r9,buttonRow:l9,primaryButton:c9,ghostButton:d9,dots:u9,dot:f9};function p9({onNext:t}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Fe.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Fe.logoImage})}),i.jsx("h1",{className:Fe.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Fe.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function m9({onNext:t,onBack:s}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Fe.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Fe.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:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const h9=[{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 g9({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Fe.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Fe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Fe.runtimeGrid,children:h9.map(u=>i.jsxs("button",{type:"button",className:Fe.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:Fe.runtimeName,children:u.name}),i.jsx("span",{className:Fe.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function v9(){return typeof Notification<"u"}function y9({onFinish:t,onBack:s,finishDisabled:o}){const r=v9(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Fe.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Fe.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:Fe.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:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const b9=4,rx={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function x9(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=mt(),{showToast:c}=Sn(),d=kt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),x=t.find(w=>w.id==="claude-code"),S=y.useCallback(w=>{g(w),p(3)},[]),k=y.useCallback(()=>{const w=m;b(!0);const N=[];if(x&&w!==x.runtime){const C=rx[w]??"sonnet";N.push(s(x.id,void 0,void 0,void 0,w,C))}const T=t.find(C=>C.id===W0);if(T&&w!==T.runtime){const C=rx[w]??"sonnet";N.push(s(W0,void 0,void 0,void 0,w,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,x,t,s,o,d,c]);return r===!0?i.jsx(ds,{to:"/",replace:!0}):i.jsx("div",{className:Fe.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Fe.container,children:[i.jsx(us,{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(p9,{onNext:()=>p(1)}),u===1&&i.jsx(m9,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(g9,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!x}),u===3&&i.jsx(y9,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Fe.dots,children:Array.from({length:b9},(w,N)=>i.jsx("span",{className:Fe.dot,"data-active":N===u},N))})]})})}const _9="_root_zndgp_1",k9="_body_zndgp_7",S9="_main_zndgp_19",T9="_sidebarWrapper_zndgp_26",w9="_overlay_zndgp_51",Zr={root:_9,body:k9,main:S9,sidebarWrapper:T9,overlay:w9},j9=y.lazy(()=>DT(()=>import("./KnowledgePage-BJrUmsbY.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),V1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function N9(){const{connected:t,environments:{environments:s},sessions:{sessions:o},tasks:{tasks:r}}=mt(),{toasts:c,dismissToast:d}=Sn(),u=Zt(),p=o7(),m=p!==void 0,[g,v]=y.useState(!1),b=y.useCallback(()=>v(x=>!x),[]);return y.useEffect(()=>{v(!1)},[u.pathname]),y.useEffect(()=>{if(!g)return;const x=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[g]),i.jsxs(i.Fragment,{children:[i.jsx(t5,{connected:t,environments:s,sessions:o,onToggleSidebar:m?b:void 0,sidebarOpen:g}),i.jsx(l5,{}),i.jsxs("div",{className:Zr.body,children:[m&&i.jsx("div",{className:Zr.sidebarWrapper,"data-sidebar-open":g,children:i.jsx(m5,{content:p})}),m&&g&&i.jsx("div",{className:Zr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),i.jsxs("div",{className:Zr.main,children:[i.jsx(Va,{}),i.jsx(k5,{sessions:o,tasks:r,environments:s})]})]}),i.jsx(OI,{toasts:c,onDismiss:d}),i.jsx(EP,{})]})}function C9(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=mt(),{showToast:p}=Sn();iz(s,p),dz(c,p),oz(o,r,p);const m=kt(),g=Zt();return y.useEffect(()=>{t&&!g.pathname.includes("/tasks/")&&m(hm(t),{replace:!0})},[t,m,g.pathname]),d&&u===!1?i.jsx(ds,{to:"/setup",replace:!0}):i.jsx(i7,{children:i.jsxs("div",{className:Zr.root,children:[V1&&i.jsx(RN,{}),i.jsx(N9,{})]})})}function Cp(){const{workspaceId:t}=fs(),{workspaces:{workspaces:s}}=mt(),o=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ds,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ds,{to:p,replace:!0})}function E9(){return i.jsxs(vj,{children:[i.jsx(Ae,{path:"setup",element:i.jsx(x9,{})}),i.jsxs(Ae,{element:i.jsx(C9,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(J$,{})}),i.jsx(Ae,{path:"chat",element:i.jsx(oU,{})}),i.jsx(Ae,{path:"sessions/new",element:i.jsx(rU,{})}),i.jsx(Ae,{path:"sessions/:sessionId",element:i.jsx(uU,{})}),i.jsx(Ae,{element:i.jsx(IP,{}),children:i.jsx(Ae,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(h1,{}),children:i.jsx(j9,{})})})}),i.jsxs(Ae,{element:i.jsx(AP,{}),children:[i.jsx(Ae,{path:"tasks",element:i.jsx(K$,{})}),i.jsx(Ae,{path:"tasks/new",element:i.jsx(ex,{})}),i.jsx(Ae,{path:"tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/findings",element:i.jsx(Ia,{})})]}),i.jsxs(Ae,{element:i.jsx(MP,{}),children:[i.jsx(Ae,{path:"findings",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"findings/:findingId",element:i.jsx(ox,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(ox,{})})]}),i.jsxs(Ae,{element:i.jsx(DP,{}),children:[i.jsx(Ae,{path:"workspaces",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"workspaces/new",element:i.jsx(jU,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(hU,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(ex,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Ia,{})}),i.jsxs(Ae,{path:"environments",element:i.jsx(MU,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(Y$,{})}),i.jsx(Ae,{path:"new",element:i.jsx(CU,{})}),i.jsx(Ae,{path:":environmentId",element:i.jsx(cP,{})}),i.jsx(Ae,{path:":environmentId/edit",element:i.jsx(EU,{})})]})]}),i.jsx(Ae,{element:i.jsx(RP,{}),children:i.jsxs(Ae,{path:"settings",element:i.jsx(fP,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(ds,{to:"credentials",replace:!0})}),i.jsx(Ae,{path:"environments",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"credentials",element:i.jsx(pP,{})}),i.jsx(Ae,{path:"tokens",element:i.jsx(ds,{to:"../credentials",replace:!0})}),i.jsx(Ae,{path:"personas",element:i.jsx(mP,{})}),i.jsx(Ae,{path:"personas/new",element:i.jsx(sx,{})}),i.jsx(Ae,{path:"personas/:personaId",element:i.jsx(sx,{})}),i.jsx(Ae,{path:"appearance",element:i.jsx(wP,{})}),i.jsx(Ae,{path:"shortcuts",element:i.jsx(CP,{})}),i.jsx(Ae,{path:"about",element:i.jsx(NP,{})})]})}),i.jsx(Ae,{path:"*",element:i.jsx(ds,{to:"/",replace:!0})})]})]})}const A9=1e4;function D9(){const{onboardingCompleted:t}=mt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),A9);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(us,{mode:"wait",children:r?i.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(h1,{})},"splash"):i.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(Hj,{basename:"/".replace(/\/$/,""),children:i.jsx(E9,{})})},"app")})}function R9(){const t=V1?I7:az;return i.jsx(a7,{children:i.jsx(e7,{children:i.jsx(t,{children:i.jsx(D9,{})})})})}CT.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(R9,{})}));export{Ns as B,Lx as K,mt as a,Mp as f,hm as s,On as t,kt as u};
715
+ $\`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(qb,{selectedTools:Q,onChange:ie=>{$(ie),ve(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ie),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!pe&&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(Ei,{isOpen:H,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:_e,onCancel:()=>ue(!1)})]})}function wP(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=I1();return i.jsx(HO,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function jP(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ne.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function NP(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=mt(),r=jP();return i.jsxs(i.Fragment,{children:[r&&i.jsx(FI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(VO,{connected:t,environments:s,sessions:o})]})}function CP(){return i.jsx(DL,{})}const ax=Ri();function EP(){const t=kt();return Qs({key:"?"},()=>{t(nN)}),Qs({key:"n"},()=>{t(ax)}),Qs({key:"N"},()=>{t(ax)}),i.jsx(i.Fragment,{})}function gl(t){const s=r7();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function AP(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=mt(),o=y.useMemo(()=>i.jsx(kI,{workspaces:t,tasks:s}),[t,s]);return gl(o),i.jsx(Va,{})}function DP(){const{environments:{environments:t}}=mt(),s=y.useMemo(()=>i.jsx(R5,{environments:t}),[t]);return gl(s),i.jsx(Va,{})}function RP(){const t=y.useMemo(()=>i.jsx(p8,{}),[]);return gl(t),i.jsx(Va,{})}function MP(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=mt(),{workspaceId:r,environmentId:c}=fs();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>i.jsx(V5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return gl(d),i.jsx(Va,{})}function IP(){const{knowledge:t,workspaces:{workspaces:s}}=mt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(G6,{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 gl(u),i.jsx(Va,{})}const OP="_container_ce571_1",BP="_title_ce571_6",md={container:OP,title:BP};function LP(){return i.jsxs("div",{className:md.container,"aria-hidden":"true",children:[i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(dd,{lines:3},s))})]})}function ix(){const{environmentId:t,workspaceId:s}=fs(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=mt(),p=kt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Mp(v,s,t))},[p,s,t]);if(r)return i.jsx(LP,{});const g=s&&t?P1("Findings",s,t,d,u).slice(0,-1):b7();return i.jsxs("div",{className:md.container,"data-testid":"findings-list-page",children:[i.jsx(Ns,{segments:g}),i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx(w1,{findings:o,onFindingClick:m})]})}const zP="_container_1wwpb_1",$P="_notFound_1wwpb_6",UP="_header_1wwpb_12",PP="_categoryBadge_1wwpb_19",HP="_title_1wwpb_28",VP="_content_1wwpb_35",qP="_tags_1wwpb_77",GP="_tag_1wwpb_77",FP="_meta_1wwpb_92",ZP="_metaTimestamp_1wwpb_100",KP="_metaLink_1wwpb_105",mn={container:zP,notFound:$P,header:UP,categoryBadge:PP,title:HP,content:VP,tags:qP,tag:GP,meta:FP,metaTimestamp:ZP,metaLink:KP};function ox(){const{findingId:t,environmentId:s,workspaceId:o}=fs(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=mt(),m=kt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Finding not found."})});const g=P1(r.title,o,s,u,p),v=fd(r.category);return i.jsxs("div",{className:mn.container,"data-testid":"finding-detail-page",children:[i.jsx(Ns,{segments:g}),i.jsxs("div",{className:mn.header,children:[i.jsx("span",{className:mn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:mn.title,children:r.title})]}),r.content&&i.jsx("div",{className:mn.content,children:i.jsx(hd,{remarkPlugins:[gd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:mn.tags,children:r.tags.map(b=>i.jsx("span",{className:mn.tag,children:b},b))}),i.jsxs("div",{className:mn.meta,children:[i.jsx("span",{className:mn.metaTimestamp,title:r.createdAt,children:Qm(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(hm(r.sessionId))},children:"View Session"})]})]})}const YP="_wizard_1260s_1",JP="_container_1260s_10",WP="_stepContent_1260s_19",XP="_logoArea_1260s_28",QP="_logoImage_1260s_32",e9="_heading_1260s_41",t9="_tagline_1260s_49",n9="_subtitle_1260s_56",s9="_featureList_1260s_64",a9="_runtimeGrid_1260s_89",i9="_runtimeCard_1260s_101",o9="_runtimeName_1260s_133",r9="_runtimeDescription_1260s_139",l9="_buttonRow_1260s_144",c9="_primaryButton_1260s_151",d9="_ghostButton_1260s_185",u9="_dots_1260s_213",f9="_dot_1260s_213",Fe={wizard:YP,container:JP,stepContent:WP,logoArea:XP,logoImage:QP,heading:e9,tagline:t9,subtitle:n9,featureList:s9,runtimeGrid:a9,runtimeCard:i9,runtimeName:o9,runtimeDescription:r9,buttonRow:l9,primaryButton:c9,ghostButton:d9,dots:u9,dot:f9};function p9({onNext:t}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Fe.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Fe.logoImage})}),i.jsx("h1",{className:Fe.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Fe.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function m9({onNext:t,onBack:s}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Fe.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Fe.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:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const h9=[{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 g9({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Fe.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Fe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Fe.runtimeGrid,children:h9.map(u=>i.jsxs("button",{type:"button",className:Fe.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:Fe.runtimeName,children:u.name}),i.jsx("span",{className:Fe.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function v9(){return typeof Notification<"u"}function y9({onFinish:t,onBack:s,finishDisabled:o}){const r=v9(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Fe.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Fe.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:Fe.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:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const b9=4,rx={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function x9(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=mt(),{showToast:c}=Sn(),d=kt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),x=t.find(w=>w.id==="claude-code"),S=y.useCallback(w=>{g(w),p(3)},[]),k=y.useCallback(()=>{const w=m;b(!0);const N=[];if(x&&w!==x.runtime){const C=rx[w]??"sonnet";N.push(s(x.id,void 0,void 0,void 0,w,C))}const T=t.find(C=>C.id===W0);if(T&&w!==T.runtime){const C=rx[w]??"sonnet";N.push(s(W0,void 0,void 0,void 0,w,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,x,t,s,o,d,c]);return r===!0?i.jsx(ds,{to:"/",replace:!0}):i.jsx("div",{className:Fe.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Fe.container,children:[i.jsx(us,{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(p9,{onNext:()=>p(1)}),u===1&&i.jsx(m9,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(g9,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!x}),u===3&&i.jsx(y9,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Fe.dots,children:Array.from({length:b9},(w,N)=>i.jsx("span",{className:Fe.dot,"data-active":N===u},N))})]})})}const _9="_root_zndgp_1",k9="_body_zndgp_7",S9="_main_zndgp_19",T9="_sidebarWrapper_zndgp_26",w9="_overlay_zndgp_51",Zr={root:_9,body:k9,main:S9,sidebarWrapper:T9,overlay:w9},j9=y.lazy(()=>DT(()=>import("./KnowledgePage-DzeT3FFx.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),V1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function N9(){const{connected:t,environments:{environments:s},sessions:{sessions:o},tasks:{tasks:r}}=mt(),{toasts:c,dismissToast:d}=Sn(),u=Zt(),p=o7(),m=p!==void 0,[g,v]=y.useState(!1),b=y.useCallback(()=>v(x=>!x),[]);return y.useEffect(()=>{v(!1)},[u.pathname]),y.useEffect(()=>{if(!g)return;const x=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[g]),i.jsxs(i.Fragment,{children:[i.jsx(t5,{connected:t,environments:s,sessions:o,onToggleSidebar:m?b:void 0,sidebarOpen:g}),i.jsx(l5,{}),i.jsxs("div",{className:Zr.body,children:[m&&i.jsx("div",{className:Zr.sidebarWrapper,"data-sidebar-open":g,children:i.jsx(m5,{content:p})}),m&&g&&i.jsx("div",{className:Zr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),i.jsxs("div",{className:Zr.main,children:[i.jsx(Va,{}),i.jsx(k5,{sessions:o,tasks:r,environments:s})]})]}),i.jsx(OI,{toasts:c,onDismiss:d}),i.jsx(EP,{})]})}function C9(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=mt(),{showToast:p}=Sn();iz(s,p),dz(c,p),oz(o,r,p);const m=kt(),g=Zt();return y.useEffect(()=>{t&&!g.pathname.includes("/tasks/")&&m(hm(t),{replace:!0})},[t,m,g.pathname]),d&&u===!1?i.jsx(ds,{to:"/setup",replace:!0}):i.jsx(i7,{children:i.jsxs("div",{className:Zr.root,children:[V1&&i.jsx(RN,{}),i.jsx(N9,{})]})})}function Cp(){const{workspaceId:t}=fs(),{workspaces:{workspaces:s}}=mt(),o=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ds,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ds,{to:p,replace:!0})}function E9(){return i.jsxs(vj,{children:[i.jsx(Ae,{path:"setup",element:i.jsx(x9,{})}),i.jsxs(Ae,{element:i.jsx(C9,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(J$,{})}),i.jsx(Ae,{path:"chat",element:i.jsx(oU,{})}),i.jsx(Ae,{path:"sessions/new",element:i.jsx(rU,{})}),i.jsx(Ae,{path:"sessions/:sessionId",element:i.jsx(uU,{})}),i.jsx(Ae,{element:i.jsx(IP,{}),children:i.jsx(Ae,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(h1,{}),children:i.jsx(j9,{})})})}),i.jsxs(Ae,{element:i.jsx(AP,{}),children:[i.jsx(Ae,{path:"tasks",element:i.jsx(K$,{})}),i.jsx(Ae,{path:"tasks/new",element:i.jsx(ex,{})}),i.jsx(Ae,{path:"tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/findings",element:i.jsx(Ia,{})})]}),i.jsxs(Ae,{element:i.jsx(MP,{}),children:[i.jsx(Ae,{path:"findings",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"findings/:findingId",element:i.jsx(ox,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(ox,{})})]}),i.jsxs(Ae,{element:i.jsx(DP,{}),children:[i.jsx(Ae,{path:"workspaces",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"workspaces/new",element:i.jsx(jU,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(hU,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(ex,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Ia,{})}),i.jsxs(Ae,{path:"environments",element:i.jsx(MU,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(Y$,{})}),i.jsx(Ae,{path:"new",element:i.jsx(CU,{})}),i.jsx(Ae,{path:":environmentId",element:i.jsx(cP,{})}),i.jsx(Ae,{path:":environmentId/edit",element:i.jsx(EU,{})})]})]}),i.jsx(Ae,{element:i.jsx(RP,{}),children:i.jsxs(Ae,{path:"settings",element:i.jsx(fP,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(ds,{to:"credentials",replace:!0})}),i.jsx(Ae,{path:"environments",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"credentials",element:i.jsx(pP,{})}),i.jsx(Ae,{path:"tokens",element:i.jsx(ds,{to:"../credentials",replace:!0})}),i.jsx(Ae,{path:"personas",element:i.jsx(mP,{})}),i.jsx(Ae,{path:"personas/new",element:i.jsx(sx,{})}),i.jsx(Ae,{path:"personas/:personaId",element:i.jsx(sx,{})}),i.jsx(Ae,{path:"appearance",element:i.jsx(wP,{})}),i.jsx(Ae,{path:"shortcuts",element:i.jsx(CP,{})}),i.jsx(Ae,{path:"about",element:i.jsx(NP,{})})]})}),i.jsx(Ae,{path:"*",element:i.jsx(ds,{to:"/",replace:!0})})]})]})}const A9=1e4;function D9(){const{onboardingCompleted:t}=mt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),A9);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(us,{mode:"wait",children:r?i.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(h1,{})},"splash"):i.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(Hj,{basename:"/".replace(/\/$/,""),children:i.jsx(E9,{})})},"app")})}function R9(){const t=V1?I7:az;return i.jsx(a7,{children:i.jsx(e7,{children:i.jsx(t,{children:i.jsx(D9,{})})})})}CT.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(R9,{})}));export{Ns as B,Lx as K,mt as a,Mp as f,hm as s,On as t,kt 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-D_SccLJc.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-CSO6PNIo.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-tHPW3Rz3.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/grpc-CkqXCGns.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.96.3",
3
+ "version": "0.98.0",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
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.96.3",
42
- "@grackle-ai/web-components": "0.83.2"
41
+ "@grackle-ai/web-components": "0.83.2",
42
+ "@grackle-ai/common": "0.98.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@rushstack/heft": "1.2.7",