groove-dev 0.24.10 → 0.24.12

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.
@@ -535,7 +535,7 @@ Error generating stack: `+c.message+`
535
535
  `);l=o<0?s:s.slice(0,o)}return n+l.length>this.to?l.slice(0,this.to-n):l}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(n,s,l=0){this.block=bc.create(n,l,this.lineStart+s,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(n,s,l=0){this.startContext(this.parser.getNodeType(n),s,l)}addNode(n,s,l){typeof n=="number"&&(n=new ma(this.parser.nodeSet.types[n],Xl,Xl,(l??this.prevLineEnd())-s)),this.block.addChild(n,s-this.block.from)}addElement(n){this.block.addChild(n.toTree(this.parser.nodeSet),n.from-this.block.from)}addLeafElement(n,s){this.addNode(this.buffer.writeElements(bf(s.children,n.marks),-s.from).finish(s.type,s.to-s.from),s.from)}finishContext(){let n=this.stack.pop(),s=this.stack[this.stack.length-1];s.addChild(n.toTree(this.parser.nodeSet),n.from-s.from),this.block=s}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(n){return this.ranges.length>1?ny(this.ranges,0,n.topNode,this.ranges[0].from,this.reusePlaceholders):n}finishLeaf(n){for(let l of n.parsers)if(l.finish(this,n))return;let s=bf(this.parser.parseInline(n.content,n.start),n.marks);this.addNode(this.buffer.writeElements(s,-n.start).finish(ne.Paragraph,n.content.length),n.start)}elt(n,s,l,o){return typeof n=="string"?Ne(this.parser.getNodeType(n),s,l,o):new ry(n,s)}get buffer(){return new ly(this.parser.nodeSet)}}function ny(t,n,s,l,o){let u=t[n].to,d=[],f=[],m=s.from+l;function p(x,g){for(;g?x>=u:x>u;){let b=t[n+1].from-u;l+=b,x+=b,n++,u=t[n].to}}for(let x=s.firstChild;x;x=x.nextSibling){p(x.from+l,!0);let g=x.from+l,b,S=o.get(x.tree);S?b=S:x.to+l>u?(b=ny(t,n,x,l,o),p(x.to+l,!1)):b=x.toTree(),d.push(b),f.push(g-m)}return p(s.to+l,!1),new ma(s.type,d,f,s.to+l-m,s.tree?s.tree.propValues:void 0)}class Yc extends y0{constructor(n,s,l,o,u,d,f,m,p){super(),this.nodeSet=n,this.blockParsers=s,this.leafBlockParsers=l,this.blockNames=o,this.endLeafBlock=u,this.skipContextMarkup=d,this.inlineParsers=f,this.inlineNames=m,this.wrappers=p,this.nodeTypes=Object.create(null);for(let x of n.types)this.nodeTypes[x.name]=x.id}createParse(n,s,l){let o=new J4(this,n,s,l);for(let u of this.wrappers)o=u(o,n,s,l);return o}configure(n){let s=gf(n);if(!s)return this;let{nodeSet:l,skipContextMarkup:o}=this,u=this.blockParsers.slice(),d=this.leafBlockParsers.slice(),f=this.blockNames.slice(),m=this.inlineParsers.slice(),p=this.inlineNames.slice(),x=this.endLeafBlock.slice(),g=this.wrappers;if(qr(s.defineNodes)){o=Object.assign({},o);let b=l.types.slice(),S;for(let Q of s.defineNodes){let{name:k,block:$,composite:j,style:P}=typeof Q=="string"?{name:Q}:Q;if(b.some(U=>U.name==k))continue;j&&(o[b.length]=(U,C,X)=>j(C,X,U.value));let N=b.length,Z=j?["Block","BlockContext"]:$?N>=ne.ATXHeading1&&N<=ne.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;b.push(ni.define({id:N,name:k,props:Z&&[[sn.group,Z]]})),P&&(S||(S={}),Array.isArray(P)||P instanceof wj?S[k]=P:Object.assign(S,P))}l=new kf(b),S&&(l=l.extend($s(S)))}if(qr(s.props)&&(l=l.extend(...s.props)),qr(s.remove))for(let b of s.remove){let S=this.blockNames.indexOf(b),Q=this.inlineNames.indexOf(b);S>-1&&(u[S]=d[S]=void 0),Q>-1&&(m[Q]=void 0)}if(qr(s.parseBlock))for(let b of s.parseBlock){let S=f.indexOf(b.name);if(S>-1)u[S]=b.parse,d[S]=b.leaf;else{let Q=b.before?Ao(f,b.before):b.after?Ao(f,b.after)+1:f.length-1;u.splice(Q,0,b.parse),d.splice(Q,0,b.leaf),f.splice(Q,0,b.name)}b.endLeaf&&x.push(b.endLeaf)}if(qr(s.parseInline))for(let b of s.parseInline){let S=p.indexOf(b.name);if(S>-1)m[S]=b.parse;else{let Q=b.before?Ao(p,b.before):b.after?Ao(p,b.after)+1:p.length-1;m.splice(Q,0,b.parse),p.splice(Q,0,b.name)}}return s.wrap&&(g=g.concat(s.wrap)),new Yc(l,u,d,f,x,o,m,p,g)}getNodeType(n){let s=this.nodeTypes[n];if(s==null)throw new RangeError(`Unknown node type '${n}'`);return s}parseInline(n,s){let l=new dh(this,n,s);e:for(let o=s;o<l.end;){let u=l.char(o);for(let d of this.inlineParsers)if(d){let f=d(l,u,o);if(f>=0){o=f;continue e}}o++}return l.resolveMarkers(0)}}function qr(t){return t!=null&&t.length>0}function gf(t){if(!Array.isArray(t))return t;if(t.length==0)return null;let n=gf(t[0]);if(t.length==1)return n;let s=gf(t.slice(1));if(!s||!n)return n||s;let l=(d,f)=>(d||Xl).concat(f||Xl),o=n.wrap,u=s.wrap;return{props:l(n.props,s.props),defineNodes:l(n.defineNodes,s.defineNodes),parseBlock:l(n.parseBlock,s.parseBlock),parseInline:l(n.parseInline,s.parseInline),remove:l(n.remove,s.remove),wrap:o?u?(d,f,m,p)=>o(u(d,f,m,p),f,m,p):o:u}}function Ao(t,n){let s=t.indexOf(n);if(s<0)throw new RangeError(`Position specified relative to unknown parser ${n}`);return s}let sy=[ni.none];for(let t=1,n;n=ne[t];t++)sy[t]=ni.define({id:t,name:n,props:t>=ne.Escape?[]:[[sn.group,t in Wv?["Block","BlockContext"]:["Block","LeafBlock"]]],top:n=="Document"});const Xl=[];class ly{constructor(n){this.nodeSet=n,this.content=[],this.nodes=[]}write(n,s,l,o=0){return this.content.push(n,s,l,4+o*4),this}writeElements(n,s=0){for(let l of n)l.writeTo(this,s);return this}finish(n,s){return ma.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:n,length:s})}}let ei=class{constructor(n,s,l,o=Xl){this.type=n,this.from=s,this.to=l,this.children=o}writeTo(n,s){let l=n.content.length;n.writeElements(this.children,s),n.content.push(this.type,this.from+s,this.to+s,n.content.length+4-l)}toTree(n){return new ly(n).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}};class ry{constructor(n,s){this.tree=n,this.from=s}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return Xl}writeTo(n,s){n.nodes.push(this.tree),n.content.push(n.nodes.length-1,this.from+s,this.to+s,-1)}toTree(){return this.tree}}function Ne(t,n,s,l){return new ei(t,n,s,l)}const iy={resolve:"Emphasis",mark:"EmphasisMark"},oy={resolve:"Emphasis",mark:"EmphasisMark"},ys={},vc={};class Dt{constructor(n,s,l,o){this.type=n,this.from=s,this.to=l,this.side=o}}const X1="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let ti=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{ti=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}const zO={Escape(t,n,s){if(n!=92||s==t.end-1)return-1;let l=t.char(s+1);for(let o=0;o<X1.length;o++)if(X1.charCodeAt(o)==l)return t.append(Ne(ne.Escape,s,s+2));return-1},Entity(t,n,s){if(n!=38)return-1;let l=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(t.slice(s+1,s+31));return l?t.append(Ne(ne.Entity,s,s+1+l[0].length)):-1},InlineCode(t,n,s){if(n!=96||s&&t.char(s-1)==96)return-1;let l=s+1;for(;l<t.end&&t.char(l)==96;)l++;let o=l-s,u=0;for(;l<t.end;l++)if(t.char(l)==96){if(u++,u==o&&t.char(l+1)!=96)return t.append(Ne(ne.InlineCode,s,l+1,[Ne(ne.CodeMark,s,s+o),Ne(ne.CodeMark,l+1-o,l+1)]))}else u=0;return-1},HTMLTag(t,n,s){if(n!=60||s==t.end-1)return-1;let l=t.slice(s+1,t.end),o=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(l);if(o)return t.append(Ne(ne.Autolink,s,s+1+o[0].length,[Ne(ne.LinkMark,s,s+1),Ne(ne.URL,s+1,s+o[0].length),Ne(ne.LinkMark,s+o[0].length,s+1+o[0].length)]));let u=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(l);if(u)return t.append(Ne(ne.Comment,s,s+1+u[0].length));let d=/^\?[^]*?\?>/.exec(l);if(d)return t.append(Ne(ne.ProcessingInstruction,s,s+1+d[0].length));let f=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(l);return f?t.append(Ne(ne.HTMLTag,s,s+1+f[0].length)):-1},Emphasis(t,n,s){if(n!=95&&n!=42)return-1;let l=s+1;for(;t.char(l)==n;)l++;let o=t.slice(s-1,s),u=t.slice(l,l+1),d=ti.test(o),f=ti.test(u),m=/\s|^$/.test(o),p=/\s|^$/.test(u),x=!p&&(!f||m||d),g=!m&&(!d||p||f),b=x&&(n==42||!g||d),S=g&&(n==42||!x||f);return t.append(new Dt(n==95?iy:oy,s,l,(b?1:0)|(S?2:0)))},HardBreak(t,n,s){if(n==92&&t.char(s+1)==10)return t.append(Ne(ne.HardBreak,s,s+2));if(n==32){let l=s+1;for(;t.char(l)==32;)l++;if(t.char(l)==10&&l>=s+2)return t.append(Ne(ne.HardBreak,s,l+1))}return-1},Link(t,n,s){return n==91?t.append(new Dt(ys,s,s+1,1)):-1},Image(t,n,s){return n==33&&t.char(s+1)==91?t.append(new Dt(vc,s,s+2,1)):-1},LinkEnd(t,n,s){if(n!=93)return-1;for(let l=t.parts.length-1;l>=0;l--){let o=t.parts[l];if(o instanceof Dt&&(o.type==ys||o.type==vc)){if(!o.side||t.skipSpace(o.to)==s&&!/[(\[]/.test(t.slice(s+1,s+2)))return t.parts[l]=null,-1;let u=t.takeContent(l),d=t.parts[l]=ez(t,u,o.type==ys?ne.Link:ne.Image,o.from,s+1);if(o.type==ys)for(let f=0;f<l;f++){let m=t.parts[f];m instanceof Dt&&m.type==ys&&(m.side=0)}return d.to}}return-1}};function ez(t,n,s,l,o){let{text:u}=t,d=t.char(o),f=o;if(n.unshift(Ne(ne.LinkMark,l,l+(s==ne.Image?2:1))),n.push(Ne(ne.LinkMark,o-1,o)),d==40){let m=t.skipSpace(o+1),p=cy(u,m-t.offset,t.offset),x;p&&(m=t.skipSpace(p.to),m!=p.to&&(x=uy(u,m-t.offset,t.offset),x&&(m=t.skipSpace(x.to)))),t.char(m)==41&&(n.push(Ne(ne.LinkMark,o,o+1)),f=m+1,p&&n.push(p),x&&n.push(x),n.push(Ne(ne.LinkMark,m,f)))}else if(d==91){let m=dy(u,o-t.offset,t.offset,!1);m&&(n.push(m),f=m.to)}return Ne(s,l,f,n)}function cy(t,n,s){if(t.charCodeAt(n)==60){for(let o=n+1;o<t.length;o++){let u=t.charCodeAt(o);if(u==62)return Ne(ne.URL,n+s,o+1+s);if(u==60||u==10)return!1}return null}else{let o=0,u=n;for(let d=!1;u<t.length;u++){let f=t.charCodeAt(u);if(ua(f))break;if(d)d=!1;else if(f==40)o++;else if(f==41){if(!o)break;o--}else f==92&&(d=!0)}return u>n?Ne(ne.URL,n+s,u+s):u==t.length?null:!1}}function uy(t,n,s){let l=t.charCodeAt(n);if(l!=39&&l!=34&&l!=40)return!1;let o=l==40?41:l;for(let u=n+1,d=!1;u<t.length;u++){let f=t.charCodeAt(u);if(d)d=!1;else{if(f==o)return Ne(ne.LinkTitle,n+s,u+1+s);f==92&&(d=!0)}}return null}function dy(t,n,s,l){for(let o=!1,u=n+1,d=Math.min(t.length,u+999);u<d;u++){let f=t.charCodeAt(u);if(o)o=!1;else{if(f==93)return l?!1:Ne(ne.LinkLabel,n+s,u+1+s);if(l&&!ua(f)&&(l=!1),f==91)return!1;f==92&&(o=!0)}}return null}class dh{constructor(n,s,l){this.parser=n,this.text=s,this.offset=l,this.parts=[]}char(n){return n>=this.end?-1:this.text.charCodeAt(n-this.offset)}get end(){return this.offset+this.text.length}slice(n,s){return this.text.slice(n-this.offset,s-this.offset)}append(n){return this.parts.push(n),n.to}addDelimiter(n,s,l,o,u){return this.append(new Dt(n,s,l,(o?1:0)|(u?2:0)))}get hasOpenLink(){for(let n=this.parts.length-1;n>=0;n--){let s=this.parts[n];if(s instanceof Dt&&(s.type==ys||s.type==vc))return!0}return!1}addElement(n){return this.append(n)}resolveMarkers(n){for(let l=n;l<this.parts.length;l++){let o=this.parts[l];if(!(o instanceof Dt&&o.type.resolve&&o.side&2))continue;let u=o.type==iy||o.type==oy,d=o.to-o.from,f,m=l-1;for(;m>=n;m--){let k=this.parts[m];if(k instanceof Dt&&k.side&1&&k.type==o.type&&!(u&&(o.side&1||k.side&2)&&(k.to-k.from+d)%3==0&&((k.to-k.from)%3||d%3))){f=k;break}}if(!f)continue;let p=o.type.resolve,x=[],g=f.from,b=o.to;if(u){let k=Math.min(2,f.to-f.from,d);g=f.to-k,b=o.from+k,p=k==1?"Emphasis":"StrongEmphasis"}f.type.mark&&x.push(this.elt(f.type.mark,g,f.to));for(let k=m+1;k<l;k++)this.parts[k]instanceof ei&&x.push(this.parts[k]),this.parts[k]=null;o.type.mark&&x.push(this.elt(o.type.mark,o.from,b));let S=this.elt(p,g,b,x);this.parts[m]=u&&f.from!=g?new Dt(f.type,f.from,g,f.side):null,(this.parts[l]=u&&o.to!=b?new Dt(o.type,b,o.to,o.side):null)?this.parts.splice(l,0,S):this.parts[l]=S}let s=[];for(let l=n;l<this.parts.length;l++){let o=this.parts[l];o instanceof ei&&s.push(o)}return s}findOpeningDelimiter(n){for(let s=this.parts.length-1;s>=0;s--){let l=this.parts[s];if(l instanceof Dt&&l.type==n&&l.side&1)return s}return null}takeContent(n){let s=this.resolveMarkers(n);return this.parts.length=n,s}getDelimiterAt(n){let s=this.parts[n];return s instanceof Dt?s:null}skipSpace(n){return Yr(this.text,n-this.offset)+this.offset}elt(n,s,l,o){return typeof n=="string"?Ne(this.parser.getNodeType(n),s,l,o):new ry(n,s)}}dh.linkStart=ys;dh.imageStart=vc;function bf(t,n){if(!n.length)return t;if(!t.length)return n;let s=t.slice(),l=0;for(let o of n){for(;l<s.length&&s[l].to<o.to;)l++;if(l<s.length&&s[l].from<o.from){let u=s[l];u instanceof ei&&(s[l]=new ei(u.type,u.from,u.to,bf(u.children,[o])))}else s.splice(l++,0,o)}return s}const tz=[ne.CodeBlock,ne.ListItem,ne.OrderedList,ne.BulletList];class az{constructor(n,s){this.fragments=n,this.input=s,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,n.length&&(this.fragment=n[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(n,s){for(;this.fragment&&this.fragment.to<=n;)this.nextFragment();if(!this.fragment||this.fragment.from>(n?n-1:0))return!1;if(this.fragmentEnd<0){let u=this.fragment.to;for(;u>0&&this.input.read(u-1,u)!=`
536
536
  `;)u--;this.fragmentEnd=u?u-1:0}let l=this.cursor;l||(l=this.cursor=this.fragment.tree.cursor(),l.firstChild());let o=n+this.fragment.offset;for(;l.to<=o;)if(!l.parent())return!1;for(;;){if(l.from>=o)return this.fragment.from<=s;if(!l.childAfter(o))return!1}}matches(n){let s=this.cursor.tree;return s&&s.prop(sn.contextHash)==n}takeNodes(n){let s=this.cursor,l=this.fragment.offset,o=this.fragmentEnd-(this.fragment.openEnd?1:0),u=n.absoluteLineStart,d=u,f=n.block.children.length,m=d,p=f;for(;;){if(s.to-l>o){if(s.type.isAnonymous&&s.firstChild())continue;break}let x=Oy(s.from-l,n.ranges);if(s.to-l<=n.ranges[n.rangeI].to)n.addNode(s.tree,x);else{let g=new ma(n.parser.nodeSet.types[ne.Paragraph],[],[],0,n.block.hashProp);n.reusePlaceholders.set(g,s.tree),n.addNode(g,x)}if(s.type.is("Block")&&(tz.indexOf(s.type.id)<0?(d=s.to-l,f=n.block.children.length):(d=m,f=p),m=s.to-l,p=n.block.children.length),!s.nextSibling())break}for(;n.block.children.length>f;)n.block.children.pop(),n.block.positions.pop();return d-u}}function Oy(t,n){let s=t;for(let l=1;l<n.length;l++){let o=n[l-1].to,u=n[l].from;o<t&&(s-=u-o)}return s}const nz=$s({"Blockquote/...":A.quote,HorizontalRule:A.contentSeparator,"ATXHeading1/... SetextHeading1/...":A.heading1,"ATXHeading2/... SetextHeading2/...":A.heading2,"ATXHeading3/...":A.heading3,"ATXHeading4/...":A.heading4,"ATXHeading5/...":A.heading5,"ATXHeading6/...":A.heading6,"Comment CommentBlock":A.comment,Escape:A.escape,Entity:A.character,"Emphasis/...":A.emphasis,"StrongEmphasis/...":A.strong,"Link/... Image/...":A.link,"OrderedList/... BulletList/...":A.list,"BlockQuote/...":A.quote,"InlineCode CodeText":A.monospace,"URL Autolink":A.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":A.processingInstruction,"CodeInfo LinkLabel":A.labelName,LinkTitle:A.string,Paragraph:A.content}),sz=new Yc(new kf(sy).extend(nz),Object.keys(Zo).map(t=>Zo[t]),Object.keys(Zo).map(t=>ay[t]),Object.keys(Zo),F4,Wv,Object.keys(zO).map(t=>zO[t]),Object.keys(zO),[]);function lz(t,n,s){let l=[];for(let o=t.firstChild,u=n;;o=o.nextSibling){let d=o?o.from:s;if(d>u&&l.push({from:u,to:d}),!o)break;u=o.to}return l}function rz(t){let{codeParser:n,htmlParser:s}=t;return{wrap:k0((o,u)=>{let d=o.type.id;if(n&&(d==ne.CodeBlock||d==ne.FencedCode)){let f="";if(d==ne.FencedCode){let p=o.node.getChild(ne.CodeInfo);p&&(f=u.read(p.from,p.to))}let m=n(f);if(m)return{parser:m,overlay:p=>p.type.id==ne.CodeText,bracketed:d==ne.FencedCode}}else if(s&&(d==ne.HTMLBlock||d==ne.HTMLTag||d==ne.CommentBlock))return{parser:s,overlay:lz(o.node,o.from,o.to)};return null})}}const iz={resolve:"Strikethrough",mark:"StrikethroughMark"},oz={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":A.strikethrough}},{name:"StrikethroughMark",style:A.processingInstruction}],parseInline:[{name:"Strikethrough",parse(t,n,s){if(n!=126||t.char(s+1)!=126||t.char(s+2)==126)return-1;let l=t.slice(s-1,s),o=t.slice(s+2,s+3),u=/\s|^$/.test(l),d=/\s|^$/.test(o),f=ti.test(l),m=ti.test(o);return t.addDelimiter(iz,s,s+2,!d&&(!m||u||f),!u&&(!f||d||m))},after:"Emphasis"}]};function Vr(t,n,s=0,l,o=0){let u=0,d=!0,f=-1,m=-1,p=!1,x=()=>{l.push(t.elt("TableCell",o+f,o+m,t.parser.parseInline(n.slice(f,m),o+f)))};for(let g=s;g<n.length;g++){let b=n.charCodeAt(g);b==124&&!p?((!d||f>-1)&&u++,d=!1,l&&(f>-1&&x(),l.push(t.elt("TableDelimiter",g+o,g+o+1))),f=m=-1):(p||b!=32&&b!=9)&&(f<0&&(f=g),m=g+1),p=!p&&b==92}return f>-1&&(u++,l&&x()),u}function _1(t,n){for(let s=n;s<t.length;s++){let l=t.charCodeAt(s);if(l==124)return!0;l==92&&s++}return!1}const fy=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class Z1{constructor(){this.rows=null}nextLine(n,s,l){if(this.rows==null){this.rows=!1;let o;if((s.next==45||s.next==58||s.next==124)&&fy.test(o=s.text.slice(s.pos))){let u=[];Vr(n,l.content,0,u,l.start)==Vr(n,o,s.pos)&&(this.rows=[n.elt("TableHeader",l.start,l.start+l.content.length,u),n.elt("TableDelimiter",n.lineStart+s.pos,n.lineStart+s.text.length)])}}else if(this.rows){let o=[];Vr(n,s.text,s.pos,o,n.lineStart),this.rows.push(n.elt("TableRow",n.lineStart+s.pos,n.lineStart+s.text.length,o))}return!1}finish(n,s){return this.rows?(n.addLeafElement(s,n.elt("Table",s.start,s.start+s.content.length,this.rows)),!0):!1}}const cz={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":A.heading}},"TableRow",{name:"TableCell",style:A.content},{name:"TableDelimiter",style:A.processingInstruction}],parseBlock:[{name:"Table",leaf(t,n){return _1(n.content,0)?new Z1:null},endLeaf(t,n,s){if(s.parsers.some(o=>o instanceof Z1)||!_1(n.text,n.basePos))return!1;let l=t.peekLine();return fy.test(l)&&Vr(t,n.text,n.basePos)==Vr(t,l,n.basePos)},before:"SetextHeading"}]};class uz{nextLine(){return!1}finish(n,s){return n.addLeafElement(s,n.elt("Task",s.start,s.start+s.content.length,[n.elt("TaskMarker",s.start,s.start+3),...n.parser.parseInline(s.content.slice(3),s.start+3)])),!0}}const dz={defineNodes:[{name:"Task",block:!0,style:A.list},{name:"TaskMarker",style:A.atom}],parseBlock:[{name:"TaskList",leaf(t,n){return/^\[[ xX]\][ \t]/.test(n.content)&&t.parentType().name=="ListItem"?new uz:null},after:"SetextHeading"}]},A1=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,E1=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,Oz=/[\w-]+\.[\w-]+($|\/)/,q1=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,M1=/\/[a-zA-Z\d@.]+/gy;function Y1(t,n,s,l){let o=0;for(let u=n;u<s;u++)t[u]==l&&o++;return o}function fz(t,n){E1.lastIndex=n;let s=E1.exec(t);if(!s||Oz.exec(s[0])[0].indexOf("_")>-1)return-1;let l=n+s[0].length;for(;;){let o=t[l-1],u;if(/[?!.,:*_~]/.test(o)||o==")"&&Y1(t,n,l,")")>Y1(t,n,l,"("))l--;else if(o==";"&&(u=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(n,l))))l=n+u.index;else break}return l}function V1(t,n){q1.lastIndex=n;let s=q1.exec(t);if(!s)return-1;let l=s[0][s[0].length-1];return l=="_"||l=="-"?-1:n+s[0].length-(l=="."?1:0)}const hz={parseInline:[{name:"Autolink",parse(t,n,s){let l=s-t.offset;if(l&&/\w/.test(t.text[l-1]))return-1;A1.lastIndex=l;let o=A1.exec(t.text),u=-1;if(!o)return-1;if(o[1]||o[2]){if(u=fz(t.text,l+o[0].length),u>-1&&t.hasOpenLink){let d=/([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(l,u));u=l+d[0].length}}else o[3]?u=V1(t.text,l):(u=V1(t.text,l+o[0].length),u>-1&&o[0]=="xmpp:"&&(M1.lastIndex=u,o=M1.exec(t.text),o&&(u=o.index+o[0].length)));return u<0?-1:(t.addElement(t.elt("URL",s,u+t.offset)),u+t.offset)}}]},mz=[cz,dz,oz,hz];function hy(t,n,s){return(l,o,u)=>{if(o!=t||l.char(u+1)==t)return-1;let d=[l.elt(s,u,u+1)];for(let f=u+1;f<l.end;f++){let m=l.char(f);if(m==t)return l.addElement(l.elt(n,u,f+1,d.concat(l.elt(s,f,f+1))));if(m==92&&d.push(l.elt("Escape",f,f+++2)),ua(m))break}return-1}}const pz={defineNodes:[{name:"Superscript",style:A.special(A.content)},{name:"SuperscriptMark",style:A.processingInstruction}],parseInline:[{name:"Superscript",parse:hy(94,"Superscript","SuperscriptMark")}]},xz={defineNodes:[{name:"Subscript",style:A.special(A.content)},{name:"SubscriptMark",style:A.processingInstruction}],parseInline:[{name:"Subscript",parse:hy(126,"Subscript","SubscriptMark")}]},gz={defineNodes:[{name:"Emoji",style:A.character}],parseInline:[{name:"Emoji",parse(t,n,s){let l;return n!=58||!(l=/^[a-zA-Z_0-9]+:/.exec(t.slice(s+1,t.end)))?-1:t.addElement(t.elt("Emoji",s,s+1+l[0].length))}}]},my=w0({commentTokens:{block:{open:"<!--",close:"-->"}}}),py=new sn,xy=sz.configure({props:[Ts.add(t=>!t.is("Block")||t.is("Document")||vf(t)!=null||bz(t)?void 0:(n,s)=>({from:s.doc.lineAt(n.from).to,to:n.to})),py.add(vf),_l.add({Document:()=>null}),zj.add({Document:my})]});function vf(t){let n=/^(?:ATX|Setext)Heading(\d)$/.exec(t.name);return n?+n[1]:void 0}function bz(t){return t.name=="OrderedList"||t.name=="BulletList"}function vz(t,n){let s=t;for(;;){let l=s.nextSibling,o;if(!l||(o=vf(l.type))!=null&&o<=n)break;s=l}return s.to}const yz=$j.of((t,n,s)=>{for(let l=ga(t).resolveInner(s,-1);l&&!(l.from<n);l=l.parent){let o=l.type.prop(py);if(o==null)continue;let u=vz(l,o);if(u>s)return{from:s,to:u}}return null});function Oh(t){return new Tj(my,t,[],"markdown")}const Sz=Oh(xy),Qz=xy.configure([mz,xz,pz,gz,{props:[Ts.add({Table:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})})]}]),yc=Oh(Qz);function jz(t,n){return s=>{if(s&&t){let l=null;if(s=/\S*/.exec(s)[0],typeof t=="function"?l=t(s):l=vg.matchLanguageName(t,s,!0),l instanceof vg)return l.support?l.support.language.parser:Rj.getSkippingParser(l.load());if(l)return l.parser}return n?n.parser:null}}let RO=class{constructor(n,s,l,o,u,d,f){this.node=n,this.from=s,this.to=l,this.spaceBefore=o,this.spaceAfter=u,this.type=d,this.item=f}blank(n,s=!0){let l=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(n!=null){for(;l.length<n;)l+=" ";return l}else{for(let o=this.to-this.from-l.length-this.spaceAfter.length;o>0;o--)l+=" ";return l+(s?this.spaceAfter:"")}}marker(n,s){let l=this.node.name=="OrderedList"?String(+by(this.item,n)[2]+s):"";return this.spaceBefore+l+this.type+this.spaceAfter}};function gy(t,n){let s=[],l=[];for(let o=t;o;o=o.parent){if(o.name=="FencedCode")return l;(o.name=="ListItem"||o.name=="Blockquote")&&s.push(o)}for(let o=s.length-1;o>=0;o--){let u=s[o],d,f=n.lineAt(u.from),m=u.from-f.from;if(u.name=="Blockquote"&&(d=/^ *>( ?)/.exec(f.text.slice(m))))l.push(new RO(u,m,m+d[0].length,"",d[1],">",null));else if(u.name=="ListItem"&&u.parent.name=="OrderedList"&&(d=/^( *)\d+([.)])( *)/.exec(f.text.slice(m)))){let p=d[3],x=d[0].length;p.length>=4&&(p=p.slice(0,p.length-4),x-=4),l.push(new RO(u.parent,m,m+x,d[1],p,d[2],u))}else if(u.name=="ListItem"&&u.parent.name=="BulletList"&&(d=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(f.text.slice(m)))){let p=d[4],x=d[0].length;p.length>4&&(p=p.slice(0,p.length-4),x-=4);let g=d[2];d[3]&&(g+=d[3].replace(/[xX]/," ")),l.push(new RO(u.parent,m,m+x,d[1],p,g,u))}}return l}function by(t,n){return/^(\s*)(\d+)(?=[.)])/.exec(n.sliceString(t.from,t.from+10))}function CO(t,n,s,l=0){for(let o=-1,u=t;;){if(u.name=="ListItem"){let f=by(u,n),m=+f[2];if(o>=0){if(m!=o+1)return;s.push({from:u.from+f[1].length,to:u.from+f[0].length,insert:String(o+2+l)})}o=m}let d=u.nextSibling;if(!d)break;u=d}}function fh(t,n){let s=/^[ \t]*/.exec(t)[0].length;if(!s||n.facet(Pj)!=" ")return t;let l=Lr(t,4,s),o="";for(let u=l;u>0;)u>=4?(o+=" ",u-=4):(o+=" ",u--);return o+t.slice(s)}const wz=(t={})=>({state:n,dispatch:s})=>{let l=ga(n),{doc:o}=n,u=null,d=n.changeByRange(f=>{if(!f.empty||!yc.isActiveAt(n,f.from,-1)&&!yc.isActiveAt(n,f.from,1))return u={range:f};let m=f.from,p=o.lineAt(m),x=gy(l.resolveInner(m,-1),o);for(;x.length&&x[x.length-1].from>m-p.from;)x.pop();if(!x.length)return u={range:f};let g=x[x.length-1];if(g.to-g.spaceAfter.length>m-p.from)return u={range:f};let b=m>=g.to-g.spaceAfter.length&&!/\S/.test(p.text.slice(g.to));if(g.item&&b){let j=g.node.firstChild,P=g.node.getChild("ListItem","ListItem");if(j.to>=m||P&&P.to<m||p.from>0&&!/[^\s>]/.test(o.lineAt(p.from-1).text)||t.nonTightLists===!1){let N=x.length>1?x[x.length-2]:null,Z,U="";N&&N.item?(Z=p.from+N.from,U=N.marker(o,1)):Z=p.from+(N?N.to:0);let C=[{from:Z,to:m,insert:U}];return g.node.name=="OrderedList"&&CO(g.item,o,C,-2),N&&N.node.name=="OrderedList"&&CO(N.item,o,C),{range:Wn.cursor(Z+U.length),changes:C}}else{let N=G1(x,n,p);return{range:Wn.cursor(m+N.length+1),changes:{from:p.from,insert:N+n.lineBreak}}}}if(g.node.name=="Blockquote"&&b&&p.from){let j=o.lineAt(p.from-1),P=/>\s*$/.exec(j.text);if(P&&P.index==g.from){let N=n.changes([{from:j.from+P.index,to:j.to},{from:p.from+g.from,to:p.to}]);return{range:f.map(N),changes:N}}}let S=[];g.node.name=="OrderedList"&&CO(g.item,o,S);let Q=g.item&&g.item.from<p.from,k="";if(!Q||/^[\s\d.)\-+*>]*/.exec(p.text)[0].length>=g.to)for(let j=0,P=x.length-1;j<=P;j++)k+=j==P&&!Q?x[j].marker(o,1):x[j].blank(j<P?Lr(p.text,4,x[j+1].from)-k.length:null);let $=m;for(;$>p.from&&/\s/.test(p.text.charAt($-p.from-1));)$--;return k=fh(k,n),$z(g.node,n.doc)&&(k=G1(x,n,p)+n.lineBreak+k),S.push({from:$,to:m,insert:n.lineBreak+k}),{range:Wn.cursor($+k.length+1),changes:S}});return u?!1:(s(n.update(d,{scrollIntoView:!0,userEvent:"input"})),!0)},kz=wz();function U1(t){return t.name=="QuoteMark"||t.name=="ListMark"}function $z(t,n){if(t.name!="OrderedList"&&t.name!="BulletList")return!1;let s=t.firstChild,l=t.getChild("ListItem","ListItem");if(!l)return!1;let o=n.lineAt(s.to),u=n.lineAt(l.from),d=/^[\s>]*$/.test(o.text);return o.number+(d?0:1)<u.number}function G1(t,n,s){let l="";for(let o=0,u=t.length-2;o<=u;o++)l+=t[o].blank(o<u?Lr(s.text,4,t[o+1].from)-l.length:null,o<u);return fh(l,n)}function Tz(t,n){let s=t.resolveInner(n,-1),l=n;U1(s)&&(l=s.from,s=s.parent);for(let o;o=s.childBefore(l);)if(U1(o))l=o.from;else if(o.name=="OrderedList"||o.name=="BulletList")s=o.lastChild,l=s.to;else break;return s}const Pz=({state:t,dispatch:n})=>{let s=ga(t),l=null,o=t.changeByRange(u=>{let d=u.from,{doc:f}=t;if(u.empty&&yc.isActiveAt(t,u.from)){let m=f.lineAt(d),p=gy(Tz(s,d),f);if(p.length){let x=p[p.length-1],g=x.to-x.spaceAfter.length+(x.spaceAfter?1:0);if(d-m.from>g&&!/\S/.test(m.text.slice(g,d-m.from)))return{range:Wn.cursor(m.from+g),changes:{from:m.from+g,to:d}};if(d-m.from==g&&(!x.item||m.from<=x.item.from||!/\S/.test(m.text.slice(0,x.to)))){let b=m.from+x.from;if(x.item&&x.node.from<x.item.from&&/\S/.test(m.text.slice(x.from,x.to))){let S=x.blank(Lr(m.text,4,x.to)-Lr(m.text,4,x.from));return b==m.from&&(S=fh(S,t)),{range:Wn.cursor(b+S.length),changes:{from:b,to:m.from+x.to,insert:S}}}if(b<d)return{range:Wn.cursor(b),changes:{from:b,to:d}}}}}return l={range:u}});return l?!1:(n(t.update(o,{scrollIntoView:!0,userEvent:"delete"})),!0)},Nz=[{key:"Enter",run:kz},{key:"Backspace",run:Pz}],vy=Dv({matchClosingTags:!1});function zz(t={}){let{codeLanguages:n,defaultCodeLanguage:s,addKeymap:l=!0,base:{parser:o}=Sz,completeHTMLTags:u=!0,pasteURLAsLink:d=!0,htmlTagLanguage:f=vy}=t;if(!(o instanceof Yc))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let m=t.extensions?[t.extensions]:[],p=[f.support,yz],x;d&&p.push(_z),s instanceof Qs?(p.push(s.support),x=s.language):s&&(x=s);let g=n||x?jz(n,x):void 0;m.push(rz({codeParser:g,htmlParser:f.language.parser})),l&&p.push(kj.high(JO.of(Nz)));let b=Oh(o.configure(m));return u&&p.push(b.data.of({autocomplete:Rz})),new Qs(b,p)}function Rz(t){let{state:n,pos:s}=t,l=/<[:\-\.\w\u00b7-\uffff]*$/.exec(n.sliceDoc(s-25,s));if(!l)return null;let o=ga(n).resolveInner(s,-1);for(;o&&!o.type.isTop;){if(o.name=="CodeBlock"||o.name=="FencedCode"||o.name=="ProcessingInstructionBlock"||o.name=="CommentBlock"||o.name=="Link"||o.name=="Image")return null;o=o.parent}return{from:s-l[0].length,to:s,options:Cz(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let XO=null;function Cz(){if(XO)return XO;let t=q4(new Nj($0.create({extensions:vy}),0,!0));return XO=t?t.options:[]}const Xz=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,_z=kl.domEventHandlers({paste:(t,n)=>{var s;let{main:l}=n.state.selection;if(l.empty)return!1;let o=(s=t.clipboardData)===null||s===void 0?void 0:s.getData("text/plain");if(!o||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(o)||(/^www\./.test(o)&&(o="https://"+o),!yc.isActiveAt(n.state,l.from,1)))return!1;let u=ga(n.state),d=!1;return u.iterate({from:l.from,to:l.to,enter:f=>{(f.from>l.from||Xz.test(f.name))&&(d=!0)},leave:f=>{f.to<l.to&&(d=!0)}}),d?!1:(n.dispatch({changes:[{from:l.from,insert:"["},{from:l.to,insert:`](${o})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),Zz=1,yy=194,Sy=195,Az=196,L1=197,Ez=198,qz=199,Mz=200,Yz=2,Qy=3,D1=201,Vz=24,Uz=25,Gz=49,Lz=50,Dz=55,Wz=56,Bz=57,Hz=59,Iz=60,Fz=61,Kz=62,Jz=63,eR=65,tR=238,aR=71,nR=241,sR=242,lR=243,rR=244,iR=245,oR=246,cR=247,uR=248,jy=72,dR=249,OR=250,fR=251,hR=252,mR=253,pR=254,xR=255,gR=256,bR=73,vR=77,yR=263,SR=112,QR=130,jR=151,wR=152,kR=155,ws=10,ai=13,hh=32,Vc=9,mh=35,$R=40,TR=46,yf=123,W1=125,wy=39,ky=34,B1=92,PR=111,NR=120,zR=78,RR=117,CR=85,XR=new Set([Uz,Gz,Lz,yR,eR,QR,Wz,Bz,tR,Kz,Jz,jy,bR,vR,Iz,Fz,jR,wR,kR,SR]);function _O(t){return t==ws||t==ai}function ZO(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}const _R=new gt((t,n)=>{let s;if(t.next<0)t.acceptToken(qz);else if(n.context.flags&Io)_O(t.next)&&t.acceptToken(Ez,1);else if(((s=t.peek(-1))<0||_O(s))&&n.canShift(L1)){let l=0;for(;t.next==hh||t.next==Vc;)t.advance(),l++;(t.next==ws||t.next==ai||t.next==mh)&&t.acceptToken(L1,-l)}else _O(t.next)&&t.acceptToken(Az,1)},{contextual:!0}),ZR=new gt((t,n)=>{let s=n.context;if(s.flags)return;let l=t.peek(-1);if(l==ws||l==ai){let o=0,u=0;for(;;){if(t.next==hh)o++;else if(t.next==Vc)o+=8-o%8;else break;t.advance(),u++}o!=s.indent&&t.next!=ws&&t.next!=ai&&t.next!=mh&&(o<s.indent?t.acceptToken(Sy,-u):t.acceptToken(yy))}}),Io=1,$y=2,Ja=4,en=8,tn=16,an=32;function Fo(t,n,s){this.parent=t,this.indent=n,this.flags=s,this.hash=(t?t.hash+t.hash<<8:0)+n+(n<<4)+s+(s<<6)}const AR=new Fo(null,0,0);function ER(t){let n=0;for(let s=0;s<t.length;s++)n+=t.charCodeAt(s)==Vc?8-n%8:1;return n}const H1=new Map([[nR,0],[sR,Ja],[lR,en],[rR,en|Ja],[iR,tn],[oR,tn|Ja],[cR,tn|en],[uR,tn|en|Ja],[dR,an],[OR,an|Ja],[fR,an|en],[hR,an|en|Ja],[mR,an|tn],[pR,an|tn|Ja],[xR,an|tn|en],[gR,an|tn|en|Ja]].map(([t,n])=>[t,n|$y])),qR=new ah({start:AR,reduce(t,n,s,l){return t.flags&Io&&XR.has(n)||(n==aR||n==jy)&&t.flags&$y?t.parent:t},shift(t,n,s,l){return n==yy?new Fo(t,ER(l.read(l.pos,s.pos)),0):n==Sy?t.parent:n==Vz||n==Dz||n==Hz||n==Qy?new Fo(t,0,Io):H1.has(n)?new Fo(t,0,H1.get(n)|t.flags&Io):t},hash(t){return t.hash}}),MR=new gt(t=>{for(let n=0;n<5;n++){if(t.next!="print".charCodeAt(n))return;t.advance()}if(!/\w/.test(String.fromCharCode(t.next)))for(let n=0;;n++){let s=t.peek(n);if(!(s==hh||s==Vc)){s!=$R&&s!=TR&&s!=ws&&s!=ai&&s!=mh&&t.acceptToken(Zz);return}}}),YR=new gt((t,n)=>{let{flags:s}=n.context,l=s&Ja?ky:wy,o=(s&en)>0,u=!(s&tn),d=(s&an)>0,f=t.pos;for(;!(t.next<0);)if(d&&t.next==yf)if(t.peek(1)==yf)t.advance(2);else{if(t.pos==f){t.acceptToken(Qy,1);return}break}else if(u&&t.next==B1){if(t.pos==f){t.advance();let m=t.next;m>=0&&(t.advance(),VR(t,m)),t.acceptToken(Yz);return}break}else if(t.next==B1&&!u&&t.peek(1)>-1)t.advance(2);else if(t.next==l&&(!o||t.peek(1)==l&&t.peek(2)==l)){if(t.pos==f){t.acceptToken(D1,o?3:1);return}break}else if(t.next==ws){if(o)t.advance();else if(t.pos==f){t.acceptToken(D1);return}break}else t.advance();t.pos>f&&t.acceptToken(Mz)});function VR(t,n){if(n==PR)for(let s=0;s<2&&t.next>=48&&t.next<=55;s++)t.advance();else if(n==NR)for(let s=0;s<2&&ZO(t.next);s++)t.advance();else if(n==RR)for(let s=0;s<4&&ZO(t.next);s++)t.advance();else if(n==CR)for(let s=0;s<8&&ZO(t.next);s++)t.advance();else if(n==zR&&t.next==yf){for(t.advance();t.next>=0&&t.next!=W1&&t.next!=wy&&t.next!=ky&&t.next!=ws;)t.advance();t.next==W1&&t.advance()}}const UR=$s({'async "*" "**" FormatConversion FormatSpec':A.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":A.controlKeyword,"in not and or is del":A.operatorKeyword,"from def class global nonlocal lambda":A.definitionKeyword,import:A.moduleKeyword,"with as print":A.keyword,Boolean:A.bool,None:A.null,VariableName:A.variableName,"CallExpression/VariableName":A.function(A.variableName),"FunctionDefinition/VariableName":A.function(A.definition(A.variableName)),"ClassDefinition/VariableName":A.definition(A.className),PropertyName:A.propertyName,"CallExpression/MemberExpression/PropertyName":A.function(A.propertyName),Comment:A.lineComment,Number:A.number,String:A.string,FormatString:A.special(A.string),Escape:A.escape,UpdateOp:A.updateOperator,"ArithOp!":A.arithmeticOperator,BitOp:A.bitwiseOperator,CompareOp:A.compareOperator,AssignOp:A.definitionOperator,Ellipsis:A.punctuation,At:A.meta,"( )":A.paren,"[ ]":A.squareBracket,"{ }":A.brace,".":A.derefOperator,", ;":A.separator}),GR={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},LR=Kn.deserialize({version:14,states:"##jO`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOO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qQ%[!tQ%f0cS'v%Z0hQ'x0eQ'y0fQ,p*rQ-u,qS.i-s/sR0p0rU#uq.k0qR(w&][cOn#g$j)t,PZ!xY#[#}$Q+YQ#W[Q#zrR$TxQ%b!yQ%i!}Q%o#RQ'j${Q(V%eQ(Z%jQ(c%pQ(f%qQ*|(`Q,f*bQ-t,pQ.m-uR/].lQ$StQ(R%cR*s(SQ.l-sR/}/sR#QZR#V[R%Q!iQ%O!iV*c'm*d,g!Z!lQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v0gR%T!kT#]^#_Q%x#[R,{+YQ(m%xS+_(n(oQ,}+`Q-x,{S.n-y-zR/^.oT+Z(k+]Q$`}Q&g$QQ)o'PR+{)pQ$XzQ)W&qR+i)XQ$XzQ&o$WQ)W&qR+i)XQ#khW$Vz$W&q)XQ$[{Q&r$ZZ)R&l)S+f+g-RR$^|R)c&wXlOn)t,PQ$f!RR'Q$gQ$m!UR'R$hR*X'_Q*V'_V-g,`-h.TQ.d-lQ/P.^R/Q._U.]-l.^._Q/U.aQ/b.tQ/g.zU/i.|/j/yQ/n/RQ/|/oQ0O/tU0Q/u0S0[Q0]0UQ0a0ZR0b0^R/T.`R/d.t",nodeNames:"⚠ print Escape { Comment Script AssignStatement * BinaryExpression BitOp BitOp BitOp BitOp ArithOp ArithOp @ ArithOp ** UnaryExpression ArithOp BitOp AwaitExpression await ) ( ParenthesizedExpression BinaryExpression or and CompareOp in not is UnaryExpression ConditionalExpression if else LambdaExpression lambda ParamList VariableName AssignOp , : NamedExpression AssignOp YieldExpression yield from TupleExpression ComprehensionExpression async for LambdaExpression ] [ ArrayExpression ArrayComprehensionExpression } { DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression CallExpression ArgList AssignOp MemberExpression . PropertyName Number String FormatString FormatReplacement FormatSelfDoc FormatConversion FormatSpec FormatReplacement FormatSelfDoc ContinuedString Ellipsis None Boolean TypeDef AssignOp UpdateStatement UpdateOp ExpressionStatement DeleteStatement del PassStatement pass BreakStatement break ContinueStatement continue ReturnStatement return YieldStatement PrintStatement RaiseStatement raise ImportStatement import as ScopeStatement global nonlocal AssertStatement assert TypeDefinition type TypeParamList TypeParam StatementGroup ; IfStatement Body elif WhileStatement while ForStatement TryStatement try except finally WithStatement with FunctionDefinition def ParamList AssignOp TypeDef ClassDefinition class DecoratedStatement Decorator At MatchStatement match MatchBody MatchClause case CapturePattern LiteralPattern ArithOp ArithOp AsPattern OrPattern LogicOp AttributePattern SequencePattern MappingPattern StarPattern ClassPattern PatternArgList KeywordPattern KeywordPattern Guard",maxTerm:277,context:qR,nodeProps:[["isolate",-5,4,71,72,73,77,""],["group",-15,6,85,87,88,90,92,94,96,98,99,100,102,105,108,110,"Statement Statement",-22,8,18,21,25,40,49,50,56,57,60,61,62,63,64,67,70,71,72,79,80,81,82,"Expression",-10,114,116,119,121,122,126,128,133,135,138,"Statement",-9,143,144,147,148,150,151,152,153,154,"Pattern"],["openedBy",23,"(",54,"[",58,"{"],["closedBy",24,")",55,"]",59,"}"]],propSources:[UR],skippedNodes:[0,4],repeatNodeCount:34,tokenData:"!2|~R!`OX%TXY%oY[%T[]%o]p%Tpq%oqr'ars)Yst*xtu%Tuv,dvw-hwx.Uxy/tyz0[z{0r{|2S|}2p}!O3W!O!P4_!P!Q:Z!Q!R;k!R![>_![!]Do!]!^Es!^!_FZ!_!`Gk!`!aHX!a!b%T!b!cIf!c!dJU!d!eK^!e!hJU!h!i!#f!i!tJU!t!u!,|!u!wJU!w!x!.t!x!}JU!}#O!0S#O#P&o#P#Q!0j#Q#R!1Q#R#SJU#S#T%T#T#UJU#U#VK^#V#YJU#Y#Z!#f#Z#fJU#f#g!,|#g#iJU#i#j!.t#j#oJU#o#p!1n#p#q!1s#q#r!2a#r#s!2f#s$g%T$g;'SJU;'S;=`KW<%lOJU`%YT&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T`%lP;=`<%l%To%v]&n`%c_OX%TXY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_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!1sO!]~k!1zV%jR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[MR,ZR,_R,YR,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:t=>GR[t]||-1}],tokenPrec:7668}),I1=new $f,Ty=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function Eo(t){return(n,s,l)=>{if(l)return!1;let o=n.node.getChild("VariableName");return o&&s(o,t),!0}}const DR={FunctionDefinition:Eo("function"),ClassDefinition:Eo("class"),ForStatement(t,n,s){if(s){for(let l=t.node.firstChild;l;l=l.nextSibling)if(l.name=="VariableName")n(l,"variable");else if(l.name=="in")break}},ImportStatement(t,n){var s,l;let{node:o}=t,u=((s=o.firstChild)===null||s===void 0?void 0:s.name)=="from";for(let d=o.getChild("import");d;d=d.nextSibling)d.name=="VariableName"&&((l=d.nextSibling)===null||l===void 0?void 0:l.name)!="as"&&n(d,u?"variable":"namespace")},AssignStatement(t,n){for(let s=t.node.firstChild;s;s=s.nextSibling)if(s.name=="VariableName")n(s,"variable");else if(s.name==":"||s.name=="AssignOp")break},ParamList(t,n){for(let s=null,l=t.node.firstChild;l;l=l.nextSibling)l.name=="VariableName"&&(!s||!/\*|AssignOp/.test(s.name))&&n(l,"variable"),s=l},CapturePattern:Eo("variable"),AsPattern:Eo("variable"),__proto__:null};function Py(t,n){let s=I1.get(n);if(s)return s;let l=[],o=!0;function u(d,f){let m=t.sliceString(d.from,d.to);l.push({label:m,type:f})}return n.cursor(Qc.IncludeAnonymous).iterate(d=>{if(d.name){let f=DR[d.name];if(f&&f(d,u,o)||!o&&Ty.has(d.name))return!1;o=!1}else if(d.to-d.from>8192){for(let f of Py(t,d.node))l.push(f);return!1}}),I1.set(n,l),l}const F1=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,Ny=["String","FormatString","Comment","PropertyName"];function WR(t){let n=ga(t.state).resolveInner(t.pos,-1);if(Ny.indexOf(n.name)>-1)return null;let s=n.name=="VariableName"||n.to-n.from<20&&F1.test(t.state.sliceDoc(n.from,n.to));if(!s&&!t.explicit)return null;let l=[];for(let o=n;o;o=o.parent)Ty.has(o.name)&&(l=l.concat(Py(t.state.doc,o)));return{options:l,from:s?n.from:t.pos,validFor:F1}}const BR=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(t=>({label:t,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(t=>({label:t,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(t=>({label:t,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(t=>({label:t,type:"function"}))),HR=[Ie("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),Ie("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),Ie("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),Ie("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),Ie(`if \${}:
537
537
 
538
- `,{label:"if",detail:"block",type:"keyword"}),Ie("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),Ie("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),Ie("import ${module}",{label:"import",detail:"statement",type:"keyword"}),Ie("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],IR=S0(Ny,Q0(BR.concat(HR)));function AO(t){let{node:n,pos:s}=t,l=t.lineIndent(s,-1),o=null;for(;;){let u=n.childBefore(s);if(u)if(u.name=="Comment")s=u.from;else if(u.name=="Body"||u.name=="MatchBody")t.baseIndentFor(u)+t.unit<=l&&(o=u),n=u;else if(u.name=="MatchClause")n=u;else if(u.type.is("Statement"))n=u;else break;else break}return o}function EO(t,n){let s=t.baseIndentFor(n),l=t.lineAt(t.pos,-1),o=l.from+l.text.length;return/^\s*($|#)/.test(l.text)&&t.node.to<o+100&&!/\S/.test(t.state.sliceDoc(o,t.node.to))&&t.lineIndent(t.pos,-1)<=s||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(t.textAfter)&&t.lineIndent(t.pos,-1)>s?null:s+t.unit}const qO=si.define({name:"python",parser:LR.configure({props:[_l.add({Body:t=>{var n;let s=/^\s*(#|$)/.test(t.textAfter)&&AO(t)||t.node;return(n=EO(t,s))!==null&&n!==void 0?n:t.continue()},MatchBody:t=>{var n;let s=AO(t);return(n=EO(t,s||t.node))!==null&&n!==void 0?n:t.continue()},IfStatement:t=>/^\s*(else:|elif )/.test(t.textAfter)?t.baseIndent:t.continue(),"ForStatement WhileStatement":t=>/^\s*else:/.test(t.textAfter)?t.baseIndent:t.continue(),TryStatement:t=>/^\s*(except[ :]|finally:|else:)/.test(t.textAfter)?t.baseIndent:t.continue(),MatchStatement:t=>/^\s*case /.test(t.textAfter)?t.baseIndent+t.unit:t.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Lo({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Lo({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Lo({closing:"]"}),MemberExpression:t=>t.baseIndent+t.unit,"String FormatString":()=>null,Script:t=>{var n;let s=AO(t);return(n=s&&EO(t,s))!==null&&n!==void 0?n:t.continue()}}),Ts.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":jc,Body:(t,n)=>({from:t.from+1,to:t.to-(t.to==n.doc.length?0:1)}),"String FormatString":(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function FR(){return new Qs(qO,[qO.data.of({autocomplete:WR}),qO.data.of({autocomplete:IR})])}const qo={javascript:()=>ff({jsx:!0,typescript:!1}),typescript:()=>ff({jsx:!0,typescript:!0}),css:()=>$v(),html:()=>Dv(),json:()=>D4(),markdown:()=>zz(),python:()=>FR()},KR=kl.theme({"&":{backgroundColor:"#24282f",color:"#bcc2cd",fontFamily:"var(--font-mono)",fontSize:"13px",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{caretColor:"#33afbc"},".cm-cursor":{borderLeftColor:"#33afbc"},".cm-gutters":{backgroundColor:"#24282f",borderRight:"1px solid #2c313a",color:"#505862"},".cm-activeLineGutter":{backgroundColor:"#2c313a"},".cm-activeLine":{backgroundColor:"rgba(44, 49, 58, 0.5)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"rgba(51, 175, 188, 0.15)"}},{dark:!0});function JR({content:t,language:n,onChange:s,onSave:l}){const o=v.useRef(null),u=v.useRef(null),d=v.useRef(new Cj),f=v.useRef(s),m=v.useRef(l);return f.current=s,m.current=l,v.useEffect(()=>{if(!o.current)return;const p=qo[n]||qo.javascript,x=JO.of([{key:"Mod-s",run:()=>{var S;return(S=m.current)==null||S.call(m),!0}}]),g=$0.create({doc:t||"",extensions:[_j(),Zj(),Aj(),Ej(),qj(),Mj(),Yj(),JO.of([...Vj,...Uj,...Gj]),x,Xj,KR,d.current.of(p()),kl.updateListener.of(S=>{var Q;S.docChanged&&((Q=f.current)==null||Q.call(f,S.state.doc.toString()))})]}),b=new kl({state:g,parent:o.current});return u.current=b,()=>{b.destroy(),u.current=null}},[]),v.useEffect(()=>{const p=u.current;if(!p)return;const x=p.state.doc.toString();t!==x&&p.dispatch({changes:{from:0,to:x.length,insert:t||""}})},[t]),v.useEffect(()=>{const p=u.current;if(!p)return;const x=qo[n]||qo.javascript;p.dispatch({effects:d.current.reconfigure(x())})},[n]),i.jsx("div",{ref:o,className:"w-full h-full overflow-hidden"})}const eC=["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"],zy=["mp4","webm","mov","avi","mkv","ogv"];function tC(t){var s;const n=(s=t.split(".").pop())==null?void 0:s.toLowerCase();return eC.includes(n)||zy.includes(n)}function aC({path:t}){var u;const n=(u=t.split(".").pop())==null?void 0:u.toLowerCase(),s=`/api/files/raw?path=${encodeURIComponent(t)}`,l=t.split("/").pop(),o=zy.includes(n);return i.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center bg-surface-0 p-8 gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-3 font-sans",children:[i.jsx(We,{children:n==null?void 0:n.toUpperCase()}),i.jsx("span",{className:"font-mono",children:l}),i.jsx("a",{href:s,target:"_blank",rel:"noopener",className:"text-accent hover:text-accent/80 transition-colors",children:i.jsx(cc,{size:12})})]}),o?i.jsx("video",{src:s,controls:!0,className:"max-w-full max-h-[70vh] rounded-md border border-border"}):i.jsx("img",{src:s,alt:l,className:"max-w-full max-h-[70vh] rounded-md border border-border object-contain"})]})}function nC(){const t=W(b=>b.editorActiveFile),n=W(b=>b.editorFiles),s=W(b=>b.editorChangedFiles),l=W(b=>b.updateFileContent),o=W(b=>b.saveFile),u=W(b=>b.reloadFile),d=W(b=>b.dismissFileChange),[f,m]=v.useState("");v.useEffect(()=>{ee.get("/files/root").then(b=>m(b.root||"")).catch(()=>{})},[]);const p=t?n[t]:null,x=t&&tC(t),g=t&&s[t];return i.jsxs("div",{className:"flex h-full",children:[i.jsx("div",{className:"w-60 flex-shrink-0 border-r border-border",children:i.jsx(yN,{rootDir:f})}),i.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[i.jsx(SN,{}),i.jsxs("div",{className:"flex-1 relative min-h-0",children:[g&&i.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex items-center gap-2 px-4 py-2 bg-warning/10 border-b border-warning/20",children:[i.jsx(_c,{size:14,className:"text-warning"}),i.jsx("span",{className:"text-xs text-warning font-sans flex-1",children:"File modified externally"}),i.jsxs(je,{variant:"ghost",size:"sm",onClick:()=>u(t),children:[i.jsx(es,{size:12})," Reload"]}),i.jsxs(je,{variant:"ghost",size:"sm",onClick:()=>d(t),children:[i.jsx(Rt,{size:12})," Dismiss"]})]}),!t&&i.jsx("div",{className:"w-full h-full flex items-center justify-center text-text-4 font-sans",children:i.jsxs("div",{className:"text-center space-y-2",children:[i.jsx(dn,{size:32,className:"mx-auto"}),i.jsx("p",{className:"text-sm",children:"Open a file from the tree"})]})}),t&&x&&i.jsx(aC,{path:t}),t&&!x&&p&&i.jsx(JR,{content:p.content,language:p.language,onChange:b=>l(t,b),onSave:()=>o(t)})]})]})]})}function sC(){var k;const t=W($=>$.connected),n=W($=>$.agents),[s,l]=v.useState(null),[o,u]=v.useState(!0),[d,f]=v.useState({tokens:[],cost:[],saved:[],efficiency:[],cache:[],inputOutput:[],agents:[],turns:[]}),m=v.useRef(0);v.useEffect(()=>{if(!t)return;let $=!0;async function j(){try{const N=await ee.get("/dashboard");if(!$)return;l(N),u(!1),m.current=Date.now(),f(Z=>{var re,ge,de,K,z,B,J,fe,te;const U=Date.now(),C=(Ae,Se)=>[...Ae.slice(-59),{t:U,v:Se||0}],X=((re=N.tokens)==null?void 0:re.totalTokens)||0,T=((de=(ge=N.tokens)==null?void 0:ge.savings)==null?void 0:de.total)||0,G=X+T,E=((K=N.tokens)==null?void 0:K.totalInputTokens)||0,se=((z=N.tokens)==null?void 0:z.totalOutputTokens)||0;return{tokens:C(Z.tokens,X),cost:C(Z.cost,(B=N.tokens)==null?void 0:B.totalCostUsd),saved:C(Z.saved,T),efficiency:C(Z.efficiency,G>0?T/G*100:0),cache:C(Z.cache,(J=N.tokens)==null?void 0:J.cacheHitRate),inputOutput:C(Z.inputOutput,se>0?E/se:0),agents:C(Z.agents,((fe=N.agents)==null?void 0:fe.running)||0),turns:C(Z.turns,(te=N.tokens)==null?void 0:te.totalTurns)}})}catch{$&&u(!1)}}j();const P=setInterval(j,4e3);return()=>{$=!1,clearInterval(P)}},[t]);const p=((k=s==null?void 0:s.agents)==null?void 0:k.breakdown)||[],x=(s==null?void 0:s.routing)||null,g=(s==null?void 0:s.rotation)||null,b=(s==null?void 0:s.adaptive)||[],S=(s==null?void 0:s.journalist)||null,Q=(g==null?void 0:g.rotating)||[];return{data:s,loading:o,agents:n,connected:t,kpiHistory:d,lastFetch:m.current,agentBreakdown:p,routing:x,rotation:g,adaptive:b,journalist:S,rotating:Q}}const K1=v.memo(function({connected:n,runningCount:s,totalCount:l,uptime:o,lastFetch:u,activeTeam:d}){return i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 bg-surface-1 border-b border-border",children:[i.jsx("h2",{className:"text-xs font-semibold text-text-0 font-sans tracking-wide uppercase",children:"Command Center"}),d&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-4",children:"/"}),i.jsx("span",{className:"text-xs font-mono text-text-2",children:d.name})]}),i.jsx("div",{className:"flex-1"}),n&&i.jsxs("div",{className:"flex items-center gap-3.5 text-xs font-mono text-text-2",children:[i.jsxs("span",{children:[i.jsx("span",{className:"text-text-1",children:s}),i.jsxs("span",{className:"text-text-3",children:["/",l]}),i.jsx("span",{className:"ml-1 text-text-3",children:"agents"})]}),o>0&&i.jsxs("span",{className:"text-text-3",children:["Up ",Ec(o)]}),u>0&&i.jsxs("span",{className:"flex items-center gap-1 text-text-4",children:[i.jsx(es,{size:9}),i.jsx("span",{children:Ct(u)})]})]}),i.jsx(Pl,{status:n?"running":"crashed",size:"sm"})]})});function ia(t,n){const s=parseInt(t.slice(1,3),16),l=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return`rgba(${s},${l},${o},${n})`}const me={surface0:"#1a1e25",surface4:"#2c313a",surface5:"#333842",text0:"#e6e6e6",text1:"#bcc2cd",text2:"#8b929e",text3:"#6e7681",text4:"#505862",accent:"#33afbc",success:"#4ae168",warning:"#e5c07b",danger:"#e06c75",info:"#61afef",purple:"#c678dd",orange:"#d19a66"};function lC({data:t,color:n=me.accent,width:s=72,height:l=22}){if(!t||t.length<2)return i.jsx("div",{style:{width:s,height:l}});const o=t.map(x=>x.v),u=Math.min(...o),f=Math.max(...o)-u||1,m=t.map((x,g)=>{const b=g/(t.length-1)*s,S=l-(x.v-u)/f*(l-2)-1;return`${b},${S}`}).join(" "),p=`kpi-${n.replace("#","")}`;return i.jsxs("svg",{width:s,height:l,className:"flex-shrink-0",children:[i.jsx("defs",{children:i.jsxs("linearGradient",{id:p,x1:"0",y1:"0",x2:"0",y2:"1",children:[i.jsx("stop",{offset:"0%",stopColor:n,stopOpacity:"0.2"}),i.jsx("stop",{offset:"100%",stopColor:n,stopOpacity:"0"})]})}),i.jsx("polygon",{points:`0,${l} ${m} ${s},${l}`,fill:`url(#${p})`}),i.jsx("polyline",{points:m,fill:"none",stroke:n,strokeWidth:"1.5",strokeLinejoin:"round",strokeOpacity:"0.8"})]})}const rC=v.memo(function({label:n,value:s,sparkData:l,color:o=me.accent,className:u}){return i.jsxs("div",{className:le("flex items-center gap-2.5 px-3 py-2.5 min-w-0","bg-surface-1",u),children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5 truncate",children:n}),i.jsx("div",{className:"text-base font-semibold font-mono text-text-0 tabular-nums leading-none",children:s})]}),i.jsx(lC,{data:l,color:o})]})});function iC({kpis:t}){return i.jsx("div",{className:"flex flex-wrap border-b border-border",style:{background:"var(--color-surface-0)"},children:t.map(n=>i.jsx(rC,{label:n.label,value:n.value,sparkData:n.sparkData,color:n.color,className:le("flex-1 basis-[12.5%] min-w-[140px]","border-b border-r border-border")},n.label))})}const oC={actual:"ACT",estimated:"EST",local:"LOC"},cC=v.memo(function({agent:n,isRotating:s}){const l=n.status==="running"||n.status==="starting",o=Math.round((n.contextUsage||0)*100),u=s?"#c678dd":Ff(n.status),d=n.quality,f=(d==null?void 0:d.toolSuccessRate)!=null?Math.round(d.toolSuccessRate*100):null;return i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-surface-3 transition-colors",children:[i.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[i.jsx("span",{className:"absolute inset-0 rounded-sm",style:{background:u}}),l&&i.jsx("span",{className:"absolute inset-[-2px] rounded-sm",style:{background:u,opacity:.15,animation:"node-pulse-bar 2s ease-in-out infinite"}})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate leading-none",children:n.name}),i.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider",children:n.role}),i.jsx("span",{className:"text-2xs text-text-4",children:"/"}),i.jsx("span",{className:"text-2xs font-mono text-text-3",children:uC(n.model)})]})]}),i.jsxs("div",{className:"text-right flex-shrink-0",children:[i.jsx("div",{className:"text-xs font-mono text-text-1 tabular-nums leading-none",children:ct(n.tokens||0)}),(n.costUsd||0)>0&&i.jsx("div",{className:"text-2xs font-mono text-text-3 mt-0.5",children:Ac(n.costUsd)})]}),f!=null&&i.jsxs("span",{className:"text-2xs font-mono font-bold uppercase px-1 py-px rounded-sm flex-shrink-0",style:{color:f>=90?"#4ae168":f>=70?"#e5c07b":"#e06c75",background:f>=90?"rgba(74,225,104,0.1)":f>=70?"rgba(229,192,123,0.1)":"rgba(224,108,117,0.1)"},children:[f,"%"]}),n.costSource&&n.costSource!=="actual"&&i.jsx("span",{className:"text-2xs font-mono text-text-4 uppercase tracking-wider flex-shrink-0",children:oC[n.costSource]||""}),i.jsxs("div",{className:"w-14 flex-shrink-0",children:[i.jsx("div",{className:"flex items-center justify-end gap-1 mb-0.5",children:i.jsxs("span",{className:"text-2xs font-mono text-text-2 tabular-nums",children:[o,"%"]})}),i.jsxs("div",{className:"relative h-[3px] bg-surface-0 rounded-full overflow-visible",children:[i.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-700",style:{width:`${Math.max(o,1)}%`,background:o>80?"#e06c75":o>60?"#e5c07b":l?"#61afef":"#333842"}}),n.rotationThreshold&&i.jsx("div",{className:"absolute top-[-2px] w-px h-[7px]",style:{left:`${Math.round(n.rotationThreshold*100)}%`,background:"#c678dd"},title:`Rotation at ${Math.round(n.rotationThreshold*100)}%`})]})]})]})});function uC(t){if(!t||t==="auto"||t==="default")return"default";const n=t.match(/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)/);return n?`${n[1][0].toUpperCase()}${n[1].slice(1)} ${n[2]}.${n[3]}`:t.startsWith("gemini-")?t.replace("gemini-","Gem ").replace("-preview",""):t.length>12?t.slice(0,12)+"...":t}const dC=v.memo(function({agentBreakdown:n,rotating:s=[]}){if(!(n!=null&&n.length))return i.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-text-3 font-mono p-4",children:"No agents"});const l={};for(const u of n){const d=u.teamId||"ungrouped";l[d]||(l[d]=[]),l[d].push(u)}const o=new Set(s);return i.jsx(Ht,{className:"flex-1",children:i.jsx("div",{className:"py-1",children:Object.entries(l).map(([u,d])=>i.jsxs("div",{children:[i.jsx("div",{className:"px-3 pt-2 pb-1",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:u})}),d.map(f=>i.jsx(cC,{agent:f,isRotating:o.has(f.id)},f.id))]},u))})})}),OC=v.memo(function({data:n}){const s=v.useRef(null),l=v.useRef(null),[o,u]=v.useState({width:0,height:0}),[d,f]=v.useState(null),{width:m,height:p}=o,x={top:28,right:12,bottom:8,left:12},g=Math.max(m-x.left-x.right,0),b=Math.max(p-x.top-x.bottom,0),S=v.useMemo(()=>!n||n.length<2?[]:n.slice(1).map(($,j)=>{const P=n[j],N=($.t-P.t)/6e4,Z=Math.max(($.tokens||0)-(P.tokens||0),0);return{burnRate:N>0?Math.round(Z/N):0,cacheHitRate:$.cacheHitRate||0,running:$.running||0,agents:$.agents||0,t:$.t}}),[n]);v.useEffect(()=>{const $=s.current;if(!$)return;const j=new ResizeObserver(P=>{const{width:N,height:Z}=P[0].contentRect;N>0&&Z>0&&u({width:Math.floor(N),height:Math.floor(Z)})});return j.observe($),()=>j.disconnect()},[]);const Q=v.useCallback($=>{const j=l.current;if(!j||!S.length||g<=0)return;const P=j.getBoundingClientRect(),N=$.clientX-P.left-x.left;if(N<0||N>g){f(null);return}const Z=Math.round(N/g*(S.length-1));f({x:x.left+Z/Math.max(S.length-1,1)*g,index:Z})},[S,g,x.left]),k=v.useCallback(()=>f(null),[]);return v.useEffect(()=>{const $=l.current;if(!$||!S.length||m<=0||p<=0||g<=0||b<=0)return;const j=$.getContext("2d"),P=window.devicePixelRatio||1;$.width=m*P,$.height=p*P,j.scale(P,P),j.clearRect(0,0,m,p);const N=S.map(z=>z.burnRate),Z=S.map(z=>z.cacheHitRate),U=S.map(z=>z.running),C=Math.max(...N,100),X=Math.max(...U,1),T=z=>x.left+z/Math.max(S.length-1,1)*g,G=z=>x.top+b-z/C*b,E=z=>x.top+b-z*b,se=Math.max(g/S.length-1,2);for(let z=0;z<S.length;z++){const B=U[z];if(B<=0)continue;const J=B/X*b*.3,fe=T(z)-se/2,te=x.top+b-J;j.fillStyle=ia(me.surface5,.5),j.fillRect(fe,te,se,J)}j.setLineDash([2,4]),j.strokeStyle=ia(me.text4,.2),j.lineWidth=1;for(let z=1;z<=3;z++){const B=x.top+b/4*z;j.beginPath(),j.moveTo(x.left,B),j.lineTo(x.left+g,B),j.stroke()}j.setLineDash([]),j.font="9px 'JetBrains Mono Variable', monospace",j.textAlign="left",j.fillStyle=ia(me.text3,.5),j.fillText(`${ct(C)}/m`,x.left+4,x.top+10),j.fillText(`${ct(Math.round(C/2))}/m`,x.left+4,x.top+b/2+4),j.beginPath(),j.moveTo(x.left,x.top+b);for(let z=0;z<S.length;z++)j.lineTo(T(z),G(N[z]));j.lineTo(T(S.length-1),x.top+b),j.closePath();const re=j.createLinearGradient(0,x.top,0,x.top+b);re.addColorStop(0,ia(me.accent,.2)),re.addColorStop(.7,ia(me.accent,.04)),re.addColorStop(1,ia(me.accent,0)),j.fillStyle=re,j.fill(),j.beginPath(),j.strokeStyle=me.accent,j.lineWidth=1.5,j.lineJoin="round";for(let z=0;z<S.length;z++){const B=T(z),J=G(N[z]);z===0?j.moveTo(B,J):j.lineTo(B,J)}j.stroke();const ge=Z.some(z=>z>0);if(ge){j.beginPath(),j.strokeStyle=ia(me.info,.45),j.lineWidth=1,j.lineJoin="round",j.setLineDash([2,3]);for(let z=0;z<S.length;z++){const B=T(z),J=E(Z[z]);z===0?j.moveTo(B,J):j.lineTo(B,J)}j.stroke(),j.setLineDash([])}j.font="9px 'Inter Variable', sans-serif",j.textAlign="right";let de=m-x.right-4;const K=14;if(ge&&(j.fillStyle=ia(me.info,.5),j.fillText("Cache %",de,K),de-=j.measureText("Cache %").width+4,j.beginPath(),j.arc(de,K-3,2.5,0,Math.PI*2),j.fill(),de-=14),j.fillStyle=ia(me.surface5,.7),j.fillText("Agents",de,K),de-=j.measureText("Agents").width+4,j.beginPath(),j.arc(de,K-3,2.5,0,Math.PI*2),j.fill(),de-=14,j.fillStyle=me.accent,j.fillText("Burn Rate",de,K),de-=j.measureText("Burn Rate").width+4,j.beginPath(),j.arc(de,K-3,2.5,0,Math.PI*2),j.fill(),d&&d.index>=0&&d.index<S.length){const z=d.x,B=S[d.index];j.beginPath(),j.moveTo(z,x.top),j.lineTo(z,x.top+b),j.strokeStyle=ia(me.text1,.15),j.lineWidth=1,j.stroke();const J=G(B.burnRate);j.beginPath(),j.arc(z,J,3,0,Math.PI*2),j.fillStyle=me.accent,j.fill();const fe=[{label:"Burn",value:`${ct(B.burnRate)}/m`,color:me.accent},{label:"Cache",value:Nl(B.cacheHitRate*100),color:me.info},{label:"Agents",value:`${B.running}/${B.agents}`,color:me.text2}],te=104,Ae=fe.length*16+12;let Se=z+12;Se+te>m-8&&(Se=z-te-12);const ve=Math.max(x.top,J-Ae/2);j.fillStyle=ia(me.surface0,.92),j.beginPath(),j.roundRect(Se,ve,te,Ae,4),j.fill(),j.strokeStyle=ia(me.text4,.2),j.lineWidth=1,j.stroke(),j.textAlign="left",fe.forEach((Xe,D)=>{const ie=ve+14+D*16;j.beginPath(),j.arc(Se+8,ie-3,2,0,Math.PI*2),j.fillStyle=Xe.color,j.fill(),j.font="8px 'Inter Variable', sans-serif",j.fillStyle=me.text3,j.fillText(Xe.label,Se+14,ie),j.font="9px 'JetBrains Mono Variable', monospace",j.fillStyle=me.text0,j.textAlign="right",j.fillText(Xe.value,Se+te-8,ie),j.textAlign="left"})}},[S,m,p,d,g,b,x]),i.jsx("div",{ref:s,className:"absolute inset-0",children:m>0&&p>0&&i.jsx("canvas",{ref:l,style:{width:m,height:p},className:"block cursor-crosshair",onMouseMove:Q,onMouseLeave:k})})}),fC=v.memo(function({cacheRead:n=0,cacheCreation:s=0,totalInput:l=0,size:o=140}){const u=v.useRef(null),d=n+s+l,f=d>0?n/d*100:0;return v.useEffect(()=>{const m=u.current;if(!m)return;const p=window.devicePixelRatio||1;m.width=o*p,m.height=o*p;const x=m.getContext("2d");x.scale(p,p),x.clearRect(0,0,o,o);const g=o/2,b=o/2,S=(o-12)/2,Q=5,k=135*Math.PI/180,$=405*Math.PI/180,j=$-k;if(x.beginPath(),x.arc(g,b,S,k,$),x.strokeStyle=me.surface4,x.lineWidth=Q,x.lineCap="round",x.stroke(),d>0){const P=n/d,N=s/d;if(P>0){const Z=k+j*P;x.beginPath(),x.arc(g,b,S,k,Z),x.strokeStyle=me.accent,x.lineWidth=Q,x.lineCap="round",x.stroke()}if(N>0){const Z=k+j*P,U=Z+j*N;x.beginPath(),x.arc(g,b,S,Z,U),x.strokeStyle=me.purple,x.lineWidth=Q,x.lineCap="butt",x.stroke()}}x.textAlign="center",x.textBaseline="middle",x.font=`600 ${o*.2}px 'JetBrains Mono Variable', monospace`,x.fillStyle=me.text0,x.fillText(`${Math.round(f)}%`,g,b-3),x.font=`500 ${o*.08}px 'JetBrains Mono Variable', monospace`,x.fillStyle=me.text3,x.fillText("CACHE",g,b+o*.13)},[n,s,l,o,d,f]),i.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-3 py-3",children:[i.jsx("canvas",{ref:u,className:"flex-shrink-0",style:{width:o,height:o}}),i.jsxs("div",{className:"w-full mt-3 space-y-1.5 max-w-[160px]",children:[i.jsx(MO,{color:me.accent,label:"Read",value:ct(n)}),i.jsx(MO,{color:me.purple,label:"Create",value:ct(s)}),i.jsx(MO,{color:me.surface5,label:"Miss",value:ct(Math.max(l-n-s,0))})]})]})});function MO({color:t,label:n,value:s}){return i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:t}}),i.jsx("span",{className:"text-text-3 uppercase tracking-wider flex-1",children:n}),i.jsx("span",{className:"text-text-1 tabular-nums",children:s})]})}const YO={heavy:me.danger,medium:me.warning,light:me.success},hC={heavy:"Heavy",medium:"Medium",light:"Light"},mC=v.memo(function({routing:n,size:s=120}){const l=v.useRef(null);if(!n)return null;const{byTier:o={},costByTier:u={},totalDecisions:d=0,autoRoutedCount:f=0}=n,m=["heavy","medium","light"],p=m.reduce((x,g)=>x+(o[g]||0),0);return v.useEffect(()=>{const x=l.current;if(!x)return;const g=window.devicePixelRatio||1;x.width=s*g,x.height=s*g;const b=x.getContext("2d");b.scale(g,g),b.clearRect(0,0,s,s);const S=s/2,Q=s/2,k=(s-12)/2,$=5;if(p===0)b.beginPath(),b.arc(S,Q,k,0,Math.PI*2),b.strokeStyle=me.surface4,b.lineWidth=$,b.stroke();else{let j=-Math.PI/2;for(const P of m){const N=o[P]||0;if(N===0)continue;const Z=N/p*Math.PI*2;b.beginPath(),b.arc(S,Q,k,j,j+Z),b.strokeStyle=YO[P],b.lineWidth=$,b.lineCap="butt",b.stroke(),j+=Z}}b.textAlign="center",b.textBaseline="middle",b.font=`600 ${s*.19}px 'JetBrains Mono Variable', monospace`,b.fillStyle=me.text0,b.fillText(ct(d),S,Q-3),b.font=`500 ${s*.09}px 'JetBrains Mono Variable', monospace`,b.fillStyle=me.text3,b.fillText("ROUTES",S,Q+s*.13)},[n,s,p,d]),i.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-3 py-3",children:[i.jsx("canvas",{ref:l,className:"flex-shrink-0",style:{width:s,height:s}}),i.jsx("div",{className:"w-full mt-3 space-y-2 max-w-[180px]",children:m.map(x=>{const g=o[x]||0,b=u[x]||0,S=p>0?g/p*100:0;return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:YO[x]}}),i.jsx("span",{className:"text-text-3 uppercase tracking-wider flex-1",children:hC[x]}),i.jsx("span",{className:"text-text-1 tabular-nums",children:g}),i.jsx("span",{className:"text-text-4",children:"/"}),i.jsx("span",{className:"text-text-2 tabular-nums",children:Ac(b)})]}),i.jsx("div",{className:"h-[2px] bg-surface-0 rounded-full overflow-hidden ml-3.5",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Math.min(S,100)}%`,background:YO[x]}})})]},x)})}),f>0&&i.jsxs("div",{className:"mt-2.5 text-2xs font-mono text-text-3 uppercase tracking-wider",children:[f," auto-routed"]})]})});function pC(t){const n=t+"CollectionProvider",[s,l]=Ps(n),[o,u]=s(n,{collectionRef:{current:null},itemMap:new Map}),d=k=>{const{scope:$,children:j}=k,P=Vn.useRef(null),N=Vn.useRef(new Map).current;return i.jsx(o,{scope:$,itemMap:N,collectionRef:P,children:j})};d.displayName=n;const f=t+"CollectionSlot",m=ec(f),p=Vn.forwardRef((k,$)=>{const{scope:j,children:P}=k,N=u(f,j),Z=rt($,N.collectionRef);return i.jsx(m,{ref:Z,children:P})});p.displayName=f;const x=t+"CollectionItemSlot",g="data-radix-collection-item",b=ec(x),S=Vn.forwardRef((k,$)=>{const{scope:j,children:P,...N}=k,Z=Vn.useRef(null),U=rt($,Z),C=u(x,j);return Vn.useEffect(()=>(C.itemMap.set(Z,{ref:Z,...N}),()=>void C.itemMap.delete(Z))),i.jsx(b,{[g]:"",ref:U,children:P})});S.displayName=x;function Q(k){const $=u(t+"CollectionConsumer",k);return Vn.useCallback(()=>{const P=$.collectionRef.current;if(!P)return[];const N=Array.from(P.querySelectorAll(`[${g}]`));return Array.from($.itemMap.values()).sort((C,X)=>N.indexOf(C.ref.current)-N.indexOf(X.ref.current))},[$.collectionRef,$.itemMap])}return[{Provider:d,Slot:p,ItemSlot:S},Q,l]}var VO="rovingFocusGroup.onEntryFocus",xC={bubbles:!1,cancelable:!0},di="RovingFocusGroup",[Sf,Ry,gC]=pC(di),[bC,Cy]=Ps(di,[gC]),[vC,yC]=bC(di),Xy=v.forwardRef((t,n)=>i.jsx(Sf.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(Sf.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(SC,{...t,ref:n})})}));Xy.displayName=di;var SC=v.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:l,loop:o=!1,dir:u,currentTabStopId:d,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:m,onEntryFocus:p,preventScrollOnEntryFocus:x=!1,...g}=t,b=v.useRef(null),S=rt(n,b),Q=Kf(u),[k,$]=Pc({prop:d,defaultProp:f??null,onChange:m,caller:di}),[j,P]=v.useState(!1),N=zt(p),Z=Ry(s),U=v.useRef(!1),[C,X]=v.useState(0);return v.useEffect(()=>{const T=b.current;if(T)return T.addEventListener(VO,N),()=>T.removeEventListener(VO,N)},[N]),i.jsx(vC,{scope:s,orientation:l,dir:Q,loop:o,currentTabStopId:k,onItemFocus:v.useCallback(T=>$(T),[$]),onItemShiftTab:v.useCallback(()=>P(!0),[]),onFocusableItemAdd:v.useCallback(()=>X(T=>T+1),[]),onFocusableItemRemove:v.useCallback(()=>X(T=>T-1),[]),children:i.jsx(Be.div,{tabIndex:j||C===0?-1:0,"data-orientation":l,...g,ref:S,style:{outline:"none",...t.style},onMouseDown:Ee(t.onMouseDown,()=>{U.current=!0}),onFocus:Ee(t.onFocus,T=>{const G=!U.current;if(T.target===T.currentTarget&&G&&!j){const E=new CustomEvent(VO,xC);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const se=Z().filter(z=>z.focusable),re=se.find(z=>z.active),ge=se.find(z=>z.id===k),K=[re,ge,...se].filter(Boolean).map(z=>z.ref.current);Ay(K,x)}}U.current=!1}),onBlur:Ee(t.onBlur,()=>P(!1))})})}),_y="RovingFocusGroupItem",Zy=v.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:l=!0,active:o=!1,tabStopId:u,children:d,...f}=t,m=Sl(),p=u||m,x=yC(_y,s),g=x.currentTabStopId===p,b=Ry(s),{onFocusableItemAdd:S,onFocusableItemRemove:Q,currentTabStopId:k}=x;return v.useEffect(()=>{if(l)return S(),()=>Q()},[l,S,Q]),i.jsx(Sf.ItemSlot,{scope:s,id:p,focusable:l,active:o,children:i.jsx(Be.span,{tabIndex:g?0:-1,"data-orientation":x.orientation,...f,ref:n,onMouseDown:Ee(t.onMouseDown,$=>{l?x.onItemFocus(p):$.preventDefault()}),onFocus:Ee(t.onFocus,()=>x.onItemFocus(p)),onKeyDown:Ee(t.onKeyDown,$=>{if($.key==="Tab"&&$.shiftKey){x.onItemShiftTab();return}if($.target!==$.currentTarget)return;const j=wC($,x.orientation,x.dir);if(j!==void 0){if($.metaKey||$.ctrlKey||$.altKey||$.shiftKey)return;$.preventDefault();let N=b().filter(Z=>Z.focusable).map(Z=>Z.ref.current);if(j==="last")N.reverse();else if(j==="prev"||j==="next"){j==="prev"&&N.reverse();const Z=N.indexOf($.currentTarget);N=x.loop?kC(N,Z+1):N.slice(Z+1)}setTimeout(()=>Ay(N))}}),children:typeof d=="function"?d({isCurrentTabStop:g,hasTabStop:k!=null}):d})})});Zy.displayName=_y;var QC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jC(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function wC(t,n,s){const l=jC(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(l))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(l)))return QC[l]}function Ay(t,n=!1){const s=document.activeElement;for(const l of t)if(l===s||(l.focus({preventScroll:n}),document.activeElement!==s))return}function kC(t,n){return t.map((s,l)=>t[(n+l)%t.length])}var $C=Xy,TC=Zy,Uc="Tabs",[PC]=Ps(Uc,[Cy]),Ey=Cy(),[NC,ph]=PC(Uc),qy=v.forwardRef((t,n)=>{const{__scopeTabs:s,value:l,onValueChange:o,defaultValue:u,orientation:d="horizontal",dir:f,activationMode:m="automatic",...p}=t,x=Kf(f),[g,b]=Pc({prop:l,onChange:o,defaultProp:u??"",caller:Uc});return i.jsx(NC,{scope:s,baseId:Sl(),value:g,onValueChange:b,orientation:d,dir:x,activationMode:m,children:i.jsx(Be.div,{dir:x,"data-orientation":d,...p,ref:n})})});qy.displayName=Uc;var My="TabsList",Yy=v.forwardRef((t,n)=>{const{__scopeTabs:s,loop:l=!0,...o}=t,u=ph(My,s),d=Ey(s);return i.jsx($C,{asChild:!0,...d,orientation:u.orientation,dir:u.dir,loop:l,children:i.jsx(Be.div,{role:"tablist","aria-orientation":u.orientation,...o,ref:n})})});Yy.displayName=My;var Vy="TabsTrigger",Uy=v.forwardRef((t,n)=>{const{__scopeTabs:s,value:l,disabled:o=!1,...u}=t,d=ph(Vy,s),f=Ey(s),m=Dy(d.baseId,l),p=Wy(d.baseId,l),x=l===d.value;return i.jsx(TC,{asChild:!0,...f,focusable:!o,active:x,children:i.jsx(Be.button,{type:"button",role:"tab","aria-selected":x,"aria-controls":p,"data-state":x?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:m,...u,ref:n,onMouseDown:Ee(t.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?d.onValueChange(l):g.preventDefault()}),onKeyDown:Ee(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&d.onValueChange(l)}),onFocus:Ee(t.onFocus,()=>{const g=d.activationMode!=="manual";!x&&!o&&g&&d.onValueChange(l)})})})});Uy.displayName=Vy;var Gy="TabsContent",Ly=v.forwardRef((t,n)=>{const{__scopeTabs:s,value:l,forceMount:o,children:u,...d}=t,f=ph(Gy,s),m=Dy(f.baseId,l),p=Wy(f.baseId,l),x=l===f.value,g=v.useRef(x);return v.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),i.jsx(ba,{present:o||x,children:({present:b})=>i.jsx(Be.div,{"data-state":x?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":m,hidden:!b,id:p,tabIndex:0,...d,ref:n,style:{...t.style,animationDuration:g.current?"0s":void 0},children:b&&u})})});Ly.displayName=Gy;function Dy(t,n){return`${t}-trigger-${n}`}function Wy(t,n){return`${t}-content-${n}`}var zC=qy,RC=Yy,CC=Uy,XC=Ly;function By({children:t,...n}){return i.jsx(zC,{...n,children:t})}function Hy({children:t,className:n,...s}){return i.jsx(RC,{className:le("flex items-center gap-0 border-b border-border-subtle",n),...s,children:t})}function Ur({children:t,className:n,...s}){return i.jsx(CC,{className:le("px-3 py-2 text-sm font-medium font-sans text-text-2","border-b-2 border-transparent","hover:text-text-0 hover:bg-surface-5/50","data-[state=active]:text-text-0 data-[state=active]:border-accent","transition-colors duration-100 cursor-pointer select-none","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent",n),...s,children:t})}function Gr({children:t,className:n,...s}){return i.jsx(XC,{className:le("flex-1 min-h-0",n),...s,children:t})}function J1({data:t,color:n=me.accent,width:s=60,height:l=16}){if(!t||t.length<2)return i.jsx("div",{style:{width:s,height:l}});const o=Array.isArray(t[0])?t:t.map(p=>typeof p=="number"?p:p.v),u=Math.min(...o),f=Math.max(...o)-u||1,m=o.map((p,x)=>{const g=x/(o.length-1)*s,b=l-(p-u)/f*(l-2)-1;return`${g},${b}`}).join(" ");return i.jsx("svg",{width:s,height:l,className:"flex-shrink-0",children:i.jsx("polyline",{points:m,fill:"none",stroke:n,strokeWidth:"1",strokeLinejoin:"round",strokeOpacity:"0.7"})})}function UO({label:t,value:n,total:s,color:l}){const o=s>0?n/s*100:0;return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs font-mono",children:[i.jsx("span",{className:"text-text-2",children:t}),i.jsx("span",{className:"text-text-1 tabular-nums",children:ct(n)})]}),i.jsx("div",{className:"h-[2px] bg-surface-0 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Math.min(o,100)}%`,background:l}})})]})}function _C({tokens:t,rotation:n}){var d;const s=(t==null?void 0:t.savings)||{},l=s.total||0,u=((t==null?void 0:t.totalTokens)||0)+l;return i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-3 space-y-4",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Rotations"}),i.jsx("div",{className:"text-xl font-mono font-semibold text-text-0 tabular-nums leading-none",children:(n==null?void 0:n.totalRotations)||0})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Saved"}),i.jsx("div",{className:"text-xl font-mono font-semibold text-success tabular-nums leading-none",children:ct(l)}),u>0&&i.jsxs("div",{className:"text-2xs font-mono text-text-3 mt-0.5",children:[Nl(l/u*100)," of total"]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(UO,{label:"Rotation",value:s.fromRotation||0,total:u,color:me.accent}),i.jsx(UO,{label:"Conflict prevention",value:s.fromConflictPrevention||0,total:u,color:me.purple}),i.jsx(UO,{label:"Cold-start skip",value:s.fromColdStartSkip||0,total:u,color:me.info})]}),((d=n==null?void 0:n.history)==null?void 0:d.length)>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1.5",children:"Recent"}),i.jsx("div",{className:"space-y-1",children:n.history.slice(-8).reverse().map((f,m)=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono px-2 py-1 bg-surface-0 rounded",children:[i.jsx("span",{className:"text-text-1 font-medium capitalize truncate flex-1",children:f.agentName||f.role}),i.jsx("span",{className:"text-text-3 tabular-nums",children:Nl((f.contextUsage||0)*100)}),i.jsx("span",{className:"text-text-4",children:Ct(f.timestamp)})]},m))})]})]})})}function ZC({adaptive:t}){return t!=null&&t.length?i.jsx(Ht,{className:"flex-1",children:i.jsx("div",{className:"p-3 space-y-3",children:t.map(n=>{var s,l;return i.jsxs("div",{className:"bg-surface-0 rounded px-2.5 py-2 space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs font-mono text-text-1 flex-1 truncate",children:n.key}),i.jsx("span",{className:"text-xs font-mono font-semibold text-text-0 tabular-nums",children:Nl(n.threshold*100)}),i.jsx("span",{className:le("text-2xs font-mono font-bold uppercase px-1 py-px rounded-sm",n.converged?"text-success bg-success/10":"text-text-3 bg-surface-3"),children:n.converged?"CONV":`${n.adjustments} adj`})]}),((s=n.thresholdHistory)==null?void 0:s.length)>1&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider",children:"Drift"}),i.jsx(J1,{data:n.thresholdHistory.map(o=>o.v),color:n.converged?me.success:me.accent,width:80,height:14})]}),((l=n.recentScores)==null?void 0:l.length)>1&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider",children:"Quality"}),i.jsx(J1,{data:n.recentScores,color:me.warning,width:80,height:14})]})]},n.key)})})}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-text-3 font-mono p-4",children:"No adaptive profiles"})}function AC({journalist:t}){var n;return t?i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-3 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Cycles"}),i.jsx("div",{className:"text-lg font-mono font-semibold text-text-0 tabular-nums leading-none",children:t.cycleCount||0})]}),t.lastCycleAt&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Last"}),i.jsx("div",{className:"text-xs font-mono text-text-2",children:Ct(t.lastCycleAt)})]}),t.synthesizing&&i.jsx("span",{className:"text-2xs font-mono font-bold text-accent uppercase tracking-wider animate-pulse",children:"Synthesizing"})]}),t.lastSummary&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1",children:"Summary"}),i.jsx("div",{className:"text-xs font-sans text-text-2 leading-relaxed bg-surface-0 rounded px-2.5 py-2 max-h-24 overflow-y-auto",children:t.lastSummary})]}),t.projectMap&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1",children:"Project Map"}),i.jsx("div",{className:"text-xs font-mono text-text-2 leading-relaxed bg-surface-0 rounded px-2.5 py-2 max-h-48 overflow-y-auto whitespace-pre-wrap",children:t.projectMap})]}),t.decisions&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1",children:"Decisions"}),i.jsx("div",{className:"text-xs font-mono text-text-2 leading-relaxed bg-surface-0 rounded px-2.5 py-2 max-h-36 overflow-y-auto whitespace-pre-wrap",children:t.decisions})]}),((n=t.recentHistory)==null?void 0:n.length)>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1.5",children:"History"}),i.jsx("div",{className:"space-y-1",children:t.recentHistory.slice().reverse().map((s,l)=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono px-2 py-1 bg-surface-0 rounded",children:[i.jsxs("span",{className:"text-text-3",children:["#",s.cycle]}),i.jsxs("span",{className:"text-text-2 flex-1 truncate",children:[s.agentCount," agents"]}),i.jsx("span",{className:"text-text-4",children:Ct(s.timestamp)})]},l))})]})]})}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-text-3 font-mono p-4",children:"Journalist inactive"})}const EC=v.memo(function({tokens:n,rotation:s,adaptive:l,journalist:o}){return i.jsxs(By,{defaultValue:"rotation",className:"flex flex-col h-full",children:[i.jsxs(Hy,{className:"flex-shrink-0 px-1",children:[i.jsxs(Ur,{value:"rotation",className:"text-xs px-2.5 py-1.5 gap-1",children:[i.jsx(El,{size:11}),"Rotation"]}),i.jsxs(Ur,{value:"adaptive",className:"text-xs px-2.5 py-1.5 gap-1",children:[i.jsx(v5,{size:11}),"Adaptive"]}),i.jsxs(Ur,{value:"journalist",className:"text-xs px-2.5 py-1.5 gap-1",children:[i.jsx(Bf,{size:11}),"Journalist"]})]}),i.jsx(Gr,{value:"rotation",className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(_C,{tokens:n,rotation:s})}),i.jsx(Gr,{value:"adaptive",className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(ZC,{adaptive:l})}),i.jsx(Gr,{value:"journalist",className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(AC,{journalist:o})})]})}),e0={spawn:mP,rotation:El,completion:Br,error:_c,default:Na},t0={spawn:"text-accent",rotation:"text-purple",completion:"text-success",error:"text-danger",default:"text-text-3"},qC=v.memo(function({events:n=[]}){return n.length?i.jsx("div",{className:"flex items-center gap-3 overflow-x-auto py-2 px-3",children:n.slice(-15).reverse().map((s,l)=>{const o=e0[s.type]||e0.default,u=t0[s.type]||t0.default;return i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(o,{size:11,className:u}),i.jsx("span",{className:"text-xs font-sans text-text-2 whitespace-nowrap",children:s.text}),i.jsx("span",{className:"text-2xs font-mono text-text-4",children:Ct(s.timestamp||s.t)})]},l)})}):i.jsx("div",{className:"text-xs text-text-3 font-mono py-2.5 text-center",children:"No recent activity"})});function Nt({className:t,...n}){return i.jsx("div",{className:le("rounded-md bg-surface-4","bg-gradient-to-r from-surface-4 via-surface-5 to-surface-4","bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",t),...n})}function MC(){return i.jsxs("div",{className:"flex-1 grid gap-px p-0",style:{gridTemplateRows:"auto minmax(0, 1fr) minmax(0, 1fr)",gridTemplateColumns:"3fr 1.5fr 1.5fr",background:"#282c34"},children:[i.jsx("div",{className:"col-span-3",children:i.jsx(Nt,{className:"h-[72px] rounded-none"})}),i.jsx(Nt,{className:"rounded-none"}),i.jsx(Nt,{className:"rounded-none"}),i.jsx(Nt,{className:"rounded-none"}),i.jsx(Nt,{className:"rounded-none"}),i.jsx("div",{className:"col-span-2",children:i.jsx(Nt,{className:"h-full rounded-none"})})]})}function YC(){const{data:t,loading:n,agents:s,connected:l,kpiHistory:o,lastFetch:u,agentBreakdown:d,routing:f,rotation:m,adaptive:p,journalist:x,rotating:g}=sC(),b=s.filter(C=>C.status==="running").length;if(!l)return i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i.jsxs("div",{className:"text-center space-y-2 text-text-3 font-mono",children:[i.jsx(Rc,{size:28,className:"mx-auto"}),i.jsx("p",{className:"text-xs",children:"Connecting to daemon..."})]})});if(n||!t)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx(K1,{connected:l,runningCount:0,totalCount:0,uptime:0,lastFetch:0}),i.jsx(MC,{})]});const S=t.tokens||{},Q={totalTokens:S.totalTokens||0,totalCostUsd:S.totalCostUsd||0,totalInputTokens:S.totalInputTokens||0,totalOutputTokens:S.totalOutputTokens||0,cacheReadTokens:S.cacheReadTokens||0,cacheCreationTokens:S.cacheCreationTokens||0,cacheHitRate:S.cacheHitRate||0,totalTurns:S.totalTurns||0,agentCount:S.agentCount||0,savings:S.savings||{}},k=Q.totalTokens+(Q.savings.total||0),$=k>0?(Q.savings.total||0)/k*100:0,j=Q.totalOutputTokens>0?(Q.totalInputTokens/Q.totalOutputTokens).toFixed(1):"—",P=t.timeline||{},N=P.snapshots||[],Z=P.events||t.events||[],U=[{label:"Tokens Used",value:ct(Q.totalTokens),sparkData:o.tokens,color:me.accent},{label:"Total Cost",value:Ac(Q.totalCostUsd),sparkData:o.cost,color:me.warning},{label:"Tokens Saved",value:ct(Q.savings.total||0),sparkData:o.saved,color:me.success},{label:"Efficiency",value:Nl($),sparkData:o.efficiency,color:me.purple},{label:"Cache Rate",value:Nl(Q.cacheHitRate*100),sparkData:o.cache,color:me.info},{label:"I/O Ratio",value:`${j}:1`,sparkData:o.inputOutput,color:me.orange},{label:"Agents",value:`${b}/${s.length}`,sparkData:o.agents,color:me.accent},{label:"Turns",value:ct(Q.totalTurns),sparkData:o.turns,color:me.text2}];return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx(K1,{connected:l,runningCount:b,totalCount:s.length,uptime:t.uptime||0,lastFetch:u,activeTeam:t.activeTeam}),i.jsx(iC,{kpis:U}),i.jsxs("div",{className:"flex-1 min-h-0 grid",style:{gridTemplateRows:"minmax(0, 1fr) minmax(0, 1fr)",gridTemplateColumns:"3fr 1.5fr 1.5fr",background:"#282c34",gap:"1px"},children:[i.jsx("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 relative",children:i.jsx(OC,{data:N})}),i.jsxs("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-l border-border",children:[i.jsx("div",{className:"px-3 pt-2.5 pb-1",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:"Cache Performance"})}),i.jsx(fC,{cacheRead:Q.cacheReadTokens,cacheCreation:Q.cacheCreationTokens,totalInput:Q.totalInputTokens})]}),i.jsxs("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-l border-border",children:[i.jsx("div",{className:"px-3 pt-2.5 pb-1",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:"Model Routing"})}),i.jsx(mC,{routing:f})]}),i.jsxs("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-t border-border",children:[i.jsx("div",{className:"px-3 pt-2.5 pb-1 flex-shrink-0",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:"Agent Fleet"})}),i.jsx(dC,{agentBreakdown:d,rotating:g})]}),i.jsx("div",{className:"col-span-2 min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-t border-l border-border",children:i.jsx(EC,{tokens:Q,rotation:m,adaptive:p,journalist:x})})]}),i.jsx("div",{className:"flex-shrink-0 bg-surface-1 border-t border-border",children:i.jsx(qC,{events:Z})})]})}const a0={sm:12,md:16,lg:20};function VC({fill:t="full",size:n,color:s="#fbbf24",emptyColor:l="rgba(255,255,255,0.4)"}){const o=`star-${Math.random().toString(36).slice(2,8)}`;return i.jsxs("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",children:[t==="half"&&i.jsx("defs",{children:i.jsxs("linearGradient",{id:o,children:[i.jsx("stop",{offset:"50%",stopColor:s}),i.jsx("stop",{offset:"50%",stopColor:l})]})}),i.jsx("path",{d:"M10 1.5l2.47 5.01 5.53.8-4 3.9.94 5.49L10 14.27 5.06 16.7 6 11.21l-4-3.9 5.53-.8L10 1.5z",fill:t==="full"?s:t==="half"?`url(#${o})`:l})]})}function Iy({rating:t=0,count:n,size:s="sm"}){const l=a0[s]||a0.sm,o=[];for(let u=1;u<=5;u++)t>=u?o.push("full"):t>=u-.5?o.push("half"):o.push("empty");return i.jsxs("span",{className:"inline-flex items-center",style:{gap:1},children:[o.map((u,d)=>i.jsx(VC,{fill:u,size:l},d)),n!=null&&i.jsxs("span",{className:"ml-1 text-[11px] text-[var(--text-dim,#6b7f95)] font-sans",children:["(",n,")"]})]})}const n0={design:{color:"#c678dd",bg:"rgba(198,120,221,0.12)"},quality:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"},devtools:{color:"#33afbc",bg:"rgba(51,175,188,0.14)"},workflow:{color:"#fbbf24",bg:"rgba(251,191,36,0.12)"},security:{color:"#f87171",bg:"rgba(248,113,113,0.12)"},specialized:{color:"#f59e0b",bg:"rgba(245,158,11,0.12)"},verified:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"},anthropic:{color:"#f59e0b",bg:"rgba(245,158,11,0.12)"},published:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"},draft:{color:"#6b7f95",bg:"rgba(255,255,255,0.06)"},review:{color:"#c678dd",bg:"rgba(198,120,221,0.12)"},rejected:{color:"#f87171",bg:"rgba(248,113,113,0.12)"},free:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"}};function Fy({label:t,variant:n,className:s}){const l=n0[n]||n0.draft;return i.jsx("span",{className:le("inline-flex items-center whitespace-nowrap font-sans select-none",s),style:{padding:"3px 8px",borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.4,color:l.color,background:l.bg},children:t})}function Ky({price:t=0,size:n="sm"}){const s=!t||t===0,l={sm:"text-2xs px-2 py-0.5",md:"text-xs px-2.5 py-0.5",lg:"text-xs px-3 py-1"};return i.jsx("span",{className:`inline-flex items-center font-mono font-semibold rounded whitespace-nowrap ${l[n]||l.sm} ${s?"bg-success/12 text-success":"bg-white/8 text-text-1"}`,children:s?"Free":`$${t.toFixed(2)}`})}function Jy({type:t="verified",size:n=12}){const s=t==="claude-official"||t==="anthropic"?"#f59e0b":"#4ade80";return i.jsxs("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",className:"inline-block flex-shrink-0",children:[i.jsx("path",{d:"M10 0l2.36 3.15L16.18 2l.68 3.93L20.8 7.1l-1.87 3.52L20.8 14.14l-3.94 1.17-.68 3.93-3.82-1.15L10 21.24l-2.36-3.15-3.82 1.15-.68-3.93-3.94-1.17 1.87-3.52L-.8 7.1l3.94-1.17.68-3.93 3.82 1.15L10 0z",fill:s}),i.jsx("path",{d:"M7 10.5l2 2 4-4.5",fill:"none",stroke:"#24282f",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}const eS="groove_favorites";function xh(){try{return JSON.parse(localStorage.getItem(eS)||"[]")}catch{return[]}}function UC(t){return xh().includes(t)}function GC(t){const n=xh(),s=n.indexOf(t);return s>=0?n.splice(s,1):n.push(t),localStorage.setItem(eS,JSON.stringify(n)),s<0}function LC(t){const n=new Set(xh());return t.map(s=>({...s,favorited:n.has(s.id)}))}function DC({filled:t,size:n=16}){return i.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:t?"#f87171":"none",stroke:t?"#f87171":"rgba(255,255,255,0.3)",strokeWidth:"2",children:i.jsx("path",{d:"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"})})}function WC(){return i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function BC({skill:t,onClick:n}){var u,d;const[s,l]=v.useState(()=>UC(t.id));function o(f){f.stopPropagation(),l(GC(t.id))}return i.jsxs("div",{onClick:()=>n==null?void 0:n(t),className:le("flex flex-col cursor-pointer group","bg-surface-1 border border-border-subtle rounded-md","hover:border-accent/30 hover:bg-surface-2","transition-all duration-150"),style:{padding:20,minHeight:280},children:[i.jsxs("div",{className:"flex justify-between items-start",children:[i.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 bg-accent/12 text-[20px]",children:t.icon||((d=(u=t.name)==null?void 0:u[0])==null?void 0:d.toUpperCase())||"?"}),i.jsx("button",{onClick:o,className:"opacity-40 group-hover:opacity-80 hover:!opacity-100 transition-opacity cursor-pointer bg-transparent border-0 p-0",children:i.jsx(DC,{filled:s})})]}),i.jsx("div",{className:"mt-3 text-[15px] font-semibold text-text-0 font-sans line-clamp-2 leading-snug",children:t.name}),i.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-text-3 font-sans",children:[i.jsxs("span",{children:["by ",t.author||"Community"]}),(t.source==="claude-official"||t.verified)&&i.jsx(Jy,{type:t.source,size:12})]}),i.jsx("div",{className:"mt-2.5 text-xs text-text-2 font-sans line-clamp-3 flex-1 leading-relaxed",children:t.description}),i.jsx("div",{className:"mt-3",children:i.jsx(Fy,{label:t.category||"general",variant:t.category||"draft"})}),i.jsx("div",{className:"h-px bg-border-subtle my-3"}),i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(Iy,{rating:t.rating||0,count:t.rating_count||t.ratingCount||0,size:"sm"}),i.jsxs("span",{className:"flex items-center gap-1 text-xs text-text-3 font-mono",children:[i.jsx(WC,{}),ct(t.downloads||0)]}),i.jsx(Ky,{price:t.price||0,size:"sm"})]})]})}function tS(){return i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md animate-pulse",style:{padding:20,minHeight:280},children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-surface-4"}),i.jsx("div",{className:"mt-3 h-4 w-[70%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-2 h-3 w-[40%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-3.5 h-3 w-full rounded bg-surface-4"}),i.jsx("div",{className:"mt-1.5 h-3 w-[90%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-1.5 h-3 w-[60%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-3.5 h-5 w-[50px] rounded bg-surface-4"}),i.jsx("div",{className:"h-px bg-surface-4 my-3"}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("div",{className:"h-3 w-16 rounded bg-surface-4"}),i.jsx("div",{className:"h-3 w-12 rounded bg-surface-4"}),i.jsx("div",{className:"h-3 w-10 rounded bg-surface-4"})]})]})}const HC={slack:"https://cdn.simpleicons.org/slack/E01E5A",github:"https://cdn.simpleicons.org/github/white",stripe:"https://cdn.simpleicons.org/stripe/635BFF",gmail:"https://cdn.simpleicons.org/gmail/EA4335","google-calendar":"https://cdn.simpleicons.org/googlecalendar/4285F4","google-drive":"https://cdn.simpleicons.org/googledrive/4285F4","google-maps":"https://cdn.simpleicons.org/googlemaps/4285F4",postgres:"https://cdn.simpleicons.org/postgresql/4169E1",notion:"https://cdn.simpleicons.org/notion/white",discord:"https://cdn.simpleicons.org/discord/5865F2",linear:"https://cdn.simpleicons.org/linear/5E6AD2","brave-search":"https://cdn.simpleicons.org/brave/FB542B","home-assistant":"https://cdn.simpleicons.org/homeassistant/18BCF2"};function IC({item:t,size:n=40}){const s=HC[t.id];if(s)return i.jsxs("div",{className:"rounded-md bg-surface-4 flex items-center justify-center flex-shrink-0 overflow-hidden",style:{width:n,height:n},children:[i.jsx("img",{src:s,alt:t.name,className:"w-5 h-5",onError:u=>{u.target.style.display="none",u.target.nextSibling.style.display="flex"}}),i.jsx("div",{className:"hidden items-center justify-center w-full h-full text-lg font-bold font-sans text-text-1",children:(t.name||"?")[0]})]});const l=(t.name||"?")[0].toUpperCase(),o=t.name?t.name.charCodeAt(0)*37%360:200;return i.jsx("div",{className:"rounded-md flex items-center justify-center flex-shrink-0 text-lg font-bold font-sans",style:{width:n,height:n,background:`hsl(${o}, 40%, 18%)`,color:`hsl(${o}, 60%, 65%)`},children:l})}function FC({item:t,onClick:n,className:s}){var o;const l=t.installed;return i.jsxs("button",{onClick:()=>n(t),className:le("flex flex-col p-5 rounded-md border border-border-subtle bg-surface-1 text-left","hover:border-accent/30 hover:bg-surface-2","transition-all duration-150 cursor-pointer group",s),style:{minHeight:200},children:[i.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[i.jsx(IC,{item:t,size:36}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-[14px] font-semibold text-text-0 font-sans truncate",children:t.name}),(t.verified||t.verified==="mcp-official")&&i.jsx(Br,{size:11,className:"text-accent flex-shrink-0"})]}),i.jsx("span",{className:"text-2xs text-text-3 font-sans",children:t.author||"Community"})]})]}),i.jsx("p",{className:"text-xs text-text-2 font-sans line-clamp-3 mb-3 flex-1 leading-relaxed",children:t.description}),i.jsx("div",{className:"h-px bg-border-subtle my-2"}),i.jsxs("div",{className:"flex items-center gap-3 text-2xs text-text-3 font-sans",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Uf,{size:10}),ct(t.downloads||0)]}),(t.rating||0)>0&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Gb,{size:10,className:"text-warning",fill:"currentColor"}),(o=t.rating)==null?void 0:o.toFixed(1)]}),i.jsx("span",{className:"flex-1"}),l&&i.jsx(We,{variant:"accent",className:"text-2xs",children:"Installed"})]})]})}function aS({value:t,onChange:n,placeholder:s="Search skills, tags, authors...",large:l}){const[o,u]=v.useState(t||""),d=v.useRef(null);v.useEffect(()=>{u(t||"")},[t]);function f(m){const p=m.target.value;u(p),clearTimeout(d.current),d.current=setTimeout(()=>n(p),300)}return i.jsxs("div",{className:"relative w-full",children:[i.jsx(ql,{size:16,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-text-4 pointer-events-none"}),i.jsx("input",{value:o,onChange:f,placeholder:s,className:le("w-full font-sans outline-none","bg-surface-0 border border-border text-text-0 placeholder:text-text-4","focus:border-accent/40 transition-colors",l?"py-3 pl-11 pr-12 text-[15px] rounded-lg":"py-2.5 pl-10 pr-3 text-sm rounded-md")}),l&&i.jsx("kbd",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 bg-surface-4 text-text-4 px-2 py-0.5 rounded text-xs font-mono",children:"/"})]})}const KC=[{id:"",label:"All"},{id:"design",label:"Design"},{id:"quality",label:"Quality"},{id:"devtools",label:"Dev Tools"},{id:"workflow",label:"Workflow"},{id:"security",label:"Security"},{id:"specialized",label:"Specialized"}];function JC({selected:t="",categories:n=KC,onSelect:s}){return i.jsx("div",{className:"flex gap-2 overflow-x-auto",style:{scrollbarWidth:"none"},children:n.map(l=>{const o=t===l.id;return i.jsx("button",{onClick:()=>s(l.id),className:le("whitespace-nowrap font-sans cursor-pointer select-none transition-all text-[13px] rounded-full border",o?"bg-accent text-surface-0 border-accent font-semibold":"bg-surface-1 text-text-3 border-border-subtle hover:text-text-1 hover:border-border font-medium"),style:{padding:"7px 16px"},children:l.label},l.id)})})}function Gc(){const t=W(n=>n.addToast);return{success:(n,s)=>t("success",n,s),error:(n,s)=>t("error",n,s),info:(n,s)=>t("info",n,s),warning:(n,s)=>t("warning",n,s)}}function eX({skill:t,onBack:n}){var k,$,j;const s=Gc(),[l,o]=v.useState(""),[u,d]=v.useState(!1),[f,m]=v.useState(!1),[p,x]=v.useState(t.installed),[g,b]=v.useState(!0);v.useEffect(()=>{b(!0),ee.get(`/skills/${t.id}/content`).then(P=>{o(P.content||""),d(P.requiresPurchase||!1)}).catch(()=>{}).finally(()=>b(!1))},[t.id]);async function S(){m(!0);try{await ee.post(`/skills/${t.id}/install`),x(!0),s.success(`${t.name} installed`)}catch(P){s.error("Install failed",P.message)}m(!1)}async function Q(){const{marketplaceAuthenticated:P,marketplaceLogin:N,marketplaceCheckout:Z}=W.getState();if(!P){N();return}try{await Z(t.id)}catch{}}return i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-6 py-5",children:[i.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-xs text-text-3 font-sans hover:text-text-0 cursor-pointer bg-transparent border-0 mb-4",children:[i.jsx(kb,{size:14})," Back"]}),i.jsxs("div",{className:"flex gap-8",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-11 h-11 rounded-lg flex items-center justify-center flex-shrink-0 bg-accent/10 border border-accent/20 text-[22px]",children:t.icon||(($=(k=t.name)==null?void 0:k[0])==null?void 0:$.toUpperCase())}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h1",{className:"text-lg font-bold text-text-0 font-sans",children:t.name}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-text-3 font-sans",children:[i.jsx("span",{children:t.author||"Community"}),(t.source==="claude-official"||t.verified)&&i.jsx(Jy,{type:t.source,size:13})]})]})]}),i.jsx("p",{className:"mt-3 text-sm text-text-2 font-sans leading-relaxed",children:t.description}),((j=t.tags)==null?void 0:j.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:t.tags.map(P=>i.jsx("span",{className:"text-2xs text-text-3 font-sans px-2 py-0.5 rounded bg-surface-4",children:P},P))}),i.jsx("div",{className:"h-px bg-border-subtle my-5"}),g?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"h-3 w-48 bg-surface-4 rounded animate-pulse"}),i.jsx("div",{className:"h-3 w-full bg-surface-4 rounded animate-pulse"}),i.jsx("div",{className:"h-3 w-3/4 bg-surface-4 rounded animate-pulse"})]}):l?i.jsxs("div",{className:"text-sm text-text-2 font-sans leading-relaxed",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 mb-2",children:"About"}),i.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:l})]}):u?i.jsxs("div",{className:"bg-warning/5 border border-warning/15 rounded-lg px-4 py-3",children:[i.jsx("p",{className:"text-sm text-text-1 font-sans font-medium",children:"Paid skill — purchase to view content"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Sign in and purchase this skill to access its full instructions."})]}):i.jsx("p",{className:"text-xs text-text-4 font-sans",children:"Content loading failed — check your connection."})]}),i.jsx("div",{className:"w-[240px] flex-shrink-0",children:i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-lg p-4 sticky top-4",children:[i.jsx(Ky,{price:t.price||0,size:"md"}),u&&!p?i.jsxs("button",{onClick:Q,className:"w-full mt-3 py-2 px-3 text-xs font-sans font-semibold rounded cursor-pointer transition-all hover:opacity-85 flex items-center justify-center gap-2 border bg-warning/15 text-warning border-warning/20 hover:bg-warning/25",children:["Buy $",(t.price||0).toFixed(2)]}):i.jsx("button",{onClick:S,disabled:f||p,className:`w-full mt-3 py-2 px-3 text-xs font-sans font-semibold rounded cursor-pointer transition-all hover:opacity-85 disabled:opacity-60 disabled:cursor-not-allowed flex items-center justify-center gap-2 border ${p?"bg-success/15 text-success border-success/20":"bg-accent/15 text-accent border-accent/20 hover:bg-accent/25"}`,children:f?"Installing...":p?"✓ Installed":"Install"}),i.jsx("div",{className:"mt-4 flex flex-col gap-2.5",children:[["Downloads",i.jsx("span",{className:"font-mono text-text-0",children:ct(t.downloads||0)},"d")],["Rating",i.jsx(Iy,{rating:t.rating||0,count:t.rating_count||t.ratingCount,size:"sm"},"r")],["Version",i.jsx("span",{className:"font-mono text-text-0",children:t.version||"1.0.0"},"v")],["Category",i.jsx(Fy,{label:t.category||"general",variant:t.category||"draft"},"c")],["Source",i.jsx("span",{className:"text-text-0",children:t.source==="claude-official"?"Anthropic":"Community"},"s")]].map(([P,N])=>i.jsxs("div",{className:"flex justify-between items-center text-xs font-sans",children:[i.jsx("span",{className:"text-text-3",children:P}),N]},P))})]})})]})]})})}function tX(){const[t,n]=v.useState([]),[s,l]=v.useState(!0),[o,u]=v.useState(""),[d,f]=v.useState(""),[m,p]=v.useState("popular"),[x,g]=v.useState(null);return v.useEffect(()=>{l(!0);const b=new URLSearchParams;o&&b.set("search",o),d&&b.set("category",d),m&&b.set("sort",m),ee.get(`/skills/registry?${b}`).then(S=>n(LC(S.skills||S.items||(Array.isArray(S)?S:[])))).catch(()=>n([])).finally(()=>l(!1))},[o,d,m]),x?i.jsx(eX,{skill:x,onBack:()=>g(null)}):i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-5 py-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-72",children:i.jsx(aS,{value:o,onChange:u})}),i.jsx(JC,{selected:d,onSelect:f}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsxs("select",{value:m,onChange:b=>p(b.target.value),className:"appearance-none font-sans cursor-pointer pr-7 py-2 pl-3 text-xs bg-surface-0 border border-border-subtle rounded text-text-1 focus:outline-none",children:[i.jsx("option",{value:"popular",children:"Popular"}),i.jsx("option",{value:"rating",children:"Top Rated"}),i.jsx("option",{value:"newest",children:"Newest"}),i.jsx("option",{value:"name",children:"A-Z"})]}),i.jsx(In,{size:12,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-4 pointer-events-none"})]}),i.jsx("span",{className:"text-2xs text-text-4 font-mono flex-shrink-0",children:t.length})]}),i.jsx("div",{className:"mt-4 grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:s?Array.from({length:8}).map((b,S)=>i.jsx(tS,{},S)):t.map(b=>i.jsx(BC,{skill:b,onClick:g},b.id))}),!s&&t.length===0&&i.jsx("div",{className:"text-center py-16 text-text-4 font-sans text-sm",children:"No skills found."})]})})}function aX(){const[t,n]=v.useState([]),[s,l]=v.useState(!0),[o,u]=v.useState(""),d=Gc();return v.useEffect(()=>{l(!0),ee.get(`/integrations/registry?search=${encodeURIComponent(o)}`).then(f=>n(f.integrations||f.items||(Array.isArray(f)?f:[]))).catch(()=>n([])).finally(()=>l(!1))},[o]),i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-5 py-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-72",children:i.jsx(aS,{value:o,onChange:u,placeholder:"Search integrations..."})}),i.jsx("div",{className:"flex-1"}),i.jsx("span",{className:"text-2xs text-text-4 font-mono flex-shrink-0",children:t.length})]}),i.jsx("div",{className:"mt-4 grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:s?Array.from({length:6}).map((f,m)=>i.jsx(tS,{},m)):t.map(f=>i.jsx(FC,{item:f,onClick:()=>d.info(`${f.name} — install via CLI: groove integrations install ${f.id}`)},f.id))}),!s&&t.length===0&&i.jsx("div",{className:"text-center py-16 text-text-4 font-sans text-sm",children:"No integrations found."})]})})}function nX(){const t=W(g=>g.marketplaceAuthenticated),n=W(g=>g.marketplaceLogin),[s,l]=v.useState([]),[o,u]=v.useState([]),[d,f]=v.useState(!0),m=Gc(),p=v.useRef(null);v.useEffect(()=>{f(!0),Promise.all([t?ee.get("/auth/purchases").then(g=>g.purchases||[]).catch(()=>[]):Promise.resolve([]),ee.get("/skills/installed").then(g=>Array.isArray(g)?g:g.skills||[]).catch(()=>[])]).then(([g,b])=>{l(g),u(b)}).finally(()=>f(!1))},[t]);async function x(g){var S;const b=(S=g.target.files)==null?void 0:S[0];if(b){try{const Q=await b.text(),k=b.name.replace(/\.md$/i,"");await ee.post("/skills/import",{name:k,content:Q}),m.success(`Imported "${k}"`);const $=await ee.get("/skills/installed");u(Array.isArray($)?$:$.skills||[])}catch(Q){m.error("Import failed",Q.message)}g.target.value=""}}return d?i.jsx("div",{className:"p-5 space-y-3",children:[...Array(4)].map((g,b)=>i.jsx(Nt,{className:"h-14 rounded-md"},b))}):i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-5 py-4 space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("input",{ref:p,type:"file",accept:".md",onChange:x,className:"hidden"}),i.jsxs(je,{variant:"secondary",size:"md",onClick:()=>{var g;return(g=p.current)==null?void 0:g.click()},className:"gap-1.5",children:[i.jsx(dP,{size:13}),"Import .md Skill"]}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Drop a markdown skill file to install locally"})]}),t&&s.length>0&&i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider mb-3 flex items-center gap-1.5",children:[i.jsx(gO,{size:12}),"Purchases (",s.length,")"]}),i.jsx("div",{className:"space-y-1.5",children:s.map(g=>{var b,S;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-1 border border-border-subtle",children:[i.jsx("div",{className:"w-8 h-8 rounded-md bg-accent/10 flex items-center justify-center text-sm flex-shrink-0",children:g.skill_icon||((S=(b=g.skill_name)==null?void 0:b[0])==null?void 0:S.toUpperCase())||"?"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate",children:g.skill_name||g.skill_id}),i.jsxs("div",{className:"text-2xs text-text-4 font-sans",children:["$",(g.amount||0).toFixed(2)," · ",Ct(g.created_at)]})]}),i.jsx(We,{variant:"success",className:"text-2xs flex-shrink-0",children:"Owned"})]},g.id||g.skill_id)})})]}),t&&s.length===0&&i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md px-4 py-6 text-center",children:[i.jsx(gO,{size:20,className:"mx-auto text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No purchases yet"})]}),!t&&i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md px-4 py-6 text-center",children:[i.jsx(gO,{size:20,className:"mx-auto text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-2 font-sans mb-3",children:"Sign in to see your purchases"}),i.jsxs(je,{variant:"primary",size:"sm",onClick:n,className:"gap-1.5 mx-auto",children:[i.jsx(Df,{size:12})," Sign in"]})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider mb-3 flex items-center gap-1.5",children:[i.jsx(_b,{size:12}),"Installed (",o.length,")"]}),o.length===0?i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md px-4 py-6 text-center",children:[i.jsx(Uf,{size:20,className:"mx-auto text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No skills installed — browse the Skills tab or import a .md file"})]}):i.jsx("div",{className:"space-y-1.5",children:o.map(g=>{var b,S;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-1 border border-border-subtle group",children:[i.jsx("div",{className:"w-8 h-8 rounded-md bg-accent/10 flex items-center justify-center text-sm flex-shrink-0",children:g.icon||((S=(b=g.name)==null?void 0:b[0])==null?void 0:S.toUpperCase())||"?"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate",children:g.name||g.id}),i.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:g.description||g.category||"local skill"})]}),i.jsx(We,{variant:"accent",className:"text-2xs flex-shrink-0",children:"Installed"})]},g.id)})})]})]})})}function sX(){const t=W(o=>o.marketplaceAuthenticated),n=W(o=>o.marketplaceUser),s=W(o=>o.marketplaceLogin),l=W(o=>o.marketplaceLogout);return t?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded bg-surface-3 border border-border-subtle",children:[i.jsx("div",{className:"w-4 h-4 rounded-full bg-accent/20 flex items-center justify-center",children:i.jsx(Lb,{size:9,className:"text-accent"})}),i.jsx("span",{className:"text-xs text-text-0 font-sans font-medium max-w-[120px] truncate",children:(n==null?void 0:n.displayName)||(n==null?void 0:n.id)||"Account"})]}),i.jsx("button",{onClick:l,className:"flex items-center gap-1 px-2 py-1.5 rounded text-xs text-text-3 hover:text-text-0 hover:bg-surface-3 font-sans cursor-pointer transition-colors",children:i.jsx(Rb,{size:11})})]}):i.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold font-sans text-text-0 bg-accent/15 border border-accent/25 rounded hover:bg-accent/25 cursor-pointer transition-colors",children:[i.jsx(Df,{size:12}),"Sign in"]})}function lX(){const[t,n]=v.useState("skills"),s=[{id:"skills",label:"Skills",icon:Ub},{id:"integrations",label:"Integrations",icon:Zb},{id:"library",label:"My Library",icon:_b}];return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"flex-shrink-0 bg-surface-1 border-b border-border-subtle",children:i.jsxs("div",{className:"flex items-center px-5 h-11",children:[i.jsx("div",{className:"flex items-center",children:s.map(l=>{const o=l.icon;return i.jsxs("button",{onClick:()=>n(l.id),className:`flex items-center gap-1.5 px-3 py-2.5 text-xs font-semibold font-sans cursor-pointer select-none border-b-2 -mb-px transition-colors ${t===l.id?"border-accent text-text-0":"border-transparent text-text-3 hover:text-text-1"}`,children:[i.jsx(o,{size:12}),l.label]},l.id)})}),i.jsx("div",{className:"flex-1"}),i.jsx(sX,{})]})}),i.jsxs("div",{className:"flex-1 min-h-0",children:[t==="skills"&&i.jsx(tX,{}),t==="integrations"&&i.jsx(aX,{}),t==="library"&&i.jsx(nX,{})]})]})}function rX({children:t,className:n,hover:s,...l}){return i.jsx("div",{className:le("rounded-md border border-border bg-surface-1",s&&"hover:border-accent/50 hover:bg-surface-2 transition-all duration-150 cursor-pointer",n),...l,children:t})}function iX(){const t=W(l=>l.pendingApprovals),n=W(l=>l.approveRequest),s=W(l=>l.rejectRequest);return t.length===0?null:i.jsxs("div",{className:"px-4 pt-4 space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(_c,{size:13,className:"text-warning"}),i.jsxs("span",{className:"text-xs font-semibold text-warning font-sans",children:["Pending Approval (",t.length,")"]})]}),t.map(l=>{var o,u,d;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-md bg-warning/5 border border-warning/20",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"text-xs text-text-0 font-sans font-medium truncate",children:[l.agentName,": ",((o=l.action)==null?void 0:o.description)||((u=l.action)==null?void 0:u.type)||"action"]}),((d=l.action)==null?void 0:d.filePath)&&i.jsx("div",{className:"text-2xs text-text-3 font-mono truncate mt-0.5",children:l.action.filePath}),i.jsx("div",{className:"text-2xs text-text-4 font-sans mt-0.5",children:Ct(l.requestedAt)})]}),i.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[i.jsxs(je,{variant:"primary",size:"sm",onClick:()=>n(l.id),className:"h-7 px-2.5 gap-1 text-2xs",children:[i.jsx(Yb,{size:11})," Approve"]}),i.jsxs(je,{variant:"danger",size:"sm",onClick:()=>s(l.id),className:"h-7 px-2.5 gap-1 text-2xs",children:[i.jsx(eP,{size:11})," Reject"]})]})]},l.id)})]})}function oX(){const t=W(m=>m.resolvedApprovals),[n,s]=v.useState([]),[l,o]=v.useState(!0);v.useEffect(()=>{const m=setInterval(u,4e3);return u(),()=>clearInterval(m)},[]);async function u(){try{const m=await ee.get("/pm/history");s(m.history||m||[])}catch{}o(!1)}const d=new Set,f=[...t,...n].filter(m=>{const p=m.id||`${m.agentName}-${m.timestamp}`;return d.has(p)?!1:(d.add(p),!0)});return l&&f.length===0?i.jsx("div",{className:"p-4 space-y-2",children:[...Array(4)].map((m,p)=>i.jsx(Nt,{className:"h-12 rounded-md"},p))}):i.jsxs(Ht,{className:"flex-1",children:[i.jsx(iX,{}),i.jsxs("div",{className:"p-4 space-y-2",children:[f.length===0&&i.jsxs("div",{className:"text-center py-12 text-text-4 font-sans",children:[i.jsx(Br,{size:32,className:"mx-auto mb-2"}),i.jsx("p",{className:"text-sm",children:"No approval history"}),i.jsx("p",{className:"text-2xs text-text-4 mt-1",children:'Approvals appear when agents use "Agent Approve" permission mode'})]}),f.map((m,p)=>{var x;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-md bg-surface-1 border border-border-subtle",children:[m.status==="approved"||m.verdict==="approved"?i.jsx(Br,{size:14,className:"text-success flex-shrink-0"}):i.jsx(X5,{size:14,className:"text-danger flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"text-xs text-text-0 font-sans truncate",children:[m.agentName,": ",((x=m.action)==null?void 0:x.description)||m.action||"action"]}),m.reason&&i.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:m.reason})]}),i.jsx("span",{className:"text-2xs text-text-4 font-sans flex-shrink-0",children:Ct(m.resolvedAt||m.timestamp)})]},m.id||p)})]})]})}function cX(){const[t,n]=v.useState([]),[s,l]=v.useState(!0),o=Gc();v.useEffect(()=>{const f=setInterval(u,1e4);return u(),()=>clearInterval(f)},[]);async function u(){try{const f=await ee.get("/schedules");n(f.schedules||f||[])}catch{}l(!1)}async function d(f,m){try{await ee.post(`/schedules/${f}/${m?"disable":"enable"}`),u()}catch(p){o.error("Failed to toggle schedule",p.message)}}return s?i.jsx("div",{className:"p-4 space-y-2",children:[...Array(3)].map((f,m)=>i.jsx(Nt,{className:"h-16 rounded-md"},m))}):i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-2",children:[t.length===0&&i.jsxs("div",{className:"text-center py-12 text-text-4 font-sans",children:[i.jsx(oc,{size:32,className:"mx-auto mb-2"}),i.jsx("p",{className:"text-sm",children:"No schedules configured"})]}),t.map(f=>i.jsx(rX,{className:"p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:f.name}),i.jsx(We,{variant:f.enabled?"success":"default",children:f.enabled?"Active":"Paused"})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-mono mt-0.5",children:[f.cron," · ",f.role]})]}),i.jsx(je,{variant:"ghost",size:"sm",onClick:()=>d(f.id,f.enabled),children:f.enabled?"Pause":"Enable"})]})},f.id))]})})}function uX(){return i.jsxs(By,{defaultValue:"approvals",className:"flex flex-col h-full",children:[i.jsxs("div",{className:"px-4 pt-3 bg-surface-1 border-b border-border",children:[i.jsx("div",{className:"flex items-center gap-4 mb-0",children:i.jsx("h2",{className:"text-base font-semibold text-text-0 font-sans",children:"Management"})}),i.jsxs(Hy,{className:"border-b-0",children:[i.jsx(Ur,{value:"approvals",children:"Approvals"}),i.jsx(Ur,{value:"schedules",children:"Schedules"})]})]}),i.jsx(Gr,{value:"approvals",className:"flex-1 min-h-0",children:i.jsx(oX,{})}),i.jsx(Gr,{value:"schedules",className:"flex-1 min-h-0",children:i.jsx(cX,{})})]})}const dX={code:"Code",general:"General"},OX={light:"text-success",medium:"text-accent",heavy:"text-warning"};function fX(t){return t<1?`${Math.round(t*1024)} MB`:`${t} GB`}function nS({hardware:t}){if(!t)return null;const{totalRamGb:n,gpu:s,isAppleSilicon:l}=t;return i.jsxs("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg border border-border-subtle px-3 py-2.5",children:[i.jsx(Wf,{size:14,className:"text-text-3 flex-shrink-0"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"flex items-center gap-2 text-xs font-sans",children:[i.jsxs("span",{className:"text-text-0 font-semibold",children:[n," GB RAM"]}),s&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-4",children:"·"}),i.jsx("span",{className:"text-text-2",children:s.name})]}),l&&i.jsx(We,{variant:"accent",className:"text-2xs",children:"Unified Memory"})]})})]})}function hX({onRecheck:t}){const[n,s]=v.useState(null),[l,o]=v.useState(!1),[u,d]=v.useState(!1),[f,m]=v.useState(!1),p=W(Z=>Z.addToast);v.useEffect(()=>{ee.post("/providers/ollama/check").then(s).catch(()=>{})},[]);async function x(){o(!0);try{const Z=await ee.post("/providers/ollama/check");s(Z),Z.installed&&Z.serverRunning?(p("success","Ollama is ready!"),t()):Z.installed?p("info","Ollama installed — server needs to start"):p("info","Ollama not found — install and try again")}catch{}o(!1)}async function g(){d(!0);try{if((await ee.post("/providers/ollama/serve")).ok){p("success","Ollama server started!");let U=!1;for(let C=0;C<5;C++){await new Promise(T=>setTimeout(T,2e3));const X=await ee.post("/providers/ollama/check");if(s(X),X.serverRunning){U=!0;break}}U&&t()}}catch(Z){p("error","Could not start server",Z.message)}d(!1)}function b(Z){navigator.clipboard.writeText(Z),m(!0),setTimeout(()=>m(!1),2e3)}if(!n)return i.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Loading..."});const{hardware:S,install:Q,requirements:k,installed:$,serverRunning:j}=n,P=S.totalRamGb>=k.minRAM,N=S.recommended;return i.jsxs("div",{className:"space-y-3 p-3",children:[i.jsx(nS,{hardware:S}),P?i.jsxs("div",{className:"flex items-start gap-2 bg-success/8 border border-success/20 rounded-lg px-3 py-2.5",children:[i.jsx(oa,{size:14,className:"text-success flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs font-sans",children:[i.jsx("span",{className:"text-success font-semibold",children:"Your system is ready."}),i.jsx("span",{className:"text-text-2 ml-1",children:N.code?`Recommended: ${N.code}`:`${S.totalRamGb} GB RAM available`})]})]}):i.jsxs("div",{className:"flex items-start gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[i.jsx(cn,{size:14,className:"text-warning flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs font-sans text-text-2",children:[i.jsxs("span",{className:"text-warning font-semibold",children:[S.totalRamGb," GB RAM detected."]})," ","Minimum ",k.minRAM," GB needed. Smallest models may still work."]})]}),$&&!j&&i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-start gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[i.jsx(cn,{size:14,className:"text-warning flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs font-sans text-text-2",children:[i.jsx("span",{className:"text-warning font-semibold",children:"Ollama installed but server not running."})," ","The server needs to be running to pull and use models."]})]}),i.jsxs(je,{variant:"primary",size:"md",onClick:g,disabled:u,className:"w-full gap-1.5",children:[i.jsx(Na,{size:12}),u?"Starting...":"Start Ollama Server"]})]}),!$&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:"text-xs font-semibold text-text-1 font-sans",children:"Install Ollama"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 bg-surface-0 border border-border-subtle rounded-md px-3 py-2 text-xs font-mono text-text-1 truncate",children:Q.command}),i.jsxs(je,{variant:"secondary",size:"sm",onClick:()=>b(Q.command),className:"h-8 px-2.5 gap-1 flex-shrink-0",children:[f?i.jsx(oa,{size:12}):i.jsx(uf,{size:12}),f?"Copied":"Copy"]})]}),Q.alt&&i.jsx("p",{className:"text-2xs text-text-4 font-sans",children:Q.alt})]}),i.jsxs(je,{variant:"secondary",size:"md",onClick:x,disabled:l,className:"w-full gap-1.5",children:[i.jsx(es,{size:12,className:l?"animate-spin":""}),l?"Checking...":$?"Check again":"I installed it — check again"]})]})}function mX({model:t,isInstalled:n,isRecommended:s,canRun:l,onPull:o,onDelete:u,pulling:d}){const f=d===t.id;return i.jsxs("div",{className:le("flex items-center gap-2 px-3 py-2 border-t border-border-subtle transition-colors",!l&&"opacity-40"),children:[n?i.jsx(oa,{size:12,className:"text-success flex-shrink-0"}):i.jsx("div",{className:"w-3"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-mono text-text-1 truncate",children:t.name}),s&&i.jsx(Gb,{size:10,className:"text-warning flex-shrink-0"})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("span",{className:le("text-2xs font-semibold font-sans",OX[t.tier]),children:t.tier}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:fX(t.sizeGb)}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:["· ",t.ramGb," GB RAM"]})]})]}),n?i.jsx("button",{onClick:()=>u(t.id),className:"p-1.5 text-text-4 hover:text-danger rounded transition-colors cursor-pointer",title:"Remove model",children:i.jsx(Xc,{size:12})}):l?i.jsx(je,{variant:"secondary",size:"sm",onClick:()=>o(t.id),disabled:!!d,className:"h-7 px-2 text-2xs gap-1",children:f?i.jsxs(i.Fragment,{children:[i.jsx(es,{size:10,className:"animate-spin"})," Pulling..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Uf,{size:10})," Pull"]})}):i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:["Needs ",t.ramGb," GB"]})]})}function pX({onStopped:t}){const[n,s]=v.useState(null),l=W(d=>d.addToast);async function o(){s("stopping");try{(await ee.post("/providers/ollama/stop")).ok?(l("info","Ollama server stopped"),t&&t()):l("error","Could not stop server")}catch(d){l("error","Stop failed",d.message)}s(null)}async function u(){s("restarting");try{(await ee.post("/providers/ollama/restart")).ok?l("success","Ollama server restarted"):l("error","Restart failed")}catch(d){l("error","Restart failed",d.message)}s(null)}return i.jsxs("div",{className:"flex items-center gap-2 bg-success/8 border border-success/20 rounded-lg px-3 py-2",children:[i.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[i.jsx("span",{className:"absolute inset-0 rounded-full bg-success"}),i.jsx("span",{className:"absolute inset-[-2px] rounded-full bg-success opacity-20 animate-pulse"})]}),i.jsx("span",{className:"text-xs font-sans text-success font-semibold",children:"Server Running"}),i.jsx("span",{className:"text-2xs font-mono text-text-4",children:":11434"}),i.jsx("div",{className:"flex-1"}),i.jsxs("button",{onClick:u,disabled:!!n,className:"flex items-center gap-1 text-2xs font-sans text-text-3 hover:text-accent cursor-pointer transition-colors disabled:opacity-40",children:[i.jsx(es,{size:10,className:n==="restarting"?"animate-spin":""}),n==="restarting"?"Restarting...":"Restart"]}),i.jsxs("button",{onClick:o,disabled:!!n,className:"flex items-center gap-1 text-2xs font-sans text-text-3 hover:text-danger cursor-pointer transition-colors disabled:opacity-40",children:[i.jsx(cn,{size:10}),n==="stopping"?"Stopping...":"Stop"]})]})}function xX({onModelChange:t}){var T,G;const[n,s]=v.useState(null),[l,o]=v.useState(null),[u,d]=v.useState("code"),[f,m]=v.useState(!1),[p,x]=v.useState(!1),g=W(E=>E.addToast),b=v.useRef(!1);function S(){ee.get("/providers/ollama/models").then(E=>{var se;s(E),!b.current&&((se=E.installed)==null?void 0:se.length)===0&&(b.current=!0,setTimeout(S,2e3))}).catch(()=>{})}v.useEffect(()=>{S()},[]);async function Q(E){o(E);try{await ee.post("/providers/ollama/pull",{model:E}),g("success",`Pulled ${E}`),S(),t&&t()}catch(se){g("error",`Pull failed: ${se.message}`)}o(null)}async function k(E){try{await ee.delete(`/providers/ollama/models/${encodeURIComponent(E)}`),g("info",`Removed ${E}`),S(),t&&t()}catch(se){g("error",`Delete failed: ${se.message}`)}}if(!n)return i.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Loading..."});const{installed:$,catalog:j,hardware:P}=n,N=new Set($.map(E=>E.id)),Z=P.totalRamGb,U=[(T=P.recommended)==null?void 0:T.code,(G=P.recommended)==null?void 0:G.general].filter(Boolean),C=j.filter(E=>E.category===u),X=f?C:C.filter(E=>E.ramGb<=Z);return p?i.jsxs("div",{className:"space-y-3 p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[i.jsx(cn,{size:14,className:"text-warning flex-shrink-0"}),i.jsxs("span",{className:"text-xs font-sans text-text-2",children:[i.jsx("span",{className:"text-warning font-semibold",children:"Ollama server stopped."})," ","Start it again to pull and use models."]})]}),i.jsxs(je,{variant:"primary",size:"md",onClick:async()=>{try{(await ee.post("/providers/ollama/serve")).ok&&(g("success","Ollama server started!"),x(!1),b.current=!1,setTimeout(S,2e3))}catch(E){g("error","Could not start server",E.message)}},className:"w-full gap-1.5",children:[i.jsx(Na,{size:12}),"Start Ollama Server"]})]}):i.jsxs("div",{className:"space-y-2 p-3",children:[i.jsx(pX,{onStopped:()=>x(!0)}),i.jsx(nS,{hardware:P}),$.length>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-sans text-text-2",children:[i.jsx(Nb,{size:12,className:"text-text-3"}),i.jsx("span",{className:"font-semibold",children:$.length})," model",$.length!==1?"s":""," installed"]}),i.jsx("div",{className:"flex bg-surface-0 rounded-lg p-0.5 border border-border-subtle",children:Object.entries(dX).map(([E,se])=>i.jsx("button",{onClick:()=>d(E),className:le("flex-1 px-3 py-1.5 text-2xs font-semibold font-sans rounded-md transition-all cursor-pointer",u===E?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:se},E))}),i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-0 overflow-hidden",children:[X.map(E=>i.jsx(mX,{model:E,isInstalled:N.has(E.id),isRecommended:U.includes(E.id),canRun:E.ramGb<=Z,onPull:Q,onDelete:k,pulling:l},E.id)),X.length===0&&i.jsxs("div",{className:"px-3 py-4 text-center text-xs text-text-4 font-sans",children:["No ",u," models available for your hardware"]})]}),!f&&C.length>X.length&&i.jsxs("button",{onClick:()=>m(!0),className:"flex items-center gap-1 text-2xs text-text-3 hover:text-accent font-sans cursor-pointer transition-colors",children:[i.jsx(In,{size:10}),"Show ",C.length-X.length," more (exceed your RAM)"]})]})}function sS({isInstalled:t,onModelChange:n}){const[s,l]=v.useState(!1),[o,u]=v.useState(!1);return v.useEffect(()=>{t?ee.post("/providers/ollama/check").then(d=>{l(d.installed&&d.serverRunning),u(!0)}).catch(()=>u(!0)):u(!0)},[t]),o?s?i.jsx(xX,{onModelChange:n}):i.jsx(hX,{onRecheck:()=>{l(!0),n&&n()}}):i.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Checking Ollama..."})}var GO="focusScope.autoFocusOnMount",LO="focusScope.autoFocusOnUnmount",s0={bubbles:!1,cancelable:!0},gX="FocusScope",lS=v.forwardRef((t,n)=>{const{loop:s=!1,trapped:l=!1,onMountAutoFocus:o,onUnmountAutoFocus:u,...d}=t,[f,m]=v.useState(null),p=zt(o),x=zt(u),g=v.useRef(null),b=rt(n,k=>m(k)),S=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(l){let k=function(N){if(S.paused||!f)return;const Z=N.target;f.contains(Z)?g.current=Z:Un(g.current,{select:!0})},$=function(N){if(S.paused||!f)return;const Z=N.relatedTarget;Z!==null&&(f.contains(Z)||Un(g.current,{select:!0}))},j=function(N){if(document.activeElement===document.body)for(const U of N)U.removedNodes.length>0&&Un(f)};document.addEventListener("focusin",k),document.addEventListener("focusout",$);const P=new MutationObserver(j);return f&&P.observe(f,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",$),P.disconnect()}}},[l,f,S.paused]),v.useEffect(()=>{if(f){r0.add(S);const k=document.activeElement;if(!f.contains(k)){const j=new CustomEvent(GO,s0);f.addEventListener(GO,p),f.dispatchEvent(j),j.defaultPrevented||(bX(jX(rS(f)),{select:!0}),document.activeElement===k&&Un(f))}return()=>{f.removeEventListener(GO,p),setTimeout(()=>{const j=new CustomEvent(LO,s0);f.addEventListener(LO,x),f.dispatchEvent(j),j.defaultPrevented||Un(k??document.body,{select:!0}),f.removeEventListener(LO,x),r0.remove(S)},0)}}},[f,p,x,S]);const Q=v.useCallback(k=>{if(!s&&!l||S.paused)return;const $=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,j=document.activeElement;if($&&j){const P=k.currentTarget,[N,Z]=vX(P);N&&Z?!k.shiftKey&&j===Z?(k.preventDefault(),s&&Un(N,{select:!0})):k.shiftKey&&j===N&&(k.preventDefault(),s&&Un(Z,{select:!0})):j===P&&k.preventDefault()}},[s,l,S.paused]);return i.jsx(Be.div,{tabIndex:-1,...d,ref:b,onKeyDown:Q})});lS.displayName=gX;function bX(t,{select:n=!1}={}){const s=document.activeElement;for(const l of t)if(Un(l,{select:n}),document.activeElement!==s)return}function vX(t){const n=rS(t),s=l0(n,t),l=l0(n.reverse(),t);return[s,l]}function rS(t){const n=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:l=>{const o=l.tagName==="INPUT"&&l.type==="hidden";return l.disabled||l.hidden||o?NodeFilter.FILTER_SKIP:l.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n}function l0(t,n){for(const s of t)if(!yX(s,{upTo:n}))return s}function yX(t,{upTo:n}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(n!==void 0&&t===n)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function SX(t){return t instanceof HTMLInputElement&&"select"in t}function Un(t,{select:n=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&SX(t)&&n&&t.select()}}var r0=QX();function QX(){let t=[];return{add(n){const s=t[0];n!==s&&(s==null||s.pause()),t=i0(t,n),t.unshift(n)},remove(n){var s;t=i0(t,n),(s=t[0])==null||s.resume()}}}function i0(t,n){const s=[...t],l=s.indexOf(n);return l!==-1&&s.splice(l,1),s}function jX(t){return t.filter(n=>n.tagName!=="A")}var DO=0;function wX(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??o0()),document.body.insertAdjacentElement("beforeend",t[1]??o0()),DO++,()=>{DO===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),DO--}},[])}function o0(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var wa=function(){return wa=Object.assign||function(n){for(var s,l=1,o=arguments.length;l<o;l++){s=arguments[l];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(n[u]=s[u])}return n},wa.apply(this,arguments)};function iS(t,n){var s={};for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&n.indexOf(l)<0&&(s[l]=t[l]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,l=Object.getOwnPropertySymbols(t);o<l.length;o++)n.indexOf(l[o])<0&&Object.prototype.propertyIsEnumerable.call(t,l[o])&&(s[l[o]]=t[l[o]]);return s}function kX(t,n,s){if(s||arguments.length===2)for(var l=0,o=n.length,u;l<o;l++)(u||!(l in n))&&(u||(u=Array.prototype.slice.call(n,0,l)),u[l]=n[l]);return t.concat(u||Array.prototype.slice.call(n))}var Ko="right-scroll-bar-position",Jo="width-before-scroll-bar",$X="with-scroll-bars-hidden",TX="--removed-body-scroll-bar-size";function WO(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function PX(t,n){var s=v.useState(function(){return{value:t,callback:n,facade:{get current(){return s.value},set current(l){var o=s.value;o!==l&&(s.value=l,s.callback(l,o))}}}})[0];return s.callback=n,s.facade}var NX=typeof window<"u"?v.useLayoutEffect:v.useEffect,c0=new WeakMap;function zX(t,n){var s=PX(null,function(l){return t.forEach(function(o){return WO(o,l)})});return NX(function(){var l=c0.get(s);if(l){var o=new Set(l),u=new Set(t),d=s.current;o.forEach(function(f){u.has(f)||WO(f,null)}),u.forEach(function(f){o.has(f)||WO(f,d)})}c0.set(s,t)},[t]),s}function RX(t){return t}function CX(t,n){n===void 0&&(n=RX);var s=[],l=!1,o={read:function(){if(l)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(u){var d=n(u,l);return s.push(d),function(){s=s.filter(function(f){return f!==d})}},assignSyncMedium:function(u){for(l=!0;s.length;){var d=s;s=[],d.forEach(u)}s={push:function(f){return u(f)},filter:function(){return s}}},assignMedium:function(u){l=!0;var d=[];if(s.length){var f=s;s=[],f.forEach(u),d=s}var m=function(){var x=d;d=[],x.forEach(u)},p=function(){return Promise.resolve().then(m)};p(),s={push:function(x){d.push(x),p()},filter:function(x){return d=d.filter(x),s}}}};return o}function XX(t){t===void 0&&(t={});var n=CX(null);return n.options=wa({async:!0,ssr:!1},t),n}var oS=function(t){var n=t.sideCar,s=iS(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var l=n.read();if(!l)throw new Error("Sidecar medium not found");return v.createElement(l,wa({},s))};oS.isSideCarExport=!0;function _X(t,n){return t.useMedium(n),oS}var cS=XX(),BO=function(){},Lc=v.forwardRef(function(t,n){var s=v.useRef(null),l=v.useState({onScrollCapture:BO,onWheelCapture:BO,onTouchMoveCapture:BO}),o=l[0],u=l[1],d=t.forwardProps,f=t.children,m=t.className,p=t.removeScrollBar,x=t.enabled,g=t.shards,b=t.sideCar,S=t.noRelative,Q=t.noIsolation,k=t.inert,$=t.allowPinchZoom,j=t.as,P=j===void 0?"div":j,N=t.gapMode,Z=iS(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),U=b,C=zX([s,n]),X=wa(wa({},Z),o);return v.createElement(v.Fragment,null,x&&v.createElement(U,{sideCar:cS,removeScrollBar:p,shards:g,noRelative:S,noIsolation:Q,inert:k,setCallbacks:u,allowPinchZoom:!!$,lockRef:s,gapMode:N}),d?v.cloneElement(v.Children.only(f),wa(wa({},X),{ref:C})):v.createElement(P,wa({},X,{className:m,ref:C}),f))});Lc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Lc.classNames={fullWidth:Jo,zeroRight:Ko};var ZX=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function AX(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=ZX();return n&&t.setAttribute("nonce",n),t}function EX(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function qX(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var MX=function(){var t=0,n=null;return{add:function(s){t==0&&(n=AX())&&(EX(n,s),qX(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},YX=function(){var t=MX();return function(n,s){v.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&s])}},uS=function(){var t=YX(),n=function(s){var l=s.styles,o=s.dynamic;return t(l,o),null};return n},VX={left:0,top:0,right:0,gap:0},HO=function(t){return parseInt(t||"",10)||0},UX=function(t){var n=window.getComputedStyle(document.body),s=n[t==="padding"?"paddingLeft":"marginLeft"],l=n[t==="padding"?"paddingTop":"marginTop"],o=n[t==="padding"?"paddingRight":"marginRight"];return[HO(s),HO(l),HO(o)]},GX=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return VX;var n=UX(t),s=document.documentElement.clientWidth,l=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,l-s+n[2]-n[0])}},LX=uS(),wl="data-scroll-locked",DX=function(t,n,s,l){var o=t.left,u=t.top,d=t.right,f=t.gap;return s===void 0&&(s="margin"),`
538
+ `,{label:"if",detail:"block",type:"keyword"}),Ie("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),Ie("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),Ie("import ${module}",{label:"import",detail:"statement",type:"keyword"}),Ie("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],IR=S0(Ny,Q0(BR.concat(HR)));function AO(t){let{node:n,pos:s}=t,l=t.lineIndent(s,-1),o=null;for(;;){let u=n.childBefore(s);if(u)if(u.name=="Comment")s=u.from;else if(u.name=="Body"||u.name=="MatchBody")t.baseIndentFor(u)+t.unit<=l&&(o=u),n=u;else if(u.name=="MatchClause")n=u;else if(u.type.is("Statement"))n=u;else break;else break}return o}function EO(t,n){let s=t.baseIndentFor(n),l=t.lineAt(t.pos,-1),o=l.from+l.text.length;return/^\s*($|#)/.test(l.text)&&t.node.to<o+100&&!/\S/.test(t.state.sliceDoc(o,t.node.to))&&t.lineIndent(t.pos,-1)<=s||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(t.textAfter)&&t.lineIndent(t.pos,-1)>s?null:s+t.unit}const qO=si.define({name:"python",parser:LR.configure({props:[_l.add({Body:t=>{var n;let s=/^\s*(#|$)/.test(t.textAfter)&&AO(t)||t.node;return(n=EO(t,s))!==null&&n!==void 0?n:t.continue()},MatchBody:t=>{var n;let s=AO(t);return(n=EO(t,s||t.node))!==null&&n!==void 0?n:t.continue()},IfStatement:t=>/^\s*(else:|elif )/.test(t.textAfter)?t.baseIndent:t.continue(),"ForStatement WhileStatement":t=>/^\s*else:/.test(t.textAfter)?t.baseIndent:t.continue(),TryStatement:t=>/^\s*(except[ :]|finally:|else:)/.test(t.textAfter)?t.baseIndent:t.continue(),MatchStatement:t=>/^\s*case /.test(t.textAfter)?t.baseIndent+t.unit:t.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Lo({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Lo({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Lo({closing:"]"}),MemberExpression:t=>t.baseIndent+t.unit,"String FormatString":()=>null,Script:t=>{var n;let s=AO(t);return(n=s&&EO(t,s))!==null&&n!==void 0?n:t.continue()}}),Ts.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":jc,Body:(t,n)=>({from:t.from+1,to:t.to-(t.to==n.doc.length?0:1)}),"String FormatString":(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function FR(){return new Qs(qO,[qO.data.of({autocomplete:WR}),qO.data.of({autocomplete:IR})])}const qo={javascript:()=>ff({jsx:!0,typescript:!1}),typescript:()=>ff({jsx:!0,typescript:!0}),css:()=>$v(),html:()=>Dv(),json:()=>D4(),markdown:()=>zz(),python:()=>FR()},KR=kl.theme({"&":{backgroundColor:"#24282f",color:"#bcc2cd",fontFamily:"var(--font-mono)",fontSize:"13px",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{caretColor:"#33afbc"},".cm-cursor":{borderLeftColor:"#33afbc"},".cm-gutters":{backgroundColor:"#24282f",borderRight:"1px solid #2c313a",color:"#505862"},".cm-activeLineGutter":{backgroundColor:"#2c313a"},".cm-activeLine":{backgroundColor:"rgba(44, 49, 58, 0.5)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"rgba(51, 175, 188, 0.15)"}},{dark:!0});function JR({content:t,language:n,onChange:s,onSave:l}){const o=v.useRef(null),u=v.useRef(null),d=v.useRef(new Cj),f=v.useRef(s),m=v.useRef(l);return f.current=s,m.current=l,v.useEffect(()=>{if(!o.current)return;const p=qo[n]||qo.javascript,x=JO.of([{key:"Mod-s",run:()=>{var S;return(S=m.current)==null||S.call(m),!0}}]),g=$0.create({doc:t||"",extensions:[_j(),Zj(),Aj(),Ej(),qj(),Mj(),Yj(),JO.of([...Vj,...Uj,...Gj]),x,Xj,KR,d.current.of(p()),kl.updateListener.of(S=>{var Q;S.docChanged&&((Q=f.current)==null||Q.call(f,S.state.doc.toString()))})]}),b=new kl({state:g,parent:o.current});return u.current=b,()=>{b.destroy(),u.current=null}},[]),v.useEffect(()=>{const p=u.current;if(!p)return;const x=p.state.doc.toString();t!==x&&p.dispatch({changes:{from:0,to:x.length,insert:t||""}})},[t]),v.useEffect(()=>{const p=u.current;if(!p)return;const x=qo[n]||qo.javascript;p.dispatch({effects:d.current.reconfigure(x())})},[n]),i.jsx("div",{ref:o,className:"w-full h-full overflow-hidden"})}const eC=["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"],zy=["mp4","webm","mov","avi","mkv","ogv"];function tC(t){var s;const n=(s=t.split(".").pop())==null?void 0:s.toLowerCase();return eC.includes(n)||zy.includes(n)}function aC({path:t}){var u;const n=(u=t.split(".").pop())==null?void 0:u.toLowerCase(),s=`/api/files/raw?path=${encodeURIComponent(t)}`,l=t.split("/").pop(),o=zy.includes(n);return i.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center bg-surface-0 p-8 gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-3 font-sans",children:[i.jsx(We,{children:n==null?void 0:n.toUpperCase()}),i.jsx("span",{className:"font-mono",children:l}),i.jsx("a",{href:s,target:"_blank",rel:"noopener",className:"text-accent hover:text-accent/80 transition-colors",children:i.jsx(cc,{size:12})})]}),o?i.jsx("video",{src:s,controls:!0,className:"max-w-full max-h-[70vh] rounded-md border border-border"}):i.jsx("img",{src:s,alt:l,className:"max-w-full max-h-[70vh] rounded-md border border-border object-contain"})]})}function nC(){const t=W(b=>b.editorActiveFile),n=W(b=>b.editorFiles),s=W(b=>b.editorChangedFiles),l=W(b=>b.updateFileContent),o=W(b=>b.saveFile),u=W(b=>b.reloadFile),d=W(b=>b.dismissFileChange),[f,m]=v.useState("");v.useEffect(()=>{ee.get("/files/root").then(b=>m(b.root||"")).catch(()=>{})},[]);const p=t?n[t]:null,x=t&&tC(t),g=t&&s[t];return i.jsxs("div",{className:"flex h-full",children:[i.jsx("div",{className:"w-60 flex-shrink-0 border-r border-border",children:i.jsx(yN,{rootDir:f})}),i.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[i.jsx(SN,{}),i.jsxs("div",{className:"flex-1 relative min-h-0",children:[g&&i.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex items-center gap-2 px-4 py-2 bg-warning/10 border-b border-warning/20",children:[i.jsx(_c,{size:14,className:"text-warning"}),i.jsx("span",{className:"text-xs text-warning font-sans flex-1",children:"File modified externally"}),i.jsxs(je,{variant:"ghost",size:"sm",onClick:()=>u(t),children:[i.jsx(es,{size:12})," Reload"]}),i.jsxs(je,{variant:"ghost",size:"sm",onClick:()=>d(t),children:[i.jsx(Rt,{size:12})," Dismiss"]})]}),!t&&i.jsx("div",{className:"w-full h-full flex items-center justify-center text-text-4 font-sans",children:i.jsxs("div",{className:"text-center space-y-2",children:[i.jsx(dn,{size:32,className:"mx-auto"}),i.jsx("p",{className:"text-sm",children:"Open a file from the tree"})]})}),t&&x&&i.jsx(aC,{path:t}),t&&!x&&p&&i.jsx(JR,{content:p.content,language:p.language,onChange:b=>l(t,b),onSave:()=>o(t)})]})]})]})}function sC(){var k;const t=W($=>$.connected),n=W($=>$.agents),[s,l]=v.useState(null),[o,u]=v.useState(!0),[d,f]=v.useState({tokens:[],cost:[],saved:[],efficiency:[],cache:[],inputOutput:[],agents:[],turns:[]}),m=v.useRef(0);v.useEffect(()=>{if(!t)return;let $=!0;async function j(){try{const N=await ee.get("/dashboard");if(!$)return;l(N),u(!1),m.current=Date.now(),f(Z=>{var re,ge,de,K,z,B,J,fe,te;const U=Date.now(),C=(Ae,Se)=>[...Ae.slice(-59),{t:U,v:Se||0}],X=((re=N.tokens)==null?void 0:re.totalTokens)||0,T=((de=(ge=N.tokens)==null?void 0:ge.savings)==null?void 0:de.total)||0,G=X+T,E=((K=N.tokens)==null?void 0:K.totalInputTokens)||0,se=((z=N.tokens)==null?void 0:z.totalOutputTokens)||0;return{tokens:C(Z.tokens,X),cost:C(Z.cost,(B=N.tokens)==null?void 0:B.totalCostUsd),saved:C(Z.saved,T),efficiency:C(Z.efficiency,G>0?T/G*100:0),cache:C(Z.cache,(J=N.tokens)==null?void 0:J.cacheHitRate),inputOutput:C(Z.inputOutput,se>0?E/se:0),agents:C(Z.agents,((fe=N.agents)==null?void 0:fe.running)||0),turns:C(Z.turns,(te=N.tokens)==null?void 0:te.totalTurns)}})}catch{$&&u(!1)}}j();const P=setInterval(j,4e3);return()=>{$=!1,clearInterval(P)}},[t]);const p=((k=s==null?void 0:s.agents)==null?void 0:k.breakdown)||[],x=(s==null?void 0:s.routing)||null,g=(s==null?void 0:s.rotation)||null,b=(s==null?void 0:s.adaptive)||[],S=(s==null?void 0:s.journalist)||null,Q=(g==null?void 0:g.rotating)||[];return{data:s,loading:o,agents:n,connected:t,kpiHistory:d,lastFetch:m.current,agentBreakdown:p,routing:x,rotation:g,adaptive:b,journalist:S,rotating:Q}}const K1=v.memo(function({connected:n,runningCount:s,totalCount:l,uptime:o,lastFetch:u,activeTeam:d}){return i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 bg-surface-1 border-b border-border",children:[i.jsx("h2",{className:"text-xs font-semibold text-text-0 font-sans tracking-wide uppercase",children:"Command Center"}),d&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-4",children:"/"}),i.jsx("span",{className:"text-xs font-mono text-text-2",children:d.name})]}),i.jsx("div",{className:"flex-1"}),n&&i.jsxs("div",{className:"flex items-center gap-3.5 text-xs font-mono text-text-2",children:[i.jsxs("span",{children:[i.jsx("span",{className:"text-text-1",children:s}),i.jsxs("span",{className:"text-text-3",children:["/",l]}),i.jsx("span",{className:"ml-1 text-text-3",children:"agents"})]}),o>0&&i.jsxs("span",{className:"text-text-3",children:["Up ",Ec(o)]}),u>0&&i.jsxs("span",{className:"flex items-center gap-1 text-text-4",children:[i.jsx(es,{size:9}),i.jsx("span",{children:Ct(u)})]})]}),i.jsx(Pl,{status:n?"running":"crashed",size:"sm"})]})});function ia(t,n){const s=parseInt(t.slice(1,3),16),l=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return`rgba(${s},${l},${o},${n})`}const me={surface0:"#1a1e25",surface4:"#2c313a",surface5:"#333842",text0:"#e6e6e6",text1:"#bcc2cd",text2:"#8b929e",text3:"#6e7681",text4:"#505862",accent:"#33afbc",success:"#4ae168",warning:"#e5c07b",danger:"#e06c75",info:"#61afef",purple:"#c678dd",orange:"#d19a66"};function lC({data:t,color:n=me.accent,width:s=72,height:l=22}){if(!t||t.length<2)return i.jsx("div",{style:{width:s,height:l}});const o=t.map(x=>x.v),u=Math.min(...o),f=Math.max(...o)-u||1,m=t.map((x,g)=>{const b=g/(t.length-1)*s,S=l-(x.v-u)/f*(l-2)-1;return`${b},${S}`}).join(" "),p=`kpi-${n.replace("#","")}`;return i.jsxs("svg",{width:s,height:l,className:"flex-shrink-0",children:[i.jsx("defs",{children:i.jsxs("linearGradient",{id:p,x1:"0",y1:"0",x2:"0",y2:"1",children:[i.jsx("stop",{offset:"0%",stopColor:n,stopOpacity:"0.2"}),i.jsx("stop",{offset:"100%",stopColor:n,stopOpacity:"0"})]})}),i.jsx("polygon",{points:`0,${l} ${m} ${s},${l}`,fill:`url(#${p})`}),i.jsx("polyline",{points:m,fill:"none",stroke:n,strokeWidth:"1.5",strokeLinejoin:"round",strokeOpacity:"0.8"})]})}const rC=v.memo(function({label:n,value:s,sparkData:l,color:o=me.accent,className:u}){return i.jsxs("div",{className:le("flex items-center gap-2.5 px-3 py-2.5 min-w-0","bg-surface-1",u),children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5 truncate",children:n}),i.jsx("div",{className:"text-base font-semibold font-mono text-text-0 tabular-nums leading-none",children:s})]}),i.jsx(lC,{data:l,color:o})]})});function iC({kpis:t}){return i.jsx("div",{className:"flex flex-wrap border-b border-border",style:{background:"var(--color-surface-0)"},children:t.map(n=>i.jsx(rC,{label:n.label,value:n.value,sparkData:n.sparkData,color:n.color,className:le("flex-1 basis-[12.5%] min-w-[140px]","border-b border-r border-border")},n.label))})}const oC={actual:"ACT",estimated:"EST",local:"LOC"},cC=v.memo(function({agent:n,isRotating:s}){const l=n.status==="running"||n.status==="starting",o=Math.round((n.contextUsage||0)*100),u=s?"#c678dd":Ff(n.status),d=n.quality,f=(d==null?void 0:d.toolSuccessRate)!=null?Math.round(d.toolSuccessRate*100):null,m=n.rotationThreshold?Math.round(n.rotationThreshold*100):null;return i.jsxs("div",{className:"px-3 py-2 hover:bg-surface-3 transition-colors space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[i.jsx("span",{className:"absolute inset-0 rounded-sm",style:{background:u}}),l&&i.jsx("span",{className:"absolute inset-[-2px] rounded-sm",style:{background:u,opacity:.15,animation:"node-pulse-bar 2s ease-in-out infinite"}})]}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate leading-none",children:n.name}),i.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider",children:n.role}),i.jsx("span",{className:"text-2xs text-text-4",children:"/"}),i.jsx("span",{className:"text-2xs font-mono text-text-3",children:uC(n.model)})]})]}),i.jsx("div",{className:"flex-1"}),f!=null&&i.jsxs("span",{className:"text-2xs font-mono font-bold uppercase px-1 py-px rounded-sm flex-shrink-0",style:{color:f>=90?"#4ae168":f>=70?"#e5c07b":"#e06c75",background:f>=90?"rgba(74,225,104,0.1)":f>=70?"rgba(229,192,123,0.1)":"rgba(224,108,117,0.1)"},children:[f,"%"]}),n.costSource&&n.costSource!=="actual"&&i.jsx("span",{className:"text-2xs font-mono text-text-4 uppercase tracking-wider flex-shrink-0",children:oC[n.costSource]||""}),i.jsxs("div",{className:"text-right flex-shrink-0",children:[i.jsx("div",{className:"text-xs font-mono text-text-1 tabular-nums leading-none",children:ct(n.tokens||0)}),(n.costUsd||0)>0&&i.jsx("div",{className:"text-2xs font-mono text-text-3 mt-0.5",children:Ac(n.costUsd)})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1 h-[3px] bg-surface-0 rounded-full overflow-visible",children:[i.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-700",style:{width:`${Math.max(o,1)}%`,background:o>80?"#e06c75":o>60?"#e5c07b":l?"#61afef":"#333842"}}),m&&i.jsx("div",{className:"absolute top-[-2px] w-px h-[7px]",style:{left:`${m}%`,background:"#c678dd"},title:`Rotation at ${m}%`})]}),i.jsxs("span",{className:"text-2xs font-mono text-text-2 tabular-nums flex-shrink-0 w-7 text-right",children:[o,"%"]})]})]})});function uC(t){if(!t||t==="auto"||t==="default")return"default";const n=t.match(/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)/);return n?`${n[1][0].toUpperCase()}${n[1].slice(1)} ${n[2]}.${n[3]}`:t.startsWith("gemini-")?t.replace("gemini-","Gem ").replace("-preview",""):t.length>12?t.slice(0,12)+"...":t}const dC=v.memo(function({agentBreakdown:n,rotating:s=[]}){if(!(n!=null&&n.length))return i.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-text-3 font-mono p-4",children:"No agents"});const l={};for(const u of n){const d=u.teamId||"ungrouped";l[d]||(l[d]=[]),l[d].push(u)}const o=new Set(s);return i.jsx(Ht,{className:"flex-1",children:i.jsx("div",{className:"py-1",children:Object.entries(l).map(([u,d])=>i.jsxs("div",{children:[i.jsx("div",{className:"px-3 pt-2 pb-1",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:u})}),d.map(f=>i.jsx(cC,{agent:f,isRotating:o.has(f.id)},f.id))]},u))})})}),OC=v.memo(function({data:n}){const s=v.useRef(null),l=v.useRef(null),[o,u]=v.useState({width:0,height:0}),[d,f]=v.useState(null),{width:m,height:p}=o,x={top:28,right:12,bottom:8,left:12},g=Math.max(m-x.left-x.right,0),b=Math.max(p-x.top-x.bottom,0),S=v.useMemo(()=>!n||n.length<2?[]:n.slice(1).map(($,j)=>{const P=n[j],N=($.t-P.t)/6e4,Z=Math.max(($.tokens||0)-(P.tokens||0),0);return{burnRate:N>0?Math.round(Z/N):0,cacheHitRate:$.cacheHitRate||0,running:$.running||0,agents:$.agents||0,t:$.t}}),[n]);v.useEffect(()=>{const $=s.current;if(!$)return;const j=new ResizeObserver(P=>{const{width:N,height:Z}=P[0].contentRect;N>0&&Z>0&&u({width:Math.floor(N),height:Math.floor(Z)})});return j.observe($),()=>j.disconnect()},[]);const Q=v.useCallback($=>{const j=l.current;if(!j||!S.length||g<=0)return;const P=j.getBoundingClientRect(),N=$.clientX-P.left-x.left;if(N<0||N>g){f(null);return}const Z=Math.round(N/g*(S.length-1));f({x:x.left+Z/Math.max(S.length-1,1)*g,index:Z})},[S,g,x.left]),k=v.useCallback(()=>f(null),[]);return v.useEffect(()=>{const $=l.current;if(!$||!S.length||m<=0||p<=0||g<=0||b<=0)return;const j=$.getContext("2d"),P=window.devicePixelRatio||1;$.width=m*P,$.height=p*P,j.scale(P,P),j.clearRect(0,0,m,p);const N=S.map(z=>z.burnRate),Z=S.map(z=>z.cacheHitRate),U=S.map(z=>z.running),C=Math.max(...N,100),X=Math.max(...U,1),T=z=>x.left+z/Math.max(S.length-1,1)*g,G=z=>x.top+b-z/C*b,E=z=>x.top+b-z*b,se=Math.max(g/S.length-1,2);for(let z=0;z<S.length;z++){const B=U[z];if(B<=0)continue;const J=B/X*b*.3,fe=T(z)-se/2,te=x.top+b-J;j.fillStyle=ia(me.surface5,.5),j.fillRect(fe,te,se,J)}j.setLineDash([2,4]),j.strokeStyle=ia(me.text4,.2),j.lineWidth=1;for(let z=1;z<=3;z++){const B=x.top+b/4*z;j.beginPath(),j.moveTo(x.left,B),j.lineTo(x.left+g,B),j.stroke()}j.setLineDash([]),j.font="9px 'JetBrains Mono Variable', monospace",j.textAlign="left",j.fillStyle=ia(me.text3,.5),j.fillText(`${ct(C)}/m`,x.left+4,x.top+10),j.fillText(`${ct(Math.round(C/2))}/m`,x.left+4,x.top+b/2+4),j.beginPath(),j.moveTo(x.left,x.top+b);for(let z=0;z<S.length;z++)j.lineTo(T(z),G(N[z]));j.lineTo(T(S.length-1),x.top+b),j.closePath();const re=j.createLinearGradient(0,x.top,0,x.top+b);re.addColorStop(0,ia(me.accent,.2)),re.addColorStop(.7,ia(me.accent,.04)),re.addColorStop(1,ia(me.accent,0)),j.fillStyle=re,j.fill(),j.beginPath(),j.strokeStyle=me.accent,j.lineWidth=1.5,j.lineJoin="round";for(let z=0;z<S.length;z++){const B=T(z),J=G(N[z]);z===0?j.moveTo(B,J):j.lineTo(B,J)}j.stroke();const ge=Z.some(z=>z>0);if(ge){j.beginPath(),j.strokeStyle=ia(me.info,.45),j.lineWidth=1,j.lineJoin="round",j.setLineDash([2,3]);for(let z=0;z<S.length;z++){const B=T(z),J=E(Z[z]);z===0?j.moveTo(B,J):j.lineTo(B,J)}j.stroke(),j.setLineDash([])}j.font="9px 'Inter Variable', sans-serif",j.textAlign="right";let de=m-x.right-4;const K=14;if(ge&&(j.fillStyle=ia(me.info,.5),j.fillText("Cache %",de,K),de-=j.measureText("Cache %").width+4,j.beginPath(),j.arc(de,K-3,2.5,0,Math.PI*2),j.fill(),de-=14),j.fillStyle=ia(me.surface5,.7),j.fillText("Agents",de,K),de-=j.measureText("Agents").width+4,j.beginPath(),j.arc(de,K-3,2.5,0,Math.PI*2),j.fill(),de-=14,j.fillStyle=me.accent,j.fillText("Burn Rate",de,K),de-=j.measureText("Burn Rate").width+4,j.beginPath(),j.arc(de,K-3,2.5,0,Math.PI*2),j.fill(),d&&d.index>=0&&d.index<S.length){const z=d.x,B=S[d.index];j.beginPath(),j.moveTo(z,x.top),j.lineTo(z,x.top+b),j.strokeStyle=ia(me.text1,.15),j.lineWidth=1,j.stroke();const J=G(B.burnRate);j.beginPath(),j.arc(z,J,3,0,Math.PI*2),j.fillStyle=me.accent,j.fill();const fe=[{label:"Burn",value:`${ct(B.burnRate)}/m`,color:me.accent},{label:"Cache",value:Nl(B.cacheHitRate*100),color:me.info},{label:"Agents",value:`${B.running}/${B.agents}`,color:me.text2}],te=104,Ae=fe.length*16+12;let Se=z+12;Se+te>m-8&&(Se=z-te-12);const ve=Math.max(x.top,J-Ae/2);j.fillStyle=ia(me.surface0,.92),j.beginPath(),j.roundRect(Se,ve,te,Ae,4),j.fill(),j.strokeStyle=ia(me.text4,.2),j.lineWidth=1,j.stroke(),j.textAlign="left",fe.forEach((Xe,D)=>{const ie=ve+14+D*16;j.beginPath(),j.arc(Se+8,ie-3,2,0,Math.PI*2),j.fillStyle=Xe.color,j.fill(),j.font="8px 'Inter Variable', sans-serif",j.fillStyle=me.text3,j.fillText(Xe.label,Se+14,ie),j.font="9px 'JetBrains Mono Variable', monospace",j.fillStyle=me.text0,j.textAlign="right",j.fillText(Xe.value,Se+te-8,ie),j.textAlign="left"})}},[S,m,p,d,g,b,x]),i.jsx("div",{ref:s,className:"absolute inset-0",children:m>0&&p>0&&i.jsx("canvas",{ref:l,style:{width:m,height:p},className:"block cursor-crosshair",onMouseMove:Q,onMouseLeave:k})})}),fC=v.memo(function({cacheRead:n=0,cacheCreation:s=0,totalInput:l=0,size:o=140}){const u=v.useRef(null),d=n+s+l,f=d>0?n/d*100:0;return v.useEffect(()=>{const m=u.current;if(!m)return;const p=window.devicePixelRatio||1;m.width=o*p,m.height=o*p;const x=m.getContext("2d");x.scale(p,p),x.clearRect(0,0,o,o);const g=o/2,b=o/2,S=(o-12)/2,Q=5,k=135*Math.PI/180,$=405*Math.PI/180,j=$-k;if(x.beginPath(),x.arc(g,b,S,k,$),x.strokeStyle=me.surface4,x.lineWidth=Q,x.lineCap="round",x.stroke(),d>0){const P=n/d,N=s/d;if(P>0){const Z=k+j*P;x.beginPath(),x.arc(g,b,S,k,Z),x.strokeStyle=me.accent,x.lineWidth=Q,x.lineCap="round",x.stroke()}if(N>0){const Z=k+j*P,U=Z+j*N;x.beginPath(),x.arc(g,b,S,Z,U),x.strokeStyle=me.purple,x.lineWidth=Q,x.lineCap="butt",x.stroke()}}x.textAlign="center",x.textBaseline="middle",x.font=`600 ${o*.2}px 'JetBrains Mono Variable', monospace`,x.fillStyle=me.text0,x.fillText(`${Math.round(f)}%`,g,b-3),x.font=`500 ${o*.08}px 'JetBrains Mono Variable', monospace`,x.fillStyle=me.text3,x.fillText("CACHE",g,b+o*.13)},[n,s,l,o,d,f]),i.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-3 py-3",children:[i.jsx("canvas",{ref:u,className:"flex-shrink-0",style:{width:o,height:o}}),i.jsxs("div",{className:"w-full mt-3 space-y-1.5 max-w-[160px]",children:[i.jsx(MO,{color:me.accent,label:"Read",value:ct(n)}),i.jsx(MO,{color:me.purple,label:"Create",value:ct(s)}),i.jsx(MO,{color:me.surface5,label:"Miss",value:ct(Math.max(l-n-s,0))})]})]})});function MO({color:t,label:n,value:s}){return i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:t}}),i.jsx("span",{className:"text-text-3 uppercase tracking-wider flex-1",children:n}),i.jsx("span",{className:"text-text-1 tabular-nums",children:s})]})}const YO={heavy:me.danger,medium:me.warning,light:me.success},hC={heavy:"Heavy",medium:"Medium",light:"Light"},mC=v.memo(function({routing:n,size:s=120}){const l=v.useRef(null);if(!n)return null;const{byTier:o={},costByTier:u={},totalDecisions:d=0,autoRoutedCount:f=0}=n,m=["heavy","medium","light"],p=m.reduce((x,g)=>x+(o[g]||0),0);return v.useEffect(()=>{const x=l.current;if(!x)return;const g=window.devicePixelRatio||1;x.width=s*g,x.height=s*g;const b=x.getContext("2d");b.scale(g,g),b.clearRect(0,0,s,s);const S=s/2,Q=s/2,k=(s-12)/2,$=5;if(p===0)b.beginPath(),b.arc(S,Q,k,0,Math.PI*2),b.strokeStyle=me.surface4,b.lineWidth=$,b.stroke();else{let j=-Math.PI/2;for(const P of m){const N=o[P]||0;if(N===0)continue;const Z=N/p*Math.PI*2;b.beginPath(),b.arc(S,Q,k,j,j+Z),b.strokeStyle=YO[P],b.lineWidth=$,b.lineCap="butt",b.stroke(),j+=Z}}b.textAlign="center",b.textBaseline="middle",b.font=`600 ${s*.19}px 'JetBrains Mono Variable', monospace`,b.fillStyle=me.text0,b.fillText(ct(d),S,Q-3),b.font=`500 ${s*.09}px 'JetBrains Mono Variable', monospace`,b.fillStyle=me.text3,b.fillText("ROUTES",S,Q+s*.13)},[n,s,p,d]),i.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-3 py-3",children:[i.jsx("canvas",{ref:l,className:"flex-shrink-0",style:{width:s,height:s}}),i.jsx("div",{className:"w-full mt-3 space-y-2 max-w-[180px]",children:m.map(x=>{const g=o[x]||0,b=u[x]||0,S=p>0?g/p*100:0;return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:YO[x]}}),i.jsx("span",{className:"text-text-3 uppercase tracking-wider flex-1",children:hC[x]}),i.jsx("span",{className:"text-text-1 tabular-nums",children:g}),i.jsx("span",{className:"text-text-4",children:"/"}),i.jsx("span",{className:"text-text-2 tabular-nums",children:Ac(b)})]}),i.jsx("div",{className:"h-[2px] bg-surface-0 rounded-full overflow-hidden ml-3.5",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Math.min(S,100)}%`,background:YO[x]}})})]},x)})}),f>0&&i.jsxs("div",{className:"mt-2.5 text-2xs font-mono text-text-3 uppercase tracking-wider",children:[f," auto-routed"]})]})});function pC(t){const n=t+"CollectionProvider",[s,l]=Ps(n),[o,u]=s(n,{collectionRef:{current:null},itemMap:new Map}),d=k=>{const{scope:$,children:j}=k,P=Vn.useRef(null),N=Vn.useRef(new Map).current;return i.jsx(o,{scope:$,itemMap:N,collectionRef:P,children:j})};d.displayName=n;const f=t+"CollectionSlot",m=ec(f),p=Vn.forwardRef((k,$)=>{const{scope:j,children:P}=k,N=u(f,j),Z=rt($,N.collectionRef);return i.jsx(m,{ref:Z,children:P})});p.displayName=f;const x=t+"CollectionItemSlot",g="data-radix-collection-item",b=ec(x),S=Vn.forwardRef((k,$)=>{const{scope:j,children:P,...N}=k,Z=Vn.useRef(null),U=rt($,Z),C=u(x,j);return Vn.useEffect(()=>(C.itemMap.set(Z,{ref:Z,...N}),()=>void C.itemMap.delete(Z))),i.jsx(b,{[g]:"",ref:U,children:P})});S.displayName=x;function Q(k){const $=u(t+"CollectionConsumer",k);return Vn.useCallback(()=>{const P=$.collectionRef.current;if(!P)return[];const N=Array.from(P.querySelectorAll(`[${g}]`));return Array.from($.itemMap.values()).sort((C,X)=>N.indexOf(C.ref.current)-N.indexOf(X.ref.current))},[$.collectionRef,$.itemMap])}return[{Provider:d,Slot:p,ItemSlot:S},Q,l]}var VO="rovingFocusGroup.onEntryFocus",xC={bubbles:!1,cancelable:!0},di="RovingFocusGroup",[Sf,Ry,gC]=pC(di),[bC,Cy]=Ps(di,[gC]),[vC,yC]=bC(di),Xy=v.forwardRef((t,n)=>i.jsx(Sf.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(Sf.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(SC,{...t,ref:n})})}));Xy.displayName=di;var SC=v.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:l,loop:o=!1,dir:u,currentTabStopId:d,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:m,onEntryFocus:p,preventScrollOnEntryFocus:x=!1,...g}=t,b=v.useRef(null),S=rt(n,b),Q=Kf(u),[k,$]=Pc({prop:d,defaultProp:f??null,onChange:m,caller:di}),[j,P]=v.useState(!1),N=zt(p),Z=Ry(s),U=v.useRef(!1),[C,X]=v.useState(0);return v.useEffect(()=>{const T=b.current;if(T)return T.addEventListener(VO,N),()=>T.removeEventListener(VO,N)},[N]),i.jsx(vC,{scope:s,orientation:l,dir:Q,loop:o,currentTabStopId:k,onItemFocus:v.useCallback(T=>$(T),[$]),onItemShiftTab:v.useCallback(()=>P(!0),[]),onFocusableItemAdd:v.useCallback(()=>X(T=>T+1),[]),onFocusableItemRemove:v.useCallback(()=>X(T=>T-1),[]),children:i.jsx(Be.div,{tabIndex:j||C===0?-1:0,"data-orientation":l,...g,ref:S,style:{outline:"none",...t.style},onMouseDown:Ee(t.onMouseDown,()=>{U.current=!0}),onFocus:Ee(t.onFocus,T=>{const G=!U.current;if(T.target===T.currentTarget&&G&&!j){const E=new CustomEvent(VO,xC);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const se=Z().filter(z=>z.focusable),re=se.find(z=>z.active),ge=se.find(z=>z.id===k),K=[re,ge,...se].filter(Boolean).map(z=>z.ref.current);Ay(K,x)}}U.current=!1}),onBlur:Ee(t.onBlur,()=>P(!1))})})}),_y="RovingFocusGroupItem",Zy=v.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:l=!0,active:o=!1,tabStopId:u,children:d,...f}=t,m=Sl(),p=u||m,x=yC(_y,s),g=x.currentTabStopId===p,b=Ry(s),{onFocusableItemAdd:S,onFocusableItemRemove:Q,currentTabStopId:k}=x;return v.useEffect(()=>{if(l)return S(),()=>Q()},[l,S,Q]),i.jsx(Sf.ItemSlot,{scope:s,id:p,focusable:l,active:o,children:i.jsx(Be.span,{tabIndex:g?0:-1,"data-orientation":x.orientation,...f,ref:n,onMouseDown:Ee(t.onMouseDown,$=>{l?x.onItemFocus(p):$.preventDefault()}),onFocus:Ee(t.onFocus,()=>x.onItemFocus(p)),onKeyDown:Ee(t.onKeyDown,$=>{if($.key==="Tab"&&$.shiftKey){x.onItemShiftTab();return}if($.target!==$.currentTarget)return;const j=wC($,x.orientation,x.dir);if(j!==void 0){if($.metaKey||$.ctrlKey||$.altKey||$.shiftKey)return;$.preventDefault();let N=b().filter(Z=>Z.focusable).map(Z=>Z.ref.current);if(j==="last")N.reverse();else if(j==="prev"||j==="next"){j==="prev"&&N.reverse();const Z=N.indexOf($.currentTarget);N=x.loop?kC(N,Z+1):N.slice(Z+1)}setTimeout(()=>Ay(N))}}),children:typeof d=="function"?d({isCurrentTabStop:g,hasTabStop:k!=null}):d})})});Zy.displayName=_y;var QC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jC(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function wC(t,n,s){const l=jC(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(l))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(l)))return QC[l]}function Ay(t,n=!1){const s=document.activeElement;for(const l of t)if(l===s||(l.focus({preventScroll:n}),document.activeElement!==s))return}function kC(t,n){return t.map((s,l)=>t[(n+l)%t.length])}var $C=Xy,TC=Zy,Uc="Tabs",[PC]=Ps(Uc,[Cy]),Ey=Cy(),[NC,ph]=PC(Uc),qy=v.forwardRef((t,n)=>{const{__scopeTabs:s,value:l,onValueChange:o,defaultValue:u,orientation:d="horizontal",dir:f,activationMode:m="automatic",...p}=t,x=Kf(f),[g,b]=Pc({prop:l,onChange:o,defaultProp:u??"",caller:Uc});return i.jsx(NC,{scope:s,baseId:Sl(),value:g,onValueChange:b,orientation:d,dir:x,activationMode:m,children:i.jsx(Be.div,{dir:x,"data-orientation":d,...p,ref:n})})});qy.displayName=Uc;var My="TabsList",Yy=v.forwardRef((t,n)=>{const{__scopeTabs:s,loop:l=!0,...o}=t,u=ph(My,s),d=Ey(s);return i.jsx($C,{asChild:!0,...d,orientation:u.orientation,dir:u.dir,loop:l,children:i.jsx(Be.div,{role:"tablist","aria-orientation":u.orientation,...o,ref:n})})});Yy.displayName=My;var Vy="TabsTrigger",Uy=v.forwardRef((t,n)=>{const{__scopeTabs:s,value:l,disabled:o=!1,...u}=t,d=ph(Vy,s),f=Ey(s),m=Dy(d.baseId,l),p=Wy(d.baseId,l),x=l===d.value;return i.jsx(TC,{asChild:!0,...f,focusable:!o,active:x,children:i.jsx(Be.button,{type:"button",role:"tab","aria-selected":x,"aria-controls":p,"data-state":x?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:m,...u,ref:n,onMouseDown:Ee(t.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?d.onValueChange(l):g.preventDefault()}),onKeyDown:Ee(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&d.onValueChange(l)}),onFocus:Ee(t.onFocus,()=>{const g=d.activationMode!=="manual";!x&&!o&&g&&d.onValueChange(l)})})})});Uy.displayName=Vy;var Gy="TabsContent",Ly=v.forwardRef((t,n)=>{const{__scopeTabs:s,value:l,forceMount:o,children:u,...d}=t,f=ph(Gy,s),m=Dy(f.baseId,l),p=Wy(f.baseId,l),x=l===f.value,g=v.useRef(x);return v.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),i.jsx(ba,{present:o||x,children:({present:b})=>i.jsx(Be.div,{"data-state":x?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":m,hidden:!b,id:p,tabIndex:0,...d,ref:n,style:{...t.style,animationDuration:g.current?"0s":void 0},children:b&&u})})});Ly.displayName=Gy;function Dy(t,n){return`${t}-trigger-${n}`}function Wy(t,n){return`${t}-content-${n}`}var zC=qy,RC=Yy,CC=Uy,XC=Ly;function By({children:t,...n}){return i.jsx(zC,{...n,children:t})}function Hy({children:t,className:n,...s}){return i.jsx(RC,{className:le("flex items-center gap-0 border-b border-border-subtle",n),...s,children:t})}function Ur({children:t,className:n,...s}){return i.jsx(CC,{className:le("px-3 py-2 text-sm font-medium font-sans text-text-2","border-b-2 border-transparent","hover:text-text-0 hover:bg-surface-5/50","data-[state=active]:text-text-0 data-[state=active]:border-accent","transition-colors duration-100 cursor-pointer select-none","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent",n),...s,children:t})}function Gr({children:t,className:n,...s}){return i.jsx(XC,{className:le("flex-1 min-h-0",n),...s,children:t})}function J1({data:t,color:n=me.accent,width:s=60,height:l=16}){if(!t||t.length<2)return i.jsx("div",{style:{width:s,height:l}});const o=Array.isArray(t[0])?t:t.map(p=>typeof p=="number"?p:p.v),u=Math.min(...o),f=Math.max(...o)-u||1,m=o.map((p,x)=>{const g=x/(o.length-1)*s,b=l-(p-u)/f*(l-2)-1;return`${g},${b}`}).join(" ");return i.jsx("svg",{width:s,height:l,className:"flex-shrink-0",children:i.jsx("polyline",{points:m,fill:"none",stroke:n,strokeWidth:"1",strokeLinejoin:"round",strokeOpacity:"0.7"})})}function UO({label:t,value:n,total:s,color:l}){const o=s>0?n/s*100:0;return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs font-mono",children:[i.jsx("span",{className:"text-text-2",children:t}),i.jsx("span",{className:"text-text-1 tabular-nums",children:ct(n)})]}),i.jsx("div",{className:"h-[2px] bg-surface-0 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Math.min(o,100)}%`,background:l}})})]})}function _C({tokens:t,rotation:n}){var d;const s=(t==null?void 0:t.savings)||{},l=s.total||0,u=((t==null?void 0:t.totalTokens)||0)+l;return i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-3 space-y-4",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Rotations"}),i.jsx("div",{className:"text-xl font-mono font-semibold text-text-0 tabular-nums leading-none",children:(n==null?void 0:n.totalRotations)||0})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Saved"}),i.jsx("div",{className:"text-xl font-mono font-semibold text-success tabular-nums leading-none",children:ct(l)}),u>0&&i.jsxs("div",{className:"text-2xs font-mono text-text-3 mt-0.5",children:[Nl(l/u*100)," of total"]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(UO,{label:"Rotation",value:s.fromRotation||0,total:u,color:me.accent}),i.jsx(UO,{label:"Conflict prevention",value:s.fromConflictPrevention||0,total:u,color:me.purple}),i.jsx(UO,{label:"Cold-start skip",value:s.fromColdStartSkip||0,total:u,color:me.info})]}),((d=n==null?void 0:n.history)==null?void 0:d.length)>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1.5",children:"Recent"}),i.jsx("div",{className:"space-y-1",children:n.history.slice(-8).reverse().map((f,m)=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono px-2 py-1 bg-surface-0 rounded",children:[i.jsx("span",{className:"text-text-1 font-medium capitalize truncate flex-1",children:f.agentName||f.role}),i.jsx("span",{className:"text-text-3 tabular-nums",children:Nl((f.contextUsage||0)*100)}),i.jsx("span",{className:"text-text-4",children:Ct(f.timestamp)})]},m))})]})]})})}function ZC({adaptive:t}){return t!=null&&t.length?i.jsx(Ht,{className:"flex-1",children:i.jsx("div",{className:"p-3 space-y-3",children:t.map(n=>{var s,l;return i.jsxs("div",{className:"bg-surface-0 rounded px-2.5 py-2 space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs font-mono text-text-1 flex-1 truncate",children:n.key}),i.jsx("span",{className:"text-xs font-mono font-semibold text-text-0 tabular-nums",children:Nl(n.threshold*100)}),i.jsx("span",{className:le("text-2xs font-mono font-bold uppercase px-1 py-px rounded-sm",n.converged?"text-success bg-success/10":"text-text-3 bg-surface-3"),children:n.converged?"CONV":`${n.adjustments} adj`})]}),((s=n.thresholdHistory)==null?void 0:s.length)>1&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider",children:"Drift"}),i.jsx(J1,{data:n.thresholdHistory.map(o=>o.v),color:n.converged?me.success:me.accent,width:80,height:14})]}),((l=n.recentScores)==null?void 0:l.length)>1&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider",children:"Quality"}),i.jsx(J1,{data:n.recentScores,color:me.warning,width:80,height:14})]})]},n.key)})})}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-text-3 font-mono p-4",children:"No adaptive profiles"})}function AC({journalist:t}){var n;return t?i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-3 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Cycles"}),i.jsx("div",{className:"text-lg font-mono font-semibold text-text-0 tabular-nums leading-none",children:t.cycleCount||0})]}),t.lastCycleAt&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-0.5",children:"Last"}),i.jsx("div",{className:"text-xs font-mono text-text-2",children:Ct(t.lastCycleAt)})]}),t.synthesizing&&i.jsx("span",{className:"text-2xs font-mono font-bold text-accent uppercase tracking-wider animate-pulse",children:"Synthesizing"})]}),t.lastSummary&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1",children:"Summary"}),i.jsx("div",{className:"text-xs font-sans text-text-2 leading-relaxed",children:t.lastSummary})]}),t.projectMap&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1",children:"Project Map"}),i.jsx("div",{className:"text-xs font-mono text-text-2 leading-relaxed whitespace-pre-wrap",children:t.projectMap})]}),t.decisions&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1",children:"Decisions"}),i.jsx("div",{className:"text-xs font-mono text-text-2 leading-relaxed whitespace-pre-wrap",children:t.decisions})]}),((n=t.recentHistory)==null?void 0:n.length)>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-2xs font-mono text-text-3 uppercase tracking-wider mb-1.5",children:"History"}),i.jsx("div",{className:"space-y-1",children:t.recentHistory.slice().reverse().map((s,l)=>i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono px-2 py-1 bg-surface-0 rounded",children:[i.jsxs("span",{className:"text-text-3",children:["#",s.cycle]}),i.jsxs("span",{className:"text-text-2 flex-1 truncate",children:[s.agentCount," agents"]}),i.jsx("span",{className:"text-text-4",children:Ct(s.timestamp)})]},l))})]})]})}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-text-3 font-mono p-4",children:"Journalist inactive"})}const EC=v.memo(function({tokens:n,rotation:s,adaptive:l,journalist:o}){return i.jsxs(By,{defaultValue:"rotation",className:"flex flex-col h-full",children:[i.jsxs(Hy,{className:"flex-shrink-0 px-1",children:[i.jsxs(Ur,{value:"rotation",className:"text-xs px-2.5 py-1.5 gap-1",children:[i.jsx(El,{size:11}),"Rotation"]}),i.jsxs(Ur,{value:"adaptive",className:"text-xs px-2.5 py-1.5 gap-1",children:[i.jsx(v5,{size:11}),"Adaptive"]}),i.jsxs(Ur,{value:"journalist",className:"text-xs px-2.5 py-1.5 gap-1",children:[i.jsx(Bf,{size:11}),"Journalist"]})]}),i.jsx(Gr,{value:"rotation",className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(_C,{tokens:n,rotation:s})}),i.jsx(Gr,{value:"adaptive",className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(ZC,{adaptive:l})}),i.jsx(Gr,{value:"journalist",className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(AC,{journalist:o})})]})}),e0={spawn:mP,rotation:El,completion:Br,error:_c,default:Na},t0={spawn:"text-accent",rotation:"text-purple",completion:"text-success",error:"text-danger",default:"text-text-3"},qC=v.memo(function({events:n=[]}){return n.length?i.jsx("div",{className:"flex items-center gap-3 overflow-x-auto py-2 px-3",children:n.slice(-15).reverse().map((s,l)=>{const o=e0[s.type]||e0.default,u=t0[s.type]||t0.default;return i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(o,{size:11,className:u}),i.jsx("span",{className:"text-xs font-sans text-text-2 whitespace-nowrap",children:s.text}),i.jsx("span",{className:"text-2xs font-mono text-text-4",children:Ct(s.timestamp||s.t)})]},l)})}):i.jsx("div",{className:"text-xs text-text-3 font-mono py-2.5 text-center",children:"No recent activity"})});function Nt({className:t,...n}){return i.jsx("div",{className:le("rounded-md bg-surface-4","bg-gradient-to-r from-surface-4 via-surface-5 to-surface-4","bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",t),...n})}function MC(){return i.jsxs("div",{className:"flex-1 grid gap-px p-0",style:{gridTemplateRows:"auto minmax(0, 1fr) minmax(0, 1fr)",gridTemplateColumns:"3fr 1.5fr 1.5fr",background:"#282c34"},children:[i.jsx("div",{className:"col-span-3",children:i.jsx(Nt,{className:"h-[72px] rounded-none"})}),i.jsx(Nt,{className:"rounded-none"}),i.jsx(Nt,{className:"rounded-none"}),i.jsx(Nt,{className:"rounded-none"}),i.jsx(Nt,{className:"rounded-none"}),i.jsx("div",{className:"col-span-2",children:i.jsx(Nt,{className:"h-full rounded-none"})})]})}function YC(){const{data:t,loading:n,agents:s,connected:l,kpiHistory:o,lastFetch:u,agentBreakdown:d,routing:f,rotation:m,adaptive:p,journalist:x,rotating:g}=sC(),b=s.filter(C=>C.status==="running").length;if(!l)return i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i.jsxs("div",{className:"text-center space-y-2 text-text-3 font-mono",children:[i.jsx(Rc,{size:28,className:"mx-auto"}),i.jsx("p",{className:"text-xs",children:"Connecting to daemon..."})]})});if(n||!t)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx(K1,{connected:l,runningCount:0,totalCount:0,uptime:0,lastFetch:0}),i.jsx(MC,{})]});const S=t.tokens||{},Q={totalTokens:S.totalTokens||0,totalCostUsd:S.totalCostUsd||0,totalInputTokens:S.totalInputTokens||0,totalOutputTokens:S.totalOutputTokens||0,cacheReadTokens:S.cacheReadTokens||0,cacheCreationTokens:S.cacheCreationTokens||0,cacheHitRate:S.cacheHitRate||0,totalTurns:S.totalTurns||0,agentCount:S.agentCount||0,savings:S.savings||{}},k=Q.totalTokens+(Q.savings.total||0),$=k>0?(Q.savings.total||0)/k*100:0,j=Q.totalOutputTokens>0?(Q.totalInputTokens/Q.totalOutputTokens).toFixed(1):"—",P=t.timeline||{},N=P.snapshots||[],Z=P.events||t.events||[],U=[{label:"Tokens Used",value:ct(Q.totalTokens),sparkData:o.tokens,color:me.accent},{label:"Total Cost",value:Ac(Q.totalCostUsd),sparkData:o.cost,color:me.warning},{label:"Tokens Saved",value:ct(Q.savings.total||0),sparkData:o.saved,color:me.success},{label:"Efficiency",value:Nl($),sparkData:o.efficiency,color:me.purple},{label:"Cache Rate",value:Nl(Q.cacheHitRate*100),sparkData:o.cache,color:me.info},{label:"I/O Ratio",value:`${j}:1`,sparkData:o.inputOutput,color:me.orange},{label:"Agents",value:`${b}/${s.length}`,sparkData:o.agents,color:me.accent},{label:"Turns",value:ct(Q.totalTurns),sparkData:o.turns,color:me.text2}];return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx(K1,{connected:l,runningCount:b,totalCount:s.length,uptime:t.uptime||0,lastFetch:u,activeTeam:t.activeTeam}),i.jsx(iC,{kpis:U}),i.jsxs("div",{className:"flex-1 min-h-0 grid",style:{gridTemplateRows:"minmax(0, 1fr) minmax(0, 1fr)",gridTemplateColumns:"3fr 1.5fr 1.5fr",background:"#282c34",gap:"1px"},children:[i.jsx("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 relative",children:i.jsx(OC,{data:N})}),i.jsxs("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-l border-border",children:[i.jsx("div",{className:"px-3 pt-2.5 pb-1",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:"Cache Performance"})}),i.jsx(fC,{cacheRead:Q.cacheReadTokens,cacheCreation:Q.cacheCreationTokens,totalInput:Q.totalInputTokens})]}),i.jsxs("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-l border-border",children:[i.jsx("div",{className:"px-3 pt-2.5 pb-1",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:"Model Routing"})}),i.jsx(mC,{routing:f})]}),i.jsxs("div",{className:"min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-t border-border",children:[i.jsx("div",{className:"px-3 pt-2.5 pb-1 flex-shrink-0",children:i.jsx("span",{className:"text-2xs font-mono text-text-3 uppercase tracking-widest",children:"Agent Fleet"})}),i.jsx(dC,{agentBreakdown:d,rotating:g})]}),i.jsx("div",{className:"col-span-2 min-w-0 min-h-0 overflow-hidden bg-surface-1 flex flex-col border-t border-l border-border",children:i.jsx(EC,{tokens:Q,rotation:m,adaptive:p,journalist:x})})]}),i.jsx("div",{className:"flex-shrink-0 bg-surface-1 border-t border-border",children:i.jsx(qC,{events:Z})})]})}const a0={sm:12,md:16,lg:20};function VC({fill:t="full",size:n,color:s="#fbbf24",emptyColor:l="rgba(255,255,255,0.4)"}){const o=`star-${Math.random().toString(36).slice(2,8)}`;return i.jsxs("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",children:[t==="half"&&i.jsx("defs",{children:i.jsxs("linearGradient",{id:o,children:[i.jsx("stop",{offset:"50%",stopColor:s}),i.jsx("stop",{offset:"50%",stopColor:l})]})}),i.jsx("path",{d:"M10 1.5l2.47 5.01 5.53.8-4 3.9.94 5.49L10 14.27 5.06 16.7 6 11.21l-4-3.9 5.53-.8L10 1.5z",fill:t==="full"?s:t==="half"?`url(#${o})`:l})]})}function Iy({rating:t=0,count:n,size:s="sm"}){const l=a0[s]||a0.sm,o=[];for(let u=1;u<=5;u++)t>=u?o.push("full"):t>=u-.5?o.push("half"):o.push("empty");return i.jsxs("span",{className:"inline-flex items-center",style:{gap:1},children:[o.map((u,d)=>i.jsx(VC,{fill:u,size:l},d)),n!=null&&i.jsxs("span",{className:"ml-1 text-[11px] text-[var(--text-dim,#6b7f95)] font-sans",children:["(",n,")"]})]})}const n0={design:{color:"#c678dd",bg:"rgba(198,120,221,0.12)"},quality:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"},devtools:{color:"#33afbc",bg:"rgba(51,175,188,0.14)"},workflow:{color:"#fbbf24",bg:"rgba(251,191,36,0.12)"},security:{color:"#f87171",bg:"rgba(248,113,113,0.12)"},specialized:{color:"#f59e0b",bg:"rgba(245,158,11,0.12)"},verified:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"},anthropic:{color:"#f59e0b",bg:"rgba(245,158,11,0.12)"},published:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"},draft:{color:"#6b7f95",bg:"rgba(255,255,255,0.06)"},review:{color:"#c678dd",bg:"rgba(198,120,221,0.12)"},rejected:{color:"#f87171",bg:"rgba(248,113,113,0.12)"},free:{color:"#4ade80",bg:"rgba(74,222,128,0.12)"}};function Fy({label:t,variant:n,className:s}){const l=n0[n]||n0.draft;return i.jsx("span",{className:le("inline-flex items-center whitespace-nowrap font-sans select-none",s),style:{padding:"3px 8px",borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.4,color:l.color,background:l.bg},children:t})}function Ky({price:t=0,size:n="sm"}){const s=!t||t===0,l={sm:"text-2xs px-2 py-0.5",md:"text-xs px-2.5 py-0.5",lg:"text-xs px-3 py-1"};return i.jsx("span",{className:`inline-flex items-center font-mono font-semibold rounded whitespace-nowrap ${l[n]||l.sm} ${s?"bg-success/12 text-success":"bg-white/8 text-text-1"}`,children:s?"Free":`$${t.toFixed(2)}`})}function Jy({type:t="verified",size:n=12}){const s=t==="claude-official"||t==="anthropic"?"#f59e0b":"#4ade80";return i.jsxs("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",className:"inline-block flex-shrink-0",children:[i.jsx("path",{d:"M10 0l2.36 3.15L16.18 2l.68 3.93L20.8 7.1l-1.87 3.52L20.8 14.14l-3.94 1.17-.68 3.93-3.82-1.15L10 21.24l-2.36-3.15-3.82 1.15-.68-3.93-3.94-1.17 1.87-3.52L-.8 7.1l3.94-1.17.68-3.93 3.82 1.15L10 0z",fill:s}),i.jsx("path",{d:"M7 10.5l2 2 4-4.5",fill:"none",stroke:"#24282f",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}const eS="groove_favorites";function xh(){try{return JSON.parse(localStorage.getItem(eS)||"[]")}catch{return[]}}function UC(t){return xh().includes(t)}function GC(t){const n=xh(),s=n.indexOf(t);return s>=0?n.splice(s,1):n.push(t),localStorage.setItem(eS,JSON.stringify(n)),s<0}function LC(t){const n=new Set(xh());return t.map(s=>({...s,favorited:n.has(s.id)}))}function DC({filled:t,size:n=16}){return i.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:t?"#f87171":"none",stroke:t?"#f87171":"rgba(255,255,255,0.3)",strokeWidth:"2",children:i.jsx("path",{d:"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"})})}function WC(){return i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function BC({skill:t,onClick:n}){var u,d;const[s,l]=v.useState(()=>UC(t.id));function o(f){f.stopPropagation(),l(GC(t.id))}return i.jsxs("div",{onClick:()=>n==null?void 0:n(t),className:le("flex flex-col cursor-pointer group","bg-surface-1 border border-border-subtle rounded-md","hover:border-accent/30 hover:bg-surface-2","transition-all duration-150"),style:{padding:20,minHeight:280},children:[i.jsxs("div",{className:"flex justify-between items-start",children:[i.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 bg-accent/12 text-[20px]",children:t.icon||((d=(u=t.name)==null?void 0:u[0])==null?void 0:d.toUpperCase())||"?"}),i.jsx("button",{onClick:o,className:"opacity-40 group-hover:opacity-80 hover:!opacity-100 transition-opacity cursor-pointer bg-transparent border-0 p-0",children:i.jsx(DC,{filled:s})})]}),i.jsx("div",{className:"mt-3 text-[15px] font-semibold text-text-0 font-sans line-clamp-2 leading-snug",children:t.name}),i.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-text-3 font-sans",children:[i.jsxs("span",{children:["by ",t.author||"Community"]}),(t.source==="claude-official"||t.verified)&&i.jsx(Jy,{type:t.source,size:12})]}),i.jsx("div",{className:"mt-2.5 text-xs text-text-2 font-sans line-clamp-3 flex-1 leading-relaxed",children:t.description}),i.jsx("div",{className:"mt-3",children:i.jsx(Fy,{label:t.category||"general",variant:t.category||"draft"})}),i.jsx("div",{className:"h-px bg-border-subtle my-3"}),i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(Iy,{rating:t.rating||0,count:t.rating_count||t.ratingCount||0,size:"sm"}),i.jsxs("span",{className:"flex items-center gap-1 text-xs text-text-3 font-mono",children:[i.jsx(WC,{}),ct(t.downloads||0)]}),i.jsx(Ky,{price:t.price||0,size:"sm"})]})]})}function tS(){return i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md animate-pulse",style:{padding:20,minHeight:280},children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-surface-4"}),i.jsx("div",{className:"mt-3 h-4 w-[70%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-2 h-3 w-[40%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-3.5 h-3 w-full rounded bg-surface-4"}),i.jsx("div",{className:"mt-1.5 h-3 w-[90%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-1.5 h-3 w-[60%] rounded bg-surface-4"}),i.jsx("div",{className:"mt-3.5 h-5 w-[50px] rounded bg-surface-4"}),i.jsx("div",{className:"h-px bg-surface-4 my-3"}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("div",{className:"h-3 w-16 rounded bg-surface-4"}),i.jsx("div",{className:"h-3 w-12 rounded bg-surface-4"}),i.jsx("div",{className:"h-3 w-10 rounded bg-surface-4"})]})]})}const HC={slack:"https://cdn.simpleicons.org/slack/E01E5A",github:"https://cdn.simpleicons.org/github/white",stripe:"https://cdn.simpleicons.org/stripe/635BFF",gmail:"https://cdn.simpleicons.org/gmail/EA4335","google-calendar":"https://cdn.simpleicons.org/googlecalendar/4285F4","google-drive":"https://cdn.simpleicons.org/googledrive/4285F4","google-maps":"https://cdn.simpleicons.org/googlemaps/4285F4",postgres:"https://cdn.simpleicons.org/postgresql/4169E1",notion:"https://cdn.simpleicons.org/notion/white",discord:"https://cdn.simpleicons.org/discord/5865F2",linear:"https://cdn.simpleicons.org/linear/5E6AD2","brave-search":"https://cdn.simpleicons.org/brave/FB542B","home-assistant":"https://cdn.simpleicons.org/homeassistant/18BCF2"};function IC({item:t,size:n=40}){const s=HC[t.id];if(s)return i.jsxs("div",{className:"rounded-md bg-surface-4 flex items-center justify-center flex-shrink-0 overflow-hidden",style:{width:n,height:n},children:[i.jsx("img",{src:s,alt:t.name,className:"w-5 h-5",onError:u=>{u.target.style.display="none",u.target.nextSibling.style.display="flex"}}),i.jsx("div",{className:"hidden items-center justify-center w-full h-full text-lg font-bold font-sans text-text-1",children:(t.name||"?")[0]})]});const l=(t.name||"?")[0].toUpperCase(),o=t.name?t.name.charCodeAt(0)*37%360:200;return i.jsx("div",{className:"rounded-md flex items-center justify-center flex-shrink-0 text-lg font-bold font-sans",style:{width:n,height:n,background:`hsl(${o}, 40%, 18%)`,color:`hsl(${o}, 60%, 65%)`},children:l})}function FC({item:t,onClick:n,className:s}){var o;const l=t.installed;return i.jsxs("button",{onClick:()=>n(t),className:le("flex flex-col p-5 rounded-md border border-border-subtle bg-surface-1 text-left","hover:border-accent/30 hover:bg-surface-2","transition-all duration-150 cursor-pointer group",s),style:{minHeight:200},children:[i.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[i.jsx(IC,{item:t,size:36}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-[14px] font-semibold text-text-0 font-sans truncate",children:t.name}),(t.verified||t.verified==="mcp-official")&&i.jsx(Br,{size:11,className:"text-accent flex-shrink-0"})]}),i.jsx("span",{className:"text-2xs text-text-3 font-sans",children:t.author||"Community"})]})]}),i.jsx("p",{className:"text-xs text-text-2 font-sans line-clamp-3 mb-3 flex-1 leading-relaxed",children:t.description}),i.jsx("div",{className:"h-px bg-border-subtle my-2"}),i.jsxs("div",{className:"flex items-center gap-3 text-2xs text-text-3 font-sans",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Uf,{size:10}),ct(t.downloads||0)]}),(t.rating||0)>0&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Gb,{size:10,className:"text-warning",fill:"currentColor"}),(o=t.rating)==null?void 0:o.toFixed(1)]}),i.jsx("span",{className:"flex-1"}),l&&i.jsx(We,{variant:"accent",className:"text-2xs",children:"Installed"})]})]})}function aS({value:t,onChange:n,placeholder:s="Search skills, tags, authors...",large:l}){const[o,u]=v.useState(t||""),d=v.useRef(null);v.useEffect(()=>{u(t||"")},[t]);function f(m){const p=m.target.value;u(p),clearTimeout(d.current),d.current=setTimeout(()=>n(p),300)}return i.jsxs("div",{className:"relative w-full",children:[i.jsx(ql,{size:16,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-text-4 pointer-events-none"}),i.jsx("input",{value:o,onChange:f,placeholder:s,className:le("w-full font-sans outline-none","bg-surface-0 border border-border text-text-0 placeholder:text-text-4","focus:border-accent/40 transition-colors",l?"py-3 pl-11 pr-12 text-[15px] rounded-lg":"py-2.5 pl-10 pr-3 text-sm rounded-md")}),l&&i.jsx("kbd",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 bg-surface-4 text-text-4 px-2 py-0.5 rounded text-xs font-mono",children:"/"})]})}const KC=[{id:"",label:"All"},{id:"design",label:"Design"},{id:"quality",label:"Quality"},{id:"devtools",label:"Dev Tools"},{id:"workflow",label:"Workflow"},{id:"security",label:"Security"},{id:"specialized",label:"Specialized"}];function JC({selected:t="",categories:n=KC,onSelect:s}){return i.jsx("div",{className:"flex gap-2 overflow-x-auto",style:{scrollbarWidth:"none"},children:n.map(l=>{const o=t===l.id;return i.jsx("button",{onClick:()=>s(l.id),className:le("whitespace-nowrap font-sans cursor-pointer select-none transition-all text-[13px] rounded-full border",o?"bg-accent text-surface-0 border-accent font-semibold":"bg-surface-1 text-text-3 border-border-subtle hover:text-text-1 hover:border-border font-medium"),style:{padding:"7px 16px"},children:l.label},l.id)})})}function Gc(){const t=W(n=>n.addToast);return{success:(n,s)=>t("success",n,s),error:(n,s)=>t("error",n,s),info:(n,s)=>t("info",n,s),warning:(n,s)=>t("warning",n,s)}}function eX({skill:t,onBack:n}){var k,$,j;const s=Gc(),[l,o]=v.useState(""),[u,d]=v.useState(!1),[f,m]=v.useState(!1),[p,x]=v.useState(t.installed),[g,b]=v.useState(!0);v.useEffect(()=>{b(!0),ee.get(`/skills/${t.id}/content`).then(P=>{o(P.content||""),d(P.requiresPurchase||!1)}).catch(()=>{}).finally(()=>b(!1))},[t.id]);async function S(){m(!0);try{await ee.post(`/skills/${t.id}/install`),x(!0),s.success(`${t.name} installed`)}catch(P){s.error("Install failed",P.message)}m(!1)}async function Q(){const{marketplaceAuthenticated:P,marketplaceLogin:N,marketplaceCheckout:Z}=W.getState();if(!P){N();return}try{await Z(t.id)}catch{}}return i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-6 py-5",children:[i.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-xs text-text-3 font-sans hover:text-text-0 cursor-pointer bg-transparent border-0 mb-4",children:[i.jsx(kb,{size:14})," Back"]}),i.jsxs("div",{className:"flex gap-8",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-11 h-11 rounded-lg flex items-center justify-center flex-shrink-0 bg-accent/10 border border-accent/20 text-[22px]",children:t.icon||(($=(k=t.name)==null?void 0:k[0])==null?void 0:$.toUpperCase())}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h1",{className:"text-lg font-bold text-text-0 font-sans",children:t.name}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-text-3 font-sans",children:[i.jsx("span",{children:t.author||"Community"}),(t.source==="claude-official"||t.verified)&&i.jsx(Jy,{type:t.source,size:13})]})]})]}),i.jsx("p",{className:"mt-3 text-sm text-text-2 font-sans leading-relaxed",children:t.description}),((j=t.tags)==null?void 0:j.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:t.tags.map(P=>i.jsx("span",{className:"text-2xs text-text-3 font-sans px-2 py-0.5 rounded bg-surface-4",children:P},P))}),i.jsx("div",{className:"h-px bg-border-subtle my-5"}),g?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"h-3 w-48 bg-surface-4 rounded animate-pulse"}),i.jsx("div",{className:"h-3 w-full bg-surface-4 rounded animate-pulse"}),i.jsx("div",{className:"h-3 w-3/4 bg-surface-4 rounded animate-pulse"})]}):l?i.jsxs("div",{className:"text-sm text-text-2 font-sans leading-relaxed",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 mb-2",children:"About"}),i.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:l})]}):u?i.jsxs("div",{className:"bg-warning/5 border border-warning/15 rounded-lg px-4 py-3",children:[i.jsx("p",{className:"text-sm text-text-1 font-sans font-medium",children:"Paid skill — purchase to view content"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Sign in and purchase this skill to access its full instructions."})]}):i.jsx("p",{className:"text-xs text-text-4 font-sans",children:"Content loading failed — check your connection."})]}),i.jsx("div",{className:"w-[240px] flex-shrink-0",children:i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-lg p-4 sticky top-4",children:[i.jsx(Ky,{price:t.price||0,size:"md"}),u&&!p?i.jsxs("button",{onClick:Q,className:"w-full mt-3 py-2 px-3 text-xs font-sans font-semibold rounded cursor-pointer transition-all hover:opacity-85 flex items-center justify-center gap-2 border bg-warning/15 text-warning border-warning/20 hover:bg-warning/25",children:["Buy $",(t.price||0).toFixed(2)]}):i.jsx("button",{onClick:S,disabled:f||p,className:`w-full mt-3 py-2 px-3 text-xs font-sans font-semibold rounded cursor-pointer transition-all hover:opacity-85 disabled:opacity-60 disabled:cursor-not-allowed flex items-center justify-center gap-2 border ${p?"bg-success/15 text-success border-success/20":"bg-accent/15 text-accent border-accent/20 hover:bg-accent/25"}`,children:f?"Installing...":p?"✓ Installed":"Install"}),i.jsx("div",{className:"mt-4 flex flex-col gap-2.5",children:[["Downloads",i.jsx("span",{className:"font-mono text-text-0",children:ct(t.downloads||0)},"d")],["Rating",i.jsx(Iy,{rating:t.rating||0,count:t.rating_count||t.ratingCount,size:"sm"},"r")],["Version",i.jsx("span",{className:"font-mono text-text-0",children:t.version||"1.0.0"},"v")],["Category",i.jsx(Fy,{label:t.category||"general",variant:t.category||"draft"},"c")],["Source",i.jsx("span",{className:"text-text-0",children:t.source==="claude-official"?"Anthropic":"Community"},"s")]].map(([P,N])=>i.jsxs("div",{className:"flex justify-between items-center text-xs font-sans",children:[i.jsx("span",{className:"text-text-3",children:P}),N]},P))})]})})]})]})})}function tX(){const[t,n]=v.useState([]),[s,l]=v.useState(!0),[o,u]=v.useState(""),[d,f]=v.useState(""),[m,p]=v.useState("popular"),[x,g]=v.useState(null);return v.useEffect(()=>{l(!0);const b=new URLSearchParams;o&&b.set("search",o),d&&b.set("category",d),m&&b.set("sort",m),ee.get(`/skills/registry?${b}`).then(S=>n(LC(S.skills||S.items||(Array.isArray(S)?S:[])))).catch(()=>n([])).finally(()=>l(!1))},[o,d,m]),x?i.jsx(eX,{skill:x,onBack:()=>g(null)}):i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-5 py-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-72",children:i.jsx(aS,{value:o,onChange:u})}),i.jsx(JC,{selected:d,onSelect:f}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsxs("select",{value:m,onChange:b=>p(b.target.value),className:"appearance-none font-sans cursor-pointer pr-7 py-2 pl-3 text-xs bg-surface-0 border border-border-subtle rounded text-text-1 focus:outline-none",children:[i.jsx("option",{value:"popular",children:"Popular"}),i.jsx("option",{value:"rating",children:"Top Rated"}),i.jsx("option",{value:"newest",children:"Newest"}),i.jsx("option",{value:"name",children:"A-Z"})]}),i.jsx(In,{size:12,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-4 pointer-events-none"})]}),i.jsx("span",{className:"text-2xs text-text-4 font-mono flex-shrink-0",children:t.length})]}),i.jsx("div",{className:"mt-4 grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:s?Array.from({length:8}).map((b,S)=>i.jsx(tS,{},S)):t.map(b=>i.jsx(BC,{skill:b,onClick:g},b.id))}),!s&&t.length===0&&i.jsx("div",{className:"text-center py-16 text-text-4 font-sans text-sm",children:"No skills found."})]})})}function aX(){const[t,n]=v.useState([]),[s,l]=v.useState(!0),[o,u]=v.useState(""),d=Gc();return v.useEffect(()=>{l(!0),ee.get(`/integrations/registry?search=${encodeURIComponent(o)}`).then(f=>n(f.integrations||f.items||(Array.isArray(f)?f:[]))).catch(()=>n([])).finally(()=>l(!1))},[o]),i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-5 py-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-72",children:i.jsx(aS,{value:o,onChange:u,placeholder:"Search integrations..."})}),i.jsx("div",{className:"flex-1"}),i.jsx("span",{className:"text-2xs text-text-4 font-mono flex-shrink-0",children:t.length})]}),i.jsx("div",{className:"mt-4 grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:s?Array.from({length:6}).map((f,m)=>i.jsx(tS,{},m)):t.map(f=>i.jsx(FC,{item:f,onClick:()=>d.info(`${f.name} — install via CLI: groove integrations install ${f.id}`)},f.id))}),!s&&t.length===0&&i.jsx("div",{className:"text-center py-16 text-text-4 font-sans text-sm",children:"No integrations found."})]})})}function nX(){const t=W(g=>g.marketplaceAuthenticated),n=W(g=>g.marketplaceLogin),[s,l]=v.useState([]),[o,u]=v.useState([]),[d,f]=v.useState(!0),m=Gc(),p=v.useRef(null);v.useEffect(()=>{f(!0),Promise.all([t?ee.get("/auth/purchases").then(g=>g.purchases||[]).catch(()=>[]):Promise.resolve([]),ee.get("/skills/installed").then(g=>Array.isArray(g)?g:g.skills||[]).catch(()=>[])]).then(([g,b])=>{l(g),u(b)}).finally(()=>f(!1))},[t]);async function x(g){var S;const b=(S=g.target.files)==null?void 0:S[0];if(b){try{const Q=await b.text(),k=b.name.replace(/\.md$/i,"");await ee.post("/skills/import",{name:k,content:Q}),m.success(`Imported "${k}"`);const $=await ee.get("/skills/installed");u(Array.isArray($)?$:$.skills||[])}catch(Q){m.error("Import failed",Q.message)}g.target.value=""}}return d?i.jsx("div",{className:"p-5 space-y-3",children:[...Array(4)].map((g,b)=>i.jsx(Nt,{className:"h-14 rounded-md"},b))}):i.jsx(Ht,{className:"h-full",children:i.jsxs("div",{className:"px-5 py-4 space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("input",{ref:p,type:"file",accept:".md",onChange:x,className:"hidden"}),i.jsxs(je,{variant:"secondary",size:"md",onClick:()=>{var g;return(g=p.current)==null?void 0:g.click()},className:"gap-1.5",children:[i.jsx(dP,{size:13}),"Import .md Skill"]}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Drop a markdown skill file to install locally"})]}),t&&s.length>0&&i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider mb-3 flex items-center gap-1.5",children:[i.jsx(gO,{size:12}),"Purchases (",s.length,")"]}),i.jsx("div",{className:"space-y-1.5",children:s.map(g=>{var b,S;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-1 border border-border-subtle",children:[i.jsx("div",{className:"w-8 h-8 rounded-md bg-accent/10 flex items-center justify-center text-sm flex-shrink-0",children:g.skill_icon||((S=(b=g.skill_name)==null?void 0:b[0])==null?void 0:S.toUpperCase())||"?"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate",children:g.skill_name||g.skill_id}),i.jsxs("div",{className:"text-2xs text-text-4 font-sans",children:["$",(g.amount||0).toFixed(2)," · ",Ct(g.created_at)]})]}),i.jsx(We,{variant:"success",className:"text-2xs flex-shrink-0",children:"Owned"})]},g.id||g.skill_id)})})]}),t&&s.length===0&&i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md px-4 py-6 text-center",children:[i.jsx(gO,{size:20,className:"mx-auto text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No purchases yet"})]}),!t&&i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md px-4 py-6 text-center",children:[i.jsx(gO,{size:20,className:"mx-auto text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-2 font-sans mb-3",children:"Sign in to see your purchases"}),i.jsxs(je,{variant:"primary",size:"sm",onClick:n,className:"gap-1.5 mx-auto",children:[i.jsx(Df,{size:12})," Sign in"]})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider mb-3 flex items-center gap-1.5",children:[i.jsx(_b,{size:12}),"Installed (",o.length,")"]}),o.length===0?i.jsxs("div",{className:"bg-surface-1 border border-border-subtle rounded-md px-4 py-6 text-center",children:[i.jsx(Uf,{size:20,className:"mx-auto text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No skills installed — browse the Skills tab or import a .md file"})]}):i.jsx("div",{className:"space-y-1.5",children:o.map(g=>{var b,S;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-1 border border-border-subtle group",children:[i.jsx("div",{className:"w-8 h-8 rounded-md bg-accent/10 flex items-center justify-center text-sm flex-shrink-0",children:g.icon||((S=(b=g.name)==null?void 0:b[0])==null?void 0:S.toUpperCase())||"?"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate",children:g.name||g.id}),i.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:g.description||g.category||"local skill"})]}),i.jsx(We,{variant:"accent",className:"text-2xs flex-shrink-0",children:"Installed"})]},g.id)})})]})]})})}function sX(){const t=W(o=>o.marketplaceAuthenticated),n=W(o=>o.marketplaceUser),s=W(o=>o.marketplaceLogin),l=W(o=>o.marketplaceLogout);return t?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded bg-surface-3 border border-border-subtle",children:[i.jsx("div",{className:"w-4 h-4 rounded-full bg-accent/20 flex items-center justify-center",children:i.jsx(Lb,{size:9,className:"text-accent"})}),i.jsx("span",{className:"text-xs text-text-0 font-sans font-medium max-w-[120px] truncate",children:(n==null?void 0:n.displayName)||(n==null?void 0:n.id)||"Account"})]}),i.jsx("button",{onClick:l,className:"flex items-center gap-1 px-2 py-1.5 rounded text-xs text-text-3 hover:text-text-0 hover:bg-surface-3 font-sans cursor-pointer transition-colors",children:i.jsx(Rb,{size:11})})]}):i.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold font-sans text-text-0 bg-accent/15 border border-accent/25 rounded hover:bg-accent/25 cursor-pointer transition-colors",children:[i.jsx(Df,{size:12}),"Sign in"]})}function lX(){const[t,n]=v.useState("skills"),s=[{id:"skills",label:"Skills",icon:Ub},{id:"integrations",label:"Integrations",icon:Zb},{id:"library",label:"My Library",icon:_b}];return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"flex-shrink-0 bg-surface-1 border-b border-border-subtle",children:i.jsxs("div",{className:"flex items-center px-5 h-11",children:[i.jsx("div",{className:"flex items-center",children:s.map(l=>{const o=l.icon;return i.jsxs("button",{onClick:()=>n(l.id),className:`flex items-center gap-1.5 px-3 py-2.5 text-xs font-semibold font-sans cursor-pointer select-none border-b-2 -mb-px transition-colors ${t===l.id?"border-accent text-text-0":"border-transparent text-text-3 hover:text-text-1"}`,children:[i.jsx(o,{size:12}),l.label]},l.id)})}),i.jsx("div",{className:"flex-1"}),i.jsx(sX,{})]})}),i.jsxs("div",{className:"flex-1 min-h-0",children:[t==="skills"&&i.jsx(tX,{}),t==="integrations"&&i.jsx(aX,{}),t==="library"&&i.jsx(nX,{})]})]})}function rX({children:t,className:n,hover:s,...l}){return i.jsx("div",{className:le("rounded-md border border-border bg-surface-1",s&&"hover:border-accent/50 hover:bg-surface-2 transition-all duration-150 cursor-pointer",n),...l,children:t})}function iX(){const t=W(l=>l.pendingApprovals),n=W(l=>l.approveRequest),s=W(l=>l.rejectRequest);return t.length===0?null:i.jsxs("div",{className:"px-4 pt-4 space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(_c,{size:13,className:"text-warning"}),i.jsxs("span",{className:"text-xs font-semibold text-warning font-sans",children:["Pending Approval (",t.length,")"]})]}),t.map(l=>{var o,u,d;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-md bg-warning/5 border border-warning/20",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"text-xs text-text-0 font-sans font-medium truncate",children:[l.agentName,": ",((o=l.action)==null?void 0:o.description)||((u=l.action)==null?void 0:u.type)||"action"]}),((d=l.action)==null?void 0:d.filePath)&&i.jsx("div",{className:"text-2xs text-text-3 font-mono truncate mt-0.5",children:l.action.filePath}),i.jsx("div",{className:"text-2xs text-text-4 font-sans mt-0.5",children:Ct(l.requestedAt)})]}),i.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[i.jsxs(je,{variant:"primary",size:"sm",onClick:()=>n(l.id),className:"h-7 px-2.5 gap-1 text-2xs",children:[i.jsx(Yb,{size:11})," Approve"]}),i.jsxs(je,{variant:"danger",size:"sm",onClick:()=>s(l.id),className:"h-7 px-2.5 gap-1 text-2xs",children:[i.jsx(eP,{size:11})," Reject"]})]})]},l.id)})]})}function oX(){const t=W(m=>m.resolvedApprovals),[n,s]=v.useState([]),[l,o]=v.useState(!0);v.useEffect(()=>{const m=setInterval(u,4e3);return u(),()=>clearInterval(m)},[]);async function u(){try{const m=await ee.get("/pm/history");s(m.history||m||[])}catch{}o(!1)}const d=new Set,f=[...t,...n].filter(m=>{const p=m.id||`${m.agentName}-${m.timestamp}`;return d.has(p)?!1:(d.add(p),!0)});return l&&f.length===0?i.jsx("div",{className:"p-4 space-y-2",children:[...Array(4)].map((m,p)=>i.jsx(Nt,{className:"h-12 rounded-md"},p))}):i.jsxs(Ht,{className:"flex-1",children:[i.jsx(iX,{}),i.jsxs("div",{className:"p-4 space-y-2",children:[f.length===0&&i.jsxs("div",{className:"text-center py-12 text-text-4 font-sans",children:[i.jsx(Br,{size:32,className:"mx-auto mb-2"}),i.jsx("p",{className:"text-sm",children:"No approval history"}),i.jsx("p",{className:"text-2xs text-text-4 mt-1",children:'Approvals appear when agents use "Agent Approve" permission mode'})]}),f.map((m,p)=>{var x;return i.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-md bg-surface-1 border border-border-subtle",children:[m.status==="approved"||m.verdict==="approved"?i.jsx(Br,{size:14,className:"text-success flex-shrink-0"}):i.jsx(X5,{size:14,className:"text-danger flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"text-xs text-text-0 font-sans truncate",children:[m.agentName,": ",((x=m.action)==null?void 0:x.description)||m.action||"action"]}),m.reason&&i.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:m.reason})]}),i.jsx("span",{className:"text-2xs text-text-4 font-sans flex-shrink-0",children:Ct(m.resolvedAt||m.timestamp)})]},m.id||p)})]})]})}function cX(){const[t,n]=v.useState([]),[s,l]=v.useState(!0),o=Gc();v.useEffect(()=>{const f=setInterval(u,1e4);return u(),()=>clearInterval(f)},[]);async function u(){try{const f=await ee.get("/schedules");n(f.schedules||f||[])}catch{}l(!1)}async function d(f,m){try{await ee.post(`/schedules/${f}/${m?"disable":"enable"}`),u()}catch(p){o.error("Failed to toggle schedule",p.message)}}return s?i.jsx("div",{className:"p-4 space-y-2",children:[...Array(3)].map((f,m)=>i.jsx(Nt,{className:"h-16 rounded-md"},m))}):i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-2",children:[t.length===0&&i.jsxs("div",{className:"text-center py-12 text-text-4 font-sans",children:[i.jsx(oc,{size:32,className:"mx-auto mb-2"}),i.jsx("p",{className:"text-sm",children:"No schedules configured"})]}),t.map(f=>i.jsx(rX,{className:"p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:f.name}),i.jsx(We,{variant:f.enabled?"success":"default",children:f.enabled?"Active":"Paused"})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-mono mt-0.5",children:[f.cron," · ",f.role]})]}),i.jsx(je,{variant:"ghost",size:"sm",onClick:()=>d(f.id,f.enabled),children:f.enabled?"Pause":"Enable"})]})},f.id))]})})}function uX(){return i.jsxs(By,{defaultValue:"approvals",className:"flex flex-col h-full",children:[i.jsxs("div",{className:"px-4 pt-3 bg-surface-1 border-b border-border",children:[i.jsx("div",{className:"flex items-center gap-4 mb-0",children:i.jsx("h2",{className:"text-base font-semibold text-text-0 font-sans",children:"Management"})}),i.jsxs(Hy,{className:"border-b-0",children:[i.jsx(Ur,{value:"approvals",children:"Approvals"}),i.jsx(Ur,{value:"schedules",children:"Schedules"})]})]}),i.jsx(Gr,{value:"approvals",className:"flex-1 min-h-0",children:i.jsx(oX,{})}),i.jsx(Gr,{value:"schedules",className:"flex-1 min-h-0",children:i.jsx(cX,{})})]})}const dX={code:"Code",general:"General"},OX={light:"text-success",medium:"text-accent",heavy:"text-warning"};function fX(t){return t<1?`${Math.round(t*1024)} MB`:`${t} GB`}function nS({hardware:t}){if(!t)return null;const{totalRamGb:n,gpu:s,isAppleSilicon:l}=t;return i.jsxs("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg border border-border-subtle px-3 py-2.5",children:[i.jsx(Wf,{size:14,className:"text-text-3 flex-shrink-0"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"flex items-center gap-2 text-xs font-sans",children:[i.jsxs("span",{className:"text-text-0 font-semibold",children:[n," GB RAM"]}),s&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-4",children:"·"}),i.jsx("span",{className:"text-text-2",children:s.name})]}),l&&i.jsx(We,{variant:"accent",className:"text-2xs",children:"Unified Memory"})]})})]})}function hX({onRecheck:t}){const[n,s]=v.useState(null),[l,o]=v.useState(!1),[u,d]=v.useState(!1),[f,m]=v.useState(!1),p=W(Z=>Z.addToast);v.useEffect(()=>{ee.post("/providers/ollama/check").then(s).catch(()=>{})},[]);async function x(){o(!0);try{const Z=await ee.post("/providers/ollama/check");s(Z),Z.installed&&Z.serverRunning?(p("success","Ollama is ready!"),t()):Z.installed?p("info","Ollama installed — server needs to start"):p("info","Ollama not found — install and try again")}catch{}o(!1)}async function g(){d(!0);try{if((await ee.post("/providers/ollama/serve")).ok){p("success","Ollama server started!");let U=!1;for(let C=0;C<5;C++){await new Promise(T=>setTimeout(T,2e3));const X=await ee.post("/providers/ollama/check");if(s(X),X.serverRunning){U=!0;break}}U&&t()}}catch(Z){p("error","Could not start server",Z.message)}d(!1)}function b(Z){navigator.clipboard.writeText(Z),m(!0),setTimeout(()=>m(!1),2e3)}if(!n)return i.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Loading..."});const{hardware:S,install:Q,requirements:k,installed:$,serverRunning:j}=n,P=S.totalRamGb>=k.minRAM,N=S.recommended;return i.jsxs("div",{className:"space-y-3 p-3",children:[i.jsx(nS,{hardware:S}),P?i.jsxs("div",{className:"flex items-start gap-2 bg-success/8 border border-success/20 rounded-lg px-3 py-2.5",children:[i.jsx(oa,{size:14,className:"text-success flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs font-sans",children:[i.jsx("span",{className:"text-success font-semibold",children:"Your system is ready."}),i.jsx("span",{className:"text-text-2 ml-1",children:N.code?`Recommended: ${N.code}`:`${S.totalRamGb} GB RAM available`})]})]}):i.jsxs("div",{className:"flex items-start gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[i.jsx(cn,{size:14,className:"text-warning flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs font-sans text-text-2",children:[i.jsxs("span",{className:"text-warning font-semibold",children:[S.totalRamGb," GB RAM detected."]})," ","Minimum ",k.minRAM," GB needed. Smallest models may still work."]})]}),$&&!j&&i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-start gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[i.jsx(cn,{size:14,className:"text-warning flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-xs font-sans text-text-2",children:[i.jsx("span",{className:"text-warning font-semibold",children:"Ollama installed but server not running."})," ","The server needs to be running to pull and use models."]})]}),i.jsxs(je,{variant:"primary",size:"md",onClick:g,disabled:u,className:"w-full gap-1.5",children:[i.jsx(Na,{size:12}),u?"Starting...":"Start Ollama Server"]})]}),!$&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:"text-xs font-semibold text-text-1 font-sans",children:"Install Ollama"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 bg-surface-0 border border-border-subtle rounded-md px-3 py-2 text-xs font-mono text-text-1 truncate",children:Q.command}),i.jsxs(je,{variant:"secondary",size:"sm",onClick:()=>b(Q.command),className:"h-8 px-2.5 gap-1 flex-shrink-0",children:[f?i.jsx(oa,{size:12}):i.jsx(uf,{size:12}),f?"Copied":"Copy"]})]}),Q.alt&&i.jsx("p",{className:"text-2xs text-text-4 font-sans",children:Q.alt})]}),i.jsxs(je,{variant:"secondary",size:"md",onClick:x,disabled:l,className:"w-full gap-1.5",children:[i.jsx(es,{size:12,className:l?"animate-spin":""}),l?"Checking...":$?"Check again":"I installed it — check again"]})]})}function mX({model:t,isInstalled:n,isRecommended:s,canRun:l,onPull:o,onDelete:u,pulling:d}){const f=d===t.id;return i.jsxs("div",{className:le("flex items-center gap-2 px-3 py-2 border-t border-border-subtle transition-colors",!l&&"opacity-40"),children:[n?i.jsx(oa,{size:12,className:"text-success flex-shrink-0"}):i.jsx("div",{className:"w-3"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-mono text-text-1 truncate",children:t.name}),s&&i.jsx(Gb,{size:10,className:"text-warning flex-shrink-0"})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("span",{className:le("text-2xs font-semibold font-sans",OX[t.tier]),children:t.tier}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:fX(t.sizeGb)}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:["· ",t.ramGb," GB RAM"]})]})]}),n?i.jsx("button",{onClick:()=>u(t.id),className:"p-1.5 text-text-4 hover:text-danger rounded transition-colors cursor-pointer",title:"Remove model",children:i.jsx(Xc,{size:12})}):l?i.jsx(je,{variant:"secondary",size:"sm",onClick:()=>o(t.id),disabled:!!d,className:"h-7 px-2 text-2xs gap-1",children:f?i.jsxs(i.Fragment,{children:[i.jsx(es,{size:10,className:"animate-spin"})," Pulling..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Uf,{size:10})," Pull"]})}):i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:["Needs ",t.ramGb," GB"]})]})}function pX({onStopped:t}){const[n,s]=v.useState(null),l=W(d=>d.addToast);async function o(){s("stopping");try{(await ee.post("/providers/ollama/stop")).ok?(l("info","Ollama server stopped"),t&&t()):l("error","Could not stop server")}catch(d){l("error","Stop failed",d.message)}s(null)}async function u(){s("restarting");try{(await ee.post("/providers/ollama/restart")).ok?l("success","Ollama server restarted"):l("error","Restart failed")}catch(d){l("error","Restart failed",d.message)}s(null)}return i.jsxs("div",{className:"flex items-center gap-2 bg-success/8 border border-success/20 rounded-lg px-3 py-2",children:[i.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[i.jsx("span",{className:"absolute inset-0 rounded-full bg-success"}),i.jsx("span",{className:"absolute inset-[-2px] rounded-full bg-success opacity-20 animate-pulse"})]}),i.jsx("span",{className:"text-xs font-sans text-success font-semibold",children:"Server Running"}),i.jsx("span",{className:"text-2xs font-mono text-text-4",children:":11434"}),i.jsx("div",{className:"flex-1"}),i.jsxs("button",{onClick:u,disabled:!!n,className:"flex items-center gap-1 text-2xs font-sans text-text-3 hover:text-accent cursor-pointer transition-colors disabled:opacity-40",children:[i.jsx(es,{size:10,className:n==="restarting"?"animate-spin":""}),n==="restarting"?"Restarting...":"Restart"]}),i.jsxs("button",{onClick:o,disabled:!!n,className:"flex items-center gap-1 text-2xs font-sans text-text-3 hover:text-danger cursor-pointer transition-colors disabled:opacity-40",children:[i.jsx(cn,{size:10}),n==="stopping"?"Stopping...":"Stop"]})]})}function xX({onModelChange:t}){var T,G;const[n,s]=v.useState(null),[l,o]=v.useState(null),[u,d]=v.useState("code"),[f,m]=v.useState(!1),[p,x]=v.useState(!1),g=W(E=>E.addToast),b=v.useRef(!1);function S(){ee.get("/providers/ollama/models").then(E=>{var se;s(E),!b.current&&((se=E.installed)==null?void 0:se.length)===0&&(b.current=!0,setTimeout(S,2e3))}).catch(()=>{})}v.useEffect(()=>{S()},[]);async function Q(E){o(E);try{await ee.post("/providers/ollama/pull",{model:E}),g("success",`Pulled ${E}`),S(),t&&t()}catch(se){g("error",`Pull failed: ${se.message}`)}o(null)}async function k(E){try{await ee.delete(`/providers/ollama/models/${encodeURIComponent(E)}`),g("info",`Removed ${E}`),S(),t&&t()}catch(se){g("error",`Delete failed: ${se.message}`)}}if(!n)return i.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Loading..."});const{installed:$,catalog:j,hardware:P}=n,N=new Set($.map(E=>E.id)),Z=P.totalRamGb,U=[(T=P.recommended)==null?void 0:T.code,(G=P.recommended)==null?void 0:G.general].filter(Boolean),C=j.filter(E=>E.category===u),X=f?C:C.filter(E=>E.ramGb<=Z);return p?i.jsxs("div",{className:"space-y-3 p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[i.jsx(cn,{size:14,className:"text-warning flex-shrink-0"}),i.jsxs("span",{className:"text-xs font-sans text-text-2",children:[i.jsx("span",{className:"text-warning font-semibold",children:"Ollama server stopped."})," ","Start it again to pull and use models."]})]}),i.jsxs(je,{variant:"primary",size:"md",onClick:async()=>{try{(await ee.post("/providers/ollama/serve")).ok&&(g("success","Ollama server started!"),x(!1),b.current=!1,setTimeout(S,2e3))}catch(E){g("error","Could not start server",E.message)}},className:"w-full gap-1.5",children:[i.jsx(Na,{size:12}),"Start Ollama Server"]})]}):i.jsxs("div",{className:"space-y-2 p-3",children:[i.jsx(pX,{onStopped:()=>x(!0)}),i.jsx(nS,{hardware:P}),$.length>0&&i.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-sans text-text-2",children:[i.jsx(Nb,{size:12,className:"text-text-3"}),i.jsx("span",{className:"font-semibold",children:$.length})," model",$.length!==1?"s":""," installed"]}),i.jsx("div",{className:"flex bg-surface-0 rounded-lg p-0.5 border border-border-subtle",children:Object.entries(dX).map(([E,se])=>i.jsx("button",{onClick:()=>d(E),className:le("flex-1 px-3 py-1.5 text-2xs font-semibold font-sans rounded-md transition-all cursor-pointer",u===E?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:se},E))}),i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-0 overflow-hidden",children:[X.map(E=>i.jsx(mX,{model:E,isInstalled:N.has(E.id),isRecommended:U.includes(E.id),canRun:E.ramGb<=Z,onPull:Q,onDelete:k,pulling:l},E.id)),X.length===0&&i.jsxs("div",{className:"px-3 py-4 text-center text-xs text-text-4 font-sans",children:["No ",u," models available for your hardware"]})]}),!f&&C.length>X.length&&i.jsxs("button",{onClick:()=>m(!0),className:"flex items-center gap-1 text-2xs text-text-3 hover:text-accent font-sans cursor-pointer transition-colors",children:[i.jsx(In,{size:10}),"Show ",C.length-X.length," more (exceed your RAM)"]})]})}function sS({isInstalled:t,onModelChange:n}){const[s,l]=v.useState(!1),[o,u]=v.useState(!1);return v.useEffect(()=>{t?ee.post("/providers/ollama/check").then(d=>{l(d.installed&&d.serverRunning),u(!0)}).catch(()=>u(!0)):u(!0)},[t]),o?s?i.jsx(xX,{onModelChange:n}):i.jsx(hX,{onRecheck:()=>{l(!0),n&&n()}}):i.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Checking Ollama..."})}var GO="focusScope.autoFocusOnMount",LO="focusScope.autoFocusOnUnmount",s0={bubbles:!1,cancelable:!0},gX="FocusScope",lS=v.forwardRef((t,n)=>{const{loop:s=!1,trapped:l=!1,onMountAutoFocus:o,onUnmountAutoFocus:u,...d}=t,[f,m]=v.useState(null),p=zt(o),x=zt(u),g=v.useRef(null),b=rt(n,k=>m(k)),S=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(l){let k=function(N){if(S.paused||!f)return;const Z=N.target;f.contains(Z)?g.current=Z:Un(g.current,{select:!0})},$=function(N){if(S.paused||!f)return;const Z=N.relatedTarget;Z!==null&&(f.contains(Z)||Un(g.current,{select:!0}))},j=function(N){if(document.activeElement===document.body)for(const U of N)U.removedNodes.length>0&&Un(f)};document.addEventListener("focusin",k),document.addEventListener("focusout",$);const P=new MutationObserver(j);return f&&P.observe(f,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",$),P.disconnect()}}},[l,f,S.paused]),v.useEffect(()=>{if(f){r0.add(S);const k=document.activeElement;if(!f.contains(k)){const j=new CustomEvent(GO,s0);f.addEventListener(GO,p),f.dispatchEvent(j),j.defaultPrevented||(bX(jX(rS(f)),{select:!0}),document.activeElement===k&&Un(f))}return()=>{f.removeEventListener(GO,p),setTimeout(()=>{const j=new CustomEvent(LO,s0);f.addEventListener(LO,x),f.dispatchEvent(j),j.defaultPrevented||Un(k??document.body,{select:!0}),f.removeEventListener(LO,x),r0.remove(S)},0)}}},[f,p,x,S]);const Q=v.useCallback(k=>{if(!s&&!l||S.paused)return;const $=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,j=document.activeElement;if($&&j){const P=k.currentTarget,[N,Z]=vX(P);N&&Z?!k.shiftKey&&j===Z?(k.preventDefault(),s&&Un(N,{select:!0})):k.shiftKey&&j===N&&(k.preventDefault(),s&&Un(Z,{select:!0})):j===P&&k.preventDefault()}},[s,l,S.paused]);return i.jsx(Be.div,{tabIndex:-1,...d,ref:b,onKeyDown:Q})});lS.displayName=gX;function bX(t,{select:n=!1}={}){const s=document.activeElement;for(const l of t)if(Un(l,{select:n}),document.activeElement!==s)return}function vX(t){const n=rS(t),s=l0(n,t),l=l0(n.reverse(),t);return[s,l]}function rS(t){const n=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:l=>{const o=l.tagName==="INPUT"&&l.type==="hidden";return l.disabled||l.hidden||o?NodeFilter.FILTER_SKIP:l.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n}function l0(t,n){for(const s of t)if(!yX(s,{upTo:n}))return s}function yX(t,{upTo:n}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(n!==void 0&&t===n)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function SX(t){return t instanceof HTMLInputElement&&"select"in t}function Un(t,{select:n=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&SX(t)&&n&&t.select()}}var r0=QX();function QX(){let t=[];return{add(n){const s=t[0];n!==s&&(s==null||s.pause()),t=i0(t,n),t.unshift(n)},remove(n){var s;t=i0(t,n),(s=t[0])==null||s.resume()}}}function i0(t,n){const s=[...t],l=s.indexOf(n);return l!==-1&&s.splice(l,1),s}function jX(t){return t.filter(n=>n.tagName!=="A")}var DO=0;function wX(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??o0()),document.body.insertAdjacentElement("beforeend",t[1]??o0()),DO++,()=>{DO===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),DO--}},[])}function o0(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var wa=function(){return wa=Object.assign||function(n){for(var s,l=1,o=arguments.length;l<o;l++){s=arguments[l];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(n[u]=s[u])}return n},wa.apply(this,arguments)};function iS(t,n){var s={};for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&n.indexOf(l)<0&&(s[l]=t[l]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,l=Object.getOwnPropertySymbols(t);o<l.length;o++)n.indexOf(l[o])<0&&Object.prototype.propertyIsEnumerable.call(t,l[o])&&(s[l[o]]=t[l[o]]);return s}function kX(t,n,s){if(s||arguments.length===2)for(var l=0,o=n.length,u;l<o;l++)(u||!(l in n))&&(u||(u=Array.prototype.slice.call(n,0,l)),u[l]=n[l]);return t.concat(u||Array.prototype.slice.call(n))}var Ko="right-scroll-bar-position",Jo="width-before-scroll-bar",$X="with-scroll-bars-hidden",TX="--removed-body-scroll-bar-size";function WO(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function PX(t,n){var s=v.useState(function(){return{value:t,callback:n,facade:{get current(){return s.value},set current(l){var o=s.value;o!==l&&(s.value=l,s.callback(l,o))}}}})[0];return s.callback=n,s.facade}var NX=typeof window<"u"?v.useLayoutEffect:v.useEffect,c0=new WeakMap;function zX(t,n){var s=PX(null,function(l){return t.forEach(function(o){return WO(o,l)})});return NX(function(){var l=c0.get(s);if(l){var o=new Set(l),u=new Set(t),d=s.current;o.forEach(function(f){u.has(f)||WO(f,null)}),u.forEach(function(f){o.has(f)||WO(f,d)})}c0.set(s,t)},[t]),s}function RX(t){return t}function CX(t,n){n===void 0&&(n=RX);var s=[],l=!1,o={read:function(){if(l)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(u){var d=n(u,l);return s.push(d),function(){s=s.filter(function(f){return f!==d})}},assignSyncMedium:function(u){for(l=!0;s.length;){var d=s;s=[],d.forEach(u)}s={push:function(f){return u(f)},filter:function(){return s}}},assignMedium:function(u){l=!0;var d=[];if(s.length){var f=s;s=[],f.forEach(u),d=s}var m=function(){var x=d;d=[],x.forEach(u)},p=function(){return Promise.resolve().then(m)};p(),s={push:function(x){d.push(x),p()},filter:function(x){return d=d.filter(x),s}}}};return o}function XX(t){t===void 0&&(t={});var n=CX(null);return n.options=wa({async:!0,ssr:!1},t),n}var oS=function(t){var n=t.sideCar,s=iS(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var l=n.read();if(!l)throw new Error("Sidecar medium not found");return v.createElement(l,wa({},s))};oS.isSideCarExport=!0;function _X(t,n){return t.useMedium(n),oS}var cS=XX(),BO=function(){},Lc=v.forwardRef(function(t,n){var s=v.useRef(null),l=v.useState({onScrollCapture:BO,onWheelCapture:BO,onTouchMoveCapture:BO}),o=l[0],u=l[1],d=t.forwardProps,f=t.children,m=t.className,p=t.removeScrollBar,x=t.enabled,g=t.shards,b=t.sideCar,S=t.noRelative,Q=t.noIsolation,k=t.inert,$=t.allowPinchZoom,j=t.as,P=j===void 0?"div":j,N=t.gapMode,Z=iS(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),U=b,C=zX([s,n]),X=wa(wa({},Z),o);return v.createElement(v.Fragment,null,x&&v.createElement(U,{sideCar:cS,removeScrollBar:p,shards:g,noRelative:S,noIsolation:Q,inert:k,setCallbacks:u,allowPinchZoom:!!$,lockRef:s,gapMode:N}),d?v.cloneElement(v.Children.only(f),wa(wa({},X),{ref:C})):v.createElement(P,wa({},X,{className:m,ref:C}),f))});Lc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Lc.classNames={fullWidth:Jo,zeroRight:Ko};var ZX=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function AX(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=ZX();return n&&t.setAttribute("nonce",n),t}function EX(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function qX(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var MX=function(){var t=0,n=null;return{add:function(s){t==0&&(n=AX())&&(EX(n,s),qX(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},YX=function(){var t=MX();return function(n,s){v.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&s])}},uS=function(){var t=YX(),n=function(s){var l=s.styles,o=s.dynamic;return t(l,o),null};return n},VX={left:0,top:0,right:0,gap:0},HO=function(t){return parseInt(t||"",10)||0},UX=function(t){var n=window.getComputedStyle(document.body),s=n[t==="padding"?"paddingLeft":"marginLeft"],l=n[t==="padding"?"paddingTop":"marginTop"],o=n[t==="padding"?"paddingRight":"marginRight"];return[HO(s),HO(l),HO(o)]},GX=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return VX;var n=UX(t),s=document.documentElement.clientWidth,l=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,l-s+n[2]-n[0])}},LX=uS(),wl="data-scroll-locked",DX=function(t,n,s,l){var o=t.left,u=t.top,d=t.right,f=t.gap;return s===void 0&&(s="margin"),`
539
539
  .`.concat($X,` {
540
540
  overflow: hidden `).concat(l,`;
541
541
  padding-right: `).concat(f,"px ").concat(l,`;
@@ -581,7 +581,7 @@ If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHid
581
581
 
582
582
  For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},v_="DialogDescriptionWarning",y_=({contentRef:t,descriptionId:n})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${NS(v_).contentName}}.`;return v.useEffect(()=>{var u;const o=(u=t.current)==null?void 0:u.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(l))},[l,t,n]),null},zS=xS,RS=vS,CS=yS,XS=SS,_S=jS,ZS=kS,AS=TS;function S_({children:t,...n}){return i.jsx(zS,{...n,children:t})}function Q_({children:t,className:n,title:s,description:l,...o}){return i.jsxs(RS,{children:[i.jsx(CS,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),i.jsxs(XS,{className:le("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",n),...o,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[i.jsx(_S,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(AS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:i.jsx(Rt,{size:16})})]}),l&&i.jsx(ZS,{className:"sr-only",children:l}),t]})]})}var h0={};function j_({path:t,onNavigate:n}){const s=t.split("/").filter(Boolean);return i.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[i.jsx("button",{onClick:()=>n("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:i.jsx(Nb,{size:13})}),s.map((l,o)=>{const u="/"+s.slice(0,o+1).join("/"),d=o===s.length-1;return i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx(ii,{size:11,className:"text-text-4"}),i.jsx("button",{onClick:()=>n(u),className:le("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",d?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:l})]},o)})]})}function ES({open:t,onOpenChange:n,currentPath:s,onSelect:l}){const[o,u]=v.useState(s||h0.HOME||"/"),[d,f]=v.useState([]),[m,p]=v.useState(!1),[x,g]=v.useState(null);v.useEffect(()=>{t&&b(s||"/")},[t]);async function b($){p(!0),g(null);try{const j=await ee.get(`/browse-system?path=${encodeURIComponent($)}`);u(j.current||$),f(j.dirs||[])}catch(j){g(j.message),f([])}p(!1)}function S(){const $=o==="/"?"/":o.split("/").slice(0,-1).join("/")||"/";b($)}function Q(){b(h0.HOME||"/Users")}function k(){l(o),n(!1)}return i.jsx(S_,{open:t,onOpenChange:n,children:i.jsx(Q_,{title:"Select Working Directory",description:"Choose a directory for this agent to work in",className:"max-w-[520px]",children:i.jsxs("div",{className:"px-5 py-4 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:S,disabled:o==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(p5,{size:14})}),i.jsx("button",{onClick:Q,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(pT,{size:14})}),i.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:i.jsx(j_,{path:o,onNavigate:b})})]}),i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:i.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[m&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Lf,{size:18,className:"text-text-3 animate-spin"})}),x&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-danger font-sans",children:x})}),!m&&!x&&d.length===0&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!m&&!x&&d.map($=>i.jsxs("button",{onClick:()=>b($.path),className:le("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[$.hasChildren?i.jsx(nT,{size:15,className:"text-warning flex-shrink-0"}):i.jsx(Hr,{size:15,className:"text-text-3 flex-shrink-0"}),i.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:$.name}),$.hasChildren&&i.jsx(ii,{size:12,className:"text-text-4 flex-shrink-0"})]},$.path))]})}),i.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[i.jsx(Hr,{size:16,className:"text-accent flex-shrink-0"}),i.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:o})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(je,{variant:"ghost",size:"md",onClick:()=>n(!1),children:"Cancel"}),i.jsxs(je,{variant:"primary",size:"md",onClick:k,className:"gap-1.5",children:[i.jsx(oa,{size:14})," Select Folder"]})]})]})})})}function qS({children:t,...n}){return i.jsx(zS,{...n,children:t})}function MS({children:t,className:n,title:s,side:l="right",width:o=400,...u}){return i.jsxs(RS,{children:[i.jsx(CS,{className:"fixed inset-0 z-40 bg-black/30"}),i.jsxs(XS,{className:le("fixed top-0 z-50 h-full overflow-y-auto","bg-surface-1 border-l border-border shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out",l==="right"&&"right-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",l==="left"&&"left-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",n),style:{width:o},...u,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle sticky top-0 bg-surface-1 z-10",children:[i.jsx(_S,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(AS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(Rt,{size:16})})]}),i.jsx(ZS,{className:"sr-only",children:"Panel"}),t]})]})}function w_({value:t,onChange:n}){return i.jsx("button",{onClick:()=>n(!t),className:le("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",t?"bg-accent":"bg-surface-5"),children:i.jsx("div",{className:le("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function k_({user:t}){const[n,s]=v.useState(!1),l=(t==null?void 0:t.avatar)||(t==null?void 0:t.picture)||(t==null?void 0:t.photoURL)||(t==null?void 0:t.photo);return l&&!n?i.jsx("img",{src:l,alt:"",className:"w-6 h-6 rounded-full",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:()=>s(!0)}):i.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center",children:i.jsx(Lb,{size:12,className:"text-accent"})})}function $_({provider:t,onKeyChange:n}){var $,j;const[s,l]=v.useState(!1),[o,u]=v.useState(""),[d,f]=v.useState(!1),[m,p]=v.useState(!1),x=W(P=>P.addToast),g=t.authType==="local",b=t.authType==="subscription",S=g||b?t.installed:t.hasKey;async function Q(){if(o.trim())try{await ee.post(`/credentials/${t.id}`,{key:o.trim()}),x("success",`API key set for ${t.name}`),u(""),l(!1),n&&n()}catch(P){x("error","Failed to set key",P.message)}}async function k(){try{await ee.delete(`/credentials/${t.id}`),x("info",`Removed ${t.name} key`),n&&n()}catch(P){x("error","Remove failed",P.message)}}return g?i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(Pl,{status:S?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),S?i.jsxs(We,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(oa,{size:8})," Ready"]}):i.jsx(We,{variant:"default",className:"text-2xs",children:"Not installed"})]}),i.jsx("div",{className:"flex-1",children:m?i.jsx(sS,{isInstalled:S,onModelChange:n}):i.jsxs("div",{className:"px-4 py-3 flex flex-col h-full",children:[i.jsx("div",{className:"text-xs text-text-3 font-sans flex-1",children:S?`${(($=t.models)==null?void 0:$.length)||0} models available`:"Local AI models — free, private, no API key"}),i.jsxs(je,{variant:S?"secondary":"primary",size:"sm",onClick:()=>p(!0),className:"w-full h-7 text-2xs gap-1.5 mt-3",children:[i.jsx(Vf,{size:11}),S?"Manage Models":"Set Up Ollama"]})]})})]}):i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(Pl,{status:S?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),S?i.jsxs(We,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(oa,{size:8})," Ready"]}):i.jsx(We,{variant:"default",className:"text-2xs",children:b?"Not installed":"No key"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[120px]",children:[((j=t.models)==null?void 0:j.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:t.models.map(P=>i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-surface-4 text-2xs font-mono text-text-3",children:P.name||P.id},P.id))}),b&&S&&!t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-accent/8 border border-accent/20 rounded-md text-2xs font-sans text-accent mb-3",children:[i.jsx(oa,{size:10})," Subscription active"]}),t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsxs("div",{className:"flex-1 flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success",children:[i.jsx(oa,{size:10})," API Connected"]}),i.jsx("button",{onClick:()=>{l(!0),f(!1),u("")},className:"text-2xs text-text-4 hover:text-accent cursor-pointer font-sans",children:"Edit"}),i.jsx("button",{onClick:k,className:"text-2xs text-text-4 hover:text-danger cursor-pointer font-sans",children:"Remove"})]}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:t.hasKey?"Update API Key":`${t.name} API Key`}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:P=>u(P.target.value),onKeyDown:P=>P.key==="Enter"&&Q(),type:d?"text":"password",placeholder:"sk-...",className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>f(!d),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:d?i.jsx(Gf,{size:12}):i.jsx(oi,{size:12})})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(je,{variant:"primary",size:"sm",onClick:Q,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Key"}),i.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&!t.hasKey&&i.jsxs(je,{variant:b?"secondary":"primary",size:"sm",onClick:()=>{l(!0),f(!1),u("")},className:"w-full h-8 text-2xs gap-1.5 mt-2",children:[i.jsx(uc,{size:11}),b?"Add API key for headless mode":"Add API Key"]})]})]})}function gl({icon:t,label:n,description:s,children:l}){return i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:i.jsx(t,{size:12,className:"text-accent"})}),i.jsx("div",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:n})]}),i.jsx("div",{className:"text-2xs text-text-4 font-sans leading-relaxed",children:s}),i.jsx("div",{className:"mt-auto pt-1",children:l})]})}const YS={telegram:Hf,discord:ci,slack:Cb},Ss={telegram:"Telegram",discord:"Discord",slack:"Slack"},T_={telegram:"Bot token from @BotFather",discord:"Bot token from Developer Portal",slack:"Bot token (xoxb-...)"},P_=["critical","lifecycle","all"];function N_({type:t,open:n,onOpenChange:s}){if(!t)return null;const o={telegram:{title:"Set Up Telegram",icon:Hf,intro:"Create a Telegram bot and connect it to Groove in under 2 minutes. No dependencies required.",sections:[{title:"Create Your Bot",steps:[{text:"Open Telegram on any device and search for",link:"https://t.me/BotFather",linkText:"@BotFather"},{text:"Send /newbot to start the setup"},{text:"Choose a display name — we suggest GroovePilot"},{text:'Choose a username (must end in "bot") — e.g. GroovePilot_bot'},{text:"BotFather will reply with your bot token — copy it"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Telegram card"},{text:"Paste your bot token and click Save"},{text:"The gateway will connect automatically"}]},{title:"Link a Chat",steps:[{text:"Open a chat with your new bot in Telegram"},{text:'Send any message (e.g. "hello") — Groove captures the chat ID automatically'},{text:"Click Test in the gateway card to verify"}]},{title:"Commands",note:"All commands use / prefix in Telegram:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},discord:{title:"Set Up Discord",icon:ci,intro:"Create a Discord bot and add it to your server. Requires discord.js (installed automatically with Groove).",sections:[{title:"Create the Application",steps:[{text:"Go to the",link:"https://discord.com/developers/applications",linkText:"Discord Developer Portal"},{text:"Click New Application and name it GroovePilot"},{text:"Go to the Bot tab in the left sidebar"},{text:"Click Reset Token and copy the bot token"}]},{title:"Set Permissions & Invite",steps:[{text:"Go to OAuth2 > URL Generator"},{text:"Under Scopes, check bot"},{text:"Under Bot Permissions, check:"}],scopes:["Send Messages","Read Message History","Embed Links","Use External Emojis"],after:[{text:"Copy the generated URL at the bottom and open it in your browser"},{text:"Select your server and click Authorize"}]},{title:"Enable Message Content Intent",steps:[{text:"Go back to the Bot tab in the Developer Portal"},{text:"Scroll to Privileged Gateway Intents"},{text:"Enable Message Content Intent — required for the bot to read commands"},{text:"Click Save Changes"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Discord card"},{text:"Paste your bot token and click Save"},{text:"Send a message in any channel where the bot is — Groove captures the channel automatically"}]},{title:"Commands",note:"All commands use / prefix in Discord:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},slack:{title:"Set Up Slack",icon:Cb,intro:"Create a Slack app with Socket Mode — no public URL needed. Requires @slack/bolt (installed automatically with Groove).",sections:[{title:"Create the App",steps:[{text:"Go to",link:"https://api.slack.com/apps",linkText:"api.slack.com/apps"},{text:"Click Create New App > From scratch"},{text:"Name it GroovePilot and select your workspace"}]},{title:"Enable Socket Mode",steps:[{text:"In the left sidebar, go to Settings > Socket Mode"},{text:"Toggle Enable Socket Mode to on"},{text:"It will ask you to create an App-Level Token"},{text:'Name it "groove", add the connections:write scope'},{text:"Click Generate — copy the xapp-... token (this is your App Token)"}],important:"Save this token now — you can't view it again after closing the dialog."},{title:"Set Bot Token Scopes",steps:[{text:"Go to Features > OAuth & Permissions"},{text:"Scroll to Bot Token Scopes and add all of these:"}],scopes:["chat:write","channels:read","channels:history","groups:read","groups:history","im:history","app_mentions:read"],after:[{text:"Scroll up and click Install to Workspace"},{text:"Click Allow to grant permissions"},{text:"Copy the Bot User OAuth Token (xoxb-...) — this is your Bot Token"}]},{title:"Enable Events",steps:[{text:"Go to Features > Event Subscriptions"},{text:"Toggle Enable Events to on"},{text:"Under Subscribe to bot events, add:"}],scopes:["message.channels","message.im","app_mention"],after:[{text:"Click Save Changes at the bottom"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Slack card"},{text:"Paste your Bot Token (xoxb-...) in the first field"},{text:"Paste your App Token (xapp-...) in the second field"},{text:"Click Save — Groove will auto-connect"}]},{title:"Link a Channel",steps:[{text:"Invite the bot to a channel: /invite @GroovePilot"},{text:"Select the channel from the dropdown in the gateway card"},{text:"Or @mention the bot — it will auto-capture the channel"},{text:"Click Test to verify"}],important:"For private channels, make sure you added the groups:read scope."},{title:"Commands",note:"In Slack, use plain text commands (no / prefix) or @mention the bot:",commands:["instruct <team> <msg>","query <team> <question>","plan <description>","log <team>","brief","tokens","status","agents","help","@GroovePilot status"]}]}}[t];if(!o)return null;const u=o.icon;return i.jsx(qS,{open:n,onOpenChange:s,children:i.jsx(MS,{title:o.title,width:480,children:i.jsxs("div",{className:"px-5 py-4 space-y-5",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-accent/5 border border-accent/15 rounded-lg",children:[i.jsx("div",{className:"w-8 h-8 rounded-lg bg-accent/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx(u,{size:16,className:"text-accent"})}),i.jsx("p",{className:"text-xs text-text-2 font-sans leading-relaxed",children:o.intro})]}),o.sections.map((d,f)=>{var m;return i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-0 font-sans mb-2.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-accent/10 flex items-center justify-center text-2xs font-bold text-accent",children:f+1}),d.title]}),d.note&&i.jsx("p",{className:"text-2xs text-text-3 font-sans mb-2",children:d.note}),d.steps&&i.jsx("ol",{className:"space-y-2 mb-2",children:d.steps.map((p,x)=>i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[x+1,"."]}),i.jsxs("span",{children:[p.text,p.link&&i.jsxs(i.Fragment,{children:[" ",i.jsxs("a",{href:p.link,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-0.5 font-medium",children:[p.linkText,i.jsx(cc,{size:9})]})]})]})]},x))}),d.scopes&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 ml-6",children:d.scopes.map(p=>i.jsx("code",{className:"px-2 py-0.5 rounded bg-surface-4 text-2xs font-mono text-accent",children:p},p))}),d.after&&i.jsx("ol",{className:"space-y-2 mb-2",start:(((m=d.steps)==null?void 0:m.length)||0)+1,children:d.after.map((p,x)=>{var g;return i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[(((g=d.steps)==null?void 0:g.length)||0)+x+1,"."]}),i.jsx("span",{children:p.text})]},x)})}),d.important&&i.jsx("div",{className:"ml-6 p-2 bg-warning/8 border border-warning/20 rounded-md text-2xs text-warning font-sans",children:d.important}),d.commands&&i.jsx("div",{className:"ml-6 p-2.5 bg-surface-0 border border-border-subtle rounded-md space-y-1",children:d.commands.map(p=>i.jsx("code",{className:"block text-2xs font-mono text-text-1",children:p},p))})]},f)}),i.jsxs("a",{href:"https://docs.groovedev.ai/guide/gateways",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium mt-2",children:[i.jsx(cc,{size:10}),"Full documentation at docs.groovedev.ai"]})]})})})}function z_({gateway:t,onRefresh:n}){var ge,de;const[s,l]=v.useState(!1),[o,u]=v.useState(""),[d,f]=v.useState(""),[m,p]=v.useState(!1),[x,g]=v.useState(!1),[b,S]=v.useState(!1),[Q,k]=v.useState([]),[$,j]=v.useState(!1),P=W(K=>K.addToast);v.useEffect(()=>{t.connected&&!t.chatId&&t.type==="slack"&&ee.get(`/gateways/${t.id}/channels`).then(K=>k(Array.isArray(K)?K:[])).catch(()=>{})},[t.connected,t.chatId,t.id,t.type]);const N=YS[t.type]||Bf,Z=t.type==="slack";async function U(){if(o.trim())try{await ee.post(`/gateways/${t.id}/credentials`,{key:"bot_token",value:o.trim()}),Z&&d.trim()&&await ee.post(`/gateways/${t.id}/credentials`,{key:"app_token",value:d.trim()}),P("success","Token saved — connecting..."),u(""),f(""),l(!1);try{await ee.post(`/gateways/${t.id}/connect`),P("success",`${Ss[t.type]} connected!`)}catch(K){P("error","Token saved but connect failed",K.message)}n()}catch(K){P("error","Failed to save token",K.message)}}async function C(){g(!0);try{await ee.post(`/gateways/${t.id}/test`),P("success","Test message sent!")}catch(K){P("error","Test failed",K.message)}g(!1)}async function X(){S(!0);try{t.connected?(await ee.post(`/gateways/${t.id}/disconnect`),P("info",`${Ss[t.type]} disconnected`)):(await ee.post(`/gateways/${t.id}/connect`),P("success",`${Ss[t.type]} connected!`)),n()}catch(K){P("error",t.connected?"Disconnect failed":"Connect failed",K.message)}S(!1)}async function T(K){try{await ee.patch(`/gateways/${t.id}`,{enabled:K}),n()}catch(z){P("error","Update failed",z.message)}}async function G(K){try{await ee.patch(`/gateways/${t.id}`,{notifications:{preset:K}}),n()}catch(z){P("error","Update failed",z.message)}}async function E(K){try{await ee.patch(`/gateways/${t.id}`,{commandPermission:K}),n()}catch(z){P("error","Update failed",z.message)}}async function se(){try{await ee.delete(`/gateways/${t.id}`),P("info",`${Ss[t.type]} gateway removed`),n()}catch(K){P("error","Delete failed",K.message)}}const re=((ge=t.notifications)==null?void 0:ge.preset)||"critical";return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(Pl,{status:t.connected?"running":"crashed",size:"sm"}),i.jsx(N,{size:13,className:"text-text-2"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:Ss[t.type]}),i.jsx("div",{className:"flex-1"}),t.connected?i.jsxs(We,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(Ig,{size:8})," Connected"]}):t.enabled?i.jsx(We,{variant:"warning",className:"text-2xs",children:"Disconnected"}):i.jsx(We,{variant:"default",className:"text-2xs",children:"Disabled"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[140px]",children:[t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success mb-3",children:[i.jsx(oa,{size:10})," Gateway active",t.botUsername&&i.jsxs("span",{className:"text-text-4 ml-1",children:["@",t.botUsername]}),t.botTag&&i.jsx("span",{className:"text-text-4 ml-1",children:t.botTag})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:t.type==="slack"?"Channel":"Chat ID"}),t.chatId?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 flex items-center h-7 px-2 bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2",children:t.type==="slack"&&Q.length>0?`#${((de=Q.find(K=>K.id===t.chatId))==null?void 0:de.name)||t.chatId}`:t.chatId}),i.jsx("button",{onClick:async()=>{try{await ee.patch(`/gateways/${t.id}`,{chatId:null}),n()}catch(K){P("error","Failed",K.message)}},className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans",children:"Change"})]}):t.type==="slack"&&Q.length>0?i.jsxs("select",{onChange:async K=>{if(K.target.value)try{await ee.patch(`/gateways/${t.id}`,{chatId:K.target.value}),n()}catch(z){P("error","Failed to set channel",z.message)}},className:"w-full h-7 px-2 text-2xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",defaultValue:"",children:[i.jsx("option",{value:"",disabled:!0,children:"Select a channel..."}),Q.map(K=>i.jsxs("option",{value:K.id,children:["#",K.name]},K.id))]}):i.jsxs("div",{className:"text-2xs text-warning font-sans",children:[t.type==="slack"?"No channels found — invite the bot to a channel first.":"Send a message to the bot to auto-capture, or enter manually:",i.jsx("input",{placeholder:t.type==="slack"?"C0123456789":"Chat ID",className:"mt-1 w-full h-7 px-2 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",onKeyDown:async K=>{if(K.key==="Enter"&&K.target.value.trim())try{await ee.patch(`/gateways/${t.id}`,{chatId:K.target.value.trim()}),n()}catch(z){P("error","Failed to set channel",z.message)}}})]})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Notifications"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:P_.map(K=>i.jsx("button",{onClick:()=>G(K),className:le("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",re===K?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:K},K))})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Commands"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["full","read-only"].map(K=>i.jsx("button",{onClick:()=>E(K),className:le("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",(t.commandPermission||"full")===K?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:K==="full"?"Full Access":"Read Only"},K))})]})]}),!t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-text-3 font-sans mb-2",children:t.enabled?t.hasCredentials?"Tokens saved — click Connect.":"Configure bot token to connect.":"Gateway is disabled."}),!t.hasCredentials&&i.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer mb-2",children:[i.jsx(ic,{size:11}),"How to set up",i.jsx(cc,{size:9})]})]}),i.jsx(N_,{type:t.type,open:$,onOpenChange:j}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer",children:[i.jsx(ic,{size:11}),"Where do I get these?"]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"Bot Token"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:K=>u(K.target.value),onKeyDown:K=>K.key==="Enter"&&!Z&&U(),type:m?"text":"password",placeholder:T_[t.type],className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>p(!m),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:m?i.jsx(Gf,{size:12}):i.jsx(oi,{size:12})})]})]}),Z&&i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"App Token (Socket Mode)"}),i.jsx("input",{value:d,onChange:K=>f(K.target.value),onKeyDown:K=>K.key==="Enter"&&U(),type:m?"text":"password",placeholder:"xapp-...",className:"w-full h-9 px-3 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(je,{variant:"primary",size:"sm",onClick:U,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Token"}),i.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u(""),f("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&i.jsxs("div",{className:"flex gap-2 mt-2",children:[!t.connected&&i.jsxs(je,{variant:"primary",size:"sm",onClick:()=>l(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(uc,{size:11}),t.enabled?"Set Token":"Configure"]}),t.connected&&i.jsxs(i.Fragment,{children:[i.jsxs(je,{variant:"secondary",size:"sm",onClick:C,disabled:x,className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(If,{size:11}),x?"Sending...":"Test"]}),i.jsx(je,{variant:"secondary",size:"sm",onClick:()=>l(!0),className:"h-7 text-2xs px-2.5",children:i.jsx(uc,{size:11})})]}),i.jsx(je,{variant:"ghost",size:"sm",onClick:X,disabled:b,className:"h-7 text-2xs px-2.5",title:t.connected?"Disconnect":"Connect",children:t.connected?i.jsx(Zb,{size:11}):i.jsx(Ig,{size:11})}),i.jsx(w_,{value:t.enabled,onChange:T}),i.jsx("button",{onClick:se,className:"text-text-4 hover:text-danger cursor-pointer p-1",title:"Remove gateway",children:i.jsx(Xc,{size:11})})]})]})]})}function R_({existingTypes:t,onAdd:n}){const[s,l]=v.useState(!1),o=["telegram","discord","slack"].filter(u=>!t.includes(u));return o.length===0?null:s?i.jsxs("div",{className:"flex flex-col rounded-lg border border-accent/30 bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(Bf,{size:13,className:"text-accent"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:"Add Gateway"}),i.jsx("div",{className:"flex-1"}),i.jsx("button",{onClick:()=>l(!1),className:"text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(Rt,{size:12})})]}),i.jsx("div",{className:"p-3 space-y-2",children:o.map(u=>{const d=YS[u];return i.jsxs("button",{onClick:()=>{n(u),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-0 hover:bg-accent/8 border border-border-subtle hover:border-accent/20 cursor-pointer transition-all group",children:[i.jsx(d,{size:14,className:"text-text-3 group-hover:text-accent"}),i.jsx("span",{className:"text-xs font-medium text-text-1 group-hover:text-accent font-sans",children:Ss[u]})]},u)})})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border-subtle bg-surface-1/50 hover:bg-surface-1 hover:border-accent/30 min-h-[140px] min-w-[220px] cursor-pointer transition-all group",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/8 group-hover:bg-accent/15 flex items-center justify-center mb-2 transition-colors",children:i.jsx(Fn,{size:14,className:"text-accent"})}),i.jsx("span",{className:"text-2xs font-semibold text-text-3 group-hover:text-text-1 font-sans transition-colors",children:"Add Gateway"})]})}function C_(){const[t,n]=v.useState([]),[s,l]=v.useState(null),[o,u]=v.useState(null),[d,f]=v.useState([]),[m,p]=v.useState(!0),[x,g]=v.useState(!1),b=W(X=>X.addToast),S=W(X=>X.marketplaceUser),Q=W(X=>X.marketplaceAuthenticated),k=W(X=>X.marketplaceLogin),$=W(X=>X.marketplaceLogout);function j(){ee.get("/providers").then(X=>n(Array.isArray(X)?X:[])).catch(()=>{})}function P(){ee.get("/gateways").then(X=>f(Array.isArray(X)?X:[])).catch(()=>{})}v.useEffect(()=>{Promise.all([ee.get("/providers"),ee.get("/config"),ee.get("/status"),ee.get("/gateways")]).then(([X,T,G,E])=>{n(Array.isArray(X)?X:[]),l(T),u(G),f(Array.isArray(E)?E:[]),p(!1)}).catch(()=>p(!1))},[]);async function N(X){try{await ee.post("/gateways",{type:X}),b("success",`${Ss[X]} gateway added`),P()}catch(T){b("error","Failed to add gateway",T.message)}}async function Z(X,T){try{const G=await ee.patch("/config",{[X]:T});l(G)}catch(G){b("error","Update failed",G.message)}}if(m)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"h-12 bg-surface-1 border-b border-border"}),i.jsxs("div",{className:"flex-1 p-4 space-y-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-3",children:[...Array(4)].map((X,T)=>i.jsx(Nt,{className:"h-40 rounded-lg"},T))}),i.jsx("div",{className:"grid grid-cols-3 gap-3",children:[...Array(6)].map((X,T)=>i.jsx(Nt,{className:"h-28 rounded-lg"},T))})]})]});const U=t.filter(X=>X.authType==="local"||X.authType==="subscription"?X.installed:X.hasKey).length,C=(s==null?void 0:s.rotationThreshold)||0;return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border-b border-border flex-shrink-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 font-sans",children:"Settings"}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-4 text-2xs text-text-3 font-sans",children:[(o==null?void 0:o.version)&&i.jsxs("span",{children:["v",o.version]}),(o==null?void 0:o.port)&&i.jsxs("span",{children:[":",o.port]}),(o==null?void 0:o.uptime)>0&&i.jsxs("span",{children:["Up ",Ec(o.uptime)]})]}),i.jsx("div",{className:"w-px h-4 bg-border-subtle"}),Q?i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(k_,{user:S}),i.jsx("span",{className:"text-xs font-medium text-text-0 font-sans",children:(S==null?void 0:S.displayName)||"User"}),i.jsxs("button",{onClick:$,className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans flex items-center gap-1",children:[i.jsx(Rb,{size:10})," Sign out"]})]}):i.jsxs(je,{variant:"ghost",size:"sm",onClick:k,className:"h-7 text-2xs gap-1.5 text-text-3",children:[i.jsx(Df,{size:11})," Sign in"]}),i.jsx(Pl,{status:"running",size:"sm"})]}),i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Providers"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[U,"/",t.length," connected"]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-3",children:t.map(X=>i.jsx($_,{provider:X,onKeyChange:j},X.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Gateways"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[d.filter(X=>X.connected).length,"/",d.length," connected"]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.map(X=>i.jsx(z_,{gateway:X,onRefresh:P},X.id)),i.jsx(R_,{existingTypes:d.map(X=>X.type),onAdd:N})]})]}),s&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Configuration"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Auto-saves"})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsx(gl,{icon:Vf,label:"Default Provider",description:"Provider used when spawning new agents.",children:i.jsx("select",{value:s.defaultProvider||"claude-code",onChange:X=>Z("defaultProvider",X.target.value),className:"w-full h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",children:t.filter(X=>X.installed||X.hasKey).map(X=>i.jsx("option",{value:X.id,children:X.name},X.id))})}),i.jsx(gl,{icon:Hr,label:"Working Directory",description:"Default root directory for new agents.",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"flex-1 h-8 px-2 flex items-center bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2 truncate min-w-0",children:s.defaultWorkingDir||"Project root"}),i.jsx(je,{variant:"secondary",size:"sm",onClick:()=>g(!0),className:"h-8 px-2 flex-shrink-0",children:i.jsx(Tb,{size:12})})]})}),i.jsx(gl,{icon:Pb,label:"Rotation Threshold",description:"Context usage that triggers auto-rotation.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["auto","50%","65%","75%","85%"].map(X=>{const T=X==="auto"?0:parseInt(X,10)/100,G=C===T;return i.jsx("button",{onClick:()=>Z("rotationThreshold",T),className:le("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",G?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:X==="auto"?"Auto":X},X)})})}),i.jsx(gl,{icon:Yb,label:"QC Threshold",description:"Running agents count that triggers auto-QC.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[2,3,4,6,8].map(X=>{const T=(s.qcThreshold||2)===X;return i.jsx("button",{onClick:()=>Z("qcThreshold",X),className:le("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",T?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:X},X)})})}),i.jsx(gl,{icon:Zc,label:"Max Agents",description:"Concurrent agent limit. 0 = unlimited.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[0,4,8,12,20].map(X=>{const T=(s.maxAgents||0)===X;return i.jsx("button",{onClick:()=>Z("maxAgents",X),className:le("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",T?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:X===0?"∞":X},X)})})}),i.jsx(gl,{icon:Ir,label:"Journalist Interval",description:"Seconds between synthesis cycles.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[60,120,300,600].map(X=>{const T=(s.journalistInterval||120)===X,G=X<60?`${X}s`:`${X/60}m`;return i.jsx("button",{onClick:()=>Z("journalistInterval",X),className:le("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",T?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:G},X)})})})]})]})]})}),i.jsx(ES,{open:x,onOpenChange:g,currentPath:(s==null?void 0:s.defaultWorkingDir)||"/",onSelect:X=>Z("defaultWorkingDir",X)})]})}const jf=[];function VS(t){const n=(t||"").toLowerCase();return n.includes("reading")||n.includes("read ")?{icon:oi,color:"text-info",label:"Reading"}:n.includes("editing")||n.includes("wrote")||n.includes("writing")||n.includes("edit ")?{icon:$b,color:"text-warning",label:"Editing"}:n.includes("searching")||n.includes("search")||n.includes("grep")||n.includes("glob")?{icon:ql,color:"text-purple",label:"Searching"}:n.includes("running")||n.includes("bash")||n.includes("command")||n.includes("exec")?{icon:ui,color:"text-orange",label:"Running"}:n.includes("test")||n.includes("pass")?{icon:cf,color:"text-success",label:"Testing"}:n.includes("error")||n.includes("fail")||n.includes("crash")?{icon:cn,color:"text-danger",label:"Error"}:n.includes("rotat")?{icon:El,color:"text-accent",label:"Rotating"}:n.includes("spawn")||n.includes("start")?{icon:Na,color:"text-success",label:"Spawned"}:n.includes("tool")||n.includes("function")?{icon:bP,color:"text-text-2",label:"Tool"}:n.includes("complet")||n.includes("done")||n.includes("finish")?{icon:cf,color:"text-success",label:"Done"}:{icon:dn,color:"text-text-3",label:"Activity"}}function vl({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((n,s)=>n.startsWith("**")&&n.endsWith("**")?i.jsx("strong",{className:"font-semibold text-text-0",children:n.slice(2,-2)},s):n.startsWith("`")&&n.endsWith("`")?i.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:n.slice(1,-1)},s):i.jsx("span",{children:n},s)):null}function X_({text:t}){if(!t)return null;const n=[],s=t.split(`
583
583
  `);let l=0;for(;l<s.length;){const o=s[l];if(o.trimStart().startsWith("```")){const d=[],f=o.trim().slice(3);for(l++;l<s.length&&!s[l].trimStart().startsWith("```");)d.push(s[l]),l++;l++,n.push({type:"code",content:d.join(`
584
- `),lang:f});continue}if(/^#{1,3}\s/.test(o)||/^\*\*[^*]+:\*\*\s*$/.test(o.trim())){const d=o.replace(/^#+\s*/,"").replace(/^\*\*/,"").replace(/:\*\*\s*$/,":").trim();n.push({type:"heading",content:d}),l++;continue}if(/^\s*[-*]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*[-*]\s/.test(s[l]);)d.push(s[l].replace(/^\s*[-*]\s+/,"").trim()),l++;n.push({type:"list",items:d});continue}if(/^\s*\d+[\.)]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*\d+[\.)]\s/.test(s[l]);)d.push(s[l].replace(/^\s*\d+[\.)]\s+/,"").trim()),l++;n.push({type:"numbered",items:d});continue}if(!o.trim()){l++;continue}if(/^(Note|Warning|Important|IMPORTANT|TODO):/i.test(o.trim())){n.push({type:"note",content:o.trim()}),l++;continue}const u=[];for(;l<s.length&&s[l].trim()&&!/^#{1,3}\s/.test(s[l])&&!/^\s*[-*]\s/.test(s[l])&&!/^\s*\d+[\.)]\s/.test(s[l])&&!s[l].trimStart().startsWith("```");)u.push(s[l].trim()),l++;u.length>0&&n.push({type:"para",content:u.join(" ")})}return i.jsx("div",{className:"space-y-2",children:n.map((o,u)=>{switch(o.type){case"heading":return i.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 first:pt-0",children:[i.jsx("div",{className:"w-1 h-3.5 rounded-full bg-accent/40 flex-shrink-0"}),i.jsx("span",{className:"text-[12px] font-semibold text-text-0 font-sans",children:i.jsx(vl,{text:o.content})})]},u);case"list":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,f)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsx("span",{className:"text-accent/50 mt-0.5 flex-shrink-0",children:"-"}),i.jsx("span",{className:"min-w-0",children:i.jsx(vl,{text:d})})]},f))},u);case"numbered":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,f)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 text-right flex-shrink-0",children:[f+1,"."]}),i.jsx("span",{className:"min-w-0",children:i.jsx(vl,{text:d})})]},f))},u);case"code":return i.jsx("pre",{className:"p-2.5 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06] leading-relaxed",children:o.content},u);case"note":return i.jsxs("div",{className:"flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-warning/6 border border-warning/12",children:[i.jsx(cn,{size:10,className:"text-warning mt-0.5 flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-warning/80 font-sans",children:i.jsx(vl,{text:o.content})})]},u);case"para":default:return i.jsx("p",{className:"text-[12px] text-text-0 font-sans leading-relaxed",children:i.jsx(vl,{text:o.content})},u)}})})}function __({text:t}){if(!t)return null;const n=t.split(/(```[\s\S]*?```)/g);return i.jsx("span",{children:n.map((s,l)=>{if(s.startsWith("```")&&s.endsWith("```")){const o=s.slice(3,-3).replace(/^\w+\n/,"");return i.jsx("pre",{className:"my-1.5 p-2 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06]",children:o},l)}return i.jsx("span",{children:i.jsx(vl,{text:s})},l)})})}function Z_({msg:t}){const n=t.isQuery;return i.jsx("div",{className:"flex justify-end pl-8",children:i.jsxs("div",{className:"max-w-[90%]",children:[n&&i.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[i.jsx(ic,{size:9,className:"text-info"}),i.jsx("span",{className:"text-2xs text-info font-sans font-medium",children:"Query"})]}),i.jsx("div",{className:le("px-3.5 py-2.5 rounded-lg border","bg-info/10 border-info/25"),children:i.jsx("div",{className:"text-[12px] font-sans whitespace-pre-wrap break-words leading-relaxed text-text-0",children:i.jsx(__,{text:t.text})})}),i.jsx("div",{className:"text-[10px] text-text-4 font-sans mt-1 text-right",children:Ct(t.timestamp)})]})})}function A_({msg:t,agent:n}){var u,d;const[s,l]=v.useState(((u=t.text)==null?void 0:u.length)>600),o=((d=t.text)==null?void 0:d.length)>600;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-1 font-sans",children:(n==null?void 0:n.name)||"Agent"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:n==null?void 0:n.role}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:Ct(t.timestamp)})]}),i.jsxs("div",{className:le("border-l border-accent pl-3.5 py-1 overflow-hidden",s&&"max-h-[200px] relative"),children:[i.jsx(X_,{text:s?t.text.slice(0,600):t.text}),s&&i.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-surface-2 to-transparent flex items-end justify-center pb-2",children:i.jsxs("button",{onClick:()=>l(!1),className:"flex items-center gap-1.5 px-4 py-1.5 rounded-full bg-accent/15 border border-accent/25 text-xs text-accent font-sans font-medium hover:bg-accent/25 cursor-pointer transition-colors",children:[i.jsx(In,{size:12}),"Show full response"]})})]}),o&&!s&&i.jsxs("button",{onClick:()=>l(!0),className:"ml-4 mt-1 flex items-center gap-1 text-[11px] text-accent/60 hover:text-accent font-sans cursor-pointer",children:[i.jsx(In,{size:10,className:"rotate-180"}),"Collapse"]})]})}function E_({msg:t}){return i.jsxs("div",{className:"flex items-center gap-3 py-2",children:[i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans flex-shrink-0 uppercase tracking-wide",children:t.text}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"})]})}function q_({entries:t}){var u;const[n,s]=v.useState(0);v.useEffect(()=>{if(t.length<=1)return;const d=setInterval(()=>s(f=>(f+1)%t.length),1500);return()=>clearInterval(d)},[t.length]);const l=t[Math.min(n,t.length-1)];VS(l.text);const o=((u=l.text)==null?void 0:u.length)>60?l.text.slice(0,60)+"...":l.text;return i.jsxs("div",{className:"ml-7 flex items-center gap-2 px-3 py-2 rounded-md bg-surface-3/50 border border-border-subtle/30",children:[i.jsx(Lf,{size:11,className:"text-accent animate-spin flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-text-2 font-mono truncate flex-1 min-w-0 transition-opacity duration-300",children:o}),t.length>1&&i.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:t.length})]})}function M_({agent:t}){const n=W(m=>m.activityLog[t.id])||jf,s=n[n.length-1],l=s?VS(s.text):null,o=(l==null?void 0:l.icon)||dn,u=s&&Date.now()-s.timestamp<1e4,d=u&&s.text?s.text.length>60?s.text.slice(0,60)+"...":s.text:null,f=Math.round((t.contextUsage||0)*100);return i.jsxs("div",{className:"flex items-center gap-3 px-4 h-8 border-b border-border-subtle bg-surface-1/80 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[i.jsx("span",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),u?i.jsxs(i.Fragment,{children:[i.jsx(o,{size:10,className:le(l.color,"flex-shrink-0")}),i.jsx("span",{className:"text-[11px] text-text-2 font-sans truncate",children:d})]}):i.jsx("span",{className:"text-[11px] text-text-3 font-sans",children:"Working..."})]}),i.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:Y_(t.tokensUsed)}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"w-14 h-1 rounded-full bg-surface-4 overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${f}%`,background:f>=75?"var(--color-danger)":f>=50?"var(--color-warning)":"var(--color-accent)"}})}),i.jsxs("span",{className:"text-[10px] text-text-4 font-mono w-7 text-right",children:[f,"%"]})]})]})]})}function Y_(t){return t?t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t):"0"}function V_({agent:t}){const[n,s]=v.useState([]),l=[{text:`Initializing ${t.name}`,delay:0},{text:`Role: ${t.role}`,delay:400},{text:`Provider: ${t.provider||"claude-code"}`,delay:700},{text:"Loading workspace context",delay:1e3},{text:"Scanning project structure",delay:1400},{text:"Session active",delay:1900}];return v.useEffect(()=>{const o=l.map((u,d)=>setTimeout(()=>s(f=>[...f,d]),u.delay));return()=>o.forEach(clearTimeout)},[]),i.jsxs("div",{className:"flex flex-col px-4 pt-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[i.jsxs("div",{className:"relative w-9 h-9",children:[i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-accent/20 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin",style:{animationDuration:"1s"}}),i.jsx("span",{className:"absolute inset-[5px] rounded-full bg-accent/8"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-bold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-2xs text-accent font-mono",children:"starting up"})]})]}),i.jsx("div",{className:"space-y-2 pl-3 border-l border-accent/15",children:l.map((o,u)=>{const d=n.includes(u),f=u===l.length-1;return i.jsxs("div",{className:le("flex items-center gap-2.5 transition-all duration-300",d?"opacity-100 translate-x-0":"opacity-0 -translate-x-2"),children:[i.jsx("span",{className:le("w-1 h-1 rounded-full flex-shrink-0",f&&d?"bg-accent":d?"bg-text-3":"bg-transparent")}),i.jsx("span",{className:le("text-[11px] font-mono",f&&d?"text-accent":"text-text-3"),children:o.text}),f&&d&&i.jsxs("span",{className:"flex gap-0.5 ml-1",children:[i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"400ms"}})]})]},u)})})]})}function U_({agent:t}){const n=W(j=>j.chatHistory[t.id])||jf,s=W(j=>j.activityLog[t.id])||jf,l=W(j=>j.instructAgent),o=W(j=>j.queryAgent),[u,d]=v.useState(""),[f,m]=v.useState("instruct"),[p,x]=v.useState(!1),g=v.useRef(null),b=v.useRef(null),S=v.useMemo(()=>{var X;const j=[],P=new Set;for(const T of n){const G=`${T.from}:${(X=T.text)==null?void 0:X.slice(0,100)}`;j.find(se=>{var re;return se.kind==="chat"&&`${se.from}:${(re=se.text)==null?void 0:re.slice(0,100)}`===G&&Math.abs(se.ts-T.timestamp)<5e3})||(j.push({...T,kind:"chat",ts:T.timestamp}),P.add(T.text))}const N=P,Z=s.slice(-30);for(const T of Z)(T.text||"").trim()&&!N.has(T.text)&&j.push({...T,kind:"activity",ts:T.timestamp});j.sort((T,G)=>T.ts-G.ts);const U=[];let C=[];for(const T of j)T.kind==="activity"?C.push(T):(C.length>0&&(U.push({kind:"activity-group",entries:C}),C=[]),U.push(T));return C.length>0&&U.push({kind:"activity-group",entries:C}),U},[n,s]);v.useEffect(()=>{g.current&&requestAnimationFrame(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)})},[S.length]);async function Q(){var P;const j=u.trim();if(!(!j||p)){if(j==="/rotate"){const N=W.getState().rotateAgent;d("");try{await N(t.id)}catch{}return}d(""),x(!0);try{f==="query"?await o(t.id,j):await l(t.id,j)}catch{}x(!1),(P=b.current)==null||P.focus()}}function k(j){j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),Q())}const $=t.status==="running"||t.status==="starting";return i.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[$&&i.jsx(M_,{agent:t}),i.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[!S.some(j=>j.from==="agent"||j.kind==="activity-group")&&($?i.jsx(V_,{agent:t}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-8",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-3 flex items-center justify-center mb-3",children:i.jsx(ci,{size:18,className:"text-text-4"})}),i.jsx("p",{className:"text-sm font-semibold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Session complete — send a message to continue"})]})),S.map((j,P)=>j.kind==="activity-group"?i.jsx(q_,{entries:j.entries},`grp-${P}`):j.from==="user"?i.jsx(Z_,{msg:j},`msg-${P}`):j.from==="system"?i.jsx(E_,{msg:j},`msg-${P}`):i.jsx(A_,{msg:j,agent:t},`msg-${P}`)),p&&i.jsxs("div",{className:"flex items-center gap-2 ml-7 py-2",children:[i.jsx("div",{className:"w-5 h-5 rounded-md bg-accent/12 flex items-center justify-center",children:i.jsx(dn,{size:10,className:"text-accent"})}),i.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 rounded-2xl bg-surface-2/60 border border-border-subtle",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"400ms"}})]})]})]}),i.jsxs("div",{className:"border-t border-border px-4 py-3 bg-surface-1/50 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[i.jsxs("button",{onClick:()=>m("instruct"),className:le("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",f==="instruct"?"bg-accent/12 text-accent border border-accent/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(Cc,{size:10}),"Instruct"]}),i.jsxs("button",{onClick:()=>m("query"),className:le("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",f==="query"?"bg-info/12 text-info border border-info/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(ic,{size:10}),"Query"]}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:f==="query"?"Read-only — agent keeps working":$?"Directs the agent":"Continues the session"})]}),i.jsxs("div",{className:le("flex items-end gap-2 rounded-xl border bg-surface-0 p-1 transition-colors",f==="query"?"border-info/20 focus-within:border-info/40":"border-border-subtle focus-within:border-accent/30"),children:[i.jsx("textarea",{ref:b,value:u,onChange:j=>d(j.target.value),onKeyDown:k,placeholder:f==="query"?"Ask about this agent's work...":$?"Send an instruction...":"Continue this session...",rows:1,className:le("flex-1 resize-none px-3 py-2 text-[13px]","bg-transparent text-text-0 font-sans","placeholder:text-text-4","focus:outline-none","max-h-[120px] min-h-[36px]"),style:{height:Math.min(Math.max(36,u.split(`
584
+ `),lang:f});continue}if(/^#{1,3}\s/.test(o)||/^\*\*[^*]+:\*\*\s*$/.test(o.trim())){const d=o.replace(/^#+\s*/,"").replace(/^\*\*/,"").replace(/:\*\*\s*$/,":").trim();n.push({type:"heading",content:d}),l++;continue}if(/^\s*[-*]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*[-*]\s/.test(s[l]);)d.push(s[l].replace(/^\s*[-*]\s+/,"").trim()),l++;n.push({type:"list",items:d});continue}if(/^\s*\d+[\.)]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*\d+[\.)]\s/.test(s[l]);)d.push(s[l].replace(/^\s*\d+[\.)]\s+/,"").trim()),l++;n.push({type:"numbered",items:d});continue}if(!o.trim()){l++;continue}if(/^(Note|Warning|Important|IMPORTANT|TODO):/i.test(o.trim())){n.push({type:"note",content:o.trim()}),l++;continue}const u=[];for(;l<s.length&&s[l].trim()&&!/^#{1,3}\s/.test(s[l])&&!/^\s*[-*]\s/.test(s[l])&&!/^\s*\d+[\.)]\s/.test(s[l])&&!s[l].trimStart().startsWith("```");)u.push(s[l].trim()),l++;u.length>0&&n.push({type:"para",content:u.join(" ")})}return i.jsx("div",{className:"space-y-2",children:n.map((o,u)=>{switch(o.type){case"heading":return i.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 first:pt-0",children:[i.jsx("div",{className:"w-1 h-3.5 rounded-full bg-accent/40 flex-shrink-0"}),i.jsx("span",{className:"text-[12px] font-semibold text-text-0 font-sans",children:i.jsx(vl,{text:o.content})})]},u);case"list":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,f)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsx("span",{className:"text-accent/50 mt-0.5 flex-shrink-0",children:"-"}),i.jsx("span",{className:"min-w-0",children:i.jsx(vl,{text:d})})]},f))},u);case"numbered":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,f)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 text-right flex-shrink-0",children:[f+1,"."]}),i.jsx("span",{className:"min-w-0",children:i.jsx(vl,{text:d})})]},f))},u);case"code":return i.jsx("pre",{className:"p-2.5 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06] leading-relaxed",children:o.content},u);case"note":return i.jsxs("div",{className:"flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-warning/6 border border-warning/12",children:[i.jsx(cn,{size:10,className:"text-warning mt-0.5 flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-warning/80 font-sans",children:i.jsx(vl,{text:o.content})})]},u);case"para":default:return i.jsx("p",{className:"text-[12px] text-text-0 font-sans leading-relaxed",children:i.jsx(vl,{text:o.content})},u)}})})}function __({text:t}){if(!t)return null;const n=t.split(/(```[\s\S]*?```)/g);return i.jsx("span",{children:n.map((s,l)=>{if(s.startsWith("```")&&s.endsWith("```")){const o=s.slice(3,-3).replace(/^\w+\n/,"");return i.jsx("pre",{className:"my-1.5 p-2 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06]",children:o},l)}return i.jsx("span",{children:i.jsx(vl,{text:s})},l)})})}function Z_({msg:t}){const n=t.isQuery;return i.jsx("div",{className:"flex justify-end pl-8",children:i.jsxs("div",{className:"max-w-[90%]",children:[n&&i.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[i.jsx(ic,{size:9,className:"text-info"}),i.jsx("span",{className:"text-2xs text-info font-sans font-medium",children:"Query"})]}),i.jsx("div",{className:le("px-3.5 py-2.5 rounded-lg border","bg-info/10 border-info/25"),children:i.jsx("div",{className:"text-[12px] font-sans whitespace-pre-wrap break-words leading-relaxed text-text-0",children:i.jsx(__,{text:t.text})})}),i.jsx("div",{className:"text-[10px] text-text-4 font-sans mt-1 text-right",children:Ct(t.timestamp)})]})})}function A_({msg:t,agent:n}){var u,d;const[s,l]=v.useState(((u=t.text)==null?void 0:u.length)>600),o=((d=t.text)==null?void 0:d.length)>600;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-1 font-sans",children:(n==null?void 0:n.name)||"Agent"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:n==null?void 0:n.role}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:Ct(t.timestamp)})]}),i.jsx("div",{className:"border-l border-accent pl-3.5 py-1",children:i.jsx(X_,{text:s?t.text.slice(0,600)+"...":t.text})}),s&&i.jsxs("button",{onClick:()=>l(!1),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[i.jsx(In,{size:11}),"Show full response"]}),o&&!s&&i.jsxs("button",{onClick:()=>l(!0),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[i.jsx(In,{size:11,className:"rotate-180"}),"Collapse"]})]})}function E_({msg:t}){return i.jsxs("div",{className:"flex items-center gap-3 py-2",children:[i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans flex-shrink-0 uppercase tracking-wide",children:t.text}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"})]})}function q_({entries:t}){var u;const[n,s]=v.useState(0);v.useEffect(()=>{if(t.length<=1)return;const d=setInterval(()=>s(f=>(f+1)%t.length),1500);return()=>clearInterval(d)},[t.length]);const l=t[Math.min(n,t.length-1)];VS(l.text);const o=((u=l.text)==null?void 0:u.length)>60?l.text.slice(0,60)+"...":l.text;return i.jsxs("div",{className:"ml-7 flex items-center gap-2 px-3 py-2 rounded-md bg-surface-3/50 border border-border-subtle/30",children:[i.jsx(Lf,{size:11,className:"text-accent animate-spin flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-text-2 font-mono truncate flex-1 min-w-0 transition-opacity duration-300",children:o}),t.length>1&&i.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:t.length})]})}function M_({agent:t}){const n=W(m=>m.activityLog[t.id])||jf,s=n[n.length-1],l=s?VS(s.text):null,o=(l==null?void 0:l.icon)||dn,u=s&&Date.now()-s.timestamp<1e4,d=u&&s.text?s.text.length>60?s.text.slice(0,60)+"...":s.text:null,f=Math.round((t.contextUsage||0)*100);return i.jsxs("div",{className:"flex items-center gap-3 px-4 h-8 border-b border-border-subtle bg-surface-1/80 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[i.jsx("span",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),u?i.jsxs(i.Fragment,{children:[i.jsx(o,{size:10,className:le(l.color,"flex-shrink-0")}),i.jsx("span",{className:"text-[11px] text-text-2 font-sans truncate",children:d})]}):i.jsx("span",{className:"text-[11px] text-text-3 font-sans",children:"Working..."})]}),i.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:Y_(t.tokensUsed)}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"w-14 h-1 rounded-full bg-surface-4 overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${f}%`,background:f>=75?"var(--color-danger)":f>=50?"var(--color-warning)":"var(--color-accent)"}})}),i.jsxs("span",{className:"text-[10px] text-text-4 font-mono w-7 text-right",children:[f,"%"]})]})]})]})}function Y_(t){return t?t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t):"0"}function V_({agent:t}){const[n,s]=v.useState([]),l=[{text:`Initializing ${t.name}`,delay:0},{text:`Role: ${t.role}`,delay:400},{text:`Provider: ${t.provider||"claude-code"}`,delay:700},{text:"Loading workspace context",delay:1e3},{text:"Scanning project structure",delay:1400},{text:"Session active",delay:1900}];return v.useEffect(()=>{const o=l.map((u,d)=>setTimeout(()=>s(f=>[...f,d]),u.delay));return()=>o.forEach(clearTimeout)},[]),i.jsxs("div",{className:"flex flex-col px-4 pt-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[i.jsxs("div",{className:"relative w-9 h-9",children:[i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-accent/20 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin",style:{animationDuration:"1s"}}),i.jsx("span",{className:"absolute inset-[5px] rounded-full bg-accent/8"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-bold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-2xs text-accent font-mono",children:"starting up"})]})]}),i.jsx("div",{className:"space-y-2 pl-3 border-l border-accent/15",children:l.map((o,u)=>{const d=n.includes(u),f=u===l.length-1;return i.jsxs("div",{className:le("flex items-center gap-2.5 transition-all duration-300",d?"opacity-100 translate-x-0":"opacity-0 -translate-x-2"),children:[i.jsx("span",{className:le("w-1 h-1 rounded-full flex-shrink-0",f&&d?"bg-accent":d?"bg-text-3":"bg-transparent")}),i.jsx("span",{className:le("text-[11px] font-mono",f&&d?"text-accent":"text-text-3"),children:o.text}),f&&d&&i.jsxs("span",{className:"flex gap-0.5 ml-1",children:[i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"400ms"}})]})]},u)})})]})}function U_({agent:t}){const n=W(j=>j.chatHistory[t.id])||jf,s=W(j=>j.activityLog[t.id])||jf,l=W(j=>j.instructAgent),o=W(j=>j.queryAgent),[u,d]=v.useState(""),[f,m]=v.useState("instruct"),[p,x]=v.useState(!1),g=v.useRef(null),b=v.useRef(null),S=v.useMemo(()=>{var X;const j=[],P=new Set;for(const T of n){const G=`${T.from}:${(X=T.text)==null?void 0:X.slice(0,100)}`;j.find(se=>{var re;return se.kind==="chat"&&`${se.from}:${(re=se.text)==null?void 0:re.slice(0,100)}`===G&&Math.abs(se.ts-T.timestamp)<5e3})||(j.push({...T,kind:"chat",ts:T.timestamp}),P.add(T.text))}const N=P,Z=s.slice(-30);for(const T of Z)(T.text||"").trim()&&!N.has(T.text)&&j.push({...T,kind:"activity",ts:T.timestamp});j.sort((T,G)=>T.ts-G.ts);const U=[];let C=[];for(const T of j)T.kind==="activity"?C.push(T):(C.length>0&&(U.push({kind:"activity-group",entries:C}),C=[]),U.push(T));return C.length>0&&U.push({kind:"activity-group",entries:C}),U},[n,s]);v.useEffect(()=>{g.current&&requestAnimationFrame(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)})},[S.length]);async function Q(){var P;const j=u.trim();if(!(!j||p)){if(j==="/rotate"){const N=W.getState().rotateAgent;d("");try{await N(t.id)}catch{}return}d(""),x(!0);try{f==="query"?await o(t.id,j):await l(t.id,j)}catch{}x(!1),(P=b.current)==null||P.focus()}}function k(j){j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),Q())}const $=t.status==="running"||t.status==="starting";return i.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[$&&i.jsx(M_,{agent:t}),i.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[!S.some(j=>j.from==="agent"||j.kind==="activity-group")&&($?i.jsx(V_,{agent:t}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-8",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-3 flex items-center justify-center mb-3",children:i.jsx(ci,{size:18,className:"text-text-4"})}),i.jsx("p",{className:"text-sm font-semibold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Session complete — send a message to continue"})]})),S.map((j,P)=>j.kind==="activity-group"?i.jsx(q_,{entries:j.entries},`grp-${P}`):j.from==="user"?i.jsx(Z_,{msg:j},`msg-${P}`):j.from==="system"?i.jsx(E_,{msg:j},`msg-${P}`):i.jsx(A_,{msg:j,agent:t},`msg-${P}`)),p&&i.jsxs("div",{className:"flex items-center gap-2 ml-7 py-2",children:[i.jsx("div",{className:"w-5 h-5 rounded-md bg-accent/12 flex items-center justify-center",children:i.jsx(dn,{size:10,className:"text-accent"})}),i.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 rounded-2xl bg-surface-2/60 border border-border-subtle",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"400ms"}})]})]})]}),i.jsxs("div",{className:"border-t border-border px-4 py-3 bg-surface-1/50 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[i.jsxs("button",{onClick:()=>m("instruct"),className:le("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",f==="instruct"?"bg-accent/12 text-accent border border-accent/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(Cc,{size:10}),"Instruct"]}),i.jsxs("button",{onClick:()=>m("query"),className:le("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",f==="query"?"bg-info/12 text-info border border-info/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(ic,{size:10}),"Query"]}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:f==="query"?"Read-only — agent keeps working":$?"Directs the agent":"Continues the session"})]}),i.jsxs("div",{className:le("flex items-end gap-2 rounded-xl border bg-surface-0 p-1 transition-colors",f==="query"?"border-info/20 focus-within:border-info/40":"border-border-subtle focus-within:border-accent/30"),children:[i.jsx("textarea",{ref:b,value:u,onChange:j=>d(j.target.value),onKeyDown:k,placeholder:f==="query"?"Ask about this agent's work...":$?"Send an instruction...":"Continue this session...",rows:1,className:le("flex-1 resize-none px-3 py-2 text-[13px]","bg-transparent text-text-0 font-sans","placeholder:text-text-4","focus:outline-none","max-h-[120px] min-h-[36px]"),style:{height:Math.min(Math.max(36,u.split(`
585
585
  `).length*20),120)}}),i.jsx("button",{onClick:Q,disabled:!u.trim()||p,className:le("w-9 h-9 flex items-center justify-center rounded-lg transition-all cursor-pointer flex-shrink-0 mb-px","disabled:opacity-15 disabled:cursor-not-allowed",u.trim()?f==="query"?"bg-info text-white hover:bg-info/85":"bg-accent text-white hover:bg-accent/85":"bg-transparent text-text-4"),children:p?i.jsx(Lf,{size:15,className:"animate-spin"}):i.jsx(Hf,{size:15})})]})]})]})}function FO({options:t,value:n,onChange:s}){return i.jsx("div",{className:"flex bg-surface-0 rounded-lg p-0.5 border border-border-subtle",children:t.map(l=>i.jsx("button",{onClick:()=>s(l.value),className:le("flex-1 px-3 py-1.5 text-2xs font-semibold font-sans rounded-md transition-all cursor-pointer",n===l.value?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:l.label},l.value))})}function ha({label:t,icon:n,children:s,description:l}){return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-semibold text-text-1 font-sans",children:[n&&i.jsx(n,{size:13,className:"text-text-3"}),t]}),l&&i.jsx("p",{className:"text-2xs text-text-4 font-sans mt-0.5",children:l})]}),s]})}function G_({agent:t}){const n=W(Q=>Q.killAgent),s=W(Q=>Q.rotateAgent),l=W(Q=>Q.spawnAgent),o=W(Q=>Q.closeDetail),u=W(Q=>Q.addToast),[d,f]=v.useState(null),[m,p]=v.useState(!1),x=t.status==="running"||t.status==="starting";async function g(){f("rotate");try{await s(t.id)}catch{}f(null)}async function b(){if(!m){p(!0),setTimeout(()=>p(!1),3e3);return}f("kill");try{await n(t.id),o()}catch{}f(null),p(!1)}async function S(){f("clone");try{await l({role:t.role,provider:t.provider,model:t.model,name:`${t.name}-clone`,scope:t.scope,workingDir:t.workingDir}),u("success",`Cloned ${t.name}`)}catch{}f(null)}return x?i.jsx("div",{className:"space-y-2",children:i.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[i.jsxs(je,{variant:"primary",size:"md",onClick:g,disabled:d==="rotate",className:"gap-1.5",children:[i.jsx(El,{size:12,className:d==="rotate"?"animate-spin":""}),"Rotate"]}),i.jsxs(je,{variant:"info",size:"md",onClick:S,disabled:!!d,className:"gap-1.5",children:[i.jsx(uf,{size:12})," Clone"]}),i.jsxs(je,{variant:"danger",size:"md",onClick:b,disabled:d==="kill",className:"gap-1.5",children:[i.jsx(Vb,{size:12}),m?"Confirm":"Kill"]})]})}):i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs(je,{variant:"info",size:"md",onClick:S,disabled:!!d,className:"gap-1.5",children:[i.jsx(uf,{size:12})," Clone"]}),i.jsxs(je,{variant:"danger",size:"md",onClick:b,disabled:d==="kill",className:"gap-1.5",children:[i.jsx(Xc,{size:12}),m?"Confirm":"Remove"]})]})}function L_({agent:t}){var Xe;const n=W(D=>D.addToast),[s,l]=v.useState([]),[o,u]=v.useState(t.model||""),[d,f]=v.useState(""),[m,p]=v.useState(t.effort||"default"),[x,g]=v.useState(!1),[b,S]=v.useState(""),[Q,k]=v.useState(null),[$,j]=v.useState(!1),[P,N]=v.useState(null),[Z,U]=v.useState(t.routingMode||"auto"),[C,X]=v.useState([]),[T,G]=v.useState("hr"),[E,se]=v.useState("1"),[re,ge]=v.useState(!1),de=t.status==="running"||t.status==="starting";v.useEffect(()=>{K(),ee.get("/skills/installed").then(ie=>X(Array.isArray(ie)?ie:ie.skills||[])).catch(()=>{});function D(){K()}return window.addEventListener("groove:providers-changed",D),()=>window.removeEventListener("groove:providers-changed",D)},[]);function K(){ee.get("/providers").then(D=>l(Array.isArray(D)?D:[])).catch(()=>{})}v.useEffect(()=>{u(t.model||""),ee.get(`/agents/${t.id}/routing/recommend`).then(D=>{U((D==null?void 0:D.mode)||"fixed")}).catch(()=>{})},[t.id,t.model]);const z=s.find(D=>D.id===t.provider);async function B(D,ie){u(ie);try{await ee.patch(`/agents/${t.id}`,{model:ie}),n("success",`Model → ${ie}`)}catch(ze){n("error","Model swap failed",ze.message)}}async function J(D){try{await ee.patch(`/agents/${t.id}`,{workingDir:D}),n("success",`Working dir → ${D.split("/").pop()||D}`)}catch(ie){n("error","Update failed",ie.message)}}async function fe(D){p(D);try{await ee.patch(`/agents/${t.id}`,{effort:D}),n("success",`Effort → ${D}`)}catch(ie){n("error","Update failed",ie.message)}}async function te(D){if(!D.trim())return;const ie=[...t.scope||[],D.trim()];try{await ee.patch(`/agents/${t.id}`,{scope:ie}),f("")}catch(ze){n("error","Scope update failed",ze.message)}}async function Ae(D){const ie=(t.scope||[]).filter((ze,Ot)=>Ot!==D);try{await ee.patch(`/agents/${t.id}`,{scope:ie})}catch(ze){n("error","Scope update failed",ze.message)}}async function Se(D){if(b.trim())try{await ee.post(`/credentials/${D}`,{key:b.trim()}),n("success",`API key set for ${D}`),S(""),k(null),K(),window.dispatchEvent(new CustomEvent("groove:providers-changed"))}catch(ie){n("error","Failed to set key",ie.message)}}const ve=t.spawnedAt||t.createdAt;return i.jsxs("div",{className:"px-5 py-5 space-y-6 overflow-y-auto h-full",children:[i.jsx(ha,{label:"Active Model",icon:Vf,children:i.jsxs("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-bold font-mono text-text-0",children:t.model||"auto"}),i.jsx("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:(z==null?void 0:z.name)||t.provider})]}),(z==null?void 0:z.canHotSwap)&&de&&i.jsxs(We,{variant:"accent",className:"text-2xs gap-1",children:[i.jsx(Na,{size:8})," Hot-swap"]})]}),((Xe=z==null?void 0:z.models)==null?void 0:Xe.length)>1&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3 pt-3 border-t border-border-subtle",children:z.models.map(D=>{const ie=D.id===t.model,ze=!de||z.canHotSwap;return i.jsx("button",{onClick:()=>ze&&B(t.provider,D.id),disabled:!ze,className:le("px-2.5 py-1 rounded-md text-xs font-mono transition-all",ze?"cursor-pointer":"cursor-not-allowed opacity-40",ie?"bg-accent/15 text-accent font-semibold":"bg-surface-4 text-text-2 hover:bg-surface-5 hover:text-text-0"),children:D.name||D.id},D.id)})})]})}),i.jsx(G_,{agent:t}),i.jsxs(ha,{label:"Providers",icon:Hg,description:"Click a provider to see its models and connection status.",children:[i.jsx("div",{className:"space-y-1.5",children:s.map(D=>{const ie=D.id===t.provider,ze=D.installed||D.hasKey,Ot=P===D.id,_e=D.models||[];return i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-0 overflow-hidden",children:[i.jsxs("button",{onClick:()=>N(Ot?null:D.id),className:"w-full flex items-center gap-2.5 px-3 py-2 cursor-pointer hover:bg-surface-4/50 transition-colors",children:[i.jsx("div",{className:le("w-2 h-2 rounded-full flex-shrink-0",ze?"bg-success":"bg-text-4")}),i.jsx("span",{className:le("text-xs font-semibold font-sans flex-1 text-left",ze?"text-text-0":"text-text-3"),children:D.name||D.id}),ie&&i.jsx(We,{variant:"accent",className:"text-2xs",children:"Active"}),!ze&&i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:D.authType==="local"?"Not installed":"No key"}),i.jsx(In,{size:12,className:le("text-text-4 transition-transform",Ot&&"rotate-180")})]}),Ot&&D.authType==="local"&&i.jsx("div",{className:"border-t border-border-subtle",children:i.jsx(sS,{isInstalled:ze,onModelChange:K})}),Ot&&D.authType!=="local"&&i.jsxs("div",{className:"border-t border-border-subtle",children:[(!ze||D.hasKey)&&i.jsx("div",{className:"px-3 py-2 bg-surface-1/50",children:Q===D.id?i.jsxs("div",{className:"flex gap-1.5",children:[i.jsxs("div",{className:"flex-1 relative",children:[i.jsx("input",{value:b,onChange:tt=>S(tt.target.value),onKeyDown:tt=>tt.key==="Enter"&&Se(D.id),type:$?"text":"password",placeholder:`${D.name||D.id} API key...`,className:"w-full h-7 px-2.5 pr-7 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>j(!$),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:$?i.jsx(Gf,{size:10}):i.jsx(oi,{size:10})})]}),i.jsx(je,{variant:"primary",size:"sm",onClick:()=>Se(D.id),disabled:!b.trim(),className:"h-7 px-2 text-2xs",children:"Save"}),i.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{k(null),S("")},className:"h-7 px-2 text-2xs",children:"Cancel"})]}):i.jsxs("button",{onClick:()=>{k(D.id),S(""),j(!1)},className:"flex items-center gap-1.5 text-2xs text-text-3 hover:text-accent font-sans cursor-pointer transition-colors",children:[i.jsx(uc,{size:10}),ze?"Update API key":"Add API key to enable"]})}),ze&&_e.length>0&&_e.map(tt=>{const bt=D.id===t.provider&&tt.id===t.model,vt=!de;return i.jsxs("button",{onClick:()=>vt&&B(D.id,tt.id),disabled:!vt,className:le("w-full flex items-center gap-2 px-3 py-2 text-left text-xs font-sans transition-colors","border-t border-border-subtle",vt?"cursor-pointer hover:bg-surface-4/50":"cursor-not-allowed opacity-40",bt?"text-accent":"text-text-2"),children:[bt?i.jsx(oa,{size:11,className:"text-accent flex-shrink-0"}):i.jsx("div",{className:"w-[11px]"}),i.jsx("span",{className:"font-mono flex-1 truncate",children:tt.name||tt.id}),i.jsx(We,{variant:bt?"accent":"default",className:"text-2xs",children:tt.tier})]},tt.id)})]})]},D.id)})}),de&&i.jsxs("div",{className:"flex items-center gap-1.5 text-2xs text-text-3 font-sans mt-1.5",children:[i.jsx(cn,{size:10}),i.jsx("span",{children:"Stop agent to switch providers."})]})]}),i.jsx(ha,{label:"Working Directory",icon:Hr,description:"The root directory this agent operates in.",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"flex-1 bg-surface-0 rounded-lg px-3 py-2.5 text-sm font-mono text-text-1 border border-border-subtle truncate min-w-0",children:t.workingDir||"Project root"}),i.jsxs(je,{variant:"secondary",size:"md",onClick:()=>g(!0),className:"gap-1.5 flex-shrink-0",children:[i.jsx(Tb,{size:14})," Browse"]})]})}),i.jsx(ha,{label:"Permission Mode",icon:Fr,description:"Full Send = no approvals. Agent Approve = Fullstack Manager reviews risky operations.",children:i.jsx(FO,{options:[{value:"full",label:"Full Send"},{value:"auto",label:"Agent Approve"}],value:t.permission||"full",onChange:async D=>{try{await ee.patch(`/agents/${t.id}`,{permission:D}),n("success",`Permission → ${D==="full"?"Full Send":"Agent Approve"}`)}catch(ie){n("error","Update failed",ie.message)}}})}),i.jsxs(ha,{label:"Model Routing",icon:rc,description:"How Groove selects models for this agent's tasks.",children:[i.jsx(FO,{options:[{value:"fixed",label:"Fixed"},{value:"auto",label:"Auto"},{value:"auto-floor",label:"Auto + Floor"}],value:Z,onChange:async D=>{U(D);try{await ee.post(`/agents/${t.id}/routing`,{mode:D}),n("success",`Routing → ${D}`)}catch(ie){n("error","Update failed",ie.message)}}}),i.jsxs("div",{className:"text-2xs text-text-4 font-sans mt-1",children:[Z==="fixed"&&"Uses the selected model for all tasks.",Z==="auto"&&"Groove picks Opus/Sonnet/Haiku based on task complexity.",Z==="auto-floor"&&"Auto-routes but never drops below Sonnet."]})]}),i.jsx(ha,{label:"File Scope",icon:Fr,description:"Restrict which files this agent can access. Empty = unrestricted.",children:i.jsxs("div",{className:"flex flex-wrap gap-2",children:[(t.scope||[]).map((D,ie)=>i.jsxs(We,{variant:"default",className:"font-mono text-xs gap-1.5 px-2.5 py-1",children:[D,i.jsx("button",{onClick:()=>Ae(ie),className:"hover:text-danger cursor-pointer",children:i.jsx(Rt,{size:10})})]},ie)),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("input",{value:d,onChange:D=>f(D.target.value),onKeyDown:D=>D.key==="Enter"&&te(d),placeholder:"e.g. src/**",className:"w-28 h-7 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"}),i.jsx("button",{onClick:()=>te(d),disabled:!d.trim(),className:"w-7 h-7 flex items-center justify-center rounded-md bg-surface-4 border border-border-subtle text-text-3 hover:text-accent cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(Fn,{size:12})})]})]})}),i.jsx(ha,{label:"Effort Level",icon:Pb,description:"Controls how deep the agent reasons. Higher = more tokens but better results.",children:i.jsx(FO,{options:[{value:"min",label:"Min"},{value:"low",label:"Low"},{value:"default",label:"Default"},{value:"high",label:"High"},{value:"max",label:"Max"}],value:m,onChange:fe})}),i.jsx(ha,{label:"Agent Details",icon:Hg,children:i.jsxs("div",{className:"bg-surface-0 rounded-lg border border-border-subtle divide-y divide-border-subtle",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"ID"}),i.jsx("span",{className:"text-xs text-text-1 font-mono",children:t.id})]}),i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Role"}),i.jsx("span",{className:"text-xs text-text-1 font-sans capitalize",children:t.role})]}),i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Provider"}),i.jsx("span",{className:"text-xs text-text-1 font-mono",children:t.provider})]}),i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Model"}),i.jsx("span",{className:"text-xs text-text-1 font-mono",children:t.model||"auto"})]}),i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Status"}),i.jsx("span",{className:"text-xs text-text-1 font-sans capitalize",children:t.status})]}),i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Spawned"}),i.jsx("span",{className:"text-xs text-text-1 font-sans",children:ve?Ct(ve):"—"})]}),t.sessionId&&i.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[i.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Session"}),i.jsxs("span",{className:"text-xs text-text-1 font-mono",children:[t.sessionId.slice(0,16),"..."]})]})]})}),i.jsx(ha,{label:"Skills",icon:Ub,description:"Attach installed skills to this agent's context.",children:i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[(t.skills||[]).map(D=>i.jsxs(We,{variant:"accent",className:"font-mono text-xs gap-1.5 px-2.5 py-1",children:[D,i.jsx("button",{onClick:async()=>{try{await ee.delete(`/agents/${t.id}/skills/${D}`),n("success",`Detached ${D}`)}catch(ie){n("error","Detach failed",ie.message)}},className:"hover:text-danger cursor-pointer",children:i.jsx(Rt,{size:10})})]},D)),C.filter(D=>!(t.skills||[]).includes(D.id)).length>0&&i.jsxs("div",{className:"relative group",children:[i.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md bg-surface-4 border border-border-subtle text-text-3 hover:text-accent cursor-pointer transition-colors",children:i.jsx(Fn,{size:12})}),i.jsx("div",{className:"absolute top-full left-0 mt-1 z-20 hidden group-hover:block bg-surface-2 border border-border-subtle rounded-lg shadow-xl py-1 min-w-[160px]",children:C.filter(D=>!(t.skills||[]).includes(D.id)).map(D=>i.jsx("button",{onClick:async()=>{try{await ee.post(`/agents/${t.id}/skills/${D.id}`),n("success",`Attached ${D.name||D.id}`)}catch(ie){n("error","Attach failed",ie.message)}},className:"w-full text-left px-3 py-1.5 text-xs font-sans text-text-1 hover:bg-surface-4 cursor-pointer transition-colors",children:D.name||D.id},D.id))})]}),(t.skills||[]).length===0&&C.length===0&&i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"No skills installed — browse the Marketplace"})]})}),i.jsx(ha,{label:"Schedule",icon:Bg,description:"Run this agent on a recurring schedule.",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-text-2 font-sans",children:"Every"}),i.jsx("input",{value:E,onChange:D=>se(D.target.value.replace(/\D/g,"").slice(0,3)),className:"w-12 h-7 px-2 text-xs text-center bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono focus:outline-none focus:ring-1 focus:ring-accent",placeholder:"1"}),i.jsx("div",{className:"flex bg-surface-0 rounded-lg p-0.5 border border-border-subtle",children:[{value:"min",label:"Min"},{value:"hr",label:"Hr"},{value:"day",label:"Day"},{value:"wk",label:"Wk"},{value:"mo",label:"Mo"}].map(D=>i.jsx("button",{onClick:()=>G(D.value),className:le("px-2 py-1 text-2xs font-semibold font-sans rounded-md transition-all cursor-pointer",T===D.value?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:D.label},D.value))}),i.jsxs(je,{variant:"primary",size:"sm",disabled:re||!E||parseInt(E,10)<1,onClick:async()=>{const D=parseInt(E,10);if(!D||D<1)return;const ie={min:D===1?"* * * * *":`*/${D} * * * *`,hr:D===1?"0 * * * *":`0 */${D} * * *`,day:D===1?"0 0 * * *":`0 0 */${D} * *`,wk:`0 0 * * ${D===1?"1":"*"}`,mo:`0 0 ${D===1?"1":D} * *`};ge(!0);try{await ee.post("/schedules",{name:`${t.name} schedule`,cron:ie[T],agentConfig:{role:t.role,provider:t.provider,model:t.model,scope:t.scope,workingDir:t.workingDir,prompt:t.prompt}}),n("success",`Scheduled every ${D} ${T}`)}catch(ze){n("error","Schedule failed",ze.message)}ge(!1)},className:"h-7 px-3 text-2xs gap-1",children:[i.jsx(Bg,{size:10}),re?"...":"Set"]})]})}),t.prompt&&i.jsx(ha,{label:"Original Prompt",icon:rc,children:i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3 py-3 text-xs text-text-2 font-sans leading-relaxed max-h-40 overflow-y-auto",children:t.prompt})}),i.jsx(ES,{open:x,onOpenChange:g,currentPath:t.workingDir||"/",onSelect:J})]})}const m0=[];function D_({data:t,isAlive:n,height:s=48}){const l=v.useRef(null);return v.useEffect(()=>{const o=l.current;if(!o||!t.length)return;const u=o.getContext("2d"),d=window.devicePixelRatio||1,f=o.clientWidth,m=o.clientHeight;o.width=f*d,o.height=m*d,u.scale(d,d),u.clearRect(0,0,f,m);const p=t.map(Q=>Q.v),x=Math.min(...p),b=Math.max(...p,1)-x||1;u.beginPath(),u.moveTo(0,m),t.forEach((Q,k)=>{const $=k/(t.length-1)*f,j=m-(Q.v-x)/b*(m-4)-2;u.lineTo($,j)}),u.lineTo(f,m),u.closePath();const S=u.createLinearGradient(0,0,0,m);if(S.addColorStop(0,n?"rgba(51,175,188,0.15)":"rgba(110,118,129,0.08)"),S.addColorStop(1,"rgba(0,0,0,0)"),u.fillStyle=S,u.fill(),u.beginPath(),u.strokeStyle=n?me.accent:me.text3,u.lineWidth=1.5,t.forEach((Q,k)=>{const $=k/(t.length-1)*f,j=m-(Q.v-x)/b*(m-4)-2;k===0?u.moveTo($,j):u.lineTo($,j)}),u.stroke(),t.length>1&&n){const Q=t[t.length-1],k=f-1,$=m-(Q.v-x)/b*(m-4)-2;u.beginPath(),u.arc(k,$,5,0,Math.PI*2),u.fillStyle="rgba(51,175,188,0.3)",u.fill(),u.beginPath(),u.arc(k,$,2.5,0,Math.PI*2),u.fillStyle=me.accent,u.fill()}},[t,n]),i.jsx("div",{className:"w-full rounded-lg bg-surface-0 overflow-hidden border border-border-subtle",style:{height:s},children:i.jsx("canvas",{ref:l,className:"w-full h-full"})})}function Go({icon:t,label:n,value:s,color:l,sub:o}){return i.jsxs("div",{className:"bg-surface-0 rounded-lg px-3 py-2.5 border border-border-subtle",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(t,{size:12,className:l||"text-text-3"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans uppercase tracking-wider",children:n})]}),i.jsx("div",{className:le("text-lg font-bold font-mono tabular-nums",l||"text-text-0"),children:s}),o&&i.jsx("div",{className:"text-2xs text-text-4 font-sans mt-0.5",children:o})]})}function W_({score:t}){const n=Math.min(Math.max(t,0),100);let s=me.success,l="Healthy";return n<40?(s=me.danger,l="Degraded"):n<70&&(s=me.warning,l="Fair"),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[i.jsxs("span",{className:"text-2xs text-text-3 font-sans flex items-center gap-1.5",children:[i.jsx(hT,{size:11}),"Session Health"]}),i.jsxs("span",{className:"text-xs font-bold font-mono",style:{color:s},children:[n,"/100"]})]}),i.jsx("div",{className:"h-2 bg-surface-0 rounded-full overflow-hidden border border-border-subtle",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${n}%`,background:s}})}),i.jsx("span",{className:"text-2xs font-sans mt-1 block",style:{color:s},children:l})]})}function B_(t){const n=(t||"").toLowerCase();return n.includes("edit")||n.includes("writ")?{icon:$b,color:"text-warning"}:n.includes("read")||n.includes("view")?{icon:oi,color:"text-info"}:n.includes("search")||n.includes("grep")||n.includes("glob")?{icon:ql,color:"text-purple"}:n.includes("bash")||n.includes("command")||n.includes("terminal")?{icon:ui,color:"text-orange"}:n.includes("error")||n.includes("fail")?{icon:cn,color:"text-danger"}:n.includes("spawn")||n.includes("start")?{icon:Na,color:"text-success"}:n.includes("complet")||n.includes("done")?{icon:cf,color:"text-success"}:{icon:oc,color:"text-text-4"}}function H_({agent:t}){const n=W(d=>d.tokenTimeline[t.id])||m0,s=W(d=>d.activityLog[t.id])||m0,l=t.status==="running"||t.status==="starting",o=v.useMemo(()=>{if(n.length<2)return 0;const d=n.slice(-10),f=(d[d.length-1].t-d[0].t)/6e4,m=d[d.length-1].v-d[0].v;return f>0?Math.round(m/f):0},[n]),u=v.useMemo(()=>{const d=t.contextUsage||0;let f=100;return d>90?f-=50:d>70?f-=25:d>50&&(f-=10),o>5e3?f-=15:o>3e3&&(f-=8),t.status==="crashed"&&(f=10),t.status==="completed"&&(f=95),Math.max(0,Math.min(100,f))},[t.contextUsage,t.status,o]);return i.jsxs("div",{className:"px-5 py-5 space-y-5 overflow-y-auto h-full",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Token Burn"}),l&&i.jsx("span",{className:"text-2xs text-accent font-mono animate-pulse",children:"LIVE"})]}),i.jsx(D_,{data:n,isAlive:l,height:56})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsx(Go,{icon:tT,label:"Burn Rate",value:o>0?`${ct(o)}/m`:"—",color:o>5e3?"text-danger":o>2e3?"text-warning":"text-text-0"}),i.jsx(Go,{icon:G5,label:"Cost",value:Ac(t.costUsd||0),color:"text-text-0"}),i.jsx(Go,{icon:El,label:"Rotations",value:t.rotations||"0",color:"text-text-0"}),i.jsx(Go,{icon:Na,label:"Turns",value:t.turns||"0",color:"text-text-0"})]}),i.jsx(W_,{score:u}),t.prompt&&i.jsxs("div",{children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider block mb-1.5",children:"Task"}),i.jsx("div",{className:"bg-surface-0 rounded-lg px-3 py-2.5 text-xs text-text-2 font-sans leading-relaxed max-h-28 overflow-y-auto border border-border-subtle",children:t.prompt})]}),s.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider block mb-2",children:"Activity"}),i.jsxs("div",{className:"space-y-0 relative",children:[i.jsx("div",{className:"absolute left-[9px] top-2 bottom-2 w-px bg-border-subtle"}),s.slice(-12).reverse().map((d,f)=>{const m=B_(d.text),p=m.icon;return i.jsxs("div",{className:"flex items-start gap-3 py-1.5 relative",children:[i.jsx("div",{className:le("w-[18px] h-[18px] rounded-full flex items-center justify-center flex-shrink-0 z-10","bg-surface-1 border border-border-subtle"),children:i.jsx(p,{size:9,className:m.color})}),i.jsx("span",{className:"text-2xs text-text-2 font-sans flex-1 line-clamp-1 pt-0.5",children:d.text}),i.jsx("span",{className:"text-2xs text-text-4 font-mono flex-shrink-0 pt-0.5",children:Ct(d.timestamp)})]},f)})]})]})]})}function I_({agent:t}){const n=W(P=>P.addToast),[s,l]=v.useState([]),[o,u]=v.useState(""),[d,f]=v.useState(null),[m,p]=v.useState(""),[x,g]=v.useState(""),[b,S]=v.useState(!1);async function Q(){try{const P=await ee.get(`/agents/${t.id}/mdfiles`);l(P.files||[]),u(P.workingDir||"")}catch{}}v.useEffect(()=>{Q()},[t.id]);async function k(P){try{const N=await ee.get(`/agents/${t.id}/mdfiles/read?path=${encodeURIComponent(P)}`);p(N.content||""),g(N.content||""),f(P)}catch(N){n("error","Failed to read file",N.message)}}async function $(){if(d){S(!0);try{await ee.put(`/agents/${t.id}/mdfiles/write`,{path:d,content:m}),g(m),n("success",`Saved ${d}`)}catch(P){n("error","Save failed",P.message)}S(!1)}}const j=m!==x;return d?i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle",children:[i.jsx("button",{onClick:()=>{f(null),p(""),g("")},className:"p-1 text-text-3 hover:text-text-0 cursor-pointer",children:i.jsx(kb,{size:14})}),i.jsx(Dn,{size:12,className:"text-accent"}),i.jsx("span",{className:"text-xs text-text-0 font-sans font-medium flex-1 truncate",children:d}),j&&i.jsx("span",{className:"text-[10px] text-warning font-sans",children:"unsaved"}),i.jsxs("button",{onClick:$,disabled:!j||b,className:le("flex items-center gap-1 px-2.5 py-1 rounded text-2xs font-sans font-medium cursor-pointer transition-colors",j?"bg-accent/15 text-accent hover:bg-accent/25":"text-text-4 opacity-50 cursor-not-allowed"),children:[i.jsx(WT,{size:10}),b?"Saving...":"Save"]})]}),i.jsx("textarea",{value:m,onChange:P=>p(P.target.value),className:"flex-1 w-full px-4 py-3 bg-surface-0 text-[12px] font-mono text-text-1 leading-relaxed resize-none focus:outline-none",spellCheck:!1})]}):i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border-subtle",children:[i.jsx(Dn,{size:12,className:"text-text-3"}),i.jsx("span",{className:"text-2xs font-semibold text-text-2 font-sans uppercase tracking-wider flex-1",children:"Markdown Files"}),i.jsx("button",{onClick:Q,className:"p-1 text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(es,{size:11})})]}),o&&i.jsx("div",{className:"px-4 py-1.5 text-[10px] text-text-4 font-mono truncate border-b border-border-subtle/50",children:o}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:s.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-4",children:[i.jsx(Dn,{size:20,className:"text-text-4 mb-2"}),i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No markdown files found"}),i.jsx("p",{className:"text-[10px] text-text-4 font-sans mt-1",children:"MD files in the agent's working directory will appear here"})]}):i.jsx("div",{className:"py-1",children:s.map(P=>i.jsxs("button",{onClick:()=>k(P.path),className:"w-full flex items-center gap-2.5 px-4 py-2 text-left hover:bg-surface-5 transition-colors cursor-pointer",children:[i.jsx(Dn,{size:13,className:"text-accent flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("span",{className:"text-xs text-text-0 font-sans block truncate",children:P.name}),i.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:P.path})]}),i.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:P.size>1024?`${(P.size/1024).toFixed(1)}K`:`${P.size}B`})]},P.path))})})]})}const F_={running:"success",starting:"warning",stopped:"default",crashed:"danger",completed:"accent",killed:"default",rotating:"purple"},K_={running:"Running",starting:"Starting",stopped:"Stopped",crashed:"Crashed",completed:"Done",killed:"Killed",rotating:"Rotating"},J_=[{id:"command",label:"Chat",icon:ci},{id:"config",label:"Config",icon:Mb},{id:"telemetry",label:"Monitor",icon:rc},{id:"mdfiles",label:"Files",icon:Dn}];function eZ({agent:t}){const n=W(m=>m.addToast),[s,l]=v.useState(!1),[o,u]=v.useState(t.name),d=v.useRef(null);async function f(){const m=o.trim();if(!m||m===t.name){l(!1);return}try{await ee.patch(`/agents/${t.id}`,{name:m.replace(/\s+/g,"-")}),n("success",`Renamed → ${m}`)}catch(p){n("error","Rename failed",p.message),u(t.name)}l(!1)}return s?i.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[i.jsx("input",{ref:d,value:o,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&f(),m.key==="Escape"&&(u(t.name),l(!1))},className:"flex-1 min-w-0 h-6 px-1.5 text-sm font-bold bg-surface-0 border border-accent/30 rounded text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent/40",autoFocus:!0}),i.jsx("button",{onClick:f,className:"p-0.5 text-accent hover:text-accent/80 cursor-pointer",children:i.jsx(oa,{size:12})}),i.jsx("button",{onClick:()=>{u(t.name),l(!1)},className:"p-0.5 text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(Rt,{size:12})})]}):i.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 group",children:[i.jsx("h2",{className:"text-sm font-bold text-text-0 font-sans truncate",children:t.name}),i.jsx("button",{onClick:()=>{u(t.name),l(!0)},className:"p-0.5 text-text-4 opacity-0 group-hover:opacity-100 hover:text-text-1 cursor-pointer transition-opacity",children:i.jsx(Cc,{size:10})})]})}function tZ(){const t=W(p=>p.detailPanel),n=W(p=>p.agents),[s,l]=v.useState("command");if((t==null?void 0:t.type)!=="agent")return null;const o=n.find(p=>p.id===t.agentId);if(!o)return null;const u=o.status==="running"||o.status==="starting",d=Math.round((o.contextUsage||0)*100),f=o.spawnedAt||o.createdAt,m=f?Math.floor((Date.now()-new Date(f).getTime())/1e3):0;return Db(o.role),i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"pl-4 pr-10 pt-3 pb-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(eZ,{agent:o}),i.jsx(We,{variant:F_[o.status]||"default",dot:u?"pulse":void 0,className:"text-2xs flex-shrink-0",children:K_[o.status]||o.status})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 text-2xs text-text-3 font-mono",children:[i.jsx("span",{className:"capitalize",children:o.role}),i.jsx("span",{className:"text-text-4",children:"·"}),i.jsxs("span",{children:[o.provider,":",o.model||"auto"]}),i.jsx("span",{className:"text-text-4",children:"·"}),i.jsxs("span",{children:[ct(o.tokensUsed||0)," tok"]}),d>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-4",children:"·"}),i.jsxs("span",{className:le(d>80?"text-danger":d>60?"text-warning":"text-text-3"),children:[d,"% ctx"]})]}),i.jsx("span",{className:"text-text-4",children:"·"}),i.jsx("span",{children:Ec(m)})]})]}),i.jsx("div",{className:"flex items-center px-4 border-b border-border-subtle",children:J_.map(p=>{const x=p.icon,g=s===p.id;return i.jsxs("button",{onClick:()=>l(p.id),className:le("flex items-center gap-1.5 px-3 py-2 text-2xs font-semibold font-sans transition-all cursor-pointer select-none border-b-2 -mb-px",g?"border-accent text-text-0":"border-transparent text-text-3 hover:text-text-1"),children:[i.jsx(x,{size:11}),p.label]},p.id)})})]}),i.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[s==="command"&&i.jsx(U_,{agent:o}),s==="config"&&i.jsx(L_,{agent:o}),s==="telemetry"&&i.jsx(H_,{agent:o}),s==="mdfiles"&&i.jsx(I_,{agent:o})]})]})}const wf=v.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("input",{ref:u,className:le("h-8 w-full rounded-md px-3 text-sm","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));wf.displayName="Input";const US=v.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("textarea",{ref:u,className:le("w-full rounded-md px-3 py-2 text-sm resize-none","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));US.displayName="Textarea";const aZ=[{id:"planner",label:"Planner",desc:"Plans the team and tasks",icon:Eb,tier:"Heavy"},{id:"backend",label:"Backend",desc:"APIs, services, databases",icon:qb,tier:"Medium"},{id:"frontend",label:"Frontend",desc:"UI, components, styling",icon:Wf,tier:"Medium"},{id:"fullstack",label:"Fullstack",desc:"End-to-end implementation",icon:dn,tier:"Heavy"},{id:"testing",label:"Testing",desc:"Tests, coverage, QA",icon:If,tier:"Medium"},{id:"devops",label:"DevOps",desc:"CI/CD, infra, deployment",icon:A5,tier:"Medium"},{id:"docs",label:"Docs",desc:"Documentation, guides",icon:Dn,tier:"Light"},{id:"security",label:"Security",desc:"Audits, vulnerabilities",icon:Fr,tier:"Medium"},{id:"database",label:"Database",desc:"Schema, migrations, queries",icon:V5,tier:"Medium"},{id:"cmo",label:"CMO",desc:"Marketing, content, growth",icon:TT,tier:"Medium"},{id:"cfo",label:"CFO",desc:"Finance, metrics, forecasting",icon:S5,tier:"Medium"},{id:"ea",label:"EA",desc:"Executive assistant, scheduling",icon:fP,tier:"Light"},{id:"support",label:"Support",desc:"Customer support, FAQs",icon:OT,tier:"Medium"},{id:"analyst",label:"Analyst",desc:"Data analysis, insights",icon:Rc,tier:"Medium"}];function nZ(){const t=W(E=>E.detailPanel),n=W(E=>E.closeDetail),s=W(E=>E.spawnAgent),l=W(E=>E.fetchProviders),o=(t==null?void 0:t.type)==="spawn",[u,d]=v.useState(""),[f,m]=v.useState(""),[p,x]=v.useState(""),[g,b]=v.useState(""),[S,Q]=v.useState(""),[k,$]=v.useState(""),[j,P]=v.useState([]),[N,Z]=v.useState(!1);v.useEffect(()=>{o&&(l().then(E=>{P(Array.isArray(E)?E:E.providers||[])}).catch(()=>{}),d(""),m(""),x(""),b(""),Q(""),$(""))},[o,l]);const U=u||f,C=j.find(E=>E.id===g),X=(C==null?void 0:C.models)||[],T=j.filter(E=>E.installed);async function G(){if(U){Z(!0);try{const E={role:U,...p&&{name:p.replace(/\s+/g,"-")},...g&&{provider:g},...S&&{model:S},...k&&{prompt:k}};await s(E),n()}catch{}Z(!1)}}return i.jsx(qS,{open:o,onOpenChange:E=>{E||n()},children:i.jsx(MS,{title:"Spawn Agent",width:480,children:i.jsxs("div",{className:"flex flex-col h-[calc(100%-57px)]",children:[i.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-6",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider block mb-3",children:"Choose Role"}),i.jsx("div",{className:"grid grid-cols-2 gap-2",children:aZ.map(E=>{const se=Db(E.id),re=u===E.id;return i.jsxs("button",{onClick:()=>{d(E.id),m("")},className:le("flex items-center gap-2.5 p-3 rounded-md border text-left transition-all cursor-pointer",re?"border-accent bg-accent/5":"border-border-subtle bg-surface-1 hover:border-border hover:bg-surface-2"),children:[i.jsx("div",{className:"w-8 h-8 rounded-md flex items-center justify-center flex-shrink-0",style:{background:se.bg},children:i.jsx(E.icon,{size:16,style:{color:se.text}})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans",children:E.label}),i.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:E.desc})]})]},E.id)})}),i.jsx("div",{className:"mt-3",children:i.jsx(wf,{placeholder:"or type a custom role...",value:f,onChange:E=>{m(E.target.value),d("")},className:"text-xs"})})]}),U&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("label",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider block",children:"Configuration"}),i.jsx(wf,{label:"Name (optional)",value:p,onChange:E=>x(E.target.value),placeholder:`${U}-1`}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Provider"}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:g,onChange:E=>{b(E.target.value),Q("")},className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent",children:[i.jsx("option",{value:"",children:"Auto"}),T.map(E=>i.jsx("option",{value:E.id,children:E.name},E.id))]}),i.jsx(In,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Model"}),i.jsxs("div",{className:"relative",children:[i.jsxs("select",{value:S,onChange:E=>Q(E.target.value),disabled:!g,className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-40",children:[i.jsx("option",{value:"",children:"Auto"}),X.map(E=>i.jsx("option",{value:E.id,children:E.name},E.id))]}),i.jsx(In,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]})]})]}),g&&C&&i.jsx("div",{className:"text-2xs text-text-3 font-sans flex items-center gap-2",children:C.hasKey?i.jsx(We,{variant:"success",children:"API key set"}):C.authType==="subscription"?i.jsx(We,{variant:"accent",children:"Subscription"}):i.jsxs(We,{variant:"warning",children:["No API key — set with: groove set-key ",g," YOUR_KEY"]})}),i.jsx(US,{label:"Prompt (optional)",value:k,onChange:E=>$(E.target.value),placeholder:"What should this agent work on?",rows:3})]})]}),i.jsxs("div",{className:"border-t border-border-subtle px-5 py-4 bg-surface-1",children:[U&&i.jsxs("div",{className:"flex items-center gap-2 mb-3 text-xs text-text-3 font-sans",children:[i.jsx("span",{children:"Spawning"}),i.jsx(We,{variant:"accent",children:U}),g&&i.jsxs("span",{children:["on ",(C==null?void 0:C.name)||g]}),p&&i.jsxs("span",{children:["as ",p.replace(/\s+/g,"-")]})]}),i.jsx(je,{variant:"primary",size:"lg",onClick:G,disabled:!U||N,className:"w-full",children:N?"Spawning...":"Spawn Agent"})]})]})})})}function p0({title:t,icon:n,defaultOpen:s=!1,badge:l,children:o,className:u}){const[d,f]=v.useState(s);return i.jsxs("div",{className:le("border-t border-border-subtle",u),children:[i.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center gap-2 px-5 py-3 text-left cursor-pointer hover:bg-surface-5/30 transition-colors group",children:[i.jsx(ii,{size:12,className:le("text-text-4 transition-transform duration-200 flex-shrink-0",d&&"rotate-90")}),n&&i.jsx(n,{size:13,className:"text-text-3 flex-shrink-0"}),i.jsx("span",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider flex-1",children:t}),l&&i.jsx("span",{className:"text-2xs font-mono text-text-4 bg-surface-4 px-1.5 py-0.5 rounded",children:l})]}),d&&i.jsx("div",{className:"px-5 pb-4",children:o})]})}function sZ(){const t=W(g=>g.journalistStatus),n=W(g=>g.fetchJournalist),s=W(g=>g.triggerJournalistCycle),[l,o]=v.useState(!0),[u,d]=v.useState(!1);v.useEffect(()=>{n().then(()=>o(!1));const g=setInterval(n,1e4);return()=>clearInterval(g)},[n]);async function f(){d(!0);try{await s()}catch{}d(!1)}if(l)return i.jsxs("div",{className:"p-5 space-y-4",children:[i.jsx(Nt,{className:"h-6 w-32 rounded"}),i.jsx(Nt,{className:"h-20 rounded-md"}),i.jsx(Nt,{className:"h-20 rounded-md"})]});const m=t||{},p=m.lastSynthesis,x=m.history||[];return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle flex items-center gap-2",children:[i.jsx(Ir,{size:16,className:"text-accent"}),i.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans flex-1",children:"Journalist"}),i.jsxs(je,{variant:"secondary",size:"sm",onClick:f,disabled:u,className:"gap-1.5 text-2xs",children:[i.jsx(es,{size:11,className:u?"animate-spin":""}),u?"Running...":"Run Synthesis"]})]}),i.jsx(Ht,{className:"flex-1",children:i.jsxs("div",{className:"px-5 py-4 space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3 text-2xs text-text-3 font-sans",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(rc,{size:10}),i.jsxs("span",{children:[m.cycleCount||0," cycles"]})]}),m.lastCycleTime&&i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(oc,{size:10}),i.jsxs("span",{children:["Last: ",Ct(m.lastCycleTime)]})]}),i.jsx(We,{variant:m.cycleCount>0?"success":"default",className:"text-2xs",children:m.cycleCount>0?"Active":"Idle"})]}),(p==null?void 0:p.summary)&&i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"text-xs font-semibold text-text-1 font-sans flex items-center gap-1.5",children:[i.jsx(Dn,{size:12,className:"text-text-3"}),"Latest Summary"]}),i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3 text-xs text-text-2 font-sans leading-relaxed",children:p.summary})]}),(p==null?void 0:p.projectMap)&&i.jsx(p0,{title:"Project Map",icon:jT,children:i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3 text-xs text-text-2 font-mono leading-relaxed max-h-64 overflow-y-auto whitespace-pre-wrap",children:p.projectMap})}),(p==null?void 0:p.decisions)&&i.jsx(p0,{title:"Decisions Log",icon:Dn,children:i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3 text-xs text-text-2 font-mono leading-relaxed max-h-64 overflow-y-auto whitespace-pre-wrap",children:p.decisions})}),x.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"text-xs font-semibold text-text-1 font-sans flex items-center gap-1.5",children:[i.jsx(oc,{size:12,className:"text-text-3"}),"History (",x.length,")"]}),i.jsx("div",{className:"space-y-1.5",children:x.slice().reverse().slice(0,20).map((g,b)=>i.jsxs("div",{className:"bg-surface-0 rounded-md border border-border-subtle px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[i.jsxs(We,{variant:"default",className:"text-2xs",children:["Cycle ",g.cycle]}),i.jsxs("span",{className:"text-text-4 font-sans",children:[g.agentCount," agent",g.agentCount!==1?"s":""]}),i.jsx("span",{className:"text-text-4 font-sans ml-auto",children:Ct(g.timestamp)})]}),g.summary&&i.jsx("p",{className:"text-xs text-text-2 font-sans mt-1 leading-relaxed",children:g.summary})]},b))})]}),!p&&x.length===0&&i.jsxs("div",{className:"text-center py-8 text-text-4 font-sans",children:[i.jsx(Ir,{size:28,className:"mx-auto mb-2"}),i.jsx("p",{className:"text-sm",children:"No synthesis data yet"}),i.jsx("p",{className:"text-2xs mt-1",children:"The journalist runs automatically when agents are active, or trigger manually above"})]})]})})]})}function lZ({children:t,height:n,onHeightChange:s,visible:l,fullHeight:o,tabs:u,activeTab:d,onSelectTab:f,onAddTab:m,onCloseTab:p,onToggleFullHeight:x,onMinimize:g}){const b=v.useRef(!1),S=v.useRef(0),Q=v.useRef(0),k=v.useCallback(j=>{if(o)return;j.preventDefault(),b.current=!0,S.current=j.clientY,Q.current=n;function P(Z){if(!b.current)return;const U=S.current-Z.clientY,C=Math.min(Math.max(Q.current+U,120),600);s(C)}function N(){b.current=!1,document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",N)}document.addEventListener("mousemove",P),document.addEventListener("mouseup",N)},[n,s,o]);if(!l)return null;const $=u||[{id:"default",label:"Terminal"}];return i.jsxs("div",{className:"flex flex-col border-t border-border bg-surface-0 relative",style:o?{flex:1,minHeight:0}:{height:n,flexShrink:0},children:[!o&&i.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 cursor-row-resize hover:bg-accent/30 transition-colors z-10",onMouseDown:k}),i.jsxs("div",{className:"flex items-center h-9 bg-surface-1 border-b border-border-subtle flex-shrink-0 pl-3 pr-1.5",children:[i.jsxs("div",{className:"flex items-center gap-0 flex-1 min-w-0 overflow-x-auto scrollbar-none",children:[$.map(j=>i.jsxs("button",{onClick:()=>f==null?void 0:f(j.id),className:le("flex items-center gap-1.5 pl-2.5 pr-1 h-7 text-2xs font-sans cursor-pointer select-none transition-colors flex-shrink-0 rounded-t",j.id===d?"text-text-0 bg-surface-0":"text-text-3 hover:text-text-1 hover:bg-surface-0/50"),children:[i.jsx(ui,{size:10}),i.jsx("span",{className:"truncate max-w-[80px]",children:j.label}),$.length>1&&i.jsx("button",{onClick:P=>{P.stopPropagation(),p==null||p(j.id)},className:"ml-0.5 p-0.5 rounded hover:bg-surface-5 text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(Rt,{size:9})})]},j.id)),i.jsx("button",{onClick:m,className:"flex items-center justify-center w-6 h-6 text-text-4 hover:text-text-1 hover:bg-surface-0/50 rounded cursor-pointer transition-colors flex-shrink-0 ml-0.5",title:"New terminal",children:i.jsx(Fn,{size:11})})]}),i.jsx("div",{className:"flex items-center gap-0.5 flex-shrink-0 ml-2",children:o?i.jsx("button",{onClick:g,className:"p-1.5 rounded text-text-3 hover:text-text-0 hover:bg-surface-5 cursor-pointer transition-colors",title:"Restore",children:i.jsx(RT,{size:12})}):i.jsx("button",{onClick:x,className:"p-1.5 rounded text-text-3 hover:text-text-0 hover:bg-surface-5 cursor-pointer transition-colors",title:"Maximize",children:i.jsx(kT,{size:12})})})]}),i.jsx("div",{className:"flex-1 min-h-0 p-2",children:t})]})}const rZ={background:"#1a1e25",foreground:"#bcc2cd",cursor:"#33afbc",cursorAccent:"#1a1e25",selectionBackground:"rgba(51, 175, 188, 0.25)",black:"#1a1e25",red:"#e06c75",green:"#4ae168",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#33afbc",white:"#bcc2cd",brightBlack:"#505862",brightRed:"#e06c75",brightGreen:"#4ae168",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#33afbc",brightWhite:"#e6e6e6"};let KO=0;function iZ({tabId:t,visible:n}){const s=v.useRef(null),l=v.useRef(null),o=v.useRef(null),u=v.useRef(null),d=v.useRef(!1);return v.useEffect(()=>{if(!s.current||d.current)return;d.current=!0;const f=new Lj({theme:rZ,fontFamily:"'JetBrains Mono Variable', 'SF Mono', monospace",fontSize:13,lineHeight:1.4,cursorBlink:!0,cursorStyle:"bar",scrollback:5e3,allowProposedApi:!0}),m=new Dj;f.loadAddon(m),f.loadAddon(new Wj),f.open(s.current),l.current=f,requestAnimationFrame(()=>m.fit());function p(){const g=W.getState().ws;if(!g||g.readyState!==WebSocket.OPEN){setTimeout(p,500);return}g.send(JSON.stringify({type:"terminal:spawn",cols:f.cols,rows:f.rows}));function b(S){let Q;try{Q=JSON.parse(S.data)}catch{return}Q.type==="terminal:spawned"&&!o.current?o.current=Q.id:Q.type==="terminal:output"&&Q.id===o.current?f.write(Q.data):Q.type==="terminal:exit"&&Q.id===o.current&&(f.write(`\r
586
586
  \x1B[90m[session ended]\x1B[0m\r
587
587
  `),o.current=null)}g.addEventListener("message",b),u.current={ws:g,handler:b},f.onData(S=>{const Q=W.getState().ws;(Q==null?void 0:Q.readyState)===WebSocket.OPEN&&o.current&&Q.send(JSON.stringify({type:"terminal:input",id:o.current,data:S}))}),f.onResize(({cols:S,rows:Q})=>{const k=W.getState().ws;(k==null?void 0:k.readyState)===WebSocket.OPEN&&o.current&&k.send(JSON.stringify({type:"terminal:resize",id:o.current,rows:Q,cols:S}))})}p();const x=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{m.fit()}catch{}})});return x.observe(s.current),()=>{x.disconnect();const g=W.getState().ws;(g==null?void 0:g.readyState)===WebSocket.OPEN&&o.current&&g.send(JSON.stringify({type:"terminal:kill",id:o.current})),u.current&&u.current.ws.removeEventListener("message",u.current.handler),f.dispose(),d.current=!1}},[]),v.useEffect(()=>{n&&l.current&&requestAnimationFrame(()=>{var f,m,p,x,g;try{(g=(x=(p=(m=(f=l.current._addonManager)==null?void 0:f._addons)==null?void 0:m[0])==null?void 0:p.instance)==null?void 0:x.fit)==null||g.call(x)}catch{}})},[n]),i.jsx("div",{ref:s,className:"w-full h-full",style:{display:n?"block":"none"}})}function oZ(){const t=W(b=>b.terminalVisible),n=W(b=>b.terminalHeight),s=W(b=>b.setTerminalVisible),l=W(b=>b.setTerminalHeight),o=W(b=>b.terminalFullHeight),u=W(b=>b.setTerminalFullHeight),[d,f]=v.useState([{id:"term-0",label:"Terminal"}]),[m,p]=v.useState("term-0"),x=v.useCallback(()=>{KO++;const b=`term-${KO}`;f(S=>[...S,{id:b,label:`Terminal ${KO+1}`}]),p(b)},[]),g=v.useCallback(b=>{f(S=>{const Q=S.filter(k=>k.id!==b);if(Q.length===0)return s(!1),S;if(m===b){const k=S.findIndex(j=>j.id===b),$=Q[Math.min(k,Q.length-1)];p($.id)}return Q})},[m,s]);return i.jsx(lZ,{visible:t,height:n,onHeightChange:l,fullHeight:o,tabs:d,activeTab:m,onSelectTab:p,onAddTab:x,onCloseTab:g,onToggleFullHeight:()=>u(!0),onMinimize:()=>u(!1),children:d.map(b=>i.jsx(iZ,{tabId:b.id,visible:b.id===m},b.id))})}class cZ extends Vn.Component{constructor(n){super(n),this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}render(){return this.state.error?i.jsxs("div",{className:"h-screen bg-surface-0 p-10 font-sans",children:[i.jsx("h2",{className:"text-lg font-semibold text-text-0 mb-4",children:"Groove — Render Error"}),i.jsx("pre",{className:"text-sm text-danger whitespace-pre-wrap mb-4",children:this.state.error.message}),i.jsx("pre",{className:"text-xs text-text-3 whitespace-pre-wrap",children:this.state.error.stack}),i.jsx("button",{onClick:()=>this.setState({error:null}),className:"mt-6 px-4 py-2 bg-accent text-surface-0 rounded-md font-medium text-sm cursor-pointer",children:"Try Again"})]}):this.props.children}}function uZ(){const t=W(o=>o.activeView),n=W(o=>o.detailPanel);let s;switch(t){case"agents":s=i.jsx(e1,{});break;case"editor":s=i.jsx(nC,{});break;case"dashboard":s=i.jsx(YC,{});break;case"marketplace":s=i.jsx(lX,{});break;case"teams":s=i.jsx(uX,{});break;case"settings":s=i.jsx(C_,{});break;default:s=i.jsx(e1,{})}let l=null;if(n)switch(n.type){case"agent":l=i.jsx(tZ,{});break;case"journalist":l=i.jsx(sZ,{});break;case"spawn":l=null;break}return i.jsxs(qP,{detailContent:l,terminalContent:i.jsx(oZ,{}),children:[s,i.jsx(nZ,{})]})}function dZ(){return i.jsxs("div",{className:"h-screen bg-surface-0 flex flex-col items-center justify-center gap-4",children:[i.jsx("img",{src:"/favicon.png",alt:"",className:"w-10 h-10 opacity-60 animate-pulse"}),i.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Connecting..."})]})}function OZ(){const t=W(s=>s.connect),n=W(s=>s.hydrated);return v.useEffect(()=>{t()},[t]),n?i.jsx(cZ,{children:i.jsx(uZ,{})}):i.jsx(dZ,{})}Kj.createRoot(document.getElementById("root")).render(i.jsx(v.StrictMode,{children:i.jsx(OZ,{})}));