@grackle-ai/web 0.126.1 → 0.127.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,l as rt,b as A,z as it,s as T,m as st,n as X,j as N}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-CaNPCfQt.js";import"./grpc-pBcDZw1z.js";import"./markdown-CPoGw-1N.js";function ht(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 dt(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 gt(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 xt(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 _t(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function yt(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 vt(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 mt(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 pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(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 kt(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 jt(t){return t[0]}function At(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 P(t,e,n){var o=new U(e??jt,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(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=P.prototype=U.prototype;R.copy=function(){var t=new U(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=dt;R.addAll=gt;R.cover=xt;R.data=_t;R.extent=yt;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=kt;R.x=At;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(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=P(e,It,Lt).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,M,I){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||M<h-g||b>p+g||I<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 Et(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 Dt(t){var e=Et,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,M,I,k,D,g;m<f;++m)x=t[m],b=x.source,M=x.target,I=M.x+M.vx-b.x-b.vx||S(i),k=M.y+M.vy-b.y-b.vy||S(i),D=Math.sqrt(I*I+k*k),D=(D-r[m])/D*a*o[m],I*=D,k*=D,M.vx-=I*(g=y[m]),M.vy-=k*g,b.vx+=I*(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,M)=>[e(b,M,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 Bt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Bt*t+zt)%Q)/Q}function St(t){return t.x}function $t(t){return t.y}var Gt=10,Ot=Math.PI*(3-Math.sqrt(5));function Ft(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=Tt();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=Gt*Math.sqrt(.5+l),m=l*Ot;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,M,I,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)I=t[f],x=l-I.x,b=a-I.y,M=x*x+b*b,M<u&&(k=I,u=M);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){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=P(t,St,$t).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 Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},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 te(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 ee({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 M of b)h({width:M.contentRect.width,height:M.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 M=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);M.append("title").text(g=>g.type),y.current=M;const I=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=I,I.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),I.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),I.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=Ft(m).force("link",Dt(b).id(g=>g.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(_.width/2,_.height/2)).force("collide",Rt($/2+16)).on("tick",()=>{M.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),I.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 I.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=te(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 ne="_panel_1ml6r_1",re="_header_1ml6r_24",ie="_title_1ml6r_32",se="_closeButton_1ml6r_42",ae="_body_1ml6r_55",oe="_badge_1ml6r_61",ce="_section_1ml6r_72",le="_sectionLabel_1ml6r_76",ue="_content_1ml6r_84",fe="_tags_1ml6r_92",he="_tag_1ml6r_92",de="_viewLink_1ml6r_107",ge="_edgeList_1ml6r_121",xe="_edgeItem_1ml6r_127",_e="_edgeType_1ml6r_136",ye="_edgeNodeLink_1ml6r_142",ve="_timestamps_1ml6r_154",C={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:_e,edgeNodeLink:ye,timestamps:ve};function me({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(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return N.jsxs("div",{className:C.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:C.header,children:[N.jsx("h3",{className:C.title,children:r.label}),N.jsx("button",{className:C.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:C.body,children:[N.jsx("div",{className:C.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Content"}),N.jsx("p",{className:C.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Tags"}),N.jsx("div",{className:C.tags,children:r.tags.map(i=>N.jsx("span",{className:C.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:C.section,children:N.jsx("button",{className:C.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:C.section,children:[N.jsxs("div",{className:C.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:C.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:C.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:C.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:C.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:C.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 pe="_layout_n9vg6_1",we="_graphArea_n9vg6_8",Ne="_empty_n9vg6_15",H={layout:pe,graphArea:we,empty:Ne};function Me(){const{knowledge:t}=lt();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:ft}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ut,{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(ee,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(me,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
1
+ import{t as nt,l as rt,b as A,z as it,s as T,m as st,n as X,j as N}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-Bm2vqhAx.js";import"./grpc-pBcDZw1z.js";import"./markdown-CPoGw-1N.js";function ht(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 dt(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 gt(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 xt(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 _t(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function yt(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 vt(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 mt(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 pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(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 kt(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 jt(t){return t[0]}function At(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 P(t,e,n){var o=new U(e??jt,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(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=P.prototype=U.prototype;R.copy=function(){var t=new U(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=dt;R.addAll=gt;R.cover=xt;R.data=_t;R.extent=yt;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=kt;R.x=At;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(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=P(e,It,Lt).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,M,I){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||M<h-g||b>p+g||I<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 Et(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 Dt(t){var e=Et,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,M,I,k,D,g;m<f;++m)x=t[m],b=x.source,M=x.target,I=M.x+M.vx-b.x-b.vx||S(i),k=M.y+M.vy-b.y-b.vy||S(i),D=Math.sqrt(I*I+k*k),D=(D-r[m])/D*a*o[m],I*=D,k*=D,M.vx-=I*(g=y[m]),M.vy-=k*g,b.vx+=I*(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,M)=>[e(b,M,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 Bt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Bt*t+zt)%Q)/Q}function St(t){return t.x}function $t(t){return t.y}var Gt=10,Ot=Math.PI*(3-Math.sqrt(5));function Ft(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=Tt();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=Gt*Math.sqrt(.5+l),m=l*Ot;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,M,I,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)I=t[f],x=l-I.x,b=a-I.y,M=x*x+b*b,M<u&&(k=I,u=M);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){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=P(t,St,$t).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 Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},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 te(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 ee({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 M of b)h({width:M.contentRect.width,height:M.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 M=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);M.append("title").text(g=>g.type),y.current=M;const I=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=I,I.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),I.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),I.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=Ft(m).force("link",Dt(b).id(g=>g.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(_.width/2,_.height/2)).force("collide",Rt($/2+16)).on("tick",()=>{M.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),I.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 I.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=te(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 ne="_panel_1ml6r_1",re="_header_1ml6r_24",ie="_title_1ml6r_32",se="_closeButton_1ml6r_42",ae="_body_1ml6r_55",oe="_badge_1ml6r_61",ce="_section_1ml6r_72",le="_sectionLabel_1ml6r_76",ue="_content_1ml6r_84",fe="_tags_1ml6r_92",he="_tag_1ml6r_92",de="_viewLink_1ml6r_107",ge="_edgeList_1ml6r_121",xe="_edgeItem_1ml6r_127",_e="_edgeType_1ml6r_136",ye="_edgeNodeLink_1ml6r_142",ve="_timestamps_1ml6r_154",C={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:_e,edgeNodeLink:ye,timestamps:ve};function me({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(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return N.jsxs("div",{className:C.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:C.header,children:[N.jsx("h3",{className:C.title,children:r.label}),N.jsx("button",{className:C.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:C.body,children:[N.jsx("div",{className:C.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Content"}),N.jsx("p",{className:C.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Tags"}),N.jsx("div",{className:C.tags,children:r.tags.map(i=>N.jsx("span",{className:C.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:C.section,children:N.jsx("button",{className:C.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:C.section,children:[N.jsxs("div",{className:C.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:C.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:C.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:C.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:C.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:C.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 pe="_layout_n9vg6_1",we="_graphArea_n9vg6_8",Ne="_empty_n9vg6_15",H={layout:pe,graphArea:we,empty:Ne};function Me(){const{knowledge:t}=lt();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:ft}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ut,{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(ee,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(me,{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/McpAppWidget-Bltki2U6.js","assets/dagview-B70jDsRo.js","assets/grpc-pBcDZw1z.js","assets/KnowledgePage-DQXY0aaB.js","assets/markdown-CPoGw-1N.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-Bltki2U6.js","assets/dagview-B70jDsRo.js","assets/grpc-pBcDZw1z.js","assets/KnowledgePage-C1NEElgV.js","assets/markdown-CPoGw-1N.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
2
  import{r as H2,a as P2,b as y,j as a,d as ld,H as Bo,P as Lo,i as M_,B as R_,c as I_,C as O_,M as B_,e as U2,f as Mc,h as V2,k as q2}from"./dagview-B70jDsRo.js";import{c as G2,a as xd,G as F2,b as K2,d as Z2,e as Y2,f as J2,M as W2,D as L_,A as z_,W as X2,O as Q2,g as ej,C as da,h as $_,i as H_,w as tj,t as nj,p as Rc,j as sj,R as Ic,S as py}from"./grpc-pBcDZw1z.js";import{v as aj,r as ij,t as Oc,i as oj,f as rj,M as _m,a as xm}from"./markdown-CPoGw-1N.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:{}},zr={},Yf={exports:{}},Jf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -322,7 +322,7 @@ ${r.content}`);break}}}return s.join(`
322
322
 
323
323
  ${r}
324
324
 
325
- --- End forwarded ---`}function xI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function kI({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(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),N=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=T;A<=N;A++)A<t.length&&ul(t[A])&&D.add(A);return D})}else d(T=>{const N=new Set(T);return N.has(S)?N.delete(S):N.add(S),N.size===0?(r(!1),u.current=void 0):u.current=S,N})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)ul(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((N,C)=>N-C).filter(N=>N<t.length).map(N=>t[N]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const SI="_wrapper_1cdza_1",jI="_scrollContainer_1cdza_9",TI="_selectingPadding_1cdza_16",NI="_toolbar_1cdza_20",wI="_directionToggle_1cdza_27",CI="_scrollToAnchor_1cdza_65",EI="_scrollToAnchorBottom_1cdza_89",AI="_scrollToAnchorTop_1cdza_93",DI="_eventOverflowWarning_1cdza_97",oa={wrapper:SI,scrollContainer:jI,selectingPadding:TI,toolbar:NI,directionToggle:wI,scrollToAnchor:CI,scrollToAnchorBottom:EI,scrollToAnchorTop:AI,eventOverflowWarning:DI},MI=10*1024,RI=new Set(["running","idle"]);function II(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 W1="grackle-stream-direction";function OI(){try{return localStorage.getItem(W1)==="reversed"}catch{return!1}}function BI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(Sm,{size:Ht,"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 mh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(OI),k=Z4(),[S,j]=y.useState(!1),[T,N]=y.useState(!1),[C,D]=y.useState(void 0),A=kI({events:t,formatForClipboard:J1}),E=y.useMemo(()=>t.filter(ul).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>RI.has(ce.status)&&ce.id!==d):[],[c,d]),O=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=vI({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(W1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,T]);const V=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),ne=y.useCallback(()=>[...A.selectedIndices].sort((me,xe)=>me-xe).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const xe=u==null?void 0:u.find(De=>De.id===me.environmentId);return(xe==null?void 0:xe.displayName)??me.environmentId.slice(0,8)},[c,u]),Z=y.useCallback(async(ce,me)=>{if(!m)return;const xe=le(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${xe}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,A]),se=y.useCallback(ce=>{j(!1);const me=ne(),xe=le(d),De=_I(xe,me);if(new TextEncoder().encode(De).length>MI){D({sessionId:ce,text:De}),N(!0);return}Z(ce,De).catch(()=>{})},[ne,le,d,Z]),H=y.useCallback(()=>{N(!1),C&&(Z(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,Z]),B=y.useCallback(()=>{N(!1),D(void 0)},[]),F=k?0:.2,ge=b?-8:8,ee=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Ci,{text:b?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?a.jsx(xy,{size:Ht,"aria-hidden":"true"}):a.jsx(ky,{size:Ht,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(BI,{eventsDropped:s}),a.jsx(os,{initial:!1,children:O.map((ce,me)=>{const xe=b?t.length-1-me:me;return a.jsx(Pt.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:F,ease:"easeOut"},children:a.jsx(L6,{copyText:bI(ce),isContentBearing:ul(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(xe),checkboxLabel:II(ce),onSelect:()=>{A.enterSelectionMode(xe)},onToggle:De=>{A.toggleEvent(xe,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(kD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${xe}`)})})]}),a.jsx(os,{children:A.isSelecting&&a.jsx(F6,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{V().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),a.jsx(mI,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:se,onCancel:()=>{j(!1)}}),a.jsx(_s,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${ee} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:B}),a.jsx(os,{children:!M&&a.jsxs(Pt.button,{className:`${oa.scrollToAnchor} ${b?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:$,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:[b?a.jsx(ky,{size:Ht,"aria-hidden":"true"}):a.jsx(xy,{size:Ht,"aria-hidden":"true"})," New events"]})})]})}function hh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(O=>{v(O),_("")},[]),T=y.useCallback(()=>{_("")},[]),N=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(O===M){N();return}o(O),N()},[g,s,m,r,o,N]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(O=>{if(k.current){k.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?N():O.key==="Enter"&&p&&C()},[N,p,C]),R=(()=>{if(!S)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:N,save:C,setDraft:j,clearError:T,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const LI="_editFieldWrapper_yuzty_1",zI="_editInput_yuzty_10",$I="_editTextarea_yuzty_42",HI="_editSelect_yuzty_78",PI="_editError_yuzty_111",UI="_editInputInvalid_yuzty_118",VI="_editHint_yuzty_123",qI="_unsavedDot_yuzty_132",GI="_metaValueClickable_yuzty_140",FI="_editButton_yuzty_159",KI="_metaPlaceholder_yuzty_175",ZI="_worktreeToggle_yuzty_180",it={editFieldWrapper:LI,editInput:zI,editTextarea:$I,editSelect:HI,editError:PI,editInputInvalid:UI,editHint:VI,unsavedDot:qI,metaValueClickable:GI,editButton:FI,metaPlaceholder:KI,worktreeToggle:ZI};function zt(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:_,"data-testid":k}=t,S=y.useRef(null),j=hh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const N=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(N)}},[j.isEditing]),c==="create"){const N=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:N,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:N=>j.setDraft(N.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function fm(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":_}=t,k=y.useRef(null),S=hh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var N;(N=k.current)==null||N.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},N=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${N?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),N&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:N})]})}if(S.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function bd(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":_}=t,k=y.useRef(null),S=hh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const j=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return a.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});const N=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function YI(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const JI="_nav_1snmp_1",WI="_searchForm_1snmp_8",XI="_searchInput_1snmp_15",QI="_searchButton_1snmp_33",e5="_clearButton_1snmp_68",t5="_workspaceSelect_1snmp_85",n5="_listHeader_1snmp_99",s5="_nodeList_1snmp_108",a5="_nodeItem_1snmp_116",i5="_indicator_1snmp_129",o5="_label_1snmp_136",r5="_badge_1snmp_145",es={nav:JI,searchForm:WI,searchInput:XI,searchButton:QI,clearButton:e5,workspaceSelect:t5,listHeader:n5,nodeList:s5,nodeItem:a5,indicator:i5,label:o5,badge:r5};function l5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:es.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:es.searchForm,onSubmit:v,children:[a.jsx("input",{className:es.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:es.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:es.clearButton,onClick:b,children:"Clear search"}),a.jsxs("select",{className:es.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:es.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:es.nodeList,children:t.map(S=>a.jsxs("li",{className:es.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:es.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:es.label,children:S.label}),a.jsx("span",{className:es.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const c5="_container_bwu10_1",d5="_hamburger_bwu10_33",u5="_brand_bwu10_49",f5="_brandLogo_bwu10_68",p5="_info_bwu10_75",m5="_connectionLabel_bwu10_90",h5="_connectionDot_bwu10_103",g5="_connected_bwu10_106",v5="_disconnected_bwu10_110",y5="_connecting_bwu10_113",Ms={container:c5,hamburger:d5,brand:u5,brandLogo:f5,info:p5,connectionLabel:m5,connectionDot:h5,connected:g5,disconnected:v5,connecting:y5},b5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},_5={connected:Ms.connected,connecting:Ms.connecting,disconnected:Ms.disconnected};function x5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=b5[t];return a.jsxs("div",{className:Ms.container,children:[r&&a.jsx("button",{type:"button",className:Ms.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(wT,{size:Et,"aria-hidden":"true"})}),a.jsx(Ci,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ms.brand,onClick:()=>d(Fo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:Id("icon-192x192.png"),alt:"",className:Ms.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ms.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ms.connectionDot} ${_5[t]}`,"aria-hidden":"true",children:a.jsx(Ni,{size:G_,fill:"currentColor"})})," ",a.jsx("span",{className:Ms.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const k5="_nav_gx5h3_1",S5="_tab_gx5h3_35",j5="_tabIcon_gx5h3_68",T5="_tabLabel_gx5h3_79",N5="_tabActive_gx5h3_84",w5="_tabEnd_gx5h3_90",wo={nav:k5,tab:S5,tabIcon:j5,tabLabel:T5,tabActive:N5,tabEnd:w5},ad=[{view:"dashboard",label:"Dashboard",icon:a.jsx(mT,{size:Et}),route:Fo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(Kj,{size:Et}),route:cC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(RT,{size:Et}),route:zo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(ET,{size:Et}),route:lC,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:a.jsx($j,{size:Et}),route:hx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(OT,{size:Et}),route:px,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(ZT,{size:Et}),route:sC,testId:"sidebar-tab-settings",align:"end"}];function C5(t){return t===Fo||t==="/"?"dashboard":t.startsWith(px)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(hx)?"knowledge":t.startsWith(ji)?"settings":"tasks"}function E5({tabs:t=ad}){var g;const s=Wt(),o=xt(),r=y.useRef(null),c=C5(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(N=>N===document.activeElement),k=_>=0?_:d.findIndex(N=>N.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return a.jsx("nav",{className:wo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return a.jsx(Ci,{text:v.label,placement:"bottom",className:_?wo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${wo.tab} ${b?wo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:wo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:wo.tabLabel,children:v.label})]})},v.view)})})}const A5="_container_pi6ii_1",D5="_content_pi6ii_66",n_={container:A5,content:D5},M5=320,X1=220,Q1=600,ek="grackle-sidebar-width";function R5(){try{const t=localStorage.getItem(ek);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=X1&&s<=Q1)return s}}catch{}return M5}function I5(t){try{localStorage.setItem(ek,String(t))}catch{}}function O5({content:t}){const[s]=y.useState(R5),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>=X1&&m<=Q1&&I5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:n_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:n_.content,children:t})})}const B5="_bar_tnfsh_1",L5="_btnPrimary_tnfsh_32",z5="_statusText_tnfsh_85",$5="_statusCompleted_tnfsh_90",H5="_statusFailed_tnfsh_94",P5="_statusBlocked_tnfsh_98",U5="_hintText_tnfsh_103",Ct={bar:B5,btnPrimary:L5,statusText:z5,statusCompleted:$5,statusFailed:H5,statusBlocked:P5,hintText:U5};function V5({sessions:t,tasks:s,environments:o}){const r=xt(),c=Wt(),d=nn("/sessions/:sessionId"),u=nn("/tasks/:taskId"),p=nn("/tasks/:taskId/stream"),m=nn("/tasks/:taskId/edit"),g=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=nn("/sessions/new"),k=nn("/environments/:environmentId/workspaces/:workspaceId"),S=nn("/tasks/new"),j=nn("/chat"),T=nn("/"),N=nn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,O=!!j,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!M&&!$&&!Y||!!N||(!!m||!!b)||Y||R||M)return a.jsx(a.Fragment,{});if(O)return o.find(se=>se.adapterType==="local"&&se.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Add a local environment to start chatting"})});if($)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Select a task or click + to create one"})});if(D){const Z=s.find(B=>B.id===D);if(!Z)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})});const se=new Map(s.map(B=>[B.id,B])),H=Z.dependsOn.some(B=>{const F=se.get(B);return F!==void 0&&F.status!=="complete"});if(Z.status==="not_started"){const B=H?Z.dependsOn.map(F=>se.get(F)).filter(F=>F&&F.status!=="complete").map(F=>F.title):[];return a.jsx("div",{className:Ct.bar,children:H?a.jsxs("span",{className:Ct.statusBlocked,children:["Blocked by: ",B.join(", ")]}):a.jsx("span",{className:Ct.hintText,children:"Use the buttons above to start or manage this task"})})}if(Z.status==="working"||Z.status==="paused"){const B=Z.latestSessionId||void 0,F=B?t.find(ee=>ee.id===B):void 0;return F&&F.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Waiting for agent..."})})}if(Z.status==="complete")return a.jsxs("div",{className:Ct.bar,children:[a.jsx("span",{className:`${Ct.statusText} ${Ct.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Ri(Z.workspaceId,void 0,E)),className:Ct.btnPrimary,children:"+ New Task"})]});if(Z.status==="failed")return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:`${Ct.statusText} ${Ct.statusFailed}`,children:"Task failed"})})}if(C){const Z=t.find(B=>B.id===C),se=(Z==null?void 0:Z.status)==="stopped";if(Z!==void 0&&!se)return a.jsx(a.Fragment,{});if(se)return a.jsxs("div",{className:Ct.bar,children:[a.jsxs("span",{className:`${Ct.statusText} ${Ct.hintText}`,children:["Session ",Z.endReason||Z.status]}),a.jsx("button",{onClick:()=>r(dx(Z.environmentId)),className:Ct.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})})}const q5="_nav_14i94_1",G5="_tab_14i94_24",F5="_tabActive_14i94_62",K5="_tabLabel_14i94_75",Z5="_statusDot_14i94_81",Y5="_pulse_14i94_87",J5="_addButton_14i94_99",W5="_empty_14i94_132",Ua={nav:q5,tab:G5,tabActive:F5,tabLabel:K5,statusDot:Z5,pulse:Y5,addButton:J5,empty:W5},X5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function Q5({environments:t}){const s=xt(),o=y.useRef(null),r=nn("/environments/:environmentId"),c=nn("/environments/:environmentId/edit"),d=nn("/environments/:environmentId/workspaces/:workspaceId"),u=nn("/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(_=>{s($o(_))},[s]),v=y.useCallback(_=>{var N;const k=(N=o.current)==null?void 0:N.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s($o(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Ua.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=X5[_.status]||"var(--text-tertiary)",T=_.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ua.tab} ${k?Ua.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${Ua.statusDot} ${T?Ua.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(Ni,{size:G_,fill:"currentColor"})}),a.jsx("span",{className:Ua.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),a.jsx("button",{type:"button",className:Ua.addButton,onClick:()=>s(tC),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:Ua.empty,children:"No environments yet."})]})}function eO(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 tk({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=eO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function tO(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 nO(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 iN){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ya(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=Ya(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const sO="_container_z4i38_1",aO="_header_z4i38_5",iO="_headerActions_z4i38_17",oO="_searchInput_z4i38_23",rO="_searchHighlight_z4i38_56",lO="_groupToggle_z4i38_62",cO="_groupToggleActive_z4i38_89",dO="_addButton_z4i38_93",uO="_taskRow_z4i38_120",fO="_selected_z4i38_140",pO="_expandArrow_z4i38_150",mO="_expanded_z4i38_157",hO="_leafSpacer_z4i38_161",gO="_taskStatusIcon_z4i38_166",vO="_taskTitle_z4i38_170",yO="_workspaceBadge_z4i38_177",bO="_childCountBadge_z4i38_195",_O="_dependencyBadge_z4i38_208",xO="_blockedBadge_z4i38_220",kO="_addChildButton_z4i38_225",SO="_emptyState_z4i38_268",jO="_statusGroupHeader_z4i38_275",TO="_statusGroupIcon_z4i38_294",NO="_statusGroupLabel_z4i38_298",wO="_statusGroupCount_z4i38_303",We={container:sO,header:aO,headerActions:iO,searchInput:oO,searchHighlight:rO,groupToggle:lO,groupToggleActive:cO,addButton:dO,taskRow:uO,selected:fO,expandArrow:pO,expanded:mO,leafSpacer:hO,taskStatusIcon:gO,taskTitle:vO,workspaceBadge:yO,childCountBadge:bO,dependencyBadge:_O,blockedBadge:xO,addChildButton:kO,emptyState:SO,statusGroupHeader:jO,statusGroupIcon:TO,statusGroupLabel:NO,statusGroupCount:wO},CO=[{name:"title",weight:2},{name:"description",weight:1}],nk=16,EO=16,sk="grackle-task-group-by-status";function s_(){try{return localStorage.getItem(sk)==="true"}catch{return!1}}function AO(t){try{localStorage.setItem(sk,String(t))}catch{}}function DO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:We.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${We.expandArrow} ${s?We.expanded:""}`,"aria-hidden":"true",children:a.jsx(pa,{size:Ye})}),a.jsx("span",{className:We.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:We.statusGroupLabel,children:t.label}),a.jsx("span",{className:We.statusGroupCount,children:t.tasks.length})]}),a.jsx(os,{children:s&&a.jsx(Pt.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=Ya(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(ls(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(ls(p.id)))},className:`${We.taskRow} ${g?We.selected:""}`,style:{"--task-indent":`${nk}px`},"data-task-id":p.id,children:[a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${fl(p.status)}`,children:m.icon}),a.jsx("span",{className:We.taskTitle,title:p.title,children:a.jsx(tk,{text:p.title,indices:d.get(p.id),highlightClass:We.searchHighlight})}),v&&a.jsx("span",{className:We.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ak({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ya(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(N=>u.get(N)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=nk+s*EO,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(ls(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:N=>{N.currentTarget===N.target&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),d(ls(t.id)))},className:`${We.taskRow} ${k?We.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&a.jsx("span",{className:`${We.expandArrow} ${b?We.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),r(t.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),r(t.id))},children:a.jsx(pa,{size:Ye,"aria-hidden":"true"})}),!_&&a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${fl(t.status)}`,children:g.icon}),a.jsx("span",{className:We.taskTitle,title:t.title,children:a.jsx(tk,{text:t.title,indices:p.get(t.id),highlightClass:We.searchHighlight})}),T&&a.jsx("span",{className:We.workspaceBadge,title:T,children:T}),_&&a.jsxs("span",{className:We.childCountBadge,children:[t.children.filter(N=>N.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${We.dependencyBadge} ${v?We.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<W2&&a.jsx(Ci,{text:"Add child task",children:a.jsx("button",{onClick:N=>{N.stopPropagation(),d(Ri(t.workspaceId,t.id))},"aria-label":"Add child task",className:We.addChildButton,children:"+"})})]}),a.jsx(os,{children:_&&b&&a.jsx(Pt.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(N=>a.jsx(ak,{node:N,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},N.id))})})]})}function MO({workspaces:t,tasks:s}){const o=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(s_),[g,v]=y.useState(s_),[b,_]=y.useState(new Map),k=nn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(Z=>[Z.id,Z.status])),[s]),T=y.useMemo(()=>new Map(t.map(Z=>[Z.id,Z.name])),[t]),N=()=>{const Z=!p;AO(Z),m(Z),Z&&(v(!0),_(new Map))},C=Z=>{_(se=>{const H=new Map(se),B=H.has(Z)?H.get(Z):g;return H.set(Z,!B),H})},D=Z=>b.has(Z)?b.get(Z):g,A=Z=>{c(se=>{const H=new Set(se);return H.has(Z)?(H.delete(Z),u(B=>new Set(B).add(Z))):(H.add(Z),u(B=>{const F=new Set(B);return F.delete(Z),F})),H})};y.useEffect(()=>{const Z=new Set(s.filter(se=>se.parentTaskId).map(se=>se.parentTaskId));Z.size>0&&c(se=>{const H=new Set(se);for(const B of Z)d.has(B)||H.add(B);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const Z=J2(s,E,CO),se=new Set(Z.map(ge=>ge.item.id)),H=new Map;for(const ge of Z){const ee=ge.matches.find(ce=>ce.key==="title");ee&&H.set(ge.item.id,ee.indices)}const B=new Set(se),F=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...se]){let ee=F.get(ge);for(;ee!=null&&ee.parentTaskId;)B.add(ee.parentTaskId),ee=F.get(ee.parentTaskId)}return{directMatchTaskIds:se,treeMatchTaskIds:B,titleHighlights:H}},[E,s]),Y=O!==null,V=Y?p?O:M:null,ne=V?s.filter(Z=>V.has(Z.id)):s,le=p?[]:tO(ne);return a.jsxs("div",{className:We.container,children:[a.jsxs("div",{className:We.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:We.headerActions,children:[a.jsx(Ci,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${We.groupToggle} ${p?We.groupToggleActive:""}`,onClick:N,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(ST,{size:Ht})})}),a.jsx(Ci,{text:"New task",children:a.jsx("button",{className:We.addButton,onClick:()=>o(Ri()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:Z=>R(Z.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:We.searchInput,"data-testid":"sidebar-search"}),p?nO(ne,j).map(Z=>a.jsx(DO,{group:Z,isExpanded:D(Z.status),onToggle:()=>C(Z.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},Z.status)):le.map(Z=>a.jsx(ak,{node:Z,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},Z.id)),ne.length===0&&!Y&&a.jsx("div",{className:We.emptyState,children:"No tasks yet. Click + to create one."}),ne.length===0&&Y&&a.jsx("div",{className:We.emptyState,children:"No matching tasks"})]})}const RO="_toast_ed2dk_1",IO="_success_ed2dk_18",OO="_icon_ed2dk_22",BO="_error_ed2dk_25",LO="_warning_ed2dk_32",zO="_info_ed2dk_38",$O="_message_ed2dk_53",HO="_close_ed2dk_60",qr={toast:RO,success:IO,icon:OO,error:BO,warning:LO,info:zO,message:$O,close:HO},PO={success:a.jsx(Ai,{size:Et}),error:a.jsx(Ls,{size:Et}),warning:a.jsx(Sm,{size:Et}),info:a.jsx(km,{size:Et})};function UO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Pt.div,{className:`${qr.toast} ${qr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[a.jsx("span",{className:qr.icon,"aria-hidden":"true",children:PO[t.variant]}),a.jsx("span",{className:qr.message,children:t.message}),a.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]})}const VO="_container_qqse2_1",qO={container:VO};function GO({toasts:t,onDismiss:s}){return a.jsx("div",{className:qO.container,"data-testid":"toast-container",children:a.jsx(os,{children:t.map(o=>a.jsx(UO,{toast:o,onDismiss:s},o.id))})})}const FO="_callout_e5awm_1",KO="_success_e5awm_11",ZO="_icon_e5awm_15",YO="_error_e5awm_18",JO="_warning_e5awm_25",WO="_info_e5awm_32",XO="_content_e5awm_48",QO="_close_e5awm_53",Gr={callout:FO,success:KO,icon:ZO,error:YO,warning:JO,info:WO,content:XO,close:QO},eB={success:a.jsx(Ai,{size:Et}),error:a.jsx(Ls,{size:Et}),warning:a.jsx(Sm,{size:Et}),info:a.jsx(km,{size:Et})};function tB({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:eB[t]}),a.jsx("span",{className:Gr.content,children:s}),o&&a.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]})})}function nB({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(tB,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",a.jsx("code",{children:c})]})})}const sB="_container_m1fsr_1",aB="_heading_m1fsr_7",iB="_section_m1fsr_14",oB="_sectionTitle_m1fsr_26",rB="_sectionDescription_m1fsr_35",lB="_emptyState_m1fsr_41",cB="_tokenList_m1fsr_48",dB="_tokenRow_m1fsr_55",uB="_tokenBadge_m1fsr_68",fB="_tokenName_m1fsr_83",pB="_tokenTarget_m1fsr_90",mB="_deleteButton_m1fsr_99",hB="_addForm_m1fsr_113",gB="_formRow_m1fsr_119",vB="_input_m1fsr_125",yB="_select_m1fsr_155",bB="_addButton_m1fsr_187",_B="_emptyStateInfo_m1fsr_221",xB="_themeOptions_m1fsr_229",kB="_themeOption_m1fsr_229",SB="_themeOptionSelected_m1fsr_254",jB="_themeOptionHeader_m1fsr_259",TB="_themeOptionLabel_m1fsr_266",NB="_themeOptionDesc_m1fsr_273",wB="_variantToggle_m1fsr_279",CB="_variantButton_m1fsr_286",EB="_variantActive_m1fsr_305",AB="_themeSwatches_m1fsr_311",DB="_themeSwatch_m1fsr_311",MB="_systemToggle_m1fsr_325",RB="_systemToggleHint_m1fsr_341",IB="_themeActive_m1fsr_348",OB="_aboutGrid_m1fsr_354",BB="_aboutItem_m1fsr_360",LB="_aboutLabel_m1fsr_373",zB="_aboutValue_m1fsr_379",$B="_aboutDot_m1fsr_387",HB="_aboutDotConnected_m1fsr_394",PB="_aboutDotDisconnected_m1fsr_398",UB="_aboutDotConnecting_m1fsr_402",fe={container:sB,heading:aB,section:iB,sectionTitle:oB,sectionDescription:rB,emptyState:lB,tokenList:cB,tokenRow:dB,tokenBadge:uB,tokenName:fB,tokenTarget:pB,deleteButton:mB,addForm:hB,formRow:gB,input:vB,select:yB,addButton:bB,emptyStateInfo:_B,themeOptions:xB,themeOption:kB,themeOptionSelected:SB,themeOptionHeader:jB,themeOptionLabel:TB,themeOptionDesc:NB,variantToggle:wB,variantButton:CB,variantActive:EB,themeSwatches:AB,themeSwatch:DB,systemToggle:MB,systemToggleHint:RB,themeActive:IB,aboutGrid:OB,aboutItem:BB,aboutLabel:LB,aboutValue:zB,aboutDot:$B,aboutDotConnected:HB,aboutDotDisconnected:PB,aboutDotConnecting:UB},VB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function qB({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(""),[_,k]=y.useState(null),S=N=>{if(N.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("")},j=N=>{k(N)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return a.jsxs(a.Fragment,{children:[a.jsx(_s,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:fe.tokenList,children:t.map(N=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenBadge,children:N.tokenType}),a.jsx("span",{className:fe.tokenName,children:N.name}),a.jsx("span",{className:fe.tokenTarget,children:N.tokenType==="env_var"?N.envVar:N.filePath}),a.jsx("button",{className:fe.deleteButton,onClick:()=>j(N.name),title:`Delete ${N.name}`,"aria-label":`Delete ${N.name}`,children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]},N.name))}),a.jsxs("form",{className:fe.addForm,onSubmit:S,children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:N=>d(N.target.value)}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:N=>p(N.target.value)})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsx("select",{className:fe.select,value:m,onChange:N=>g(N.target.value),children:VB.map(N=>a.jsx("option",{value:N.value,children:N.label},N.value))}),a.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:N=>b(N.target.value)}),a.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Od=[{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"]}],ik=new Set(Od.map(t=>t.id)),a_="grackle";function pm(t){return Od.find(s=>s.id===t)}function GB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:fe.themeOptions,children:Od.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return a.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:fe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:fe.themeOptionLabel,children:d.label}),a.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:fe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:fe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:fe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const FB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},KB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function ZB({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"About"}),a.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:fe.aboutGrid,children:[a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:fe.aboutValue,children:[a.jsx("span",{className:`${fe.aboutDot} ${KB[t]}`}),FB[t]]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:fe.aboutValue,children:d})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Version"}),a.jsx("span",{className:fe.aboutValue,children:"0.126.0"})]})]})]})}const YB="_container_cddyd_1",JB="_header_cddyd_8",WB="_headerTitle_cddyd_35",XB="_badge_cddyd_44",QB="_headerActions_cddyd_54",eL="_body_cddyd_61",tL="_formContent_cddyd_73",nL="_section_cddyd_85",sL="_label_cddyd_91",aL="_titleInput_cddyd_98",iL="_descriptionTextarea_cddyd_131",oL="_parentContext_cddyd_167",rL="_parentLabel_cddyd_175",lL="_parentName_cddyd_182",cL="_personaSelect_cddyd_186",dL="_depList_cddyd_220",uL="_depItem_cddyd_226",fL="_depItemSelected_cddyd_248",pL="_noDeps_cddyd_252",mL="_btnPrimary_cddyd_258",hL="_btnGhost_cddyd_289",Qe={container:YB,header:JB,headerTitle:WB,badge:XB,headerActions:QB,body:eL,formContent:tL,section:nL,label:sL,titleInput:aL,descriptionTextarea:iL,parentContext:oL,parentLabel:rL,parentName:lL,personaSelect:cL,depList:dL,depItem:uL,depItemSelected:fL,noDeps:pL,btnPrimary:mL,btnGhost:hL};function ok({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 _=xt(),k=t==="edit",S=k&&s?d.find(ke=>ke.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,N]=y.useState(j),C=j||T,D=u.find(ke=>ke.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",O=R?d.find(ke=>ke.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[ne,le]=y.useState((S==null?void 0:S.dependsOn)??[]),[Z,se]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,B]=y.useState((S==null?void 0:S.canDecompose)??!1),[F,ge]=y.useState((S==null?void 0:S.injectKnowledge)??!0),[ee,ce]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{k&&S&&!me.current&&(me.current=!0,$(S.title),V(S.description),le(S.dependsOn),se(S.defaultPersonaId),B(S.canDecompose),ge(S.injectKnowledge))},[k,S]);const xe=d.filter(ke=>ke.workspaceId===C&&(!k||ke.id!==s)&&ke.id!==R),De=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ot=ke=>{le(ct=>ct.includes(ke)?ct.filter(ue=>ue!==ke):[...ct,ke])},bt=()=>{!De||ee||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,ne,Z),b==null||b("Task updated","success"),v?v():_(ls(s,void 0,C,A),{replace:!0})):(ce(!0),m(C,M.trim(),Y,ne.length>0?ne:void 0,R||void 0,Z,H,F,()=>{b==null||b("Task created","success"),_(o?wi(o,A):"/tasks",{replace:!0})},ke=>{b==null||b(ke,"error"),ce(!1)})))},lt=()=>{if(v){v();return}_(k&&s?ls(s,void 0,C,A):o?wi(o,A):"/tasks")},Pe=k?"edit task":R?"child task":"new task";return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsxs("div",{className:Qe.headerTitle,children:[a.jsx("span",{className:Qe.badge,children:Pe}),O&&a.jsxs("span",{className:Qe.parentContext,children:[a.jsx("span",{className:Qe.parentLabel,children:"Child of"}),a.jsx("span",{className:Qe.parentName,children:O.title})]})]}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx("button",{onClick:bt,disabled:!De||ee,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:ee?"Creating…":k?"Save Changes":"Create"}),a.jsx("button",{onClick:lt,className:Qe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:Qe.body,children:a.jsxs("div",{className:Qe.formContent,children:[E&&a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:T,onChange:ke=>N(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:ke=>$(ke.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:ke=>{ke.key==="Enter"&&De&&bt()}})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:ke=>V(ke.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:Z,onChange:ke=>se(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:H,onChange:ke=>B(ke.target.checked)}),"Can spawn subtasks"]})}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-inject-knowledge",children:[a.jsx("input",{type:"checkbox",checked:F,onChange:ke=>ge(ke.target.checked)}),"Inject related prior work from the knowledge graph"]})}),a.jsxs("div",{className:Qe.section,children:[a.jsx("div",{className:Qe.label,children:"Dependencies"}),xe.length===0?a.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:Qe.depList,children:xe.map(ke=>{const ct=ne.includes(ke.id);return a.jsxs("label",{className:`${Qe.depItem} ${ct?Qe.depItemSelected:""}`,"data-testid":`dep-option-${ke.id}`,children:[a.jsx("input",{type:"checkbox",checked:ct,onChange:()=>ot(ke.id)}),ke.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ke.status,")"]})]},ke.id)})})]})]})})]})}const gL="_actionButtons_1rjka_1",vL="_btnPrimary_1rjka_8",yL="_btnDanger_1rjka_39",bL="_btnGhost_1rjka_78",Yt={actionButtons:gL,btnPrimary:vL,btnDanger:yL,btnGhost:bL};function _L({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:m,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Yt.btnPrimary,children:"Start"}),a.jsx("button",{onClick:m,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:Yt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:u,disabled:!s,className:Yt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:Yt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:c,className:Yt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return a.jsx("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:r,className:Yt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const xL="_workpadSection_y8nj9_1",kL="_workpadLabel_y8nj9_9",SL="_workpadStatus_y8nj9_17",jL="_workpadSummary_y8nj9_23",TL="_workpadExtra_y8nj9_29",Va={workpadSection:xL,workpadLabel:kL,workpadStatus:SL,workpadSummary:jL,workpadExtra:TL};function NL({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return a.jsxs("div",{className:Va.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Va.workpadLabel,children:"Workpad"}),a.jsx("div",{className:Va.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:Va.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Va.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:Va.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:Va.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:Va.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const wL="_overviewDashboard_r05qm_1",CL="_overviewHero_r05qm_7",EL="_statusBadge_r05qm_14",AL="_statusPending_r05qm_26",DL="_statusAssigned_r05qm_31",ML="_statusInProgress_r05qm_36",RL="_statusReview_r05qm_41",IL="_statusDone_r05qm_46",OL="_statusFailed_r05qm_51",BL="_statusWaitingInput_r05qm_56",LL="_overviewBranchPill_r05qm_61",zL="_branchLink_r05qm_76",$L="_overviewSection_r05qm_87",HL="_overviewLabel_r05qm_93",PL="_overviewValue_r05qm_100",UL="_overviewMuted_r05qm_105",VL="_overviewMarkdown_r05qm_111",qL="_envRow_r05qm_180",GL="_envDot_r05qm_186",FL="_envDotGreen_r05qm_193",KL="_envDotYellow_r05qm_197",ZL="_envDotRed_r05qm_201",YL="_envDotGray_r05qm_205",JL="_depList_r05qm_209",WL="_depItem_r05qm_215",XL="_depBlocked_r05qm_222",QL="_depDone_r05qm_226",e8="_timeline_r05qm_230",t8="_timelineRow_r05qm_236",n8="_timelineKey_r05qm_243",s8="_timelineValue_r05qm_249",a8="_timelineDelta_r05qm_253",i8="_reviewNotes_r05qm_264",be={overviewDashboard:wL,overviewHero:CL,statusBadge:EL,statusPending:AL,statusAssigned:DL,statusInProgress:ML,statusReview:RL,statusDone:IL,statusFailed:OL,statusWaitingInput:BL,overviewBranchPill:LL,branchLink:zL,overviewSection:$L,overviewLabel:HL,overviewValue:PL,overviewMuted:UL,overviewMarkdown:VL,envRow:qL,envDot:GL,envDotGreen:FL,envDotYellow:KL,envDotRed:ZL,envDotGray:YL,depList:JL,depItem:WL,depBlocked:XL,depDone:QL,timeline:e8,timelineRow:t8,timelineKey:n8,timelineValue:s8,timelineDelta:a8,reviewNotes:i8};function Gc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Cp(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function i_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function o8({status:t}){const s=Ya(t),o=aN(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function r8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(o8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?a.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(_m,{remarkPlugins:[xm],children:t.description})})]}),t.workpad&&a.jsx(NL,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${i_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${i_(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:_.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:T?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Cp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Cp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Cp(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Rs(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Rs(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Ho(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Ho(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Rs((u==null?void 0:u.costMillicents)??0)," / ",Rs(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function l8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:fe.heading,children:"Plugins"}),a.jsxs("div",{className:fe.section,children:[a.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function c8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[N,C]=y.useState(null),D=t.find(M=>M.id===N),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(N)try{await c(N),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},O=async()=>{T(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(_s,{isOpen:N!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:fe.tokenList,children:t.map(M=>a.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&a.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&a.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&a.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:a.jsx(XT,{size:Ht,"aria-hidden":"true"})}),a.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]},M.id))}),a.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),a.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{O().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const d8="_container_legrg_1",u8="_header_legrg_8",f8="_headerTitle_legrg_35",p8="_badge_legrg_44",m8="_headerActions_legrg_54",h8="_body_legrg_61",g8="_formContent_legrg_73",v8="_section_legrg_85",y8="_label_legrg_91",b8="_nameInput_legrg_98",_8="_fieldInput_legrg_131",x8="_adapterSelect_legrg_164",k8="_readOnlyValue_legrg_198",S8="_codespaceSection_legrg_204",j8="_codespaceActions_legrg_210",T8="_creatingHint_legrg_216",N8="_errorHint_legrg_222",w8="_btnPrimary_legrg_235",C8="_btnGhost_legrg_266",oe={container:d8,header:u8,headerTitle:f8,badge:p8,headerActions:m8,body:h8,formContent:g8,section:v8,label:y8,nameInput:b8,fieldInput:_8,adapterSelect:x8,readOnlyValue:k8,codespaceSection:S8,codespaceActions:j8,creatingHint:T8,errorHint:N8,btnPrimary:w8,btnGhost:C8},id=1,od=65535;function Ep(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=id&&s<=od}function Ap(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function E8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?a.jsxs("div",{className:oe.codespaceSection,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repository"}),a.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:oe.codespaceActions,children:[a.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:oe.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:oe.codespaceSection,children:a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:oe.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:oe.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:oe.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:oe.errorHint,children:d})]})})}function rk({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=xt(),N=t==="edit",C=N&&s?o.find(re=>re.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[O,M]=y.useState(""),[$,Y]=y.useState(""),[V,ne]=y.useState(""),[le,Z]=y.useState(""),[se,H]=y.useState(""),[B,F]=y.useState(""),[ge,ee]=y.useState(""),[ce,me]=y.useState(""),[xe,De]=y.useState("create"),[ot,bt]=y.useState(""),[lt,Pe]=y.useState(null),ke=y.useCallback(()=>{const re={};if(E==="local"){if(O.trim()&&(re.host=O.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.port=ve)}}else if(E==="ssh"){if(re.host=O.trim(),V.trim()&&(re.user=V.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.sshPort=ve)}le.trim()&&(re.identityFile=le.trim())}else E==="docker"?xe==="attach"?ot.trim()&&(re.attach=ot.trim()):(se.trim()&&(re.image=se.trim()),B.trim()&&(re.repo=B.trim())):E==="codespace"&&(re.codespaceName=ge.trim());return re},[E,O,$,V,le,se,B,ge,xe,ot]),ct=()=>!(!D.trim()||E==="ssh"&&!O.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&xe==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Ep($)),ue=()=>{ct()&&(c(D.trim(),E,ke(),ce||void 0),j==null||j("Environment added successfully","success"),T(zo,{replace:!0}))},Re=()=>{T(s?$o(s):zo)},Q=y.useCallback((re,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig),an=ve.trim();an?et[re]=an:delete et[re],d(s,{adapterConfig:et})},[C,s,d]),nt=y.useCallback((re,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig);if(ve.trim()){const an=Number(ve);Number.isInteger(an)&&an>=id&&an<=od&&(et[re]=an)}else delete et[re];d(s,{adapterConfig:et})},[C,s,d]);if(N){if(!C)return a.jsxs("div",{className:oe.container,children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsx("div",{className:oe.formContent,children:a.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const re=Ap(C.adapterConfig);return a.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Re,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Name"}),a.jsx(zt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:lt,onActivate:Pe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Adapter Type"}),a.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(zt,{value:String(re.host??""),onSave:ve=>Q("host",ve),mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Port"}),a.jsx(zt,{value:String(re.port??""),onSave:ve=>nt("port",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(zt,{value:String(re.host??""),onSave:ve=>Q("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"User"}),a.jsx(zt,{value:String(re.user??""),onSave:ve=>Q("user",ve),mode:"edit",fieldId:"user",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"SSH Port"}),a.jsx(zt,{value:String(re.sshPort??""),onSave:ve=>nt("sshPort",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:lt,onActivate:Pe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Identity File"}),a.jsx(zt,{value:String(re.identityFile??""),onSave:ve=>Q("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:lt,onActivate:Pe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&re.attach!==void 0&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Attach (container)"}),a.jsx(zt,{value:String(re.attach??""),onSave:ve=>Q("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:lt,onActivate:Pe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&re.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Image"}),a.jsx(zt,{value:String(re.image??""),onSave:ve=>Q("image",ve),mode:"edit",fieldId:"image",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repo"}),a.jsx(zt,{value:String(re.repo??""),onSave:ve=>Q("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:lt,onActivate:Pe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace Name"}),a.jsx(zt,{value:String(re.codespaceName??""),onSave:ve=>Q("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:lt,onActivate:Pe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"new environment"})}),a.jsxs("div",{className:oe.headerActions,children:[a.jsx("button",{onClick:ue,disabled:!ct(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:re=>A(re.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:re=>{re.key==="Enter"&&ct()&&ue()}})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:re=>{R(re.target.value),re.target.value==="codespace"&&u(ce||void 0)},className:oe.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:re=>{me(re.target.value),E==="codespace"&&u(re.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(re=>a.jsxs("option",{value:re.id,children:[re.label," (@",re.username,")",re.isDefault?" — default":""]},re.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:re=>Y(re.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:V,onChange:re=>ne(re.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:re=>Y(re.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:re=>Z(re.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:xe,onChange:re=>{const ve=re.target.value;De(ve),ve==="attach"&&_()},className:oe.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),xe==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:se,onChange:re=>H(re.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:re=>F(re.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Container"}),!S&&k.length>0&&a.jsxs("select",{value:ot,onChange:re=>{bt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},className:oe.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),k.map(re=>a.jsxs("option",{value:re.name,children:[re.name," (",re.image,") ",re.status]},re.id))]}),(S||k.length===0)&&a.jsxs(a.Fragment,{children:[S?a.jsx("span",{className:oe.errorHint,children:S}):a.jsx("span",{className:oe.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:ot,onChange:re=>{bt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},placeholder:"Enter container name/ID...",className:oe.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(E8,{codespaceName:ge,onCodespaceNameChange:ee,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const A8="_group_1iprv_1",D8="_groupTitle_1iprv_8",M8="_shortcutList_1iprv_17",R8="_shortcutRow_1iprv_23",I8="_keys_1iprv_36",O8="_kbd_1iprv_43",B8="_description_1iprv_60",_i={group:A8,groupTitle:D8,shortcutList:M8,shortcutRow:R8,keys:I8,kbd:O8,description:B8},L8=[{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"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function z8(){return a.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),L8.map(t=>a.jsxs("div",{className:_i.group,children:[a.jsx("h4",{className:_i.groupTitle,children:t.title}),a.jsx("div",{className:_i.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:_i.shortcutRow,children:[a.jsx("span",{className:_i.keys,children:s.keys.map(o=>a.jsx("kbd",{className:_i.kbd,children:o},o))}),a.jsx("span",{className:_i.description,children:s.description})]},s.description))})]},t.title))]})}const $8=[{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 H8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:fe.tokenList,children:$8.map(r=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenName,children:r.label}),a.jsx("span",{className:fe.tokenTarget,children:r.description}),a.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const P8="_container_10efq_1",U8="_header_10efq_7",V8="_list_10efq_105",q8="_card_10efq_111",G8="_cardHeader_10efq_125",F8="_cardTitle_10efq_135",K8="_defaultBadge_10efq_141",Z8="_cardActions_10efq_155",Y8="_description_10efq_160",J8="_meta_10efq_166",W8="_empty_10efq_212",X8="_typeBadge_10efq_362",ts={container:P8,header:U8,list:V8,card:q8,cardHeader:G8,cardTitle:F8,defaultBadge:K8,cardActions:Z8,description:Y8,meta:J8,empty:W8,typeBadge:X8};function Q8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:ts.container,children:[a.jsxs("div",{className:ts.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ts.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ts.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return a.jsxs("div",{className:ts.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ts.cardHeader,children:[a.jsxs("span",{className:ts.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ts.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&a.jsx("span",{className:ts.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ts.description,children:v.description}),a.jsxs("div",{className:ts.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(_s,{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 e7="_container_uy08i_1",t7="_header_uy08i_7",n7="_count_uy08i_13",s7="_presets_uy08i_18",a7="_presetButton_uy08i_24",i7="_filterInput_uy08i_41",o7="_groups_uy08i_53",r7="_group_uy08i_53",l7="_groupHeader_uy08i_68",c7="_groupName_uy08i_77",d7="_groupCount_uy08i_81",u7="_toolList_uy08i_87",f7="_toolItem_uy08i_95",p7="_toolName_uy08i_103",yn={container:e7,header:t7,count:n7,presets:s7,presetButton:a7,filterInput:i7,groups:o7,group:r7,groupHeader:l7,groupName:c7,groupCount:d7,toolList:u7,toolItem:f7,toolName:p7},m7=(()=>{const t=new Map;for(const s of z_){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()}))})(),h7=[{name:"default",label:"Default",tools:L_},{name:"worker",label:"Worker",tools:X2},{name:"orchestrator",label:"Orchestrator",tools:Q2},{name:"admin",label:"Admin",tools:ej}];function o_({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 _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:yn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:yn.header,children:a.jsx("span",{className:yn.count,children:t.length===0?`Using default (${L_.length} tools)`:`${t.length} of ${z_.size} tools selected`})}),a.jsxs("div",{className:yn.presets,"data-testid":"mcp-tool-presets",children:[h7.map(v=>a.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:yn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:yn.groups,children:m7.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return a.jsxs("div",{className:yn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:yn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:yn.groupName,children:v}),a.jsxs("span",{className:yn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),a.jsx("div",{className:yn.toolList,children:_.map(S=>a.jsxs("label",{className:yn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:yn.toolName,children:S})]},S))})]},v)})})]})}function mm(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function lk(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const g7="_container_1gfuq_1",v7="_header_1gfuq_7",y7="_list_1gfuq_19",b7="_card_1gfuq_25",_7="_cardHeader_1gfuq_40",x7="_cardTitle_1gfuq_46",k7="_statusBadge_1gfuq_56",S7="_enabled_1gfuq_68",j7="_disabled_1gfuq_71",T7="_cardActions_1gfuq_75",N7="_cardMeta_1gfuq_80",w7="_empty_1gfuq_98",ns={container:g7,header:v7,list:y7,card:b7,cardHeader:_7,cardTitle:x7,statusBadge:k7,enabled:S7,disabled:j7,cardActions:T7,cardMeta:N7,empty:w7};function C7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return a.jsxs("div",{className:ns.container,children:[a.jsxs("div",{className:ns.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ns.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ns.list,children:t.map(_=>a.jsxs("div",{className:ns.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[a.jsxs("div",{className:ns.cardHeader,children:[a.jsxs("span",{className:ns.cardTitle,children:[a.jsx("strong",{children:_.title}),a.jsx("span",{className:`${ns.statusBadge} ${_.enabled?ns.enabled:ns.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ns.cardActions,onClick:k=>k.stopPropagation(),children:[a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ns.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?mm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",lk(_.nextRunAt)]}):null,_.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),a.jsx(_s,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const E7="_nav_1bhou_1",A7="_tab_1bhou_24",D7="_tabIcon_1bhou_62",M7="_tabActive_1bhou_68",Fc={nav:E7,tab:A7,tabIcon:D7,tabActive:M7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(vT,{size:Et})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(dT,{size:Et})},{path:"personas",label:"Personas",icon:a.jsx(tN,{size:Et})},{path:"schedules",label:"Schedules",icon:a.jsx(Pj,{size:Et})},{path:"appearance",label:"Appearance",icon:a.jsx(LT,{size:Et})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(bT,{size:Et})},{path:"plugins",label:"Plugins",icon:a.jsx(VT,{size:Et})},{path:"about",label:"About",icon:a.jsx(km,{size:Et})}];function R7(){var u;const t=Wt(),s=xt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${ji}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${ji}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=ia.length-1;else return;const _=ia[b].path;s(`${ji}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Fc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Fc.tab} ${m?Fc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Fc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const I7=["lifecycle:","pipe:","stdin:"];function gh(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function ck(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function O7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=ck(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const B7="_container_16qkd_1",L7="_header_16qkd_7",z7="_title_16qkd_15",$7="_headerActions_16qkd_21",H7="_internalsToggle_16qkd_27",P7="_refreshButton_16qkd_37",U7="_state_16qkd_52",V7="_group_16qkd_59",q7="_groupHeader_16qkd_63",G7="_row_16qkd_72",F7="_selected_16qkd_92",K7="_kindBadge_16qkd_96",Z7="_kindChatroom_16qkd_108",Y7="_kindPipe_16qkd_114",J7="_kindChannel_16qkd_120",W7="_streamName_16qkd_126",X7="_meta_16qkd_135",Jt={container:B7,header:L7,title:z7,headerActions:$7,internalsToggle:H7,refreshButton:P7,state:U7,group:V7,groupHeader:q7,row:G7,selected:F7,kindBadge:K7,kindChatroom:Z7,kindPipe:Y7,kindChannel:J7,streamName:W7,meta:X7},Q7={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function ez({kind:t}){return t==="chatroom"?a.jsx(DT,{size:Ye,"aria-hidden":"true"}):t==="pipe"?a.jsx(lT,{size:Ye,"aria-hidden":"true"}):a.jsx(fT,{size:Ye,"aria-hidden":"true"})}function tz({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v,hideHeaderControls:b=!1}){const _=O7(t,s),k={chatroom:Jt.kindChatroom,pipe:Jt.kindPipe,channel:Jt.kindChannel},S=j=>{var T;return((T=o.find(N=>N.id===j))==null?void 0:T.title)??j};return a.jsxs("div",{className:Jt.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:Jt.header,children:[a.jsx("span",{className:Jt.title,children:"Coordination"}),!b&&a.jsxs("div",{className:Jt.headerActions,children:[a.jsxs("label",{className:Jt.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:j=>p(j.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:Jt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(GT,{size:Ye,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:Jt.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(j=>a.jsxs("div",{className:Jt.group,children:[a.jsx("div",{className:Jt.groupHeader,children:j.taskId?S(j.taskId):"Unattached / external (CLI · MCP)"}),j.streams.map(T=>{const N=gh(T),C=T.id===m;return a.jsxs("button",{type:"button",className:`${Jt.row}${C?` ${Jt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":C?"page":void 0,children:[a.jsxs("span",{className:`${Jt.kindBadge} ${k[N]}`,children:[a.jsx(ez,{kind:N})," ",Q7[N]]}),a.jsx("span",{className:Jt.streamName,children:T.name}),a.jsxs("span",{className:Jt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},j.taskId??"__orphans__"))]})}const nz="_transcript_1p4cm_1",sz="_message_1p4cm_10",az="_meta_1p4cm_16",iz="_sender_1p4cm_24",oz="_time_1p4cm_29",rz="_content_1p4cm_34",lz="_state_1p4cm_42",qa={transcript:nz,message:sz,meta:az,sender:iz,time:oz,content:rz,state:lz};function cz(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function dz({messages:t,loading:s=!1}){return s?a.jsx("div",{className:qa.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?a.jsx("div",{className:qa.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):a.jsx("div",{className:qa.transcript,"data-testid":"stream-transcript",children:t.map(o=>a.jsxs("div",{className:qa.message,"data-testid":"stream-transcript-message",children:[a.jsxs("div",{className:qa.meta,children:[a.jsx("span",{className:qa.sender,title:o.senderId,children:o.senderId.slice(0,12)}),a.jsx("span",{className:qa.time,children:cz(o.timestamp)})]}),a.jsx("div",{className:qa.content,children:o.content})]},o.seq))})}const uz="_panel_iibrt_1",fz="_header_iibrt_24",pz="_title_iibrt_33",mz="_closeButton_iibrt_43",hz="_body_iibrt_57",gz="_section_iibrt_63",vz="_sectionLabel_iibrt_67",yz="_metaRow_iibrt_76",bz="_metaKey_iibrt_84",_z="_metaValue_iibrt_90",xz="_subscriberCard_iibrt_99",kz="_subscriberHeader_iibrt_107",Sz="_sessionLink_iibrt_114",jz="_badges_iibrt_132",Tz="_badgeRw_iibrt_150 _badge_iibrt_132",Nz="_badgeR_iibrt_150 _badge_iibrt_132",wz="_badgeW_iibrt_162 _badge_iibrt_132",Cz="_badgeAsync_iibrt_168 _badge_iibrt_132",Ez="_badgeSync_iibrt_174 _badge_iibrt_132",Az="_badgeDetach_iibrt_178 _badge_iibrt_132",Dz="_spawnTag_iibrt_184 _badge_iibrt_132",Mz="_fdNumber_iibrt_189",Rz="_emptySubscribers_iibrt_195",Iz="_metaValueMono_iibrt_201 _metaValue_iibrt_90",Oz="_advanced_iibrt_216",Bz="_advancedSummary_iibrt_220",He={panel:uz,header:fz,title:pz,closeButton:mz,body:hz,section:gz,sectionLabel:vz,metaRow:yz,metaKey:bz,metaValue:_z,subscriberCard:xz,subscriberHeader:kz,sessionLink:Sz,badges:jz,badgeRw:Tz,badgeR:Nz,badgeW:wz,badgeAsync:Cz,badgeSync:Ez,badgeDetach:Az,spawnTag:Dz,fdNumber:Mz,emptySubscribers:Rz,metaValueMono:Iz,advanced:Oz,advancedSummary:Bz},Lz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function zz({permission:t}){const s=t==="rw"?He.badgeRw:t==="r"?He.badgeR:He.badgeW;return a.jsx("span",{className:s,children:t})}function $z({mode:t}){const s=t==="async"?He.badgeAsync:t==="detach"?He.badgeDetach:He.badgeSync;return a.jsx("span",{className:s,children:t})}function Hz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=xt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),a.jsxs("div",{className:He.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:He.header,children:[a.jsx("h3",{className:He.title,children:t.name}),a.jsx("button",{type:"button",className:He.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:He.body,children:[a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Overview"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Kind"}),a.jsx("span",{className:He.metaValue,children:Lz[gh(t)]})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Participants"}),a.jsx("span",{className:He.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Buffered"}),a.jsxs("span",{className:He.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:He.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:He.sessionLink,onClick:()=>{c(Mm(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&a.jsx("span",{className:He.spawnTag,children:"spawn"})]},d.subscriptionId))]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Conversation"}),a.jsx(dz,{messages:s??[],loading:o??!1})]}),a.jsxs("details",{className:He.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:He.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Stream ID"}),a.jsx("span",{className:He.metaValueMono,children:t.id})]}),t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,children:[a.jsxs("div",{className:He.subscriberHeader,children:[a.jsxs("span",{className:He.fdNumber,children:["fd ",d.fd]}),a.jsxs("span",{className:He.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:He.badges,children:[a.jsx(zz,{permission:d.permission}),a.jsx($z,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}function Dp(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}const Pz=["--accent-green","--accent-yellow","--accent-red","--text-tertiary"];function dk(t,s){if(s)return{varName:"--text-tertiary",label:"External"};switch(t){case"running":return{varName:"--accent-green",label:"Running"};case"idle":case"suspended":case"hibernating":return{varName:"--accent-yellow",label:Dp(t)};case"failed":case"interrupted":return{varName:"--accent-red",label:Dp(t)};default:return{varName:"--text-tertiary",label:t.length>0?Dp(t):"Unknown"}}}const uk="session",vh="stream",r_="messageDot";function Kc(t){return`session:${t}`}function l_(t){return`stream:${t}`}function Uz(t){return{id:t,environmentId:"",runtime:"external",status:"external",prompt:"",startedAt:""}}function Vz(t,s){return t==="detach"?{stroke:s,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6}:{stroke:s,strokeWidth:1.5}}function qz(t,s){const o=t.permission.includes("w"),r=s.permission.includes("w"),c=t.permission.includes("r"),d=s.permission.includes("r");if(o&&!r&&d)return{source:t,target:s,bidirectional:!1};if(r&&!o&&c)return{source:s,target:t,bidirectional:!1};const u=[t,s].sort((p,m)=>p.sessionId.localeCompare(m.sessionId));return{source:u[0],target:u[1],bidirectional:!0}}function Gz(t,s){if(t.length===0)return{nodes:[],edges:[]};const o=new Map(s.map(m=>[m.id,m])),r=new Map,c=new Map,d=[],u=m=>{let g=r.get(m);if(!g){const v=o.get(m);g={kind:"session",session:v??Uz(m),streamCount:0,external:v===void 0},r.set(m,g)}return g};for(const m of t){const g=gh(m);if(g==="pipe"&&m.subscribers.length===2&&m.subscribers[0].sessionId!==m.subscribers[1].sessionId){const[v,b]=m.subscribers;u(v.sessionId).streamCount+=1,u(b.sessionId).streamCount+=1;const{source:_,target:k,bidirectional:S}=qz(v,b);d.push({id:`edge-pipe-${m.id}`,source:Kc(_.sessionId),target:Kc(k.sessionId),type:r_,data:{edgeKind:"pipe",streamId:m.id,permission:S?"rw":_.permission,deliveryMode:_.deliveryMode},style:{stroke:"var(--accent-yellow)",strokeWidth:1.5,strokeDasharray:"6 3"},markerEnd:{type:Mc.ArrowClosed},markerStart:S?{type:Mc.ArrowClosed}:void 0,animated:!1});continue}c.set(m.id,{kind:"stream",stream:m,streamKind:g,ownership:ck(m,o)});for(const v of m.subscribers){u(v.sessionId).streamCount+=1;const b=l_(m.id),_=Kc(v.sessionId),k=v.permission.includes("w"),S=v.permission.includes("r");let j,T,N=!1;k&&S?(j=_,T=b,N=!0):S?(j=b,T=_):(j=_,T=b),d.push({id:`edge-part-${m.id}-${v.subscriptionId}`,source:j,target:T,type:r_,data:{edgeKind:"participation",streamId:m.id,permission:v.permission,deliveryMode:v.deliveryMode},style:Vz(v.deliveryMode,"var(--text-tertiary)"),markerEnd:{type:Mc.ArrowClosed},markerStart:N?{type:Mc.ArrowClosed}:void 0,animated:!1})}}const p=[];for(const[m,g]of r)p.push({id:Kc(m),type:uk,position:{x:0,y:0},data:g});for(const[m,g]of c)p.push({id:l_(m),type:vh,position:{x:0,y:0},data:g});return{nodes:p,edges:d}}const Fz=200,Kz=64,Zz=180,Yz=56,Jz=40,Wz=70;function c_(t){return t===vh?{width:Zz,height:Yz}:{width:Fz,height:Kz}}function Xz(t){if(t.nodes.length===0)return t;const s=new ld.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:Jz,ranksep:Wz});for(const r of t.nodes){const{width:c,height:d}=c_(r.type);s.setNode(r.id,{width:c,height:d})}for(const r of t.edges)s.setEdge(r.source,r.target,{},r.id);return ld.layout(s),{nodes:t.nodes.map(r=>{const c=s.node(r.id),{width:d,height:u}=c_(r.type);return{...r,position:{x:c.x-d/2,y:c.y-u/2}}}),edges:t.edges}}function Qz(t,s){return y.useMemo(()=>Xz(Gz(t,s)),[t,s])}const e$="_graphContainer_1uzcp_1",t$="_empty_1uzcp_18",n$="_nodeContent_1uzcp_28",s$="_nodeHeader_1uzcp_38",a$="_nodeTitle_1uzcp_50",i$="_nodeMeta_1uzcp_58",o$="_nodeSubtle_1uzcp_64",r$="_countBadge_1uzcp_69",l$="_sessionNode_1uzcp_81",c$="_sessionAccent_1uzcp_103",d$="_external_1uzcp_109",u$="_streamNode_1uzcp_114",f$="_chatroom_1uzcp_134",p$="_channel_1uzcp_139",m$="_pipe_1uzcp_143",h$="_haloless_1uzcp_147",g$="_selected_1uzcp_153",v$="_kindBadge_1uzcp_158",y$="_handle_1uzcp_172",b$="_messageDot_1uzcp_179",vt={graphContainer:e$,empty:t$,nodeContent:n$,nodeHeader:s$,nodeTitle:a$,nodeMeta:i$,nodeSubtle:o$,countBadge:r$,sessionNode:l$,sessionAccent:c$,external:d$,streamNode:u$,chatroom:f$,channel:p$,pipe:m$,haloless:h$,selected:g$,kindBadge:v$,handle:y$,messageDot:b$};function _$({data:t}){const{session:s,streamCount:o,external:r}=t,c=dk(s.status,r),d=`var(${c.varName})`,u=r?`${vt.sessionNode} ${vt.external}`:vt.sessionNode;return a.jsxs("div",{className:u,"data-testid":`coordination-node-session-${s.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsx("div",{className:vt.sessionAccent,style:{backgroundColor:d}}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.nodeTitle,children:r?s.id:s.runtime})}),a.jsxs("div",{className:vt.nodeMeta,children:[a.jsx("span",{className:vt.nodeSubtle,style:{color:d},children:c.label}),o>0&&a.jsx("span",{className:vt.countBadge,children:o})]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}function x$({data:t,selected:s}){const{stream:o,streamKind:r,ownership:c}=t,d=r==="chatroom"?vt.chatroom:r==="pipe"?vt.pipe:vt.channel,u=[vt.streamNode,d];return c.kind!=="task"&&u.push(vt.haloless),s&&u.push(vt.selected),a.jsxs("div",{className:u.join(" "),"data-testid":`coordination-node-stream-${o.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.kindBadge,children:r})}),a.jsx("span",{className:vt.nodeTitle,children:o.name}),a.jsxs("span",{className:vt.nodeSubtle,children:[o.subscriberCount," ",o.subscriberCount===1?"subscriber":"subscribers"]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}const d_="0.7s",k$=3;function S$(t){const{sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u,markerStart:p,markerEnd:m,style:g,data:v}=t,[b]=V2({sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u}),_=v==null?void 0:v.pulseSeq;return a.jsxs(a.Fragment,{children:[a.jsx(q2,{path:b,markerStart:p,markerEnd:m,style:g}),_!==void 0&&a.jsxs("circle",{r:k$,opacity:0,className:vt.messageDot,"data-testid":"coordination-message-dot",children:[a.jsx("animateMotion",{dur:d_,repeatCount:"1",path:b}),a.jsx("animate",{attributeName:"opacity",dur:d_,repeatCount:"1",values:"0;1;1;0",keyTimes:"0;0.1;0.85;1"})]},_)]})}const Mp="#6b7a8d",j$={[uk]:_$,[vh]:x$},T$={messageDot:S$};function N$({streams:t,sessions:s,selectedStreamId:o,onSelectStream:r,recentMessages:c,resolvedThemeId:d}){const u=Qz(t,s),p=y.useMemo(()=>u.edges.map(_=>{var S,j;if(!_.data)return _;const k=(j=(S=c==null?void 0:c[_.data.streamId])==null?void 0:S.at(-1))==null?void 0:j.seq;return k===void 0?_:{..._,data:{..._.data,pulseSeq:k}}}),[u.edges,c]),m=y.useMemo(()=>u.nodes.map(_=>{const k=_.data;return k.kind==="stream"&&k.stream.id===o?{..._,selected:!0}:_}),[u.nodes,o]),g=y.useMemo(()=>{const _=getComputedStyle(document.documentElement),k={};for(const S of Pz)k[S]=_.getPropertyValue(S).trim()||Mp;return k},[d]),v=y.useCallback((_,k)=>{const S=k.data;S.kind==="stream"&&r(S.stream.id)},[r]),b=y.useCallback(_=>{const k=_.data;return k.kind==="session"?g[dk(k.session.status,k.external).varName]??Mp:Mp},[g]);return u.nodes.length===0?a.jsx("div",{className:vt.empty,"data-testid":"coordination-graph-empty",children:"No active streams to visualize"}):a.jsx("div",{className:vt.graphContainer,"data-testid":"coordination-graph",children:a.jsxs(M_,{nodes:m,edges:p,nodeTypes:j$,edgeTypes:T$,onNodeClick:v,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[a.jsx(R_,{variant:I_.Dots,gap:24,size:1,color:"var(--text-disabled)"}),a.jsx(O_,{showInteractive:!1}),a.jsx(B_,{nodeColor:b,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function w$({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(Sy.map(d=>[d,[]]));for(const d of t){const u=fl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Sy.map(d=>{const u=Ya(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const C$="_boardContainer_1c4y1_1",E$="_column_1c4y1_17",A$="_columnHeader_1c4y1_34",D$="_columnIcon_1c4y1_47",M$="_columnLabel_1c4y1_52",R$="_columnCount_1c4y1_57",I$="_cardList_1c4y1_67",O$="_emptyPlaceholder_1c4y1_76",B$="_card_1c4y1_67",L$="_cardHeader_1c4y1_107",z$="_cardStatusIcon_1c4y1_113",$$="_cardTitle_1c4y1_119",H$="_cardBadges_1c4y1_127",P$="_badge_1c4y1_134",U$="_blockedBadge_1c4y1_146",V$="_childBadge_1c4y1_151",q$="_depBadge_1c4y1_155",G$="_parentBadge_1c4y1_159",F$="_pausedSubBadge_1c4y1_166",K$="_personaBadge_1c4y1_170",Z$="_envBadge_1c4y1_174",Y$="_emptyCta_1c4y1_178",J$="_ctaButton_1c4y1_188",W$="_ctaDescription_1c4y1_204",dt={boardContainer:C$,column:E$,columnHeader:A$,columnIcon:D$,columnLabel:M$,columnCount:R$,cardList:I$,emptyPlaceholder:O$,card:B$,cardHeader:L$,cardStatusIcon:z$,cardTitle:$$,cardBadges:H$,badge:P$,blockedBadge:U$,childBadge:V$,depBadge:q$,parentBadge:G$,pausedSubBadge:F$,personaBadge:K$,envBadge:Z$,emptyCta:Y$,ctaButton:J$,ctaDescription:W$};function X$({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,N=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&T.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&N.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:N}},[p,r,c,d]),b=y.useMemo(()=>w$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:dt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:dt.ctaButton,onClick:()=>u(Ri(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:dt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:dt.boardContainer,"data-testid":"board-container",children:b.map(_=>a.jsxs("section",{className:dt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:dt.columnHeader,children:[a.jsx("span",{className:dt.columnIcon,style:{color:_.style.color},children:_.style.icon}),a.jsx("span",{className:dt.columnLabel,children:_.label}),a.jsx("span",{className:dt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),a.jsx("div",{className:dt.cardList,children:_.tasks.length===0?a.jsx("div",{className:dt.emptyPlaceholder,children:"No tasks"}):a.jsx(os,{mode:"popLayout",children:_.tasks.map(k=>a.jsx(Pt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(Q$,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(ls(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function Q$({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ya(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:dt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[a.jsxs("div",{className:dt.cardHeader,children:[a.jsx("span",{className:dt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:dt.cardTitle,children:d.title})]}),a.jsxs("div",{className:dt.cardBadges,children:[b&&a.jsx("span",{className:`${dt.badge} ${dt.parentBadge}`,title:b.title,children:b.title}),p>0&&a.jsxs("span",{className:`${dt.badge} ${dt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${dt.badge} ${dt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${dt.badge} ${dt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${dt.badge} ${dt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${dt.badge} ${dt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${dt.badge} ${dt.envBadge}`,children:r})]})]})}const e9="_formContent_ymnez_1",t9="_section_ymnez_13",n9="_label_ymnez_19",s9="_titleInput_ymnez_26",a9="_descriptionTextarea_ymnez_58",i9="_selectField_ymnez_94",o9="_checkboxRow_ymnez_128",r9="_checkboxLabel_ymnez_141",l9="_fieldError_ymnez_146",jt={formContent:e9,section:t9,label:n9,titleInput:s9,descriptionTextarea:a9,selectField:i9,checkboxRow:o9,checkboxLabel:r9,fieldError:l9};function c9(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const d9=100;function u9({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:jt.formContent,children:[a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:jt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:d9,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:jt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:jt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:jt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:jt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:jt.section,children:a.jsxs("label",{className:jt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:jt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:jt.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 fk=y.createContext(void 0),f9=4e3;function p9({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=f9)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(fk.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=y.useContext(fk);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const hm="grackle-theme",pk="grackle-prefer-system",mk="(prefers-color-scheme: dark)";let Jr=[],rd;function Rp(){rd=void 0;for(const t of Jr)t()}function gm(){return typeof window>"u"?!1:window.matchMedia(mk).matches}function nl(){if(typeof localStorage>"u")return a_;try{const t=localStorage.getItem(hm);if(t!==null&&ik.has(t))return t}catch{}return a_}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(pk)==="true"}catch{return!1}}function vm(t){return Od.find(s=>s.variantLightId===t||s.variantDarkId===t)}function hk(t,s){const o=pm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?gm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=vm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return gm()?r.variantDarkId:r.variantLightId}return t}function Ao(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=hk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ao(nl(),_d());function m9(){return rd===void 0&&(rd={themeId:nl(),systemDark:gm(),preferSystem:_d()}),rd}function h9(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function g9(){const t=y.useSyncExternalStore(h9,m9),{themeId:s,preferSystem:o}=t,r=hk(s,o),c=y.useCallback(u=>{if(ik.has(u)){try{localStorage.setItem(hm,u)}catch{}Ao(u,_d(),!0),Rp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(pk,u?"true":"false")}catch{}if(u){const p=nl(),m=pm(p);if(m!=null&&m.hidden){const g=vm(p);if(g)try{localStorage.setItem(hm,g.id)}catch{}}}Ao(nl(),u,!0),Rp()},[]);return y.useEffect(()=>{Ao(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(mk),p=()=>{const m=nl(),g=_d();if(g){const v=pm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ao(m,g),v!=null&&v.hidden){const b=vm(m);b!=null&&b.variantDarkId&&b.variantLightId&&Ao(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const gk=y.createContext(void 0);function v9({children:t}){const s=g9();return a.jsx(gk.Provider,{value:s,children:t})}function yh(){const t=y.useContext(gk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const vk=y.createContext(void 0),yk=y.createContext(void 0);function y9({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(yk.Provider,{value:r,children:a.jsx(vk.Provider,{value:s,children:t})})}function b9(){return y.useContext(vk)}function _9(){const t=y.useContext(yk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const bh=y.createContext(void 0);function pt(){const t=y.useContext(bh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function bk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _k(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function x9(t){return bk(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")&&(t.toolCallId===void 0||typeof t.toolCallId=="string")}const k9=new Set(["off","subscription","api_key"]),Zc=new Set(["off","on"]);function S9(t){return bk(t)&&k9.has(t.claude)&&Zc.has(t.github)&&Zc.has(t.copilot)&&Zc.has(t.codex)&&Zc.has(t.goose)}function xk(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 kk(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 Co=5e3;function j9(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 Ei={label:"Home",url:Fo};function T9(t){return t?[Ei,{label:"Settings",url:ji},{label:t,url:void 0}]:[Ei,{label:"Settings",url:void 0}]}const Sk={label:"Environments",url:zo};function N9(){return[Ei,{label:"Environments",url:void 0}]}function w9(){return[Ei,{label:"New Chat",url:void 0}]}function C9(t){return[Ei,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function E9(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ei,Sk,{label:(d==null?void 0:d.displayName)??"Environment",url:$o(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function A9(t,s,o,r,c){const d=j9(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ei];v&&g&&(b.push(Sk),b.push({label:v.displayName,url:$o(g)})),m&&g&&b.push({label:m.name,url:wi(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:ls(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function _h(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 u_(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 D9(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 Ip(t,s,o){return t.toolCallId?t.toolCallId:s?o(s):void 0}function xh(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const o=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const p=Ip(u,s.get(u),u_);if(p)try{const m=JSON.parse(u.content);o.set(p,{tool:m.tool,args:m.args})}catch{}}const r=new Set,d=t.map(u=>{if(u.eventType!=="tool_result")return u;const p=Ip(u,s.get(u),D9);if(!p)return u;const m=o.get(p);if(!m)return u;r.add(p);let g;const v=u.content.trim();if(v.startsWith("{"))try{const b=JSON.parse(v);typeof b.detailedContent=="string"&&(g=b.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:g}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const p=Ip(u,s.get(u),u_);return!(p&&r.has(p))});for(let u=0;u<d.length;u++){if(d[u].eventType!=="tool_use")continue;let p=!1;for(let m=u+1;m<d.length;m++)if(d[m].eventType!=="tool_use"){p=!0;break}p&&(d[u]={...d[u],settled:!0})}return d}function M9(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=jk(s),d=s.filter(m=>ym(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||ym(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function jk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function ym(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function R9(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=jk(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}):ym(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 I9(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 O9(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 Ds=[{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
325
+ --- End forwarded ---`}function xI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function kI({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(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),N=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=T;A<=N;A++)A<t.length&&ul(t[A])&&D.add(A);return D})}else d(T=>{const N=new Set(T);return N.has(S)?N.delete(S):N.add(S),N.size===0?(r(!1),u.current=void 0):u.current=S,N})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)ul(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((N,C)=>N-C).filter(N=>N<t.length).map(N=>t[N]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const SI="_wrapper_1cdza_1",jI="_scrollContainer_1cdza_9",TI="_selectingPadding_1cdza_16",NI="_toolbar_1cdza_20",wI="_directionToggle_1cdza_27",CI="_scrollToAnchor_1cdza_65",EI="_scrollToAnchorBottom_1cdza_89",AI="_scrollToAnchorTop_1cdza_93",DI="_eventOverflowWarning_1cdza_97",oa={wrapper:SI,scrollContainer:jI,selectingPadding:TI,toolbar:NI,directionToggle:wI,scrollToAnchor:CI,scrollToAnchorBottom:EI,scrollToAnchorTop:AI,eventOverflowWarning:DI},MI=10*1024,RI=new Set(["running","idle"]);function II(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 W1="grackle-stream-direction";function OI(){try{return localStorage.getItem(W1)==="reversed"}catch{return!1}}function BI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(Sm,{size:Ht,"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 mh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(OI),k=Z4(),[S,j]=y.useState(!1),[T,N]=y.useState(!1),[C,D]=y.useState(void 0),A=kI({events:t,formatForClipboard:J1}),E=y.useMemo(()=>t.filter(ul).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>RI.has(ce.status)&&ce.id!==d):[],[c,d]),O=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=vI({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(W1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,T]);const V=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),ne=y.useCallback(()=>[...A.selectedIndices].sort((me,xe)=>me-xe).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const xe=u==null?void 0:u.find(De=>De.id===me.environmentId);return(xe==null?void 0:xe.displayName)??me.environmentId.slice(0,8)},[c,u]),Z=y.useCallback(async(ce,me)=>{if(!m)return;const xe=le(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${xe}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,A]),se=y.useCallback(ce=>{j(!1);const me=ne(),xe=le(d),De=_I(xe,me);if(new TextEncoder().encode(De).length>MI){D({sessionId:ce,text:De}),N(!0);return}Z(ce,De).catch(()=>{})},[ne,le,d,Z]),H=y.useCallback(()=>{N(!1),C&&(Z(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,Z]),B=y.useCallback(()=>{N(!1),D(void 0)},[]),F=k?0:.2,ge=b?-8:8,ee=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Ci,{text:b?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?a.jsx(xy,{size:Ht,"aria-hidden":"true"}):a.jsx(ky,{size:Ht,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(BI,{eventsDropped:s}),a.jsx(os,{initial:!1,children:O.map((ce,me)=>{const xe=b?t.length-1-me:me;return a.jsx(Pt.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:F,ease:"easeOut"},children:a.jsx(L6,{copyText:bI(ce),isContentBearing:ul(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(xe),checkboxLabel:II(ce),onSelect:()=>{A.enterSelectionMode(xe)},onToggle:De=>{A.toggleEvent(xe,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(kD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${xe}`)})})]}),a.jsx(os,{children:A.isSelecting&&a.jsx(F6,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{V().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),a.jsx(mI,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:se,onCancel:()=>{j(!1)}}),a.jsx(_s,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${ee} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:B}),a.jsx(os,{children:!M&&a.jsxs(Pt.button,{className:`${oa.scrollToAnchor} ${b?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:$,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:[b?a.jsx(ky,{size:Ht,"aria-hidden":"true"}):a.jsx(xy,{size:Ht,"aria-hidden":"true"})," New events"]})})]})}function hh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(O=>{v(O),_("")},[]),T=y.useCallback(()=>{_("")},[]),N=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(O===M){N();return}o(O),N()},[g,s,m,r,o,N]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(O=>{if(k.current){k.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?N():O.key==="Enter"&&p&&C()},[N,p,C]),R=(()=>{if(!S)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:N,save:C,setDraft:j,clearError:T,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const LI="_editFieldWrapper_yuzty_1",zI="_editInput_yuzty_10",$I="_editTextarea_yuzty_42",HI="_editSelect_yuzty_78",PI="_editError_yuzty_111",UI="_editInputInvalid_yuzty_118",VI="_editHint_yuzty_123",qI="_unsavedDot_yuzty_132",GI="_metaValueClickable_yuzty_140",FI="_editButton_yuzty_159",KI="_metaPlaceholder_yuzty_175",ZI="_worktreeToggle_yuzty_180",it={editFieldWrapper:LI,editInput:zI,editTextarea:$I,editSelect:HI,editError:PI,editInputInvalid:UI,editHint:VI,unsavedDot:qI,metaValueClickable:GI,editButton:FI,metaPlaceholder:KI,worktreeToggle:ZI};function zt(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:_,"data-testid":k}=t,S=y.useRef(null),j=hh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const N=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(N)}},[j.isEditing]),c==="create"){const N=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:N,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:N=>j.setDraft(N.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function fm(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":_}=t,k=y.useRef(null),S=hh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var N;(N=k.current)==null||N.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},N=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${N?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),N&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:N})]})}if(S.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function bd(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":_}=t,k=y.useRef(null),S=hh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const j=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return a.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});const N=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function YI(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const JI="_nav_1snmp_1",WI="_searchForm_1snmp_8",XI="_searchInput_1snmp_15",QI="_searchButton_1snmp_33",e5="_clearButton_1snmp_68",t5="_workspaceSelect_1snmp_85",n5="_listHeader_1snmp_99",s5="_nodeList_1snmp_108",a5="_nodeItem_1snmp_116",i5="_indicator_1snmp_129",o5="_label_1snmp_136",r5="_badge_1snmp_145",es={nav:JI,searchForm:WI,searchInput:XI,searchButton:QI,clearButton:e5,workspaceSelect:t5,listHeader:n5,nodeList:s5,nodeItem:a5,indicator:i5,label:o5,badge:r5};function l5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:es.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:es.searchForm,onSubmit:v,children:[a.jsx("input",{className:es.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:es.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:es.clearButton,onClick:b,children:"Clear search"}),a.jsxs("select",{className:es.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:es.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:es.nodeList,children:t.map(S=>a.jsxs("li",{className:es.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:es.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:es.label,children:S.label}),a.jsx("span",{className:es.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const c5="_container_bwu10_1",d5="_hamburger_bwu10_33",u5="_brand_bwu10_49",f5="_brandLogo_bwu10_68",p5="_info_bwu10_75",m5="_connectionLabel_bwu10_90",h5="_connectionDot_bwu10_103",g5="_connected_bwu10_106",v5="_disconnected_bwu10_110",y5="_connecting_bwu10_113",Ms={container:c5,hamburger:d5,brand:u5,brandLogo:f5,info:p5,connectionLabel:m5,connectionDot:h5,connected:g5,disconnected:v5,connecting:y5},b5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},_5={connected:Ms.connected,connecting:Ms.connecting,disconnected:Ms.disconnected};function x5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=b5[t];return a.jsxs("div",{className:Ms.container,children:[r&&a.jsx("button",{type:"button",className:Ms.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(wT,{size:Et,"aria-hidden":"true"})}),a.jsx(Ci,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ms.brand,onClick:()=>d(Fo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:Id("icon-192x192.png"),alt:"",className:Ms.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ms.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ms.connectionDot} ${_5[t]}`,"aria-hidden":"true",children:a.jsx(Ni,{size:G_,fill:"currentColor"})})," ",a.jsx("span",{className:Ms.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const k5="_nav_gx5h3_1",S5="_tab_gx5h3_35",j5="_tabIcon_gx5h3_68",T5="_tabLabel_gx5h3_79",N5="_tabActive_gx5h3_84",w5="_tabEnd_gx5h3_90",wo={nav:k5,tab:S5,tabIcon:j5,tabLabel:T5,tabActive:N5,tabEnd:w5},ad=[{view:"dashboard",label:"Dashboard",icon:a.jsx(mT,{size:Et}),route:Fo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(Kj,{size:Et}),route:cC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(RT,{size:Et}),route:zo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(ET,{size:Et}),route:lC,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:a.jsx($j,{size:Et}),route:hx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(OT,{size:Et}),route:px,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(ZT,{size:Et}),route:sC,testId:"sidebar-tab-settings",align:"end"}];function C5(t){return t===Fo||t==="/"?"dashboard":t.startsWith(px)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(hx)?"knowledge":t.startsWith(ji)?"settings":"tasks"}function E5({tabs:t=ad}){var g;const s=Wt(),o=xt(),r=y.useRef(null),c=C5(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(N=>N===document.activeElement),k=_>=0?_:d.findIndex(N=>N.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return a.jsx("nav",{className:wo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return a.jsx(Ci,{text:v.label,placement:"bottom",className:_?wo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${wo.tab} ${b?wo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:wo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:wo.tabLabel,children:v.label})]})},v.view)})})}const A5="_container_pi6ii_1",D5="_content_pi6ii_66",n_={container:A5,content:D5},M5=320,X1=220,Q1=600,ek="grackle-sidebar-width";function R5(){try{const t=localStorage.getItem(ek);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=X1&&s<=Q1)return s}}catch{}return M5}function I5(t){try{localStorage.setItem(ek,String(t))}catch{}}function O5({content:t}){const[s]=y.useState(R5),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>=X1&&m<=Q1&&I5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:n_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:n_.content,children:t})})}const B5="_bar_tnfsh_1",L5="_btnPrimary_tnfsh_32",z5="_statusText_tnfsh_85",$5="_statusCompleted_tnfsh_90",H5="_statusFailed_tnfsh_94",P5="_statusBlocked_tnfsh_98",U5="_hintText_tnfsh_103",Ct={bar:B5,btnPrimary:L5,statusText:z5,statusCompleted:$5,statusFailed:H5,statusBlocked:P5,hintText:U5};function V5({sessions:t,tasks:s,environments:o}){const r=xt(),c=Wt(),d=nn("/sessions/:sessionId"),u=nn("/tasks/:taskId"),p=nn("/tasks/:taskId/stream"),m=nn("/tasks/:taskId/edit"),g=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=nn("/sessions/new"),k=nn("/environments/:environmentId/workspaces/:workspaceId"),S=nn("/tasks/new"),j=nn("/chat"),T=nn("/"),N=nn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,O=!!j,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!M&&!$&&!Y||!!N||(!!m||!!b)||Y||R||M)return a.jsx(a.Fragment,{});if(O)return o.find(se=>se.adapterType==="local"&&se.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Add a local environment to start chatting"})});if($)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Select a task or click + to create one"})});if(D){const Z=s.find(B=>B.id===D);if(!Z)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})});const se=new Map(s.map(B=>[B.id,B])),H=Z.dependsOn.some(B=>{const F=se.get(B);return F!==void 0&&F.status!=="complete"});if(Z.status==="not_started"){const B=H?Z.dependsOn.map(F=>se.get(F)).filter(F=>F&&F.status!=="complete").map(F=>F.title):[];return a.jsx("div",{className:Ct.bar,children:H?a.jsxs("span",{className:Ct.statusBlocked,children:["Blocked by: ",B.join(", ")]}):a.jsx("span",{className:Ct.hintText,children:"Use the buttons above to start or manage this task"})})}if(Z.status==="working"||Z.status==="paused"){const B=Z.latestSessionId||void 0,F=B?t.find(ee=>ee.id===B):void 0;return F&&F.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Waiting for agent..."})})}if(Z.status==="complete")return a.jsxs("div",{className:Ct.bar,children:[a.jsx("span",{className:`${Ct.statusText} ${Ct.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Ri(Z.workspaceId,void 0,E)),className:Ct.btnPrimary,children:"+ New Task"})]});if(Z.status==="failed")return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:`${Ct.statusText} ${Ct.statusFailed}`,children:"Task failed"})})}if(C){const Z=t.find(B=>B.id===C),se=(Z==null?void 0:Z.status)==="stopped";if(Z!==void 0&&!se)return a.jsx(a.Fragment,{});if(se)return a.jsxs("div",{className:Ct.bar,children:[a.jsxs("span",{className:`${Ct.statusText} ${Ct.hintText}`,children:["Session ",Z.endReason||Z.status]}),a.jsx("button",{onClick:()=>r(dx(Z.environmentId)),className:Ct.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})})}const q5="_nav_14i94_1",G5="_tab_14i94_24",F5="_tabActive_14i94_62",K5="_tabLabel_14i94_75",Z5="_statusDot_14i94_81",Y5="_pulse_14i94_87",J5="_addButton_14i94_99",W5="_empty_14i94_132",Ua={nav:q5,tab:G5,tabActive:F5,tabLabel:K5,statusDot:Z5,pulse:Y5,addButton:J5,empty:W5},X5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function Q5({environments:t}){const s=xt(),o=y.useRef(null),r=nn("/environments/:environmentId"),c=nn("/environments/:environmentId/edit"),d=nn("/environments/:environmentId/workspaces/:workspaceId"),u=nn("/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(_=>{s($o(_))},[s]),v=y.useCallback(_=>{var N;const k=(N=o.current)==null?void 0:N.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s($o(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Ua.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=X5[_.status]||"var(--text-tertiary)",T=_.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ua.tab} ${k?Ua.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${Ua.statusDot} ${T?Ua.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(Ni,{size:G_,fill:"currentColor"})}),a.jsx("span",{className:Ua.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),a.jsx("button",{type:"button",className:Ua.addButton,onClick:()=>s(tC),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:Ua.empty,children:"No environments yet."})]})}function eO(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 tk({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=eO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function tO(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 nO(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 iN){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ya(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=Ya(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const sO="_container_z4i38_1",aO="_header_z4i38_5",iO="_headerActions_z4i38_17",oO="_searchInput_z4i38_23",rO="_searchHighlight_z4i38_56",lO="_groupToggle_z4i38_62",cO="_groupToggleActive_z4i38_89",dO="_addButton_z4i38_93",uO="_taskRow_z4i38_120",fO="_selected_z4i38_140",pO="_expandArrow_z4i38_150",mO="_expanded_z4i38_157",hO="_leafSpacer_z4i38_161",gO="_taskStatusIcon_z4i38_166",vO="_taskTitle_z4i38_170",yO="_workspaceBadge_z4i38_177",bO="_childCountBadge_z4i38_195",_O="_dependencyBadge_z4i38_208",xO="_blockedBadge_z4i38_220",kO="_addChildButton_z4i38_225",SO="_emptyState_z4i38_268",jO="_statusGroupHeader_z4i38_275",TO="_statusGroupIcon_z4i38_294",NO="_statusGroupLabel_z4i38_298",wO="_statusGroupCount_z4i38_303",We={container:sO,header:aO,headerActions:iO,searchInput:oO,searchHighlight:rO,groupToggle:lO,groupToggleActive:cO,addButton:dO,taskRow:uO,selected:fO,expandArrow:pO,expanded:mO,leafSpacer:hO,taskStatusIcon:gO,taskTitle:vO,workspaceBadge:yO,childCountBadge:bO,dependencyBadge:_O,blockedBadge:xO,addChildButton:kO,emptyState:SO,statusGroupHeader:jO,statusGroupIcon:TO,statusGroupLabel:NO,statusGroupCount:wO},CO=[{name:"title",weight:2},{name:"description",weight:1}],nk=16,EO=16,sk="grackle-task-group-by-status";function s_(){try{return localStorage.getItem(sk)==="true"}catch{return!1}}function AO(t){try{localStorage.setItem(sk,String(t))}catch{}}function DO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:We.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${We.expandArrow} ${s?We.expanded:""}`,"aria-hidden":"true",children:a.jsx(pa,{size:Ye})}),a.jsx("span",{className:We.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:We.statusGroupLabel,children:t.label}),a.jsx("span",{className:We.statusGroupCount,children:t.tasks.length})]}),a.jsx(os,{children:s&&a.jsx(Pt.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=Ya(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(ls(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(ls(p.id)))},className:`${We.taskRow} ${g?We.selected:""}`,style:{"--task-indent":`${nk}px`},"data-task-id":p.id,children:[a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${fl(p.status)}`,children:m.icon}),a.jsx("span",{className:We.taskTitle,title:p.title,children:a.jsx(tk,{text:p.title,indices:d.get(p.id),highlightClass:We.searchHighlight})}),v&&a.jsx("span",{className:We.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ak({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ya(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(N=>u.get(N)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=nk+s*EO,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(ls(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:N=>{N.currentTarget===N.target&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),d(ls(t.id)))},className:`${We.taskRow} ${k?We.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&a.jsx("span",{className:`${We.expandArrow} ${b?We.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),r(t.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),r(t.id))},children:a.jsx(pa,{size:Ye,"aria-hidden":"true"})}),!_&&a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${fl(t.status)}`,children:g.icon}),a.jsx("span",{className:We.taskTitle,title:t.title,children:a.jsx(tk,{text:t.title,indices:p.get(t.id),highlightClass:We.searchHighlight})}),T&&a.jsx("span",{className:We.workspaceBadge,title:T,children:T}),_&&a.jsxs("span",{className:We.childCountBadge,children:[t.children.filter(N=>N.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${We.dependencyBadge} ${v?We.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<W2&&a.jsx(Ci,{text:"Add child task",children:a.jsx("button",{onClick:N=>{N.stopPropagation(),d(Ri(t.workspaceId,t.id))},"aria-label":"Add child task",className:We.addChildButton,children:"+"})})]}),a.jsx(os,{children:_&&b&&a.jsx(Pt.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(N=>a.jsx(ak,{node:N,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},N.id))})})]})}function MO({workspaces:t,tasks:s}){const o=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(s_),[g,v]=y.useState(s_),[b,_]=y.useState(new Map),k=nn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(Z=>[Z.id,Z.status])),[s]),T=y.useMemo(()=>new Map(t.map(Z=>[Z.id,Z.name])),[t]),N=()=>{const Z=!p;AO(Z),m(Z),Z&&(v(!0),_(new Map))},C=Z=>{_(se=>{const H=new Map(se),B=H.has(Z)?H.get(Z):g;return H.set(Z,!B),H})},D=Z=>b.has(Z)?b.get(Z):g,A=Z=>{c(se=>{const H=new Set(se);return H.has(Z)?(H.delete(Z),u(B=>new Set(B).add(Z))):(H.add(Z),u(B=>{const F=new Set(B);return F.delete(Z),F})),H})};y.useEffect(()=>{const Z=new Set(s.filter(se=>se.parentTaskId).map(se=>se.parentTaskId));Z.size>0&&c(se=>{const H=new Set(se);for(const B of Z)d.has(B)||H.add(B);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const Z=J2(s,E,CO),se=new Set(Z.map(ge=>ge.item.id)),H=new Map;for(const ge of Z){const ee=ge.matches.find(ce=>ce.key==="title");ee&&H.set(ge.item.id,ee.indices)}const B=new Set(se),F=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...se]){let ee=F.get(ge);for(;ee!=null&&ee.parentTaskId;)B.add(ee.parentTaskId),ee=F.get(ee.parentTaskId)}return{directMatchTaskIds:se,treeMatchTaskIds:B,titleHighlights:H}},[E,s]),Y=O!==null,V=Y?p?O:M:null,ne=V?s.filter(Z=>V.has(Z.id)):s,le=p?[]:tO(ne);return a.jsxs("div",{className:We.container,children:[a.jsxs("div",{className:We.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:We.headerActions,children:[a.jsx(Ci,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${We.groupToggle} ${p?We.groupToggleActive:""}`,onClick:N,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(ST,{size:Ht})})}),a.jsx(Ci,{text:"New task",children:a.jsx("button",{className:We.addButton,onClick:()=>o(Ri()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:Z=>R(Z.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:We.searchInput,"data-testid":"sidebar-search"}),p?nO(ne,j).map(Z=>a.jsx(DO,{group:Z,isExpanded:D(Z.status),onToggle:()=>C(Z.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},Z.status)):le.map(Z=>a.jsx(ak,{node:Z,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},Z.id)),ne.length===0&&!Y&&a.jsx("div",{className:We.emptyState,children:"No tasks yet. Click + to create one."}),ne.length===0&&Y&&a.jsx("div",{className:We.emptyState,children:"No matching tasks"})]})}const RO="_toast_ed2dk_1",IO="_success_ed2dk_18",OO="_icon_ed2dk_22",BO="_error_ed2dk_25",LO="_warning_ed2dk_32",zO="_info_ed2dk_38",$O="_message_ed2dk_53",HO="_close_ed2dk_60",qr={toast:RO,success:IO,icon:OO,error:BO,warning:LO,info:zO,message:$O,close:HO},PO={success:a.jsx(Ai,{size:Et}),error:a.jsx(Ls,{size:Et}),warning:a.jsx(Sm,{size:Et}),info:a.jsx(km,{size:Et})};function UO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Pt.div,{className:`${qr.toast} ${qr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[a.jsx("span",{className:qr.icon,"aria-hidden":"true",children:PO[t.variant]}),a.jsx("span",{className:qr.message,children:t.message}),a.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]})}const VO="_container_qqse2_1",qO={container:VO};function GO({toasts:t,onDismiss:s}){return a.jsx("div",{className:qO.container,"data-testid":"toast-container",children:a.jsx(os,{children:t.map(o=>a.jsx(UO,{toast:o,onDismiss:s},o.id))})})}const FO="_callout_e5awm_1",KO="_success_e5awm_11",ZO="_icon_e5awm_15",YO="_error_e5awm_18",JO="_warning_e5awm_25",WO="_info_e5awm_32",XO="_content_e5awm_48",QO="_close_e5awm_53",Gr={callout:FO,success:KO,icon:ZO,error:YO,warning:JO,info:WO,content:XO,close:QO},eB={success:a.jsx(Ai,{size:Et}),error:a.jsx(Ls,{size:Et}),warning:a.jsx(Sm,{size:Et}),info:a.jsx(km,{size:Et})};function tB({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:eB[t]}),a.jsx("span",{className:Gr.content,children:s}),o&&a.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]})})}function nB({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(tB,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",a.jsx("code",{children:c})]})})}const sB="_container_m1fsr_1",aB="_heading_m1fsr_7",iB="_section_m1fsr_14",oB="_sectionTitle_m1fsr_26",rB="_sectionDescription_m1fsr_35",lB="_emptyState_m1fsr_41",cB="_tokenList_m1fsr_48",dB="_tokenRow_m1fsr_55",uB="_tokenBadge_m1fsr_68",fB="_tokenName_m1fsr_83",pB="_tokenTarget_m1fsr_90",mB="_deleteButton_m1fsr_99",hB="_addForm_m1fsr_113",gB="_formRow_m1fsr_119",vB="_input_m1fsr_125",yB="_select_m1fsr_155",bB="_addButton_m1fsr_187",_B="_emptyStateInfo_m1fsr_221",xB="_themeOptions_m1fsr_229",kB="_themeOption_m1fsr_229",SB="_themeOptionSelected_m1fsr_254",jB="_themeOptionHeader_m1fsr_259",TB="_themeOptionLabel_m1fsr_266",NB="_themeOptionDesc_m1fsr_273",wB="_variantToggle_m1fsr_279",CB="_variantButton_m1fsr_286",EB="_variantActive_m1fsr_305",AB="_themeSwatches_m1fsr_311",DB="_themeSwatch_m1fsr_311",MB="_systemToggle_m1fsr_325",RB="_systemToggleHint_m1fsr_341",IB="_themeActive_m1fsr_348",OB="_aboutGrid_m1fsr_354",BB="_aboutItem_m1fsr_360",LB="_aboutLabel_m1fsr_373",zB="_aboutValue_m1fsr_379",$B="_aboutDot_m1fsr_387",HB="_aboutDotConnected_m1fsr_394",PB="_aboutDotDisconnected_m1fsr_398",UB="_aboutDotConnecting_m1fsr_402",fe={container:sB,heading:aB,section:iB,sectionTitle:oB,sectionDescription:rB,emptyState:lB,tokenList:cB,tokenRow:dB,tokenBadge:uB,tokenName:fB,tokenTarget:pB,deleteButton:mB,addForm:hB,formRow:gB,input:vB,select:yB,addButton:bB,emptyStateInfo:_B,themeOptions:xB,themeOption:kB,themeOptionSelected:SB,themeOptionHeader:jB,themeOptionLabel:TB,themeOptionDesc:NB,variantToggle:wB,variantButton:CB,variantActive:EB,themeSwatches:AB,themeSwatch:DB,systemToggle:MB,systemToggleHint:RB,themeActive:IB,aboutGrid:OB,aboutItem:BB,aboutLabel:LB,aboutValue:zB,aboutDot:$B,aboutDotConnected:HB,aboutDotDisconnected:PB,aboutDotConnecting:UB},VB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function qB({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(""),[_,k]=y.useState(null),S=N=>{if(N.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("")},j=N=>{k(N)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return a.jsxs(a.Fragment,{children:[a.jsx(_s,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:fe.tokenList,children:t.map(N=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenBadge,children:N.tokenType}),a.jsx("span",{className:fe.tokenName,children:N.name}),a.jsx("span",{className:fe.tokenTarget,children:N.tokenType==="env_var"?N.envVar:N.filePath}),a.jsx("button",{className:fe.deleteButton,onClick:()=>j(N.name),title:`Delete ${N.name}`,"aria-label":`Delete ${N.name}`,children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]},N.name))}),a.jsxs("form",{className:fe.addForm,onSubmit:S,children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:N=>d(N.target.value)}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:N=>p(N.target.value)})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsx("select",{className:fe.select,value:m,onChange:N=>g(N.target.value),children:VB.map(N=>a.jsx("option",{value:N.value,children:N.label},N.value))}),a.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:N=>b(N.target.value)}),a.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Od=[{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"]}],ik=new Set(Od.map(t=>t.id)),a_="grackle";function pm(t){return Od.find(s=>s.id===t)}function GB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:fe.themeOptions,children:Od.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return a.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:fe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:fe.themeOptionLabel,children:d.label}),a.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:fe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:fe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:fe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const FB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},KB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function ZB({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"About"}),a.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:fe.aboutGrid,children:[a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:fe.aboutValue,children:[a.jsx("span",{className:`${fe.aboutDot} ${KB[t]}`}),FB[t]]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:fe.aboutValue,children:d})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Version"}),a.jsx("span",{className:fe.aboutValue,children:"0.126.1"})]})]})]})}const YB="_container_cddyd_1",JB="_header_cddyd_8",WB="_headerTitle_cddyd_35",XB="_badge_cddyd_44",QB="_headerActions_cddyd_54",eL="_body_cddyd_61",tL="_formContent_cddyd_73",nL="_section_cddyd_85",sL="_label_cddyd_91",aL="_titleInput_cddyd_98",iL="_descriptionTextarea_cddyd_131",oL="_parentContext_cddyd_167",rL="_parentLabel_cddyd_175",lL="_parentName_cddyd_182",cL="_personaSelect_cddyd_186",dL="_depList_cddyd_220",uL="_depItem_cddyd_226",fL="_depItemSelected_cddyd_248",pL="_noDeps_cddyd_252",mL="_btnPrimary_cddyd_258",hL="_btnGhost_cddyd_289",Qe={container:YB,header:JB,headerTitle:WB,badge:XB,headerActions:QB,body:eL,formContent:tL,section:nL,label:sL,titleInput:aL,descriptionTextarea:iL,parentContext:oL,parentLabel:rL,parentName:lL,personaSelect:cL,depList:dL,depItem:uL,depItemSelected:fL,noDeps:pL,btnPrimary:mL,btnGhost:hL};function ok({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 _=xt(),k=t==="edit",S=k&&s?d.find(ke=>ke.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,N]=y.useState(j),C=j||T,D=u.find(ke=>ke.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",O=R?d.find(ke=>ke.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[ne,le]=y.useState((S==null?void 0:S.dependsOn)??[]),[Z,se]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,B]=y.useState((S==null?void 0:S.canDecompose)??!1),[F,ge]=y.useState((S==null?void 0:S.injectKnowledge)??!0),[ee,ce]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{k&&S&&!me.current&&(me.current=!0,$(S.title),V(S.description),le(S.dependsOn),se(S.defaultPersonaId),B(S.canDecompose),ge(S.injectKnowledge))},[k,S]);const xe=d.filter(ke=>ke.workspaceId===C&&(!k||ke.id!==s)&&ke.id!==R),De=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ot=ke=>{le(ct=>ct.includes(ke)?ct.filter(ue=>ue!==ke):[...ct,ke])},bt=()=>{!De||ee||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,ne,Z),b==null||b("Task updated","success"),v?v():_(ls(s,void 0,C,A),{replace:!0})):(ce(!0),m(C,M.trim(),Y,ne.length>0?ne:void 0,R||void 0,Z,H,F,()=>{b==null||b("Task created","success"),_(o?wi(o,A):"/tasks",{replace:!0})},ke=>{b==null||b(ke,"error"),ce(!1)})))},lt=()=>{if(v){v();return}_(k&&s?ls(s,void 0,C,A):o?wi(o,A):"/tasks")},Pe=k?"edit task":R?"child task":"new task";return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsxs("div",{className:Qe.headerTitle,children:[a.jsx("span",{className:Qe.badge,children:Pe}),O&&a.jsxs("span",{className:Qe.parentContext,children:[a.jsx("span",{className:Qe.parentLabel,children:"Child of"}),a.jsx("span",{className:Qe.parentName,children:O.title})]})]}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx("button",{onClick:bt,disabled:!De||ee,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:ee?"Creating…":k?"Save Changes":"Create"}),a.jsx("button",{onClick:lt,className:Qe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:Qe.body,children:a.jsxs("div",{className:Qe.formContent,children:[E&&a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:T,onChange:ke=>N(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:ke=>$(ke.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:ke=>{ke.key==="Enter"&&De&&bt()}})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:ke=>V(ke.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:Z,onChange:ke=>se(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:H,onChange:ke=>B(ke.target.checked)}),"Can spawn subtasks"]})}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-inject-knowledge",children:[a.jsx("input",{type:"checkbox",checked:F,onChange:ke=>ge(ke.target.checked)}),"Inject related prior work from the knowledge graph"]})}),a.jsxs("div",{className:Qe.section,children:[a.jsx("div",{className:Qe.label,children:"Dependencies"}),xe.length===0?a.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:Qe.depList,children:xe.map(ke=>{const ct=ne.includes(ke.id);return a.jsxs("label",{className:`${Qe.depItem} ${ct?Qe.depItemSelected:""}`,"data-testid":`dep-option-${ke.id}`,children:[a.jsx("input",{type:"checkbox",checked:ct,onChange:()=>ot(ke.id)}),ke.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ke.status,")"]})]},ke.id)})})]})]})})]})}const gL="_actionButtons_1rjka_1",vL="_btnPrimary_1rjka_8",yL="_btnDanger_1rjka_39",bL="_btnGhost_1rjka_78",Yt={actionButtons:gL,btnPrimary:vL,btnDanger:yL,btnGhost:bL};function _L({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:m,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Yt.btnPrimary,children:"Start"}),a.jsx("button",{onClick:m,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:Yt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:u,disabled:!s,className:Yt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:Yt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:c,className:Yt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return a.jsx("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:r,className:Yt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:p,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const xL="_workpadSection_y8nj9_1",kL="_workpadLabel_y8nj9_9",SL="_workpadStatus_y8nj9_17",jL="_workpadSummary_y8nj9_23",TL="_workpadExtra_y8nj9_29",Va={workpadSection:xL,workpadLabel:kL,workpadStatus:SL,workpadSummary:jL,workpadExtra:TL};function NL({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return a.jsxs("div",{className:Va.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Va.workpadLabel,children:"Workpad"}),a.jsx("div",{className:Va.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:Va.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Va.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:Va.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:Va.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:Va.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const wL="_overviewDashboard_r05qm_1",CL="_overviewHero_r05qm_7",EL="_statusBadge_r05qm_14",AL="_statusPending_r05qm_26",DL="_statusAssigned_r05qm_31",ML="_statusInProgress_r05qm_36",RL="_statusReview_r05qm_41",IL="_statusDone_r05qm_46",OL="_statusFailed_r05qm_51",BL="_statusWaitingInput_r05qm_56",LL="_overviewBranchPill_r05qm_61",zL="_branchLink_r05qm_76",$L="_overviewSection_r05qm_87",HL="_overviewLabel_r05qm_93",PL="_overviewValue_r05qm_100",UL="_overviewMuted_r05qm_105",VL="_overviewMarkdown_r05qm_111",qL="_envRow_r05qm_180",GL="_envDot_r05qm_186",FL="_envDotGreen_r05qm_193",KL="_envDotYellow_r05qm_197",ZL="_envDotRed_r05qm_201",YL="_envDotGray_r05qm_205",JL="_depList_r05qm_209",WL="_depItem_r05qm_215",XL="_depBlocked_r05qm_222",QL="_depDone_r05qm_226",e8="_timeline_r05qm_230",t8="_timelineRow_r05qm_236",n8="_timelineKey_r05qm_243",s8="_timelineValue_r05qm_249",a8="_timelineDelta_r05qm_253",i8="_reviewNotes_r05qm_264",be={overviewDashboard:wL,overviewHero:CL,statusBadge:EL,statusPending:AL,statusAssigned:DL,statusInProgress:ML,statusReview:RL,statusDone:IL,statusFailed:OL,statusWaitingInput:BL,overviewBranchPill:LL,branchLink:zL,overviewSection:$L,overviewLabel:HL,overviewValue:PL,overviewMuted:UL,overviewMarkdown:VL,envRow:qL,envDot:GL,envDotGreen:FL,envDotYellow:KL,envDotRed:ZL,envDotGray:YL,depList:JL,depItem:WL,depBlocked:XL,depDone:QL,timeline:e8,timelineRow:t8,timelineKey:n8,timelineValue:s8,timelineDelta:a8,reviewNotes:i8};function Gc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Cp(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function i_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function o8({status:t}){const s=Ya(t),o=aN(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function r8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(o8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?a.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(_m,{remarkPlugins:[xm],children:t.description})})]}),t.workpad&&a.jsx(NL,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${i_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${i_(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:_.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:T?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Cp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Cp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Cp(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Rs(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Rs(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Ho(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Ho(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Rs((u==null?void 0:u.costMillicents)??0)," / ",Rs(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function l8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:fe.heading,children:"Plugins"}),a.jsxs("div",{className:fe.section,children:[a.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function c8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[N,C]=y.useState(null),D=t.find(M=>M.id===N),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(N)try{await c(N),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},O=async()=>{T(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(_s,{isOpen:N!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:fe.tokenList,children:t.map(M=>a.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&a.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&a.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&a.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:a.jsx(XT,{size:Ht,"aria-hidden":"true"})}),a.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:a.jsx(Ls,{size:Ht,"aria-hidden":"true"})})]},M.id))}),a.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),a.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{O().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const d8="_container_legrg_1",u8="_header_legrg_8",f8="_headerTitle_legrg_35",p8="_badge_legrg_44",m8="_headerActions_legrg_54",h8="_body_legrg_61",g8="_formContent_legrg_73",v8="_section_legrg_85",y8="_label_legrg_91",b8="_nameInput_legrg_98",_8="_fieldInput_legrg_131",x8="_adapterSelect_legrg_164",k8="_readOnlyValue_legrg_198",S8="_codespaceSection_legrg_204",j8="_codespaceActions_legrg_210",T8="_creatingHint_legrg_216",N8="_errorHint_legrg_222",w8="_btnPrimary_legrg_235",C8="_btnGhost_legrg_266",oe={container:d8,header:u8,headerTitle:f8,badge:p8,headerActions:m8,body:h8,formContent:g8,section:v8,label:y8,nameInput:b8,fieldInput:_8,adapterSelect:x8,readOnlyValue:k8,codespaceSection:S8,codespaceActions:j8,creatingHint:T8,errorHint:N8,btnPrimary:w8,btnGhost:C8},id=1,od=65535;function Ep(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=id&&s<=od}function Ap(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function E8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?a.jsxs("div",{className:oe.codespaceSection,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repository"}),a.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:oe.codespaceActions,children:[a.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:oe.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:oe.codespaceSection,children:a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:oe.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:oe.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:oe.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:oe.errorHint,children:d})]})})}function rk({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=xt(),N=t==="edit",C=N&&s?o.find(re=>re.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[O,M]=y.useState(""),[$,Y]=y.useState(""),[V,ne]=y.useState(""),[le,Z]=y.useState(""),[se,H]=y.useState(""),[B,F]=y.useState(""),[ge,ee]=y.useState(""),[ce,me]=y.useState(""),[xe,De]=y.useState("create"),[ot,bt]=y.useState(""),[lt,Pe]=y.useState(null),ke=y.useCallback(()=>{const re={};if(E==="local"){if(O.trim()&&(re.host=O.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.port=ve)}}else if(E==="ssh"){if(re.host=O.trim(),V.trim()&&(re.user=V.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.sshPort=ve)}le.trim()&&(re.identityFile=le.trim())}else E==="docker"?xe==="attach"?ot.trim()&&(re.attach=ot.trim()):(se.trim()&&(re.image=se.trim()),B.trim()&&(re.repo=B.trim())):E==="codespace"&&(re.codespaceName=ge.trim());return re},[E,O,$,V,le,se,B,ge,xe,ot]),ct=()=>!(!D.trim()||E==="ssh"&&!O.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&xe==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Ep($)),ue=()=>{ct()&&(c(D.trim(),E,ke(),ce||void 0),j==null||j("Environment added successfully","success"),T(zo,{replace:!0}))},Re=()=>{T(s?$o(s):zo)},Q=y.useCallback((re,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig),an=ve.trim();an?et[re]=an:delete et[re],d(s,{adapterConfig:et})},[C,s,d]),nt=y.useCallback((re,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig);if(ve.trim()){const an=Number(ve);Number.isInteger(an)&&an>=id&&an<=od&&(et[re]=an)}else delete et[re];d(s,{adapterConfig:et})},[C,s,d]);if(N){if(!C)return a.jsxs("div",{className:oe.container,children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsx("div",{className:oe.formContent,children:a.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const re=Ap(C.adapterConfig);return a.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Re,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Name"}),a.jsx(zt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:lt,onActivate:Pe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Adapter Type"}),a.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(zt,{value:String(re.host??""),onSave:ve=>Q("host",ve),mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Port"}),a.jsx(zt,{value:String(re.port??""),onSave:ve=>nt("port",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(zt,{value:String(re.host??""),onSave:ve=>Q("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"User"}),a.jsx(zt,{value:String(re.user??""),onSave:ve=>Q("user",ve),mode:"edit",fieldId:"user",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"SSH Port"}),a.jsx(zt,{value:String(re.sshPort??""),onSave:ve=>nt("sshPort",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:lt,onActivate:Pe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Identity File"}),a.jsx(zt,{value:String(re.identityFile??""),onSave:ve=>Q("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:lt,onActivate:Pe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&re.attach!==void 0&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Attach (container)"}),a.jsx(zt,{value:String(re.attach??""),onSave:ve=>Q("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:lt,onActivate:Pe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&re.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Image"}),a.jsx(zt,{value:String(re.image??""),onSave:ve=>Q("image",ve),mode:"edit",fieldId:"image",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repo"}),a.jsx(zt,{value:String(re.repo??""),onSave:ve=>Q("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:lt,onActivate:Pe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace Name"}),a.jsx(zt,{value:String(re.codespaceName??""),onSave:ve=>Q("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:lt,onActivate:Pe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"new environment"})}),a.jsxs("div",{className:oe.headerActions,children:[a.jsx("button",{onClick:ue,disabled:!ct(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:re=>A(re.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:re=>{re.key==="Enter"&&ct()&&ue()}})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:re=>{R(re.target.value),re.target.value==="codespace"&&u(ce||void 0)},className:oe.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:re=>{me(re.target.value),E==="codespace"&&u(re.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(re=>a.jsxs("option",{value:re.id,children:[re.label," (@",re.username,")",re.isDefault?" — default":""]},re.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:re=>Y(re.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:V,onChange:re=>ne(re.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:re=>Y(re.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:re=>Z(re.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:xe,onChange:re=>{const ve=re.target.value;De(ve),ve==="attach"&&_()},className:oe.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),xe==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:se,onChange:re=>H(re.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:re=>F(re.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Container"}),!S&&k.length>0&&a.jsxs("select",{value:ot,onChange:re=>{bt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},className:oe.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),k.map(re=>a.jsxs("option",{value:re.name,children:[re.name," (",re.image,") ",re.status]},re.id))]}),(S||k.length===0)&&a.jsxs(a.Fragment,{children:[S?a.jsx("span",{className:oe.errorHint,children:S}):a.jsx("span",{className:oe.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:ot,onChange:re=>{bt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},placeholder:"Enter container name/ID...",className:oe.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(E8,{codespaceName:ge,onCodespaceNameChange:ee,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const A8="_group_1iprv_1",D8="_groupTitle_1iprv_8",M8="_shortcutList_1iprv_17",R8="_shortcutRow_1iprv_23",I8="_keys_1iprv_36",O8="_kbd_1iprv_43",B8="_description_1iprv_60",_i={group:A8,groupTitle:D8,shortcutList:M8,shortcutRow:R8,keys:I8,kbd:O8,description:B8},L8=[{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"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function z8(){return a.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),L8.map(t=>a.jsxs("div",{className:_i.group,children:[a.jsx("h4",{className:_i.groupTitle,children:t.title}),a.jsx("div",{className:_i.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:_i.shortcutRow,children:[a.jsx("span",{className:_i.keys,children:s.keys.map(o=>a.jsx("kbd",{className:_i.kbd,children:o},o))}),a.jsx("span",{className:_i.description,children:s.description})]},s.description))})]},t.title))]})}const $8=[{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 H8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:fe.tokenList,children:$8.map(r=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenName,children:r.label}),a.jsx("span",{className:fe.tokenTarget,children:r.description}),a.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const P8="_container_10efq_1",U8="_header_10efq_7",V8="_list_10efq_105",q8="_card_10efq_111",G8="_cardHeader_10efq_125",F8="_cardTitle_10efq_135",K8="_defaultBadge_10efq_141",Z8="_cardActions_10efq_155",Y8="_description_10efq_160",J8="_meta_10efq_166",W8="_empty_10efq_212",X8="_typeBadge_10efq_362",ts={container:P8,header:U8,list:V8,card:q8,cardHeader:G8,cardTitle:F8,defaultBadge:K8,cardActions:Z8,description:Y8,meta:J8,empty:W8,typeBadge:X8};function Q8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:ts.container,children:[a.jsxs("div",{className:ts.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ts.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ts.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return a.jsxs("div",{className:ts.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ts.cardHeader,children:[a.jsxs("span",{className:ts.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ts.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&a.jsx("span",{className:ts.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ts.description,children:v.description}),a.jsxs("div",{className:ts.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(_s,{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 e7="_container_uy08i_1",t7="_header_uy08i_7",n7="_count_uy08i_13",s7="_presets_uy08i_18",a7="_presetButton_uy08i_24",i7="_filterInput_uy08i_41",o7="_groups_uy08i_53",r7="_group_uy08i_53",l7="_groupHeader_uy08i_68",c7="_groupName_uy08i_77",d7="_groupCount_uy08i_81",u7="_toolList_uy08i_87",f7="_toolItem_uy08i_95",p7="_toolName_uy08i_103",yn={container:e7,header:t7,count:n7,presets:s7,presetButton:a7,filterInput:i7,groups:o7,group:r7,groupHeader:l7,groupName:c7,groupCount:d7,toolList:u7,toolItem:f7,toolName:p7},m7=(()=>{const t=new Map;for(const s of z_){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()}))})(),h7=[{name:"default",label:"Default",tools:L_},{name:"worker",label:"Worker",tools:X2},{name:"orchestrator",label:"Orchestrator",tools:Q2},{name:"admin",label:"Admin",tools:ej}];function o_({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 _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:yn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:yn.header,children:a.jsx("span",{className:yn.count,children:t.length===0?`Using default (${L_.length} tools)`:`${t.length} of ${z_.size} tools selected`})}),a.jsxs("div",{className:yn.presets,"data-testid":"mcp-tool-presets",children:[h7.map(v=>a.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:yn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:yn.groups,children:m7.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return a.jsxs("div",{className:yn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:yn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:yn.groupName,children:v}),a.jsxs("span",{className:yn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),a.jsx("div",{className:yn.toolList,children:_.map(S=>a.jsxs("label",{className:yn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:yn.toolName,children:S})]},S))})]},v)})})]})}function mm(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function lk(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const g7="_container_1gfuq_1",v7="_header_1gfuq_7",y7="_list_1gfuq_19",b7="_card_1gfuq_25",_7="_cardHeader_1gfuq_40",x7="_cardTitle_1gfuq_46",k7="_statusBadge_1gfuq_56",S7="_enabled_1gfuq_68",j7="_disabled_1gfuq_71",T7="_cardActions_1gfuq_75",N7="_cardMeta_1gfuq_80",w7="_empty_1gfuq_98",ns={container:g7,header:v7,list:y7,card:b7,cardHeader:_7,cardTitle:x7,statusBadge:k7,enabled:S7,disabled:j7,cardActions:T7,cardMeta:N7,empty:w7};function C7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return a.jsxs("div",{className:ns.container,children:[a.jsxs("div",{className:ns.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ns.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ns.list,children:t.map(_=>a.jsxs("div",{className:ns.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[a.jsxs("div",{className:ns.cardHeader,children:[a.jsxs("span",{className:ns.cardTitle,children:[a.jsx("strong",{children:_.title}),a.jsx("span",{className:`${ns.statusBadge} ${_.enabled?ns.enabled:ns.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ns.cardActions,onClick:k=>k.stopPropagation(),children:[a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),a.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ns.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?mm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",lk(_.nextRunAt)]}):null,_.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),a.jsx(_s,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const E7="_nav_1bhou_1",A7="_tab_1bhou_24",D7="_tabIcon_1bhou_62",M7="_tabActive_1bhou_68",Fc={nav:E7,tab:A7,tabIcon:D7,tabActive:M7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(vT,{size:Et})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(dT,{size:Et})},{path:"personas",label:"Personas",icon:a.jsx(tN,{size:Et})},{path:"schedules",label:"Schedules",icon:a.jsx(Pj,{size:Et})},{path:"appearance",label:"Appearance",icon:a.jsx(LT,{size:Et})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(bT,{size:Et})},{path:"plugins",label:"Plugins",icon:a.jsx(VT,{size:Et})},{path:"about",label:"About",icon:a.jsx(km,{size:Et})}];function R7(){var u;const t=Wt(),s=xt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${ji}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${ji}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=ia.length-1;else return;const _=ia[b].path;s(`${ji}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Fc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Fc.tab} ${m?Fc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Fc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const I7=["lifecycle:","pipe:","stdin:"];function gh(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function ck(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function O7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=ck(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const B7="_container_16qkd_1",L7="_header_16qkd_7",z7="_title_16qkd_15",$7="_headerActions_16qkd_21",H7="_internalsToggle_16qkd_27",P7="_refreshButton_16qkd_37",U7="_state_16qkd_52",V7="_group_16qkd_59",q7="_groupHeader_16qkd_63",G7="_row_16qkd_72",F7="_selected_16qkd_92",K7="_kindBadge_16qkd_96",Z7="_kindChatroom_16qkd_108",Y7="_kindPipe_16qkd_114",J7="_kindChannel_16qkd_120",W7="_streamName_16qkd_126",X7="_meta_16qkd_135",Jt={container:B7,header:L7,title:z7,headerActions:$7,internalsToggle:H7,refreshButton:P7,state:U7,group:V7,groupHeader:q7,row:G7,selected:F7,kindBadge:K7,kindChatroom:Z7,kindPipe:Y7,kindChannel:J7,streamName:W7,meta:X7},Q7={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function ez({kind:t}){return t==="chatroom"?a.jsx(DT,{size:Ye,"aria-hidden":"true"}):t==="pipe"?a.jsx(lT,{size:Ye,"aria-hidden":"true"}):a.jsx(fT,{size:Ye,"aria-hidden":"true"})}function tz({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v,hideHeaderControls:b=!1}){const _=O7(t,s),k={chatroom:Jt.kindChatroom,pipe:Jt.kindPipe,channel:Jt.kindChannel},S=j=>{var T;return((T=o.find(N=>N.id===j))==null?void 0:T.title)??j};return a.jsxs("div",{className:Jt.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:Jt.header,children:[a.jsx("span",{className:Jt.title,children:"Coordination"}),!b&&a.jsxs("div",{className:Jt.headerActions,children:[a.jsxs("label",{className:Jt.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:j=>p(j.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:Jt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(GT,{size:Ye,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:Jt.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(j=>a.jsxs("div",{className:Jt.group,children:[a.jsx("div",{className:Jt.groupHeader,children:j.taskId?S(j.taskId):"Unattached / external (CLI · MCP)"}),j.streams.map(T=>{const N=gh(T),C=T.id===m;return a.jsxs("button",{type:"button",className:`${Jt.row}${C?` ${Jt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":C?"page":void 0,children:[a.jsxs("span",{className:`${Jt.kindBadge} ${k[N]}`,children:[a.jsx(ez,{kind:N})," ",Q7[N]]}),a.jsx("span",{className:Jt.streamName,children:T.name}),a.jsxs("span",{className:Jt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},j.taskId??"__orphans__"))]})}const nz="_transcript_1p4cm_1",sz="_message_1p4cm_10",az="_meta_1p4cm_16",iz="_sender_1p4cm_24",oz="_time_1p4cm_29",rz="_content_1p4cm_34",lz="_state_1p4cm_42",qa={transcript:nz,message:sz,meta:az,sender:iz,time:oz,content:rz,state:lz};function cz(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function dz({messages:t,loading:s=!1}){return s?a.jsx("div",{className:qa.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?a.jsx("div",{className:qa.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):a.jsx("div",{className:qa.transcript,"data-testid":"stream-transcript",children:t.map(o=>a.jsxs("div",{className:qa.message,"data-testid":"stream-transcript-message",children:[a.jsxs("div",{className:qa.meta,children:[a.jsx("span",{className:qa.sender,title:o.senderId,children:o.senderId.slice(0,12)}),a.jsx("span",{className:qa.time,children:cz(o.timestamp)})]}),a.jsx("div",{className:qa.content,children:o.content})]},o.seq))})}const uz="_panel_iibrt_1",fz="_header_iibrt_24",pz="_title_iibrt_33",mz="_closeButton_iibrt_43",hz="_body_iibrt_57",gz="_section_iibrt_63",vz="_sectionLabel_iibrt_67",yz="_metaRow_iibrt_76",bz="_metaKey_iibrt_84",_z="_metaValue_iibrt_90",xz="_subscriberCard_iibrt_99",kz="_subscriberHeader_iibrt_107",Sz="_sessionLink_iibrt_114",jz="_badges_iibrt_132",Tz="_badgeRw_iibrt_150 _badge_iibrt_132",Nz="_badgeR_iibrt_150 _badge_iibrt_132",wz="_badgeW_iibrt_162 _badge_iibrt_132",Cz="_badgeAsync_iibrt_168 _badge_iibrt_132",Ez="_badgeSync_iibrt_174 _badge_iibrt_132",Az="_badgeDetach_iibrt_178 _badge_iibrt_132",Dz="_spawnTag_iibrt_184 _badge_iibrt_132",Mz="_fdNumber_iibrt_189",Rz="_emptySubscribers_iibrt_195",Iz="_metaValueMono_iibrt_201 _metaValue_iibrt_90",Oz="_advanced_iibrt_216",Bz="_advancedSummary_iibrt_220",He={panel:uz,header:fz,title:pz,closeButton:mz,body:hz,section:gz,sectionLabel:vz,metaRow:yz,metaKey:bz,metaValue:_z,subscriberCard:xz,subscriberHeader:kz,sessionLink:Sz,badges:jz,badgeRw:Tz,badgeR:Nz,badgeW:wz,badgeAsync:Cz,badgeSync:Ez,badgeDetach:Az,spawnTag:Dz,fdNumber:Mz,emptySubscribers:Rz,metaValueMono:Iz,advanced:Oz,advancedSummary:Bz},Lz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function zz({permission:t}){const s=t==="rw"?He.badgeRw:t==="r"?He.badgeR:He.badgeW;return a.jsx("span",{className:s,children:t})}function $z({mode:t}){const s=t==="async"?He.badgeAsync:t==="detach"?He.badgeDetach:He.badgeSync;return a.jsx("span",{className:s,children:t})}function Hz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=xt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),a.jsxs("div",{className:He.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:He.header,children:[a.jsx("h3",{className:He.title,children:t.name}),a.jsx("button",{type:"button",className:He.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:He.body,children:[a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Overview"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Kind"}),a.jsx("span",{className:He.metaValue,children:Lz[gh(t)]})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Participants"}),a.jsx("span",{className:He.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Buffered"}),a.jsxs("span",{className:He.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:He.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:He.sessionLink,onClick:()=>{c(Mm(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&a.jsx("span",{className:He.spawnTag,children:"spawn"})]},d.subscriptionId))]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Conversation"}),a.jsx(dz,{messages:s??[],loading:o??!1})]}),a.jsxs("details",{className:He.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:He.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Stream ID"}),a.jsx("span",{className:He.metaValueMono,children:t.id})]}),t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,children:[a.jsxs("div",{className:He.subscriberHeader,children:[a.jsxs("span",{className:He.fdNumber,children:["fd ",d.fd]}),a.jsxs("span",{className:He.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:He.badges,children:[a.jsx(zz,{permission:d.permission}),a.jsx($z,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}function Dp(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}const Pz=["--accent-green","--accent-yellow","--accent-red","--text-tertiary"];function dk(t,s){if(s)return{varName:"--text-tertiary",label:"External"};switch(t){case"running":return{varName:"--accent-green",label:"Running"};case"idle":case"suspended":case"hibernating":return{varName:"--accent-yellow",label:Dp(t)};case"failed":case"interrupted":return{varName:"--accent-red",label:Dp(t)};default:return{varName:"--text-tertiary",label:t.length>0?Dp(t):"Unknown"}}}const uk="session",vh="stream",r_="messageDot";function Kc(t){return`session:${t}`}function l_(t){return`stream:${t}`}function Uz(t){return{id:t,environmentId:"",runtime:"external",status:"external",prompt:"",startedAt:""}}function Vz(t,s){return t==="detach"?{stroke:s,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6}:{stroke:s,strokeWidth:1.5}}function qz(t,s){const o=t.permission.includes("w"),r=s.permission.includes("w"),c=t.permission.includes("r"),d=s.permission.includes("r");if(o&&!r&&d)return{source:t,target:s,bidirectional:!1};if(r&&!o&&c)return{source:s,target:t,bidirectional:!1};const u=[t,s].sort((p,m)=>p.sessionId.localeCompare(m.sessionId));return{source:u[0],target:u[1],bidirectional:!0}}function Gz(t,s){if(t.length===0)return{nodes:[],edges:[]};const o=new Map(s.map(m=>[m.id,m])),r=new Map,c=new Map,d=[],u=m=>{let g=r.get(m);if(!g){const v=o.get(m);g={kind:"session",session:v??Uz(m),streamCount:0,external:v===void 0},r.set(m,g)}return g};for(const m of t){const g=gh(m);if(g==="pipe"&&m.subscribers.length===2&&m.subscribers[0].sessionId!==m.subscribers[1].sessionId){const[v,b]=m.subscribers;u(v.sessionId).streamCount+=1,u(b.sessionId).streamCount+=1;const{source:_,target:k,bidirectional:S}=qz(v,b);d.push({id:`edge-pipe-${m.id}`,source:Kc(_.sessionId),target:Kc(k.sessionId),type:r_,data:{edgeKind:"pipe",streamId:m.id,permission:S?"rw":_.permission,deliveryMode:_.deliveryMode},style:{stroke:"var(--accent-yellow)",strokeWidth:1.5,strokeDasharray:"6 3"},markerEnd:{type:Mc.ArrowClosed},markerStart:S?{type:Mc.ArrowClosed}:void 0,animated:!1});continue}c.set(m.id,{kind:"stream",stream:m,streamKind:g,ownership:ck(m,o)});for(const v of m.subscribers){u(v.sessionId).streamCount+=1;const b=l_(m.id),_=Kc(v.sessionId),k=v.permission.includes("w"),S=v.permission.includes("r");let j,T,N=!1;k&&S?(j=_,T=b,N=!0):S?(j=b,T=_):(j=_,T=b),d.push({id:`edge-part-${m.id}-${v.subscriptionId}`,source:j,target:T,type:r_,data:{edgeKind:"participation",streamId:m.id,permission:v.permission,deliveryMode:v.deliveryMode},style:Vz(v.deliveryMode,"var(--text-tertiary)"),markerEnd:{type:Mc.ArrowClosed},markerStart:N?{type:Mc.ArrowClosed}:void 0,animated:!1})}}const p=[];for(const[m,g]of r)p.push({id:Kc(m),type:uk,position:{x:0,y:0},data:g});for(const[m,g]of c)p.push({id:l_(m),type:vh,position:{x:0,y:0},data:g});return{nodes:p,edges:d}}const Fz=200,Kz=64,Zz=180,Yz=56,Jz=40,Wz=70;function c_(t){return t===vh?{width:Zz,height:Yz}:{width:Fz,height:Kz}}function Xz(t){if(t.nodes.length===0)return t;const s=new ld.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:Jz,ranksep:Wz});for(const r of t.nodes){const{width:c,height:d}=c_(r.type);s.setNode(r.id,{width:c,height:d})}for(const r of t.edges)s.setEdge(r.source,r.target,{},r.id);return ld.layout(s),{nodes:t.nodes.map(r=>{const c=s.node(r.id),{width:d,height:u}=c_(r.type);return{...r,position:{x:c.x-d/2,y:c.y-u/2}}}),edges:t.edges}}function Qz(t,s){return y.useMemo(()=>Xz(Gz(t,s)),[t,s])}const e$="_graphContainer_1uzcp_1",t$="_empty_1uzcp_18",n$="_nodeContent_1uzcp_28",s$="_nodeHeader_1uzcp_38",a$="_nodeTitle_1uzcp_50",i$="_nodeMeta_1uzcp_58",o$="_nodeSubtle_1uzcp_64",r$="_countBadge_1uzcp_69",l$="_sessionNode_1uzcp_81",c$="_sessionAccent_1uzcp_103",d$="_external_1uzcp_109",u$="_streamNode_1uzcp_114",f$="_chatroom_1uzcp_134",p$="_channel_1uzcp_139",m$="_pipe_1uzcp_143",h$="_haloless_1uzcp_147",g$="_selected_1uzcp_153",v$="_kindBadge_1uzcp_158",y$="_handle_1uzcp_172",b$="_messageDot_1uzcp_179",vt={graphContainer:e$,empty:t$,nodeContent:n$,nodeHeader:s$,nodeTitle:a$,nodeMeta:i$,nodeSubtle:o$,countBadge:r$,sessionNode:l$,sessionAccent:c$,external:d$,streamNode:u$,chatroom:f$,channel:p$,pipe:m$,haloless:h$,selected:g$,kindBadge:v$,handle:y$,messageDot:b$};function _$({data:t}){const{session:s,streamCount:o,external:r}=t,c=dk(s.status,r),d=`var(${c.varName})`,u=r?`${vt.sessionNode} ${vt.external}`:vt.sessionNode;return a.jsxs("div",{className:u,"data-testid":`coordination-node-session-${s.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsx("div",{className:vt.sessionAccent,style:{backgroundColor:d}}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.nodeTitle,children:r?s.id:s.runtime})}),a.jsxs("div",{className:vt.nodeMeta,children:[a.jsx("span",{className:vt.nodeSubtle,style:{color:d},children:c.label}),o>0&&a.jsx("span",{className:vt.countBadge,children:o})]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}function x$({data:t,selected:s}){const{stream:o,streamKind:r,ownership:c}=t,d=r==="chatroom"?vt.chatroom:r==="pipe"?vt.pipe:vt.channel,u=[vt.streamNode,d];return c.kind!=="task"&&u.push(vt.haloless),s&&u.push(vt.selected),a.jsxs("div",{className:u.join(" "),"data-testid":`coordination-node-stream-${o.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.kindBadge,children:r})}),a.jsx("span",{className:vt.nodeTitle,children:o.name}),a.jsxs("span",{className:vt.nodeSubtle,children:[o.subscriberCount," ",o.subscriberCount===1?"subscriber":"subscribers"]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}const d_="0.7s",k$=3;function S$(t){const{sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u,markerStart:p,markerEnd:m,style:g,data:v}=t,[b]=V2({sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u}),_=v==null?void 0:v.pulseSeq;return a.jsxs(a.Fragment,{children:[a.jsx(q2,{path:b,markerStart:p,markerEnd:m,style:g}),_!==void 0&&a.jsxs("circle",{r:k$,opacity:0,className:vt.messageDot,"data-testid":"coordination-message-dot",children:[a.jsx("animateMotion",{dur:d_,repeatCount:"1",path:b}),a.jsx("animate",{attributeName:"opacity",dur:d_,repeatCount:"1",values:"0;1;1;0",keyTimes:"0;0.1;0.85;1"})]},_)]})}const Mp="#6b7a8d",j$={[uk]:_$,[vh]:x$},T$={messageDot:S$};function N$({streams:t,sessions:s,selectedStreamId:o,onSelectStream:r,recentMessages:c,resolvedThemeId:d}){const u=Qz(t,s),p=y.useMemo(()=>u.edges.map(_=>{var S,j;if(!_.data)return _;const k=(j=(S=c==null?void 0:c[_.data.streamId])==null?void 0:S.at(-1))==null?void 0:j.seq;return k===void 0?_:{..._,data:{..._.data,pulseSeq:k}}}),[u.edges,c]),m=y.useMemo(()=>u.nodes.map(_=>{const k=_.data;return k.kind==="stream"&&k.stream.id===o?{..._,selected:!0}:_}),[u.nodes,o]),g=y.useMemo(()=>{const _=getComputedStyle(document.documentElement),k={};for(const S of Pz)k[S]=_.getPropertyValue(S).trim()||Mp;return k},[d]),v=y.useCallback((_,k)=>{const S=k.data;S.kind==="stream"&&r(S.stream.id)},[r]),b=y.useCallback(_=>{const k=_.data;return k.kind==="session"?g[dk(k.session.status,k.external).varName]??Mp:Mp},[g]);return u.nodes.length===0?a.jsx("div",{className:vt.empty,"data-testid":"coordination-graph-empty",children:"No active streams to visualize"}):a.jsx("div",{className:vt.graphContainer,"data-testid":"coordination-graph",children:a.jsxs(M_,{nodes:m,edges:p,nodeTypes:j$,edgeTypes:T$,onNodeClick:v,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[a.jsx(R_,{variant:I_.Dots,gap:24,size:1,color:"var(--text-disabled)"}),a.jsx(O_,{showInteractive:!1}),a.jsx(B_,{nodeColor:b,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function w$({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(Sy.map(d=>[d,[]]));for(const d of t){const u=fl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Sy.map(d=>{const u=Ya(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const C$="_boardContainer_1c4y1_1",E$="_column_1c4y1_17",A$="_columnHeader_1c4y1_34",D$="_columnIcon_1c4y1_47",M$="_columnLabel_1c4y1_52",R$="_columnCount_1c4y1_57",I$="_cardList_1c4y1_67",O$="_emptyPlaceholder_1c4y1_76",B$="_card_1c4y1_67",L$="_cardHeader_1c4y1_107",z$="_cardStatusIcon_1c4y1_113",$$="_cardTitle_1c4y1_119",H$="_cardBadges_1c4y1_127",P$="_badge_1c4y1_134",U$="_blockedBadge_1c4y1_146",V$="_childBadge_1c4y1_151",q$="_depBadge_1c4y1_155",G$="_parentBadge_1c4y1_159",F$="_pausedSubBadge_1c4y1_166",K$="_personaBadge_1c4y1_170",Z$="_envBadge_1c4y1_174",Y$="_emptyCta_1c4y1_178",J$="_ctaButton_1c4y1_188",W$="_ctaDescription_1c4y1_204",dt={boardContainer:C$,column:E$,columnHeader:A$,columnIcon:D$,columnLabel:M$,columnCount:R$,cardList:I$,emptyPlaceholder:O$,card:B$,cardHeader:L$,cardStatusIcon:z$,cardTitle:$$,cardBadges:H$,badge:P$,blockedBadge:U$,childBadge:V$,depBadge:q$,parentBadge:G$,pausedSubBadge:F$,personaBadge:K$,envBadge:Z$,emptyCta:Y$,ctaButton:J$,ctaDescription:W$};function X$({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,N=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&T.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&N.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:N}},[p,r,c,d]),b=y.useMemo(()=>w$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:dt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:dt.ctaButton,onClick:()=>u(Ri(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:dt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:dt.boardContainer,"data-testid":"board-container",children:b.map(_=>a.jsxs("section",{className:dt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:dt.columnHeader,children:[a.jsx("span",{className:dt.columnIcon,style:{color:_.style.color},children:_.style.icon}),a.jsx("span",{className:dt.columnLabel,children:_.label}),a.jsx("span",{className:dt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),a.jsx("div",{className:dt.cardList,children:_.tasks.length===0?a.jsx("div",{className:dt.emptyPlaceholder,children:"No tasks"}):a.jsx(os,{mode:"popLayout",children:_.tasks.map(k=>a.jsx(Pt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(Q$,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(ls(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function Q$({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ya(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:dt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[a.jsxs("div",{className:dt.cardHeader,children:[a.jsx("span",{className:dt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:dt.cardTitle,children:d.title})]}),a.jsxs("div",{className:dt.cardBadges,children:[b&&a.jsx("span",{className:`${dt.badge} ${dt.parentBadge}`,title:b.title,children:b.title}),p>0&&a.jsxs("span",{className:`${dt.badge} ${dt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${dt.badge} ${dt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${dt.badge} ${dt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${dt.badge} ${dt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${dt.badge} ${dt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${dt.badge} ${dt.envBadge}`,children:r})]})]})}const e9="_formContent_ymnez_1",t9="_section_ymnez_13",n9="_label_ymnez_19",s9="_titleInput_ymnez_26",a9="_descriptionTextarea_ymnez_58",i9="_selectField_ymnez_94",o9="_checkboxRow_ymnez_128",r9="_checkboxLabel_ymnez_141",l9="_fieldError_ymnez_146",jt={formContent:e9,section:t9,label:n9,titleInput:s9,descriptionTextarea:a9,selectField:i9,checkboxRow:o9,checkboxLabel:r9,fieldError:l9};function c9(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const d9=100;function u9({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:jt.formContent,children:[a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:jt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:d9,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:jt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:jt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:jt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:jt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:jt.section,children:a.jsxs("label",{className:jt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:jt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:jt.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 fk=y.createContext(void 0),f9=4e3;function p9({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=f9)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(fk.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=y.useContext(fk);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const hm="grackle-theme",pk="grackle-prefer-system",mk="(prefers-color-scheme: dark)";let Jr=[],rd;function Rp(){rd=void 0;for(const t of Jr)t()}function gm(){return typeof window>"u"?!1:window.matchMedia(mk).matches}function nl(){if(typeof localStorage>"u")return a_;try{const t=localStorage.getItem(hm);if(t!==null&&ik.has(t))return t}catch{}return a_}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(pk)==="true"}catch{return!1}}function vm(t){return Od.find(s=>s.variantLightId===t||s.variantDarkId===t)}function hk(t,s){const o=pm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?gm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=vm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return gm()?r.variantDarkId:r.variantLightId}return t}function Ao(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=hk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ao(nl(),_d());function m9(){return rd===void 0&&(rd={themeId:nl(),systemDark:gm(),preferSystem:_d()}),rd}function h9(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function g9(){const t=y.useSyncExternalStore(h9,m9),{themeId:s,preferSystem:o}=t,r=hk(s,o),c=y.useCallback(u=>{if(ik.has(u)){try{localStorage.setItem(hm,u)}catch{}Ao(u,_d(),!0),Rp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(pk,u?"true":"false")}catch{}if(u){const p=nl(),m=pm(p);if(m!=null&&m.hidden){const g=vm(p);if(g)try{localStorage.setItem(hm,g.id)}catch{}}}Ao(nl(),u,!0),Rp()},[]);return y.useEffect(()=>{Ao(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(mk),p=()=>{const m=nl(),g=_d();if(g){const v=pm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ao(m,g),v!=null&&v.hidden){const b=vm(m);b!=null&&b.variantDarkId&&b.variantLightId&&Ao(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const gk=y.createContext(void 0);function v9({children:t}){const s=g9();return a.jsx(gk.Provider,{value:s,children:t})}function yh(){const t=y.useContext(gk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const vk=y.createContext(void 0),yk=y.createContext(void 0);function y9({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(yk.Provider,{value:r,children:a.jsx(vk.Provider,{value:s,children:t})})}function b9(){return y.useContext(vk)}function _9(){const t=y.useContext(yk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const bh=y.createContext(void 0);function pt(){const t=y.useContext(bh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function bk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _k(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function x9(t){return bk(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")&&(t.toolCallId===void 0||typeof t.toolCallId=="string")}const k9=new Set(["off","subscription","api_key"]),Zc=new Set(["off","on"]);function S9(t){return bk(t)&&k9.has(t.claude)&&Zc.has(t.github)&&Zc.has(t.copilot)&&Zc.has(t.codex)&&Zc.has(t.goose)}function xk(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 kk(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 Co=5e3;function j9(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 Ei={label:"Home",url:Fo};function T9(t){return t?[Ei,{label:"Settings",url:ji},{label:t,url:void 0}]:[Ei,{label:"Settings",url:void 0}]}const Sk={label:"Environments",url:zo};function N9(){return[Ei,{label:"Environments",url:void 0}]}function w9(){return[Ei,{label:"New Chat",url:void 0}]}function C9(t){return[Ei,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function E9(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ei,Sk,{label:(d==null?void 0:d.displayName)??"Environment",url:$o(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function A9(t,s,o,r,c){const d=j9(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ei];v&&g&&(b.push(Sk),b.push({label:v.displayName,url:$o(g)})),m&&g&&b.push({label:m.name,url:wi(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:ls(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function _h(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 u_(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 D9(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 Ip(t,s,o){return t.toolCallId?t.toolCallId:s?o(s):void 0}function xh(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const o=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const p=Ip(u,s.get(u),u_);if(p)try{const m=JSON.parse(u.content);o.set(p,{tool:m.tool,args:m.args})}catch{}}const r=new Set,d=t.map(u=>{if(u.eventType!=="tool_result")return u;const p=Ip(u,s.get(u),D9);if(!p)return u;const m=o.get(p);if(!m)return u;r.add(p);let g;const v=u.content.trim();if(v.startsWith("{"))try{const b=JSON.parse(v);typeof b.detailedContent=="string"&&(g=b.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:g}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const p=Ip(u,s.get(u),u_);return!(p&&r.has(p))});for(let u=0;u<d.length;u++){if(d[u].eventType!=="tool_use")continue;let p=!1;for(let m=u+1;m<d.length;m++)if(d[m].eventType!=="tool_use"){p=!0;break}p&&(d[u]={...d[u],settled:!0})}return d}function M9(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=jk(s),d=s.filter(m=>ym(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||ym(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function jk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function ym(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function R9(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=jk(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}):ym(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 I9(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 O9(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 Ds=[{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
326
326
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
327
327
  const header = req.headers.authorization;
328
328
  if (!header?.startsWith("Bearer ")) {
@@ -752,4 +752,4 @@ const grackle = await host.mcpServer({
752
752
  url: env.vars.GRACKLE_MCP_URL,
753
753
  });
754
754
 
755
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(o_,{selectedTools:Y,onChange:ue=>{V(ue),lt(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!me&&a.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,a.jsx(_s,{isOpen:ne,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:bt,onCancel:()=>le(!1)})]})}function sq(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=pt(),{showToast:c}=pn(),d=xt();return a.jsx(C7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(iC),onNavigateToSchedule:u=>d(fx(u))})}const aq="_container_1g4qh_1",iq="_form_1g4qh_7",oq="_formActions_1g4qh_66",rq="_editableSection_1g4qh_73",lq="_helperText_1g4qh_84",cq="_metaSection_1g4qh_90",dq="_optional_1g4qh_108",uq="_readonlyValue_1g4qh_113",Ln={container:aq,form:iq,formActions:oq,editableSection:rq,helperText:lq,metaSection:cq,optional:dq,readonlyValue:uq};function E_(){const{scheduleId:t}=ma(),s=xt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=pt(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return a.jsx($n,{to:np,replace:!0});const _=[{label:"Settings",url:ji},{label:"Schedules",url:np},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Ln.container,children:[a.jsx(ha,{segments:_}),a.jsx(fq,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(np)},showToast:o})]})}function fq({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=xt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,N]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,O]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),j(t.scheduleExpression),N(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(B=>({value:B.id,label:B.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ne=B=>{B.preventDefault(),$&&c(v,_,S,T,C||void 0).then(F=>{m("Schedule created","success"),g(fx(F.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,F)=>{t&&d(t.id,{[B]:F}).then(()=>{m("Schedule updated","success"),B==="title"&&b(String(F)),B==="description"&&k(String(F)),B==="scheduleExpression"&&j(String(F)),B==="personaId"&&N(String(F))},()=>{m("Failed to update schedule","error")})},Z=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},se=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[M?a.jsxs("div",{className:Ln.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:ne,className:Ln.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Ln.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:_,onChange:B=>k(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:B=>j(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Ln.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:T,onChange:B=>N(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Ln.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:V.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))})]}),a.jsxs("div",{className:Ln.formActions,children:[a.jsx(sn,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Ln.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Ln.formActions,children:[a.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(sn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(sn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Ln.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx(zt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:O,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx(zt,{value:_,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:R,onActivate:O,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx(zt,{value:S,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:O,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(bd,{value:T,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:O,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Ln.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Ln.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(B=>B.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Ln.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",mm(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",lk(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",mm(t.createdAt)]})]})]}):null,a.jsx(_s,{isOpen:A,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:se,onCancel:()=>E(!1)})]})}function pq(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=yh();return a.jsx(GB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function mq(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function hq(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=pt(),r=mq();return a.jsxs(a.Fragment,{children:[r&&a.jsx(nB,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(ZB,{connectionStatus:t,environments:s,sessions:o})]})}function gq(){return a.jsx(z8,{})}function vq(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=pt();return a.jsx(l8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const A_=Ri();function yq(){const t=xt();return Za({key:"?"},()=>{t(oC)}),Za({key:"n"},()=>{t(A_)}),Za({key:"N"},()=>{t(A_)}),a.jsx(a.Fragment,{})}function Ld(t){const s=_9();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function bq(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=pt(),o=y.useMemo(()=>a.jsx(MO,{workspaces:t,tasks:s}),[t,s]);return Ld(o),a.jsx(Mi,{})}function _q(){const{environments:{environments:t}}=pt(),s=y.useMemo(()=>a.jsx(Q5,{environments:t}),[t]);return Ld(s),a.jsx(Mi,{})}function xq(){const t=y.useMemo(()=>a.jsx(R7,{}),[]);return Ld(t),a.jsx(Mi,{})}function kq(){const{knowledge:t,workspaces:{workspaces:s}}=pt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(l5,{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 Ld(u),a.jsx(Mi,{})}const Sq="_wizard_1260s_1",jq="_container_1260s_10",Tq="_stepContent_1260s_19",Nq="_logoArea_1260s_28",wq="_logoImage_1260s_32",Cq="_heading_1260s_41",Eq="_tagline_1260s_49",Aq="_subtitle_1260s_56",Dq="_featureList_1260s_64",Mq="_runtimeGrid_1260s_89",Rq="_runtimeCard_1260s_101",Iq="_runtimeName_1260s_133",Oq="_runtimeDescription_1260s_139",Bq="_buttonRow_1260s_144",Lq="_primaryButton_1260s_151",zq="_ghostButton_1260s_185",$q="_dots_1260s_213",Hq="_dot_1260s_213",Xe={wizard:Sq,container:jq,stepContent:Tq,logoArea:Nq,logoImage:wq,heading:Cq,tagline:Eq,subtitle:Aq,featureList:Dq,runtimeGrid:Mq,runtimeCard:Rq,runtimeName:Iq,runtimeDescription:Oq,buttonRow:Bq,primaryButton:Lq,ghostButton:zq,dots:$q,dot:Hq};function Pq({onNext:t}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Xe.logoArea,children:a.jsx("img",{src:Id("grackle-logo.png"),alt:"Grackle",className:Xe.logoImage})}),a.jsx("h1",{className:Xe.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Xe.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function Uq({onNext:t,onBack:s}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Xe.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Xe.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Vq=[{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 qq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Xe.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Xe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Xe.runtimeGrid,children:Vq.map(u=>a.jsxs("button",{type:"button",className:Xe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Xe.runtimeName,children:u.name}),a.jsx("span",{className:Xe.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function Gq(){return typeof Notification<"u"}function Fq({onFinish:t,onBack:s,finishDisabled:o}){const r=Gq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Xe.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Xe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Xe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const Kq=4,D_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function Zq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=pt(),{showToast:c}=pn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=D_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const N=t.find(C=>C.id===py);if(N&&j!==N.runtime){const C=D_[j]??"sonnet";T.push(s(py,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?a.jsx($n,{to:"/",replace:!0}):a.jsx("div",{className:Xe.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Xe.container,children:[a.jsx(os,{mode:"wait",children:a.jsxs(Pt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Pq,{onNext:()=>p(1)}),u===1&&a.jsx(Uq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(qq,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&a.jsx(Fq,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Xe.dots,children:Array.from({length:Kq},(j,T)=>a.jsx("span",{className:Xe.dot,"data-active":T===u},T))})]})})}const Yq="_root_zndgp_1",Jq="_body_zndgp_7",Wq="_main_zndgp_19",Xq="_sidebarWrapper_zndgp_26",Qq="_overlay_zndgp_51",Wr={root:Yq,body:Jq,main:Wq,sidebarWrapper:Xq,overlay:Qq},eG=y.lazy(()=>P_(()=>import("./KnowledgePage-DQXY0aaB.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),Ck=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function tG({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=pt(),{toasts:d,dismissToast:u}=pn(),p=Wt(),m=b9(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(x5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),a.jsx(E5,{tabs:t}),a.jsxs("div",{className:Wr.body,children:[g&&a.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(O5,{content:m})}),g&&v&&a.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),a.jsxs("div",{className:Wr.main,children:[a.jsx(Mi,{}),a.jsx(V5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(GO,{toasts:d,onDismiss:u}),a.jsx(yq,{})]})}function nG(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=pt(),{pluginNames:p}=Bd(),{showToast:m}=pn();EH(s,m),IH(c,m),AH(o,r,m);const g=xt(),v=Wt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Mm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx($n,{to:"/setup",replace:!0});const b=Q9(p);return a.jsx(y9,{children:a.jsxs("div",{className:Wr.root,children:[Ck&&a.jsx(OC,{}),a.jsx(tG,{tabs:b})]})})}function Pp(){const{workspaceId:t}=ma(),{workspaces:{workspaces:s}}=pt(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx($n,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx($n,{to:m,replace:!0})}function sG(){const{pluginNames:t}=Bd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(_w,{children:[a.jsx(Ee,{path:"setup",element:a.jsx(Zq,{})}),a.jsxs(Ee,{element:a.jsx(nG,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(yU,{})}),a.jsx(Ee,{path:"sessions/new",element:a.jsx(zU,{})}),a.jsx(Ee,{path:"chat",element:a.jsx(CU,{})}),a.jsx(Ee,{path:"chat/:streamId",element:a.jsx($n,{to:"/coordination",replace:!0})}),a.jsx(Ee,{path:"coordination",element:a.jsx(LU,{})}),a.jsx(Ee,{path:"sessions/:sessionId",element:a.jsx(UU,{})}),o&&a.jsx(Ee,{element:a.jsx(kq,{}),children:a.jsx(Ee,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(Z1,{}),children:a.jsx(eG,{})})})}),s&&a.jsxs(Ee,{element:a.jsx(bq,{}),children:[a.jsx(Ee,{path:"tasks",element:a.jsx(gU,{})}),a.jsx(Ee,{path:"tasks/new",element:a.jsx(T_,{})}),a.jsx(Ee,{path:"tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/stream",element:a.jsx(Eo,{})})]}),a.jsxs(Ee,{element:a.jsx(_q,{}),children:[a.jsx(Ee,{path:"workspaces",element:a.jsx($n,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"workspaces/new",element:a.jsx(sV,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(FU,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(T_,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Eo,{})}),a.jsxs(Ee,{path:"environments",element:a.jsx(dV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(vU,{})}),a.jsx(Ee,{path:"new",element:a.jsx(iV,{})}),a.jsx(Ee,{path:":environmentId",element:a.jsx(HV,{})}),a.jsx(Ee,{path:":environmentId/edit",element:a.jsx(oV,{})})]})]}),a.jsx(Ee,{element:a.jsx(xq,{}),children:a.jsxs(Ee,{path:"settings",element:a.jsx(VV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx($n,{to:"credentials",replace:!0})}),a.jsx(Ee,{path:"environments",element:a.jsx($n,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"credentials",element:a.jsx(qV,{})}),a.jsx(Ee,{path:"github-accounts",element:a.jsx(GV,{})}),a.jsx(Ee,{path:"tokens",element:a.jsx($n,{to:"../credentials",replace:!0})}),a.jsx(Ee,{path:"personas",element:a.jsx(FV,{})}),a.jsx(Ee,{path:"personas/new",element:a.jsx(C_,{})}),a.jsx(Ee,{path:"personas/:personaId",element:a.jsx(C_,{})}),a.jsx(Ee,{path:"schedules",element:a.jsx(sq,{})}),a.jsx(Ee,{path:"schedules/new",element:a.jsx(E_,{})}),a.jsx(Ee,{path:"schedules/:scheduleId",element:a.jsx(E_,{})}),a.jsx(Ee,{path:"appearance",element:a.jsx(pq,{})}),a.jsx(Ee,{path:"shortcuts",element:a.jsx(gq,{})}),a.jsx(Ee,{path:"plugins",element:a.jsx(vq,{})}),a.jsx(Ee,{path:"about",element:a.jsx(hq,{})})]})}),a.jsx(Ee,{path:"*",element:a.jsx($n,{to:"/",replace:!0})})]})]})}const aG=1e4;function iG(){const{onboardingCompleted:t}=pt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),aG);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(os,{mode:"wait",children:r?a.jsx(Pt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(Z1,{})},"splash"):a.jsx(Pt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(Gw,{basename:"/".replace(/\/$/,""),children:a.jsx(sG,{})})},"app")})}function oG(){const t=Ck?F9:CH;return a.jsx(Y9,{children:a.jsx(v9,{children:a.jsx(p9,{children:a.jsx(t,{children:a.jsx(iG,{})})})})})}fj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(oG,{})}));export{ha as B,hx as K,pt as a,Mm as s,ls as t,xt as u};
755
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(o_,{selectedTools:Y,onChange:ue=>{V(ue),lt(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!me&&a.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,a.jsx(_s,{isOpen:ne,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:bt,onCancel:()=>le(!1)})]})}function sq(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=pt(),{showToast:c}=pn(),d=xt();return a.jsx(C7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(iC),onNavigateToSchedule:u=>d(fx(u))})}const aq="_container_1g4qh_1",iq="_form_1g4qh_7",oq="_formActions_1g4qh_66",rq="_editableSection_1g4qh_73",lq="_helperText_1g4qh_84",cq="_metaSection_1g4qh_90",dq="_optional_1g4qh_108",uq="_readonlyValue_1g4qh_113",Ln={container:aq,form:iq,formActions:oq,editableSection:rq,helperText:lq,metaSection:cq,optional:dq,readonlyValue:uq};function E_(){const{scheduleId:t}=ma(),s=xt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=pt(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return a.jsx($n,{to:np,replace:!0});const _=[{label:"Settings",url:ji},{label:"Schedules",url:np},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Ln.container,children:[a.jsx(ha,{segments:_}),a.jsx(fq,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(np)},showToast:o})]})}function fq({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=xt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,N]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,O]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),j(t.scheduleExpression),N(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(B=>({value:B.id,label:B.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ne=B=>{B.preventDefault(),$&&c(v,_,S,T,C||void 0).then(F=>{m("Schedule created","success"),g(fx(F.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,F)=>{t&&d(t.id,{[B]:F}).then(()=>{m("Schedule updated","success"),B==="title"&&b(String(F)),B==="description"&&k(String(F)),B==="scheduleExpression"&&j(String(F)),B==="personaId"&&N(String(F))},()=>{m("Failed to update schedule","error")})},Z=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},se=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[M?a.jsxs("div",{className:Ln.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:ne,className:Ln.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Ln.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:_,onChange:B=>k(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:B=>j(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Ln.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:T,onChange:B=>N(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Ln.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:V.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))})]}),a.jsxs("div",{className:Ln.formActions,children:[a.jsx(sn,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Ln.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Ln.formActions,children:[a.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(sn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(sn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Ln.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx(zt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:O,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx(zt,{value:_,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:R,onActivate:O,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx(zt,{value:S,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:O,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(bd,{value:T,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:O,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Ln.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Ln.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(B=>B.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Ln.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",mm(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",lk(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",mm(t.createdAt)]})]})]}):null,a.jsx(_s,{isOpen:A,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:se,onCancel:()=>E(!1)})]})}function pq(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=yh();return a.jsx(GB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function mq(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function hq(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=pt(),r=mq();return a.jsxs(a.Fragment,{children:[r&&a.jsx(nB,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(ZB,{connectionStatus:t,environments:s,sessions:o})]})}function gq(){return a.jsx(z8,{})}function vq(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=pt();return a.jsx(l8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const A_=Ri();function yq(){const t=xt();return Za({key:"?"},()=>{t(oC)}),Za({key:"n"},()=>{t(A_)}),Za({key:"N"},()=>{t(A_)}),a.jsx(a.Fragment,{})}function Ld(t){const s=_9();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function bq(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=pt(),o=y.useMemo(()=>a.jsx(MO,{workspaces:t,tasks:s}),[t,s]);return Ld(o),a.jsx(Mi,{})}function _q(){const{environments:{environments:t}}=pt(),s=y.useMemo(()=>a.jsx(Q5,{environments:t}),[t]);return Ld(s),a.jsx(Mi,{})}function xq(){const t=y.useMemo(()=>a.jsx(R7,{}),[]);return Ld(t),a.jsx(Mi,{})}function kq(){const{knowledge:t,workspaces:{workspaces:s}}=pt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(l5,{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 Ld(u),a.jsx(Mi,{})}const Sq="_wizard_1260s_1",jq="_container_1260s_10",Tq="_stepContent_1260s_19",Nq="_logoArea_1260s_28",wq="_logoImage_1260s_32",Cq="_heading_1260s_41",Eq="_tagline_1260s_49",Aq="_subtitle_1260s_56",Dq="_featureList_1260s_64",Mq="_runtimeGrid_1260s_89",Rq="_runtimeCard_1260s_101",Iq="_runtimeName_1260s_133",Oq="_runtimeDescription_1260s_139",Bq="_buttonRow_1260s_144",Lq="_primaryButton_1260s_151",zq="_ghostButton_1260s_185",$q="_dots_1260s_213",Hq="_dot_1260s_213",Xe={wizard:Sq,container:jq,stepContent:Tq,logoArea:Nq,logoImage:wq,heading:Cq,tagline:Eq,subtitle:Aq,featureList:Dq,runtimeGrid:Mq,runtimeCard:Rq,runtimeName:Iq,runtimeDescription:Oq,buttonRow:Bq,primaryButton:Lq,ghostButton:zq,dots:$q,dot:Hq};function Pq({onNext:t}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Xe.logoArea,children:a.jsx("img",{src:Id("grackle-logo.png"),alt:"Grackle",className:Xe.logoImage})}),a.jsx("h1",{className:Xe.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Xe.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function Uq({onNext:t,onBack:s}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Xe.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Xe.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Vq=[{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 qq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Xe.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Xe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Xe.runtimeGrid,children:Vq.map(u=>a.jsxs("button",{type:"button",className:Xe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Xe.runtimeName,children:u.name}),a.jsx("span",{className:Xe.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function Gq(){return typeof Notification<"u"}function Fq({onFinish:t,onBack:s,finishDisabled:o}){const r=Gq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Xe.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Xe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Xe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const Kq=4,D_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function Zq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=pt(),{showToast:c}=pn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=D_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const N=t.find(C=>C.id===py);if(N&&j!==N.runtime){const C=D_[j]??"sonnet";T.push(s(py,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?a.jsx($n,{to:"/",replace:!0}):a.jsx("div",{className:Xe.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Xe.container,children:[a.jsx(os,{mode:"wait",children:a.jsxs(Pt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Pq,{onNext:()=>p(1)}),u===1&&a.jsx(Uq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(qq,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&a.jsx(Fq,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Xe.dots,children:Array.from({length:Kq},(j,T)=>a.jsx("span",{className:Xe.dot,"data-active":T===u},T))})]})})}const Yq="_root_zndgp_1",Jq="_body_zndgp_7",Wq="_main_zndgp_19",Xq="_sidebarWrapper_zndgp_26",Qq="_overlay_zndgp_51",Wr={root:Yq,body:Jq,main:Wq,sidebarWrapper:Xq,overlay:Qq},eG=y.lazy(()=>P_(()=>import("./KnowledgePage-C1NEElgV.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),Ck=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function tG({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=pt(),{toasts:d,dismissToast:u}=pn(),p=Wt(),m=b9(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(x5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),a.jsx(E5,{tabs:t}),a.jsxs("div",{className:Wr.body,children:[g&&a.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(O5,{content:m})}),g&&v&&a.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),a.jsxs("div",{className:Wr.main,children:[a.jsx(Mi,{}),a.jsx(V5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(GO,{toasts:d,onDismiss:u}),a.jsx(yq,{})]})}function nG(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=pt(),{pluginNames:p}=Bd(),{showToast:m}=pn();EH(s,m),IH(c,m),AH(o,r,m);const g=xt(),v=Wt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Mm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx($n,{to:"/setup",replace:!0});const b=Q9(p);return a.jsx(y9,{children:a.jsxs("div",{className:Wr.root,children:[Ck&&a.jsx(OC,{}),a.jsx(tG,{tabs:b})]})})}function Pp(){const{workspaceId:t}=ma(),{workspaces:{workspaces:s}}=pt(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx($n,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx($n,{to:m,replace:!0})}function sG(){const{pluginNames:t}=Bd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(_w,{children:[a.jsx(Ee,{path:"setup",element:a.jsx(Zq,{})}),a.jsxs(Ee,{element:a.jsx(nG,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(yU,{})}),a.jsx(Ee,{path:"sessions/new",element:a.jsx(zU,{})}),a.jsx(Ee,{path:"chat",element:a.jsx(CU,{})}),a.jsx(Ee,{path:"chat/:streamId",element:a.jsx($n,{to:"/coordination",replace:!0})}),a.jsx(Ee,{path:"coordination",element:a.jsx(LU,{})}),a.jsx(Ee,{path:"sessions/:sessionId",element:a.jsx(UU,{})}),o&&a.jsx(Ee,{element:a.jsx(kq,{}),children:a.jsx(Ee,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(Z1,{}),children:a.jsx(eG,{})})})}),s&&a.jsxs(Ee,{element:a.jsx(bq,{}),children:[a.jsx(Ee,{path:"tasks",element:a.jsx(gU,{})}),a.jsx(Ee,{path:"tasks/new",element:a.jsx(T_,{})}),a.jsx(Ee,{path:"tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/stream",element:a.jsx(Eo,{})})]}),a.jsxs(Ee,{element:a.jsx(_q,{}),children:[a.jsx(Ee,{path:"workspaces",element:a.jsx($n,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"workspaces/new",element:a.jsx(sV,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(FU,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(T_,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Eo,{})}),a.jsxs(Ee,{path:"environments",element:a.jsx(dV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(vU,{})}),a.jsx(Ee,{path:"new",element:a.jsx(iV,{})}),a.jsx(Ee,{path:":environmentId",element:a.jsx(HV,{})}),a.jsx(Ee,{path:":environmentId/edit",element:a.jsx(oV,{})})]})]}),a.jsx(Ee,{element:a.jsx(xq,{}),children:a.jsxs(Ee,{path:"settings",element:a.jsx(VV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx($n,{to:"credentials",replace:!0})}),a.jsx(Ee,{path:"environments",element:a.jsx($n,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"credentials",element:a.jsx(qV,{})}),a.jsx(Ee,{path:"github-accounts",element:a.jsx(GV,{})}),a.jsx(Ee,{path:"tokens",element:a.jsx($n,{to:"../credentials",replace:!0})}),a.jsx(Ee,{path:"personas",element:a.jsx(FV,{})}),a.jsx(Ee,{path:"personas/new",element:a.jsx(C_,{})}),a.jsx(Ee,{path:"personas/:personaId",element:a.jsx(C_,{})}),a.jsx(Ee,{path:"schedules",element:a.jsx(sq,{})}),a.jsx(Ee,{path:"schedules/new",element:a.jsx(E_,{})}),a.jsx(Ee,{path:"schedules/:scheduleId",element:a.jsx(E_,{})}),a.jsx(Ee,{path:"appearance",element:a.jsx(pq,{})}),a.jsx(Ee,{path:"shortcuts",element:a.jsx(gq,{})}),a.jsx(Ee,{path:"plugins",element:a.jsx(vq,{})}),a.jsx(Ee,{path:"about",element:a.jsx(hq,{})})]})}),a.jsx(Ee,{path:"*",element:a.jsx($n,{to:"/",replace:!0})})]})]})}const aG=1e4;function iG(){const{onboardingCompleted:t}=pt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),aG);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(os,{mode:"wait",children:r?a.jsx(Pt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(Z1,{})},"splash"):a.jsx(Pt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(Gw,{basename:"/".replace(/\/$/,""),children:a.jsx(sG,{})})},"app")})}function oG(){const t=Ck?F9:CH;return a.jsx(Y9,{children:a.jsx(v9,{children:a.jsx(p9,{children:a.jsx(t,{children:a.jsx(iG,{})})})})})}fj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(oG,{})}));export{ha as B,hx as K,pt as a,Mm as s,ls as t,xt 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-CaNPCfQt.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-Bm2vqhAx.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-B70jDsRo.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/grpc-pBcDZw1z.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/markdown-CPoGw-1N.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.126.1",
3
+ "version": "0.127.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.126.1",
42
- "@grackle-ai/web-components": "0.126.1"
41
+ "@grackle-ai/common": "0.127.0",
42
+ "@grackle-ai/web-components": "0.127.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@rushstack/heft": "1.2.7",