import{g as ut,a as w,R as P,j as e,M as xe,b as me,d as he}from"./markdown-mWYlERSe.js";import{r as xt,c as mt,u as ht,H,P as q,a as gt,b as wt,R as bt,B as ft,d as yt,C as jt,M as kt,e as Nt}from"./flow-BL2FLl3r.js";import{h as se}from"./syntax-D2WVBaLZ.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&n(c)}).observe(document,{childList:!0,subtree:!0});function s(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=s(a);fetch(a.href,o)}})();var ce={},ze;function vt(){if(ze)return ce;ze=1;var t=xt();return ce.createRoot=t.createRoot,ce.hydrateRoot=t.hydrateRoot,ce}var Ct=vt();const St=ut(Ct);function Ze(t){var r,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(r=0;r<a;r++)t[r]&&(s=Ze(t[r]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}function y(){for(var t,r,s=0,n="",a=arguments.length;s<a;s++)(t=arguments[s])&&(r=Ze(t))&&(n&&(n+=" "),n+=r);return n}/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _t=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Xe=(...t)=>t.filter((r,s,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===s).join(" ").trim();/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */var Mt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Et=w.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:c,...i},l)=>w.createElement("svg",{ref:l,...Mt,width:r,height:r,stroke:t,strokeWidth:n?Number(s)*24/Number(r):s,className:Xe("lucide",a),...i},[...c.map(([u,x])=>w.createElement(u,x)),...Array.isArray(o)?o:[o]]));/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const N=(t,r)=>{const s=w.forwardRef(({className:n,...a},o)=>w.createElement(Et,{ref:o,iconNode:r,className:Xe(`lucide-${_t(t)}`,n),...a}));return s.displayName=`${t}`,s};/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Tt=N("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qe=N("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _e=N("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const et=N("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Me=N("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ee=N("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Te=N("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ge=N("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ot=N("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Oe=N("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Re=N("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ie=N("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Rt=N("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const It=N("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $e=N("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ue=N("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ae=N("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const tt=N("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ve=N("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const we=N("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $t=N("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const At=N("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ft=N("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Pt=N("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Dt=N("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Bt=N("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const st=N("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Lt=N("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Fe=N("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oe=N("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const at=N("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const zt=N("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Wt=N("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ht=N("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Pe=N("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qt=N("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const De=N("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Gt=N("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const be=N("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vt=N("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ut=N("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const We=N("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fe=N("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Jt=N("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Kt=N("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Y=N("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const le=N("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Be=N("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ae={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}},rt={},{useDebugValue:Yt}=P,{useSyncExternalStoreWithSelector:Zt}=ht;let He=!1;const Xt=t=>t;function Qt(t,r=Xt,s){(rt?"production":void 0)!=="production"&&s&&!He&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),He=!0);const n=Zt(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,s);return Yt(n),n}const qe=t=>{(rt?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const r=typeof t=="function"?mt(t):t,s=(n,a)=>Qt(r,n,a);return Object.assign(s,r),s},es=t=>t?qe(t):qe;function ts(){return window.location.origin}const Le=ts();async function O(t,r={}){const s=`${Le}${t}`,n={"Content-Type":"application/json",...r.headers},a=await fetch(s,{...r,headers:n});if(!a.ok){let o=a.statusText;try{const c=await a.json();o=c.detail??c.message??JSON.stringify(c)}catch{}throw new Error(`API ${a.status}: ${o}`)}if(a.status!==204)return a.json()}async function ss(t){return O("/api/runs/preflight",{method:"POST",body:JSON.stringify(t)})}async function as(t){return O("/api/runs",{method:"POST",body:JSON.stringify(t)})}async function rs(){return(await O("/api/runs")).runs}async function ns(t){return O(`/api/runs/${t}/graph`)}async function os(t){return O(`/api/runs/${t}/stop`,{method:"POST"})}async function ls(t){return(await O(`/api/runs/${t}/artifacts`)).artifacts}function is(t){return`${Le}/api/files/serve?path=${encodeURIComponent(t)}`}async function nt(t){return O("/api/open-directory",{method:"POST",body:JSON.stringify({path:t})})}async function cs(t){const r=new FormData;for(const n of t)r.append("files",n);const s=await fetch(`${Le}/api/upload`,{method:"POST",body:r});if(!s.ok)throw new Error(`Upload failed: ${s.statusText}`);return s.json()}async function Ge(t,r){return O("/api/sessions",{method:"POST",body:JSON.stringify({title:t,...r})})}async function Ve(){return(await O("/api/sessions")).sessions}async function je(t){return O(`/api/sessions/${t}`)}async function Ce(t,r){return O(`/api/sessions/${t}`,{method:"PUT",body:JSON.stringify(r)})}async function ds(t){return O(`/api/sessions/${t}`,{method:"DELETE"})}async function ps(t){return(await O(`/api/sessions/${t}/history`)).history}async function us(t){return O(`/api/sessions/${t}/full`)}async function xs(t,r){return O(`/api/sessions/${t}/runs`,{method:"POST",body:JSON.stringify(r)})}async function ms(t){return(await O(`/api/sessions/${t}/memory`)).memory}async function ot(t,r){return O(`/api/sessions/${t}/memory`,{method:"POST",body:JSON.stringify(r)})}async function hs(t,r,s){return O(`/api/sessions/${t}/memory/${r}`,{method:"PUT",body:JSON.stringify({content:s})})}async function gs(t,r){return O(`/api/sessions/${t}/memory/${r}`,{method:"DELETE"})}async function Ue(){return(await O("/api/secrets")).secrets}async function ws(t,r){return O("/api/secrets",{method:"POST",body:JSON.stringify({key:t,value:r})})}async function bs(t){return O(`/api/secrets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function fs(t){return O("/api/settings",{method:"POST",body:JSON.stringify(t)})}async function ys(){try{return await O("/api/settings")}catch{return null}}function js(t){const r=window.location.protocol==="https:"?"wss:":"ws:",s=window.location.host;return`${r}//${s}/ws/${t}`}function ks(t,r,s={}){const{maxRetries:n=8,baseDelay:a=500,onStateChange:o}=s;let c=null,i=0,l=!1,u=null;function x(){const m=js(t);c=new WebSocket(m),o==null||o("connecting"),c.onopen=()=>{i=0,o==null||o("open")},c.onmessage=h=>{try{const d=JSON.parse(h.data);r(d)}catch{}},c.onerror=()=>{o==null||o("error")},c.onclose=()=>{if(o==null||o("closed"),!l&&i<n){const h=a*Math.pow(2,i);i+=1,u=setTimeout(x,h)}}}return x(),{close(){l=!0,u&&(clearTimeout(u),u=null),c==null||c.close()},send(m){(c==null?void 0:c.readyState)===WebSocket.OPEN&&c.send(typeof m=="string"?m:JSON.stringify(m))},readyState(){return(c==null?void 0:c.readyState)??WebSocket.CLOSED}}}const lt=["report_content","report","answer","your","result","output","response","summary","analysis"];function Ns(t){const r=t.result;if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r,a=n.delegation_loop;if(a&&typeof a=="object"&&!Array.isArray(a)){const i=a.final_result;return i&&typeof i=="object"&&!Array.isArray(i)?i:a}const o=n.final_result;if(o&&typeof o=="object"&&!Array.isArray(o))return o;if(lt.some(i=>i in n&&typeof n[i]=="string"))return n}const s=t.final_result;return s&&typeof s=="object"&&!Array.isArray(s)?s:t}function it(t,r){if(typeof t=="string")return[{type:"markdown",content:t,title:r}];if(t==null||typeof t!="object"||Array.isArray(t))return[{type:"json",content:JSON.stringify(t,null,2),title:r}];const s=Ns(t),n=typeof s.confidence=="number"?s.confidence:void 0;let a,o;for(const u of lt)if(u in s&&typeof s[u]=="string"&&s[u].length>0){a=s[u],o=u;break}if(!a){for(const[u,x]of Object.entries(s))if(u!=="confidence"&&typeof x=="string"&&x.length>20){a=x,o=u;break}}if(!a)return[{type:"json",content:JSON.stringify(s,null,2),title:r}];const c=n!==void 0?`

---
**Confidence:** ${(n*100).toFixed(0)}%`:"",i=Object.keys(s).filter(u=>u!==o&&u!=="confidence"),l=[];if(i.length>0){const u={};for(const m of i)u[m]=s[m];i.some(m=>{const h=s[m];return Array.isArray(h)?h.length>0:typeof h=="object"&&h!==null?Object.keys(h).length>0:h!=null&&h!==""})&&l.push({type:"json",content:JSON.stringify(u,null,2),title:"Additional Data"})}return[{type:"markdown",content:a+c,title:r},...l]}const vs={task:"",model:"nvidia/nemotron-3-super-120b-a12b:free",worker_model:void 0,api_key:void 0,max_loops:100,max_total_tokens:1e7,max_wall_time:600,max_tool_calls:250,max_total_workers:500,max_depth:10,sandbox:"subprocess",packages:[],code_mode:!0,tool_creation:!0,tools:[],forbidden_tools:[],verbose:!1,output_dir:"",input_files:[],skills_dir:""},de={loops_used:0,loops_max:100,tokens_used:0,tokens_max:1e7,workers_used:0,workers_max:500,wall_time_ms:0,wall_time_max_ms:6e5,tool_calls_used:0,tool_calls_max:250};function te(t){const r=t.data;return r.node_id??r.agent_id??r.worker_id??t.type+"-"+t.timestamp}function Cs(t,r,s){var c;const n=r().config.verbose,a=r(),o=()=>{const i=a.graphNodes;for(let l=i.length-1;l>=0;l--){const u=i[l].data.nodeType??i[l].type;if(u==="manager"||u==="iteration")return i[l].id}return null};switch(t.type){case"run.start":{const i=t.data.model??((c=t.data.models)==null?void 0:c.manager)??r().config.model;a.addGraphNode({id:"task_root",type:"default",position:{x:0,y:0},data:{label:r().config.task.slice(0,60)||"Task",status:"running",nodeType:"task",details:{model:i}}}),a.addGraphNode({id:"manager",type:"default",position:{x:0,y:120},data:{label:`Manager (${i.split("/").pop()})`,status:"running",nodeType:"manager",details:t.data}}),a.addGraphEdge({id:"e-task-manager",source:"task_root",target:"manager",animated:!0}),a.addOutputBlock({type:"markdown",content:`**Run started** — ${i}`,title:"Run"});break}case"agent.start":case"delegation.start":{const i=te(t);a.addGraphNode({id:i,type:"default",position:{x:0,y:a.graphNodes.length*120},data:{label:t.data.agent_name??t.type,status:"running",details:t.data,nodeType:t.type==="delegation.start"?"manager":"task"}});break}case"iteration.start":{const i=t.data.iteration??"?",l=`iter_${i}`;a.addGraphNode({id:l,type:"default",position:{x:0,y:a.graphNodes.length*120},data:{label:`Iteration ${i}`,status:"running",nodeType:"iteration",details:t.data}}),a.addGraphEdge({id:`e-manager-${l}`,source:"manager",target:l,animated:!0}),a.addOutputBlock({type:"markdown",content:`**Iteration ${i}**`,title:"Iteration"});break}case"iteration.decision":{const i=t.data.iteration??"?",l=`iter_${i}`,u=t.data.decision??"unknown",x=t.data.confidence,m=t.data.reasoning??"",h=t.data.delegations;a.updateGraphNode(l,{status:u==="complete"?"complete":"running",label:`Iter ${i}: ${u.toUpperCase()}`,confidence:x,decision:u,reasoning:m,delegations:h,details:t.data});let d=`**Decision: ${u}** (confidence: ${x??"?"})

`;if(m&&(d+=`${m}

`),h&&h.length>0){d+=`**Delegations (${h.length}):**
`;for(const p of h){const g=p.tools??[];d+=`- \`${p.worker}\`: ${p.task}`,g.length>0&&(d+=` [${g.join(", ")}]`),d+=`
`}}a.addOutputBlock({type:"markdown",content:d,title:`Iteration ${i}`});break}case"worker.spawn":{const i=t.data.worker_id??te(t),l=t.data.instructions??t.data.task??"",u=t.data.tools_allowed??[],x=t.data.iteration??"",m=t.data.skills??[],h=t.data.code_mode,d=x?`iter_${x}`:null,p=d&&a.graphNodes.some(f=>f.id===d),g=t.data.parent_id??(p?d:o()??"manager");a.addGraphNode({id:i,type:"default",position:{x:250,y:a.graphNodes.length*120},data:{label:l.slice(0,60)||`Worker ${i.slice(0,8)}`,status:"running",nodeType:"worker",tools_used:u,instructions:l,iteration:x,skills:m,code_mode:h,details:t.data}}),a.addGraphEdge({id:`e-${g}-${i}`,source:g,target:i,animated:!0}),n&&a.addOutputBlock({type:"markdown",content:`**Worker spawned:** \`${i.slice(0,8)}\`

${l.slice(0,500)}${u.length?`

Tools: ${u.join(", ")}`:""}`,title:"Worker"});break}case"worker.complete":{const i=t.data.worker_id??te(t),l=!!(t.data.error||t.data.has_error),u=t.data.tools_created??[];if(a.updateGraphNode(i,{status:l?"error":"complete",confidence:t.data.confidence,outputs:t.data.result,error:t.data.error,tools_created:u}),l)a.addOutputBlock({type:"error",content:`Worker \`${i.slice(0,8)}\` failed: ${t.data.error}`,title:"Worker Error"});else if(n){const x=t.data.result??t.data.output??t.data.answer??t.data;a.addOutputBlock({type:"json",content:JSON.stringify(x,null,2),title:`Worker ${i.slice(0,8)} (confidence: ${t.data.confidence??"?"})`})}break}case"agent.complete":{const i=te(t);a.updateGraphNode(i,{status:"complete",confidence:t.data.confidence,outputs:t.data.result}),t.data.result&&a.addOutputBlock({type:"json",content:JSON.stringify(t.data.result,null,2),title:t.data.agent_name??"Agent Result"});break}case"tool.call":{const i=t.data.tool_name??t.data.tool??"Tool",l=t.data.worker_id??t.data.agent_id??t.data.caller_id??"",u=t.data.call_index,x=`tool-${l}-${i}-${u??a.graphNodes.length}`,m=t.data.output??"",h=t.data.error??"",d=t.data.arguments;if(a.addGraphNode({id:x,type:"default",position:{x:450,y:a.graphNodes.length*120},data:{label:i,status:t.data.ok===!1?"error":"complete",nodeType:"toolCall",arguments:d,outputs:m?{output:m}:void 0,error:h||void 0,details:t.data}}),l&&a.addGraphEdge({id:`e-${l}-${x}`,source:l,target:x}),i==="code.execute"&&(d!=null&&d.code)&&typeof d.code=="string"){if(a.addOutputBlock({type:"code",content:d.code,language:"python",title:`Code Execution${t.data.ok===!1?" (FAILED)":""}`}),m){a.addOutputBlock({type:"code",content:m,language:"text",title:"Output"});const p=/(\/tmp\/[^\s'"]+\.(?:png|jpg|jpeg|gif|svg))/gi,g=m.match(p);if(g)for(const f of[...new Set(g)]){const b=`/api/files/serve?path=${encodeURIComponent(f)}`;a.addOutputBlock({type:"image",content:b,title:f.split("/").pop()??"Chart"})}}h&&a.addOutputBlock({type:"error",content:h,title:"Execution Error"})}else if(i==="file.write"&&t.data.ok!==!1){const p=(d==null?void 0:d.path)??"";if(/\.(png|jpg|jpeg|gif|svg)$/i.test(p)){const g=`/api/files/serve?path=${encodeURIComponent(p)}`;a.addOutputBlock({type:"image",content:g,title:p.split("/").pop()??"Image"})}else n&&a.addOutputBlock({type:"code",content:`${i}(${l.slice(0,8)}) → OK`,title:"Tool Call"})}else n&&a.addOutputBlock({type:"code",content:`${i}(${l.slice(0,8)})${t.data.ok===!1?" → FAILED":" → OK"}`,title:"Tool Call"});break}case"tool.result":{const i=te(t);a.updateGraphNode(i,{status:"complete",outputs:t.data});break}case"budget.update":{const i=t.data,l={};typeof i.loops_used=="number"&&(l.loops_used=i.loops_used),typeof i.tokens_used=="number"&&(l.tokens_used=i.tokens_used),typeof i.workers_used=="number"&&(l.workers_used=i.workers_used);const u=i.loops,x=i.tokens,m=i.workers,h=i.wall_time,d=i.tool_calls;u&&(typeof u.used=="number"&&(l.loops_used=u.used),typeof u.max=="number"&&(l.loops_max=u.max)),x&&(typeof x.consumed=="number"&&(l.tokens_used=x.consumed),typeof x.max=="number"&&(l.tokens_max=x.max)),m&&(typeof m.spawned=="number"&&(l.workers_used=m.spawned),typeof m.max=="number"&&(l.workers_max=m.max)),h&&(typeof h.elapsed_s=="number"&&(l.wall_time_ms=h.elapsed_s*1e3),typeof h.max_s=="number"&&(l.wall_time_max_ms=h.max_s*1e3)),d&&(typeof d.used=="number"&&(l.tool_calls_used=d.used),typeof d.max=="number"&&(l.tool_calls_max=d.max)),Object.keys(l).length>0&&a.updateBudget(l);break}case"run.complete":{const i=t.data.status??"complete",l=i==="error"||i==="failed";if(a.updateGraphNode("manager",{status:l?"error":"complete"}),a.updateGraphNode("task_root",{status:l?"error":"complete"}),s({runStatus:l?"error":"complete",activePanel:"output"}),l&&t.data.result){const u=t.data.result;a.addOutputBlock({type:"error",content:u.error??JSON.stringify(u,null,2),title:"Error"})}else if(t.data.result)for(const u of it(t.data.result,"Final Result"))a.addOutputBlock(u);a.loadRunGraph(),a.loadHistory();{const u=r().currentSessionId,x=r().currentRunId;if(u&&t.data.result){const h=(typeof t.data.result=="string"?t.data.result:JSON.stringify(t.data.result,null,2)).slice(0,500);ot(u,{type:l?"observation":"finding",content:l?`Run ${(x??"").slice(0,8)} failed: ${h}`:`Run ${(x??"").slice(0,8)}: ${h}`,source:"agent",run_id:x??void 0}).then(d=>{s(p=>({experimentMemory:[d,...p.experimentMemory]}))}).catch(()=>{})}}break}case"error":{a.addOutputBlock({type:"error",content:t.data.message??t.data.error??"Unknown error",title:"Error"});break}case"log":{a.addOutputBlock({type:"markdown",content:t.data.message??"",title:"Log"});break}}}const F=es((t,r)=>({config:{...vs},updateConfig:s=>t(n=>({config:{...n.config,...s}})),currentRunId:null,runStatus:"idle",events:[],addEvent:s=>{r().events.some(o=>o.type===s.type&&o.seq===s.seq&&o.timestamp===s.timestamp)||(t(o=>({events:[...o.events,s]})),Cs(s,r,t))},graphNodes:[],graphEdges:[],addGraphNode:s=>t(n=>n.graphNodes.some(a=>a.id===s.id)?n:{graphNodes:[...n.graphNodes,s]}),addGraphEdge:s=>t(n=>n.graphEdges.some(a=>a.id===s.id)?n:{graphEdges:[...n.graphEdges,s]}),updateGraphNode:(s,n)=>t(a=>({graphNodes:a.graphNodes.map(o=>o.id===s?{...o,data:{...o.data,...n}}:o)})),selectedNodeId:null,selectNode:s=>t({selectedNodeId:s,inspectorOpen:s!==null}),loadRunGraph:async s=>{const n=s??r().currentRunId;if(n)try{const a=await ns(n);if(!a.nodes||a.nodes.length===0)return;const o=a.nodes.map((i,l)=>({id:i.id,type:"default",position:i.position??{x:0,y:l*120},data:{...i.data,nodeType:i.type}})),c=a.edges.map(i=>({id:i.id,source:i.source,target:i.target}));t({graphNodes:o,graphEdges:c})}catch{}},outputBlocks:[],addOutputBlock:s=>t(n=>({outputBlocks:[...n.outputBlocks,s]})),budget:{...de},updateBudget:s=>t(n=>({budget:{...n.budget,...s}})),activePanel:"protocol",setActivePanel:s=>t({activePanel:s}),sidebarOpen:!0,toggleSidebar:()=>t(s=>({sidebarOpen:!s.sidebarOpen})),inspectorOpen:!1,toggleInspector:()=>t(s=>({inspectorOpen:!s.inspectorOpen})),skills:[],mcpServers:[],runHistory:[],loadHistory:async()=>{try{const s=r().currentSessionId;if(s){const n=await je(s);t({runHistory:n.runs})}else{const n=await rs();t({runHistory:n})}}catch{}},startRun:async()=>{var n;const s=r();if(s.runStatus!=="running"){t({runStatus:"running",events:[],graphNodes:[],graphEdges:[],outputBlocks:[],budget:{...de,loops_max:s.config.max_loops,tokens_max:s.config.max_total_tokens,workers_max:s.config.max_total_workers,wall_time_max_ms:s.config.max_wall_time*1e3,tool_calls_max:s.config.max_tool_calls},selectedNodeId:null,activePanel:"protocol"});try{let a=[];s.attachedFiles.length>0&&(a=(await cs(s.attachedFiles)).paths);let o=s.currentSessionId;if(!o)try{const u=s.config.task.slice(0,60)||`Session ${new Date().toLocaleString()}`,x=await Ge(u);o=x.id,t(m=>({currentSessionId:x.id,sessions:[x,...m.sessions]}))}catch{}const c={...s.config,output_dir:((n=s.config.output_dir)==null?void 0:n.trim())||"",input_files:a};try{const u=await ss(c);if(!u.ok){t({runStatus:"error"}),r().addOutputBlock({type:"error",content:u.message??`No API key found for ${u.provider}. Add **${u.required_key}** in Settings → API Keys.`,title:"Missing API Key"});return}}catch{}let i;o?i=(await xs(o,c)).run_id:i=(await as(c)).run_id,t({currentRunId:i});const l=ks(i,u=>{if(r().addEvent(u),(u.type==="run.complete"||u.type==="error")&&r().currentSessionId){const x=r().currentSessionId;ps(x).then(m=>t({sessionHistory:m})).catch(()=>{}),Ve().then(m=>t({sessions:m})).catch(()=>{})}},{onStateChange:u=>t({_wsStatus:u})});t({_wsConnection:l})}catch(a){t({runStatus:"error",outputBlocks:[{type:"error",content:a instanceof Error?a.message:"Failed to start run",title:"Start Error"}]})}}},stopRun:async()=>{var n;const s=r();if(s.currentRunId){try{await os(s.currentRunId)}catch{}(n=s._wsConnection)==null||n.close(),t({runStatus:"complete",_wsConnection:null,_wsStatus:"closed"})}},reset:()=>{var n;(n=r()._wsConnection)==null||n.close(),t({currentRunId:null,runStatus:"idle",events:[],graphNodes:[],graphEdges:[],outputBlocks:[],budget:{...de},selectedNodeId:null,_wsConnection:null,_wsStatus:"closed",attachedFiles:[]})},attachedFiles:[],addFiles:s=>t(n=>({attachedFiles:[...n.attachedFiles,...s]})),removeFile:s=>t(n=>({attachedFiles:n.attachedFiles.filter((a,o)=>o!==s)})),currentSessionId:null,sessions:[],sessionHistory:[],createSession:async s=>{try{const n=s??`Experiment ${new Date().toLocaleString()}`,a=await Ge(n);t(o=>({currentSessionId:a.id,sessions:[a,...o.sessions],sessionHistory:[],outputBlocks:[],events:[],graphNodes:[],graphEdges:[],experimentMemory:[]}))}catch{}},loadSessions:async()=>{try{const s=await Ve();t({sessions:s}),s.length===0&&await r().createSession("Experiment 1")}catch{}},selectSession:async s=>{try{const n=await us(s),a=n.session.settings??{},o={};Object.keys(a).length>0&&Object.assign(o,a);const c=n.runs.length>0?n.runs[n.runs.length-1]:null,i=(c==null?void 0:c.run_id)??null,l=c?c.status==="error"||c.status==="failed"?"error":c.status==="running"?"running":"complete":"idle";c&&(o.task=c.task);const u=[],x=[];for(const p of n.runs){u.push({type:"markdown",content:`**Run started** — ${p.model}`,title:"Run"});for(const g of p.events){x.push(g);const f=g.data;switch(g.type){case"iteration.start":u.push({type:"markdown",content:`**Iteration ${f.iteration??"?"}**`,title:"Iteration"});break;case"iteration.decision":{const b=f.decision??"",S=f.reasoning??"",R=f.confidence;S?u.push({type:"markdown",content:`**Decision: ${b}** (confidence: ${R??"?"})

${S}`,title:`Iteration ${f.iteration??"?"}`}):u.push({type:"json",content:JSON.stringify(f,null,2),title:`Iteration ${f.iteration??"?"}`});break}case"worker.spawn":u.push({type:"markdown",content:`**Worker spawned:** \`${(f.worker_id??"?").slice(0,8)}\`

${(f.instructions??"").slice(0,500)}`,title:"Worker"});break;case"worker.complete":{const b=!!(f.error||f.has_error);u.push({type:b?"error":"json",content:b?`Worker failed: ${f.error}`:JSON.stringify(f.result??f,null,2),title:`Worker ${(f.worker_id??"?").slice(0,8)}`});break}case"error":u.push({type:"error",content:f.message??f.error??"Unknown error",title:"Error"});break}}if(p.result){const g=p.result;if(g.status==="error"||g.status==="failed"){const b=g.result;u.push({type:"error",content:(b==null?void 0:b.error)??JSON.stringify(g,null,2),title:"Error"})}else for(const b of it(g.result,"Final Result"))u.push(b)}}let m=[],h=[];c!=null&&c.graph&&(m=c.graph.nodes.map((p,g)=>({id:p.id,type:"default",position:p.position??{x:0,y:g*120},data:{...p.data,nodeType:p.type}})),h=c.graph.edges.map(p=>({id:p.id,source:p.source,target:p.target})));const d=n.runs.flatMap(p=>[{role:"user",content:p.task,run_id:p.run_id,timestamp:p.created_at},{role:"assistant",content:p.result?JSON.stringify(p.result.result??p.result):"",run_id:p.run_id,timestamp:p.completed_at??p.created_at,status:p.status}]);t(p=>({currentSessionId:s,currentRunId:i,runStatus:l,sessionHistory:d,outputBlocks:u,events:x,graphNodes:m,graphEdges:h,selectedNodeId:null,activePanel:"protocol",config:{...p.config,...o},budget:{...de},experimentMemory:n.memory??[]}))}catch{try{await je(s),t({currentSessionId:s,sessionHistory:[],outputBlocks:[],events:[],graphNodes:[],graphEdges:[],currentRunId:null,runStatus:"idle",experimentMemory:[]})}catch{t({currentSessionId:s,sessionHistory:[],experimentMemory:[]})}}},deleteSession:async s=>{try{await ds(s),t(n=>{const a=n.sessions.filter(c=>c.id!==s),o=n.currentSessionId===s;return{sessions:a,...o?{currentSessionId:null,sessionHistory:[],outputBlocks:[],events:[],graphNodes:[],graphEdges:[]}:{}}})}catch{}},renameSession:async(s,n)=>{try{await Ce(s,{title:n}),t(a=>({sessions:a.sessions.map(o=>o.id===s?{...o,title:n}:o)}))}catch{}},updateSessionMetadata:async(s,n)=>{try{await Ce(s,n),t(a=>({sessions:a.sessions.map(o=>o.id===s?{...o,...n}:o)}))}catch{}},experimentMemory:[],loadExperimentMemory:async()=>{const s=r().currentSessionId;if(!s){t({experimentMemory:[]});return}try{const n=await ms(s);t({experimentMemory:n})}catch{t({experimentMemory:[]})}},addMemoryEntry:async(s,n,a="user")=>{const o=r().currentSessionId;if(o)try{const c=await ot(o,{type:s,content:n,source:a});t(i=>({experimentMemory:[c,...i.experimentMemory]}))}catch{}},updateMemoryEntry:async(s,n)=>{const a=r().currentSessionId;if(a)try{await hs(a,s,n),t(o=>({experimentMemory:o.experimentMemory.map(c=>c.id===s?{...c,content:n,updated_at:new Date().toISOString()}:c)}))}catch{}},deleteMemoryEntry:async s=>{const n=r().currentSessionId;if(n)try{await gs(n,s),t(a=>({experimentMemory:a.experimentMemory.filter(o=>o.id!==s)}))}catch{}},secrets:[],loadSecrets:async()=>{try{const s=await Ue();t({secrets:s})}catch{}},addSecret:async(s,n)=>{try{await ws(s,n);const a=await Ue();t({secrets:a})}catch{}},removeSecret:async s=>{try{await bs(s),t(n=>({secrets:n.secrets.filter(a=>a.key!==s)}))}catch{}},settingsLoaded:!1,loadPersistedSettings:async()=>{try{const s=await ys();if(s){const{sidebar_open:n,inspector_open:a,active_panel:o,last_session_id:c,...i}=s,l={settingsLoaded:!0};if(Object.keys(i).length>0){const u=r();l.config={...u.config,...i}}typeof n=="boolean"&&(l.sidebarOpen=n),typeof a=="boolean"&&(l.inspectorOpen=a),typeof o=="string"&&(l.activePanel=o),typeof c=="string"&&c&&(l.currentSessionId=c,je(c).then(u=>{u&&t({currentSessionId:c})}).catch(()=>{})),t(l)}else t({settingsLoaded:!0})}catch{t({settingsLoaded:!0})}},saveCurrentSettings:async()=>{try{const s=r(),{task:n,output_dir:a,input_files:o,...c}=s.config;await fs({...c,sidebar_open:s.sidebarOpen,inspector_open:s.inspectorOpen,active_panel:s.activePanel,last_session_id:s.currentSessionId})}catch{}},_wsConnection:null,_wsStatus:"closed"}));function ke({title:t,collapsed:r,onToggle:s,defaultOpen:n=!0,icon:a,className:o,headerActions:c,children:i}){const[l,u]=w.useState(!n),x=r??l,m=s??(()=>u(h=>!h));return e.jsxs("div",{className:y("rounded-lg border border-awp-border bg-awp-panel overflow-hidden",o),children:[e.jsxs("button",{type:"button",onClick:m,className:"flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-awp-text hover:bg-awp-bg/50 transition-colors",children:[x?e.jsx(et,{className:"h-4 w-4 text-awp-muted shrink-0"}):e.jsx(_e,{className:"h-4 w-4 text-awp-muted shrink-0"}),a&&e.jsx("span",{className:"shrink-0",children:a}),e.jsx("span",{className:"truncate",children:t}),c&&e.jsx("span",{className:"ml-auto flex items-center gap-1",onClick:h=>h.stopPropagation(),children:c})]}),!x&&e.jsx("div",{className:"px-3 pb-3",children:i})]})}function Ss({tabs:t,activeId:r,activeTab:s,onChange:n,onTabChange:a,className:o}){const c=r??s??"",i=n??a??(()=>{});return e.jsx("div",{className:y("flex items-center gap-1 border-b border-awp-border bg-awp-panel px-2",o),children:t.map(l=>e.jsxs("button",{type:"button",onClick:()=>i(l.id),className:y("flex items-center gap-1.5 px-3 py-2 text-sm font-medium transition-colors relative",l.id===c?"text-awp-text":"text-awp-muted hover:text-awp-text"),children:[l.icon,l.label,l.id===c&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-awp-blue rounded-full"})]},l.id))})}const _s={default:"bg-awp-border/50 text-awp-muted",blue:"bg-awp-blue/15 text-awp-blue",green:"bg-awp-green/15 text-awp-green",yellow:"bg-awp-yellow/15 text-awp-yellow",orange:"bg-awp-orange/15 text-awp-orange",red:"bg-awp-red/15 text-awp-red",purple:"bg-awp-purple/15 text-awp-purple",cyan:"bg-awp-cyan/15 text-awp-cyan"};function J({children:t,variant:r="default",dot:s,className:n}){return e.jsxs("span",{className:y("inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium",_s[r],n),children:[s&&e.jsx("span",{className:y("h-1.5 w-1.5 rounded-full",{"bg-awp-blue animate-pulse":r==="blue","bg-awp-green":r==="green","bg-awp-yellow":r==="yellow","bg-awp-orange":r==="orange","bg-awp-red":r==="red","bg-awp-purple":r==="purple","bg-awp-cyan":r==="cyan","bg-awp-muted":r==="default"})}),t]})}function re({value:t,color:r="bg-awp-blue",showLabel:s=!1,className:n}){const a=Math.min(Math.max(t,0),1)*100;return e.jsxs("div",{className:y("flex items-center gap-2",n),children:[e.jsx("div",{className:"relative h-1.5 flex-1 rounded-full bg-awp-border/50 overflow-hidden",children:e.jsx("div",{className:y("absolute inset-y-0 left-0 rounded-full transition-all duration-500 ease-out",r),style:{width:`${a}%`}})}),s&&e.jsxs("span",{className:"text-xs text-awp-muted tabular-nums w-10 text-right",children:[Math.round(a),"%"]})]})}function Je({tooltip:t,size:r="md",active:s,className:n,children:a,...o}){const c={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-9 w-9"};return e.jsx(Ms,{content:t,children:e.jsx("button",{type:"button",...o,className:y("inline-flex items-center justify-center rounded-md transition-colors","text-awp-muted hover:text-awp-text hover:bg-awp-border/50","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-awp-blue","disabled:opacity-40 disabled:pointer-events-none",s&&"bg-awp-border/50 text-awp-text",c[r],n),children:a})})}function Ms({content:t,children:r,side:s="bottom"}){const[n,a]=w.useState(!1),o=w.useRef(null),c=w.useRef(null),i=w.useCallback(()=>{c.current=setTimeout(()=>a(!0),400)},[]),l=w.useCallback(()=>{c.current&&clearTimeout(c.current),a(!1)},[]);if(w.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),!t)return e.jsx(e.Fragment,{children:r});const u={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"};return e.jsxs("div",{ref:o,className:"relative inline-flex",onMouseEnter:i,onMouseLeave:l,onFocus:i,onBlur:l,children:[r,n&&e.jsx("div",{role:"tooltip",className:y("absolute z-50 whitespace-nowrap rounded-md px-2 py-1 text-xs font-medium","bg-awp-text text-awp-bg shadow-lg","animate-fade-in pointer-events-none",u[s]),children:t})]})}function Es({open:t,onClose:r,title:s,className:n,children:a}){const o=w.useRef(null);return w.useEffect(()=>{if(!t)return;const c=i=>{i.key==="Escape"&&r()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,r]),t?e.jsxs("div",{ref:o,className:"fixed inset-0 z-50 flex items-center justify-center",onClick:c=>{c.target===o.current&&r()},children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-fade-in"}),e.jsxs("div",{className:y("relative z-10 w-full max-w-lg rounded-xl border border-awp-border","bg-awp-panel shadow-2xl animate-fade-in",n),children:[s&&e.jsxs("div",{className:"flex items-center justify-between border-b border-awp-border px-5 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-awp-text",children:s}),e.jsx("button",{type:"button",onClick:r,className:"text-awp-muted hover:text-awp-text transition-colors",children:e.jsx(le,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"p-5",children:a})]})]}):null}function Ts(t){const r=Date.now(),s=new Date(t).getTime(),n=r-s,a=Math.floor(n/1e3);if(a<60)return"just now";const o=Math.floor(a/60);if(o<60)return`${o}m ago`;const c=Math.floor(o/60);if(c<24)return`${c}h ago`;const i=Math.floor(c/24);return i===1?"yesterday":i<7?`${i}d ago`:new Date(t).toLocaleDateString()}function Os(t){const r=new Date,s=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),n=s-864e5,a=s-7*864e5,o={Today:[],Yesterday:[],"Previous 7 Days":[],Older:[]};for(const c of t){const i=new Date(c.updated_at).getTime();i>=s?o.Today.push(c):i>=n?o.Yesterday.push(c):i>=a?o["Previous 7 Days"].push(c):o.Older.push(c)}return Object.entries(o).filter(([,c])=>c.length>0).map(([c,i])=>({label:c,sessions:i}))}function Rs(t){const r=["running","draft","complete","failed","archived"],s={running:"Running",draft:"Draft",complete:"Complete",failed:"Failed",archived:"Archived"},n={};for(const a of t){const o=a.status??"draft";n[o]||(n[o]=[]),n[o].push(a)}return r.filter(a=>{var o;return((o=n[a])==null?void 0:o.length)>0}).map(a=>({label:s[a]??a,sessions:n[a]}))}function Is(t){switch(t){case"complete":return"bg-awp-green";case"running":return"bg-awp-blue animate-pulse";case"error":case"failed":return"bg-awp-red";case"archived":return"bg-awp-muted/30";default:return"bg-awp-muted/50"}}function $s({x:t,y:r,onRename:s,onDelete:n,onClose:a}){const o=w.useRef(null);return w.useEffect(()=>{const c=i=>{o.current&&!o.current.contains(i.target)&&a()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[a]),e.jsxs("div",{ref:o,className:"fixed z-50 min-w-[140px] rounded-lg border border-awp-border bg-awp-panel shadow-xl py-1 animate-fade-in",style:{top:r,left:t},children:[e.jsxs("button",{type:"button",onClick:()=>{s(),a()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-awp-text hover:bg-awp-bg/60 transition-colors",children:[e.jsx(st,{className:"h-3 w-3"}),"Rename"]}),e.jsxs("button",{type:"button",onClick:()=>{n(),a()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-awp-red hover:bg-awp-red/10 transition-colors",children:[e.jsx(be,{className:"h-3 w-3"}),"Delete"]})]})}function As({session:t,isActive:r,onSelect:s,onRename:n,onDelete:a}){var p,g,f;const[o,c]=w.useState(!1),[i,l]=w.useState(t.title),[u,x]=w.useState(null),m=w.useRef(null);w.useEffect(()=>{var b,S;o&&((b=m.current)==null||b.focus(),(S=m.current)==null||S.select())},[o]);const h=w.useCallback(()=>{const b=i.trim();b&&b!==t.title&&n(b),c(!1)},[i,t.title,n]),d=w.useCallback(b=>{b.preventDefault(),x({x:b.clientX,y:b.clientY})},[]);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:s,onContextMenu:d,className:y("group w-full text-left rounded-lg px-3 py-2.5 transition-colors relative",r?"bg-awp-blue/10 border border-awp-blue/30":"hover:bg-awp-bg/60 border border-transparent"),children:o?e.jsx("input",{ref:m,value:i,onChange:b=>l(b.target.value),onBlur:h,onKeyDown:b=>{b.key==="Enter"&&h(),b.key==="Escape"&&(l(t.title),c(!1))},onClick:b=>b.stopPropagation(),className:"w-full bg-awp-bg border border-awp-blue/50 rounded px-1.5 py-0.5 text-xs text-awp-text focus:outline-none focus:ring-1 focus:ring-awp-blue"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:y("h-2 w-2 rounded-full shrink-0",Is(t.status??t.last_run_status))}),e.jsx("span",{className:"text-xs font-medium text-awp-text truncate flex-1",children:t.title}),e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),x({x:b.clientX,y:b.clientY})},className:"opacity-0 group-hover:opacity-100 shrink-0 text-awp-muted hover:text-awp-text transition-opacity",children:e.jsx(Rt,{className:"h-3.5 w-3.5"})})]}),t.hypothesis?e.jsx("p",{className:"text-[10px] text-awp-muted/70 truncate ml-4 mt-0.5 italic",children:t.hypothesis}):null,e.jsxs("div",{className:"flex items-center gap-2 mt-1 ml-4 flex-wrap",children:[e.jsx("span",{className:"text-[10px] text-awp-muted",children:Ts(t.updated_at)}),t.run_count>0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-awp-border/50 px-1.5 py-0.5 text-[10px] text-awp-muted",children:[e.jsx($e,{className:"h-2.5 w-2.5"}),t.run_count]}),(p=t.tags)==null?void 0:p.slice(0,3).map(b=>e.jsx("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-awp-blue/10 px-1.5 py-0.5 text-[10px] text-awp-blue/70",children:b},b)),(((g=t.tags)==null?void 0:g.length)??0)>3&&e.jsxs("span",{className:"text-[10px] text-awp-muted",children:["+",(((f=t.tags)==null?void 0:f.length)??0)-3]})]})]})}),u&&e.jsx($s,{x:u.x,y:u.y,onRename:()=>{l(t.title),c(!0)},onDelete:a,onClose:()=>x(null)})]})}function Fs({sessions:t,currentSessionId:r,onSelectSession:s,onNewSession:n,onDeleteSession:a,onRenameSession:o}){const[c,i]=w.useState(""),[l,u]=w.useState("time"),x=w.useMemo(()=>{if(!c.trim())return t;const d=c.toLowerCase();return t.filter(p=>p.title.toLowerCase().includes(d)||(p.hypothesis??"").toLowerCase().includes(d)||(p.tags??[]).some(g=>g.toLowerCase().includes(d)))},[t,c]),m=w.useMemo(()=>[...x].sort((d,p)=>new Date(p.updated_at).getTime()-new Date(d.updated_at).getTime()),[x]),h=w.useMemo(()=>l==="time"?Os(m):Rs(m),[m,l]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center justify-center gap-2 rounded-lg border border-awp-border bg-awp-bg px-3 py-2 text-xs font-medium text-awp-text hover:bg-awp-blue/10 hover:border-awp-blue/30 hover:text-awp-blue transition-colors",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"New Experiment"]}),e.jsxs("div",{className:"relative",children:[e.jsx(zt,{className:"absolute left-2.5 top-1/2 h-3 w-3 -translate-y-1/2 text-awp-muted"}),e.jsx("input",{type:"text",value:c,onChange:d=>i(d.target.value),placeholder:"Search experiments...",className:"w-full rounded-md border border-awp-border bg-awp-bg pl-7 pr-7 py-1.5 text-xs text-awp-text placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue focus:border-awp-blue transition-colors"}),c&&e.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-awp-muted hover:text-awp-text",children:e.jsx(le,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-awp-muted uppercase tracking-wider",children:"Group by"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>u("time"),className:y("px-1.5 py-0.5 text-[10px] rounded transition-colors",l==="time"?"bg-awp-blue/15 text-awp-blue font-medium":"text-awp-muted hover:text-awp-text"),children:"Time"}),e.jsx("button",{type:"button",onClick:()=>u("status"),className:y("px-1.5 py-0.5 text-[10px] rounded transition-colors",l==="status"?"bg-awp-blue/15 text-awp-blue font-medium":"text-awp-muted hover:text-awp-text"),children:"Status"})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-2 pb-3 space-y-1",children:[h.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-awp-muted gap-2",children:[e.jsx($e,{className:"h-8 w-8 text-awp-border"}),e.jsx("p",{className:"text-xs",children:c?"No matching experiments":"No experiments yet"})]}),h.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1.5",children:e.jsx("span",{className:"text-[10px] font-semibold text-awp-muted uppercase tracking-wider",children:d.label})}),e.jsx("div",{className:"space-y-0.5",children:d.sessions.map(p=>e.jsx(As,{session:p,isActive:p.id===r,onSelect:()=>s(p.id),onRename:g=>o(p.id,g),onDelete:()=>a(p.id)},p.id))})]},d.label))]})]})}const Ps=["OPENROUTER_API_KEY","OPENAI_API_KEY","ANTHROPIC_API_KEY"];function Ds({secrets:t,onAdd:r,onDelete:s}){const[n,a]=w.useState(""),[o,c]=w.useState(""),[i,l]=w.useState(null),u=w.useCallback(()=>{const d=n.trim(),p=o.trim();!d||!p||(r(d,p),a(""),c(""))},[n,o,r]),x=w.useCallback(d=>{a(d)},[]),m=w.useCallback(()=>{i&&(s(i),l(null))},[i,s]),h=new Set(t.map(d=>d.key));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-awp-blue/20 bg-awp-blue/5 p-3",children:[e.jsx(Ht,{className:"h-4 w-4 text-awp-blue shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-awp-muted leading-relaxed",children:"Secrets are stored locally and injected into workflow agents. Values are never displayed after saving."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-awp-text",children:"Add Secret"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ps.filter(d=>!h.has(d)).map(d=>e.jsx("button",{type:"button",onClick:()=>x(d),className:y("rounded-md border px-2 py-1 text-[10px] font-mono transition-colors",n===d?"border-awp-blue bg-awp-blue/15 text-awp-blue":"border-awp-border text-awp-muted hover:border-awp-muted hover:text-awp-text"),children:d},d))}),e.jsx("input",{type:"text",value:n,onChange:d=>a(d.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")),placeholder:"SECRET_KEY_NAME",className:"w-full rounded-md border border-awp-border bg-awp-bg px-3 py-1.5 text-xs text-awp-text font-mono placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue focus:border-awp-blue transition-colors"}),e.jsx("input",{type:"password",value:o,onChange:d=>c(d.target.value),placeholder:"Secret value...",className:"w-full rounded-md border border-awp-border bg-awp-bg px-3 py-1.5 text-xs text-awp-text placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue focus:border-awp-blue transition-colors"}),e.jsxs("button",{type:"button",onClick:u,disabled:!n.trim()||!o.trim(),className:y("flex w-full items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",n.trim()&&o.trim()?"bg-awp-blue/15 text-awp-blue hover:bg-awp-blue/25":"bg-awp-border/30 text-awp-muted cursor-not-allowed"),children:[e.jsx(Fe,{className:"h-3 w-3"}),"Add Secret"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-xs font-medium text-awp-muted uppercase tracking-wide",children:["Stored Secrets (",t.length,")"]}),t.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-awp-border py-4 text-center",children:[e.jsx(ve,{className:"h-6 w-6 text-awp-border mx-auto mb-1"}),e.jsx("p",{className:"text-[11px] text-awp-muted",children:"No secrets stored"})]}):e.jsx("div",{className:"space-y-1",children:t.map(d=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-awp-border bg-awp-bg px-3 py-2 group",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ve,{className:"h-3 w-3 text-awp-yellow shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-awp-text truncate",children:d.key})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[10px] text-awp-muted flex items-center gap-1",children:[e.jsx(Oe,{className:"h-2.5 w-2.5"}),new Date(d.created_at).toLocaleDateString()]}),e.jsx("button",{type:"button",onClick:()=>l(d.key),className:"opacity-0 group-hover:opacity-100 text-awp-muted hover:text-awp-red transition-all",children:e.jsx(be,{className:"h-3 w-3"})})]})]},d.key))})]}),e.jsx(Es,{open:i!==null,onClose:()=>l(null),title:"Delete Secret",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-awp-red/10 p-2",children:e.jsx(Vt,{className:"h-5 w-5 text-awp-red"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-awp-text",children:["Are you sure you want to delete the secret"," ",e.jsx("code",{className:"rounded bg-awp-bg px-1.5 py-0.5 text-xs font-mono text-awp-yellow",children:i}),"?"]}),e.jsx("p",{className:"text-xs text-awp-muted mt-1",children:"This action cannot be undone. Workflows using this secret will fail until a new value is provided."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(null),className:"rounded-md border border-awp-border px-3 py-1.5 text-xs font-medium text-awp-text hover:bg-awp-bg transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:m,className:"rounded-md bg-awp-red/15 px-3 py-1.5 text-xs font-medium text-awp-red hover:bg-awp-red/25 transition-colors",children:"Delete"})]})]})})]})}function Se(t){return t===void 0?"text-awp-muted":t>=.8?"text-awp-green":t>=.5?"text-awp-yellow":t>=.3?"text-awp-orange":"text-awp-red"}function Bs(t){return t===void 0?"border-awp-muted":t>=.8?"border-awp-green":t>=.5?"border-awp-yellow":t>=.3?"border-awp-orange":"border-awp-red"}function ie(t){const r={running:"bg-awp-blue",complete:"bg-awp-green",error:"bg-awp-red",pending:"bg-awp-muted"};return e.jsxs("span",{className:"relative flex h-2 w-2",children:[t==="running"&&e.jsx("span",{className:y("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",r[t])}),e.jsx("span",{className:y("relative inline-flex h-2 w-2 rounded-full",r[t]??"bg-awp-muted")})]})}function Q(t){return F(r=>r.selectedNodeId===t)}function ee(){return F(t=>t.selectNode)}const Ls=w.memo(function({id:r,data:s}){const n=Q(r),a=ee();return e.jsxs("div",{onClick:()=>a(r),className:y("group relative cursor-pointer transition-all duration-200 hover:scale-105",n&&"scale-105"),children:[e.jsx(H,{type:"target",position:q.Top,className:"!bg-awp-blue !border-awp-panel !w-2 !h-2"}),e.jsxs("div",{className:y("flex flex-col items-center justify-center rounded-lg border-2 bg-awp-panel px-4 py-3 min-w-[140px]","rotate-0",n?"border-awp-blue ring-2 ring-awp-blue/30 shadow-lg shadow-awp-blue/20":"border-awp-blue/60 hover:border-awp-blue hover:shadow-md hover:shadow-awp-blue/10","transition-all duration-200"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 text-awp-blue"}),ie(s.status)]}),e.jsx("span",{className:"text-xs font-medium text-awp-text text-center max-w-[120px] truncate",children:s.label})]}),e.jsx(H,{type:"source",position:q.Bottom,className:"!bg-awp-blue !border-awp-panel !w-2 !h-2"})]})}),zs=w.memo(function({id:r,data:s}){const n=Q(r),a=ee();return e.jsxs("div",{onClick:()=>a(r),className:y("group relative cursor-pointer transition-all duration-200 hover:scale-105",n&&"scale-105"),children:[e.jsx(H,{type:"target",position:q.Top,className:"!bg-awp-purple !border-awp-panel !w-2 !h-2"}),e.jsxs("div",{className:y("flex flex-col items-center justify-center rounded-xl border-2 bg-awp-panel px-5 py-3 min-w-[150px]",n?"border-awp-purple ring-2 ring-awp-purple/30 shadow-lg shadow-awp-purple/20":"border-awp-purple/60 hover:border-awp-purple hover:shadow-md hover:shadow-awp-purple/10","transition-all duration-200"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(De,{className:"h-4 w-4 text-awp-purple fill-awp-purple/30"}),ie(s.status)]}),e.jsx("span",{className:"text-xs font-semibold text-awp-text",children:s.label}),s.model&&e.jsx("span",{className:"mt-0.5 text-[10px] text-awp-muted truncate max-w-[130px]",children:String(s.model)})]}),e.jsx(H,{type:"source",position:q.Bottom,className:"!bg-awp-purple !border-awp-panel !w-2 !h-2"})]})});function Ws(t){switch(t){case"delegate":return{border:"border-awp-yellow",ring:"ring-awp-yellow/30",shadow:"shadow-awp-yellow/20",icon:"text-awp-yellow"};case"complete":return{border:"border-awp-green",ring:"ring-awp-green/30",shadow:"shadow-awp-green/20",icon:"text-awp-green"};case"fail":return{border:"border-awp-red",ring:"ring-awp-red/30",shadow:"shadow-awp-red/20",icon:"text-awp-red"};default:return{border:"border-awp-yellow/60",ring:"ring-awp-yellow/20",shadow:"shadow-awp-yellow/10",icon:"text-awp-yellow"}}}const Hs=w.memo(function({id:r,data:s}){const n=Q(r),a=ee(),o=Ws(s.decision);return e.jsxs("div",{onClick:()=>a(r),className:y("group relative cursor-pointer transition-all duration-200 hover:scale-105",n&&"scale-105"),children:[e.jsx(H,{type:"target",position:q.Top,className:"!bg-awp-yellow !border-awp-panel !w-2 !h-2"}),e.jsxs("div",{className:y("flex flex-col items-center justify-center rounded-2xl border-2 bg-awp-panel px-4 py-3 min-w-[130px]",o.border,n&&`ring-2 ${o.ring} shadow-lg ${o.shadow}`,!n&&"hover:shadow-md","transition-all duration-200"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(oe,{className:y("h-3.5 w-3.5",o.icon)}),ie(s.status)]}),e.jsxs("span",{className:"text-xs font-medium text-awp-text",children:["Iter ",s.iteration??"?"]}),s.confidence!==void 0&&e.jsxs("span",{className:y("mt-0.5 text-[10px] font-mono",Se(s.confidence)),children:[(s.confidence*100).toFixed(0),"%"]})]}),e.jsx(H,{type:"source",position:q.Bottom,className:"!bg-awp-yellow !border-awp-panel !w-2 !h-2"})]})}),qs=w.memo(function({id:r,data:s}){const n=Q(r),a=ee(),o=Bs(s.confidence);return e.jsxs("div",{onClick:()=>a(r),className:y("group relative cursor-pointer transition-all duration-200 hover:scale-105",n&&"scale-105"),children:[e.jsx(H,{type:"target",position:q.Top,className:"!bg-awp-cyan !border-awp-panel !w-2 !h-2"}),e.jsxs("div",{className:y("flex flex-col items-center justify-center rounded-full border-2 bg-awp-panel min-w-[100px] min-h-[100px] p-4",o,n&&"ring-2 ring-awp-cyan/30 shadow-lg shadow-awp-cyan/20",!n&&"hover:shadow-md","transition-all duration-200"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(ge,{className:y("h-3 w-3 fill-current",Se(s.confidence))}),ie(s.status)]}),e.jsx("span",{className:"text-[11px] font-medium text-awp-text text-center max-w-[80px] truncate",children:s.label}),s.confidence!==void 0&&e.jsxs("span",{className:y("text-[10px] font-mono",Se(s.confidence)),children:[(s.confidence*100).toFixed(0),"%"]}),s.toolCount!==void 0&&e.jsxs("span",{className:"mt-0.5 text-[9px] text-awp-muted",children:[s.toolCount," tool",Number(s.toolCount)!==1?"s":""]})]}),e.jsx(H,{type:"source",position:q.Bottom,className:"!bg-awp-cyan !border-awp-panel !w-2 !h-2"})]})}),Gs=w.memo(function({id:r,data:s}){const n=Q(r),a=ee(),o=s.status==="error";return e.jsxs("div",{onClick:()=>a(r),className:y("group relative cursor-pointer transition-all duration-200 hover:scale-110",n&&"scale-110"),children:[e.jsx(H,{type:"target",position:q.Top,className:"!bg-awp-green !border-awp-panel !w-1.5 !h-1.5"}),e.jsxs("div",{className:y("flex flex-col items-center justify-center rounded-lg border-2 bg-awp-panel px-3 py-2 min-w-[90px]",o?"border-awp-red/60":s.status==="complete"?"border-awp-green/60":"border-awp-blue/40",n&&(o?"ring-2 ring-awp-red/30":"ring-2 ring-awp-green/30"),"transition-all duration-200"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[o?e.jsx(Ut,{className:"h-3 w-3 text-awp-red fill-awp-red/20"}):e.jsx(Y,{className:"h-3 w-3 text-awp-green"}),ie(s.status)]}),e.jsx("span",{className:"mt-0.5 text-[10px] font-medium text-awp-text text-center max-w-[80px] truncate",children:s.label})]}),e.jsx(H,{type:"source",position:q.Bottom,className:"!bg-awp-green !border-awp-panel !w-1.5 !h-1.5"})]})}),Vs=w.memo(function({id:r,data:s}){const n=Q(r),a=ee(),o=s.status==="error";return e.jsxs("div",{onClick:()=>a(r),className:y("group relative cursor-pointer transition-all duration-200 hover:scale-105",n&&"scale-105"),children:[e.jsx(H,{type:"target",position:q.Top,className:y("!border-awp-panel !w-2 !h-2",o?"!bg-awp-red":"!bg-awp-green")}),e.jsxs("div",{className:y("flex flex-col items-center justify-center rounded-lg border-2 bg-awp-panel px-5 py-3 min-w-[140px]",o?"border-awp-red":"border-awp-green",n&&(o?"ring-2 ring-awp-red/30 shadow-lg shadow-awp-red/20":"ring-2 ring-awp-green/30 shadow-lg shadow-awp-green/20"),"transition-all duration-200"),children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx(Pe,{className:y("h-4 w-4",o?"text-awp-red":"text-awp-green")})}),e.jsx("span",{className:y("text-xs font-semibold",o?"text-awp-red":"text-awp-green"),children:o?"Failed":"Complete"}),s.iterationCount!==void 0&&e.jsxs("span",{className:"mt-0.5 text-[10px] text-awp-muted",children:[s.iterationCount," iteration",Number(s.iterationCount)!==1?"s":""]})]}),e.jsx(H,{type:"source",position:q.Bottom,className:y("!border-awp-panel !w-2 !h-2",o?"!bg-awp-red":"!bg-awp-green")})]})}),Us={task:Ls,manager:zs,iteration:Hs,worker:qs,toolCall:Gs,completion:Vs};function Js(t,r){if(t.length===0)return t;const s=new Map,n=new Map,a=new Map;for(const d of t)s.set(d.id,[]),a.set(d.id,d);for(const d of r){const p=s.get(d.source);p&&a.has(d.target)&&(p.push(d.target),n.set(d.target,d.source))}const o=d=>{var p,g,f;return((g=(p=a.get(d))==null?void 0:p.data)==null?void 0:g.nodeType)??((f=a.get(d))==null?void 0:f.type)??""},c=220,i=160,l=120,u=new Map,x=t.filter(d=>!n.has(d.id)).map(d=>d.id);x.length===0&&t.length>0&&x.push(t[0].id);function m(d,p,g){const f=o(d);let b=p;(f==="task"||f==="completion"||!f&&!n.has(d))&&(u.set(d,{x:g,y:b*i}),b++);const S=(s.get(d)??[]).filter(j=>a.has(j)),R=S.filter(j=>o(j)==="manager"),E=S.filter(j=>o(j)!=="manager");for(const j of R){u.set(j,{x:g,y:b*i}),b++;const I=(s.get(j)??[]).filter($=>a.has($)),B=I.filter($=>o($)==="iteration"),W=I.filter($=>o($)!=="iteration");for(const $ of B){const C=(s.get($)??[]).filter(_=>a.has(_)),G=C.filter(_=>o(_)==="worker"),z=C.filter(_=>o(_)!=="worker"),v=b*i;u.set($,{x:g,y:v});let T=1,k=!1;for(const _ of G){const A=g+T*c;u.set(_,{x:A,y:v});const Z=(s.get(_)??[]).filter(M=>a.has(M)),U=Z.filter(M=>o(M)==="toolCall"),L=Z.filter(M=>o(M)!=="toolCall");if(U.length>0){k=!0;for(let M=0;M<U.length;M++)u.set(U[M],{x:A+M*(c*.55),y:v+l});T+=Math.max(1,Math.ceil(U.length*.55))}else T++;if(L.length>0){let M=b+(k?2:1);for(const pt of L)M=m(pt,M,A)}}for(const _ of z)u.set(_,{x:g+T*c,y:v}),T++;b+=k?2:1}for(const $ of W)u.has($)||(u.set($,{x:g,y:b*i}),b++)}for(const j of E)u.has(j)||(u.set(j,{x:g,y:b*i}),b++);return b}let h=0;for(const d of x)h=m(d,h,0);for(const d of t)u.has(d.id)||(u.set(d.id,{x:0,y:h*i}),h++);return t.map(d=>({...d,position:u.get(d.id)??d.position}))}function Ks(t){var s;switch(((s=t==null?void 0:t.data)==null?void 0:s.nodeType)??(t==null?void 0:t.type)){case"task":return"#40C4FF";case"manager":return"#E040FB";case"iteration":return"#FFD600";case"worker":return"#18FFFF";case"toolCall":return"#00E676";case"completion":return"#00E676";default:return"#30363d"}}function Ys(t,r){const s=new Map(r.map(n=>[n.id,n]));return t.map(n=>{const a=s.get(n.source),o=Ks(a),c=n.animated;return{...n,type:"smoothstep",animated:c,style:{stroke:o,strokeWidth:c?2.5:1.5,opacity:c?1:.6},markerEnd:{type:Nt.ArrowClosed,color:o,width:16,height:16}}})}function Zs(t){var s,n;const r={total:t.length,tasks:0,managers:0,iterations:0,workers:0,toolCalls:0,completions:0,running:0,complete:0,errors:0};for(const a of t){const o=((s=a.data)==null?void 0:s.nodeType)??a.type,c=(n=a.data)==null?void 0:n.status;o==="task"?r.tasks++:o==="manager"?r.managers++:o==="iteration"?r.iterations++:o==="worker"?r.workers++:o==="toolCall"?r.toolCalls++:o==="completion"&&r.completions++,c==="running"?r.running++:c==="complete"?r.complete++:c==="error"&&r.errors++}return r}function Xs({stats:t}){return e.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-1 rounded-xl bg-awp-panel/90 backdrop-blur-md border border-awp-border/60 px-3 py-2 shadow-xl",children:[e.jsx(X,{icon:e.jsx(Tt,{className:"h-3 w-3"}),value:t.total,label:"nodes",color:"text-awp-text"}),e.jsx(Ke,{}),e.jsx(X,{icon:e.jsx(oe,{className:"h-3 w-3"}),value:t.iterations,label:"iter",color:"text-awp-yellow"}),e.jsx(X,{icon:e.jsx(fe,{className:"h-3 w-3"}),value:t.workers,label:"workers",color:"text-awp-cyan"}),e.jsx(X,{icon:e.jsx(Y,{className:"h-3 w-3"}),value:t.toolCalls,label:"tools",color:"text-awp-green"}),e.jsx(Ke,{}),t.running>0&&e.jsx(X,{icon:e.jsx(Be,{className:"h-3 w-3"}),value:t.running,label:"running",color:"text-awp-blue",pulse:!0}),t.errors>0&&e.jsx(X,{icon:e.jsx(le,{className:"h-3 w-3"}),value:t.errors,label:"errors",color:"text-awp-red"})]})}function X({icon:t,value:r,label:s,color:n,pulse:a}){return e.jsxs("div",{className:y("flex items-center gap-1.5 px-2 py-0.5 rounded-lg",a&&"animate-pulse"),children:[e.jsx("span",{className:n,children:t}),e.jsx("span",{className:y("text-xs font-bold tabular-nums",n),children:r}),e.jsx("span",{className:"text-[10px] text-awp-muted",children:s})]})}function Ke(){return e.jsx("div",{className:"w-px h-4 bg-awp-border/60 mx-1"})}function Qs({filters:t,setFilters:r,onFitView:s}){return e.jsxs("div",{className:"absolute top-4 right-4 z-10 flex flex-col gap-2",children:[e.jsx("div",{className:"flex flex-col rounded-xl bg-awp-panel/90 backdrop-blur-md border border-awp-border/60 shadow-xl overflow-hidden",children:e.jsx(ea,{tooltip:"Fit to view",onClick:s,icon:e.jsx($t,{className:"h-4 w-4"})})}),e.jsxs("div",{className:"flex flex-col rounded-xl bg-awp-panel/90 backdrop-blur-md border border-awp-border/60 shadow-xl overflow-hidden",children:[e.jsx(Ne,{tooltip:"Tools",active:t.showTools,onClick:()=>r(n=>({...n,showTools:!n.showTools})),icon:e.jsx(Y,{className:"h-3.5 w-3.5"}),color:"text-awp-green"}),e.jsx(Ne,{tooltip:"Workers",active:t.showWorkers,onClick:()=>r(n=>({...n,showWorkers:!n.showWorkers})),icon:e.jsx(ge,{className:"h-3.5 w-3.5"}),color:"text-awp-cyan"}),e.jsx(Ne,{tooltip:"Iterations",active:t.showIterations,onClick:()=>r(n=>({...n,showIterations:!n.showIterations})),icon:e.jsx(oe,{className:"h-3.5 w-3.5"}),color:"text-awp-yellow"})]})]})}function ea({tooltip:t,onClick:r,icon:s}){return e.jsx("button",{onClick:r,title:t,className:"flex items-center justify-center w-9 h-9 text-awp-muted hover:text-awp-text hover:bg-awp-border/40 transition-all duration-150",children:s})}function Ne({tooltip:t,active:r,onClick:s,icon:n,color:a}){return e.jsx("button",{onClick:s,title:t,className:y("flex items-center justify-center w-9 h-9 transition-all duration-150",r?`${a} bg-awp-border/20 hover:bg-awp-border/40`:"text-awp-muted/40 hover:text-awp-muted hover:bg-awp-border/20"),children:n})}function ta(){const[t,r]=w.useState(!1),s=[{icon:e.jsx(Ie,{className:"h-3 w-3 text-awp-blue"}),label:"Task",color:"bg-awp-blue"},{icon:e.jsx(De,{className:"h-3 w-3 text-awp-purple fill-awp-purple/30"}),label:"Manager",color:"bg-awp-purple"},{icon:e.jsx(oe,{className:"h-3 w-3 text-awp-yellow"}),label:"Iteration",color:"bg-awp-yellow"},{icon:e.jsx(ge,{className:"h-3 w-3 text-awp-cyan"}),label:"Worker",color:"bg-awp-cyan"},{icon:e.jsx(Y,{className:"h-3 w-3 text-awp-green"}),label:"Tool Call",color:"bg-awp-green"},{icon:e.jsx(Pe,{className:"h-3 w-3 text-awp-green"}),label:"Completion",color:"bg-awp-green"}],n=[{label:"Running",color:"bg-awp-blue",pulse:!0},{label:"Complete",color:"bg-awp-green",pulse:!1},{label:"Error",color:"bg-awp-red",pulse:!1},{label:"Pending",color:"bg-awp-muted",pulse:!1}];return e.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:t?e.jsxs("div",{className:"rounded-xl bg-awp-panel/90 backdrop-blur-md border border-awp-border/60 shadow-xl p-3 w-52 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-awp-text uppercase tracking-wider",children:"Legend"}),e.jsx("button",{onClick:()=>r(!1),className:"text-awp-muted hover:text-awp-text transition-colors",children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[9px] text-awp-muted uppercase tracking-wider mb-1",children:"Node Types"}),s.map(a=>e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[a.icon,e.jsx("span",{className:"text-[11px] text-awp-text",children:a.label})]},a.label))]}),e.jsxs("div",{className:"mt-2 pt-2 border-t border-awp-border/40 space-y-1",children:[e.jsx("div",{className:"text-[9px] text-awp-muted uppercase tracking-wider mb-1",children:"Status"}),n.map(a=>e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[a.pulse&&e.jsx("span",{className:y("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",a.color)}),e.jsx("span",{className:y("relative inline-flex h-2.5 w-2.5 rounded-full",a.color)})]}),e.jsx("span",{className:"text-[11px] text-awp-text",children:a.label})]},a.label))]})]}):e.jsxs("button",{onClick:()=>r(!0),className:"rounded-xl bg-awp-panel/90 backdrop-blur-md border border-awp-border/60 shadow-xl px-3 py-2 flex items-center gap-2 text-awp-muted hover:text-awp-text transition-colors",children:[e.jsxs("div",{className:"flex -space-x-1",children:[e.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-awp-blue border border-awp-panel"}),e.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-awp-purple border border-awp-panel"}),e.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-awp-yellow border border-awp-panel"}),e.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-awp-green border border-awp-panel"})]}),e.jsx("span",{className:"text-[11px]",children:"Legend"})]})})}function D({label:t,children:r}){return e.jsxs("div",{className:"flex items-start gap-3 py-1",children:[e.jsx("span",{className:"text-[10px] text-awp-muted shrink-0 w-[72px] text-right uppercase tracking-wider pt-px",children:t}),e.jsx("span",{className:"text-[11px] text-awp-text flex-1 min-w-0",children:r})]})}function sa({node:t,position:r}){const s=t.data??{},n=s.nodeType??t.type??"unknown",a=s.status??"pending",o=s.confidence,c=s.label??t.id,i=s.error,l=s.tools_used,u=s.toolCount,x=s.model,m=s.decision,h=s.iteration,d=s.reasoning,p=s.instructions,g=s.toolsAllowed,f=s.tools_created,b=s.budget,S=s.finalBudget,R=s.task,E=s.run_id,j=s.models,I=s.stdout,B=s.stderr,W=s.arguments,$=s.output,C=s.timing,G=s.iterationCount??s.totalIterations,z=s.code_mode,v=s.skills,T=s.outputs,k=s.worker_id,A={task:{icon:e.jsx(Ie,{className:"h-3.5 w-3.5"}),color:"text-awp-blue",border:"border-awp-blue/50"},manager:{icon:e.jsx(De,{className:"h-3.5 w-3.5 fill-current/30"}),color:"text-awp-purple",border:"border-awp-purple/50"},iteration:{icon:e.jsx(oe,{className:"h-3.5 w-3.5"}),color:"text-awp-yellow",border:"border-awp-yellow/50"},worker:{icon:e.jsx(ge,{className:"h-3.5 w-3.5"}),color:"text-awp-cyan",border:"border-awp-cyan/50"},toolCall:{icon:e.jsx(Y,{className:"h-3.5 w-3.5"}),color:"text-awp-green",border:"border-awp-green/50"},completion:{icon:e.jsx(Pe,{className:"h-3.5 w-3.5"}),color:"text-awp-green",border:"border-awp-green/50"}}[n]??{icon:null,color:"text-awp-muted",border:"border-awp-border/60"},Z=Math.min(r.x+16,window.innerWidth-380),U=Math.min(r.y-12,window.innerHeight-400);return e.jsxs("div",{className:y("fixed z-50 pointer-events-none animate-fade-in","rounded-xl bg-awp-panel/95 backdrop-blur-md border shadow-2xl","min-w-[260px] max-w-[360px] overflow-hidden",A.border),style:{left:Z,top:U},children:[e.jsxs("div",{className:y("flex items-center gap-2 px-4 py-2.5 border-b border-awp-border/30","bg-gradient-to-r from-awp-bg/80 to-transparent"),children:[e.jsx("span",{className:A.color,children:A.icon}),e.jsx("span",{className:"text-xs font-semibold text-awp-text truncate flex-1",children:c}),e.jsx(aa,{status:a})]}),e.jsxs("div",{className:"px-4 py-2.5 space-y-0.5 divide-y divide-awp-border/20",children:[e.jsx("div",{className:"pb-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-awp-muted uppercase tracking-wider",children:n}),k&&e.jsx("span",{className:"text-[9px] text-awp-muted/60 font-mono",children:k}),E&&e.jsx("span",{className:"text-[9px] text-awp-muted/60 font-mono",children:E})]})}),R&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Task",children:e.jsx("span",{className:"line-clamp-3",children:R})})}),(x||j)&&e.jsxs("div",{className:"pt-1.5",children:[x&&e.jsx(D,{label:"Model",children:e.jsx("span",{className:"font-mono text-[10px]",children:x})}),j&&!x&&Object.entries(j).map(([L,M])=>e.jsx(D,{label:L,children:e.jsx("span",{className:"font-mono text-[10px]",children:M})},L))]}),(h!==void 0||m)&&e.jsxs("div",{className:"pt-1.5",children:[h!==void 0&&e.jsx(D,{label:"Iteration",children:e.jsx("span",{className:"font-mono font-bold",children:String(h)})}),m&&e.jsx(D,{label:"Decision",children:e.jsx("span",{className:y("inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold",m==="delegate"?"bg-awp-yellow/15 text-awp-yellow":m==="complete"?"bg-awp-green/15 text-awp-green":"bg-awp-red/15 text-awp-red"),children:m.toUpperCase()})})]}),o!==void 0&&e.jsx("div",{className:"pt-1.5",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx("span",{className:"text-[10px] text-awp-muted shrink-0 w-[72px] text-right uppercase tracking-wider",children:"Confidence"}),e.jsx(ra,{value:o}),e.jsxs("span",{className:y("text-[11px] font-mono font-bold tabular-nums",o>=.8?"text-awp-green":o>=.5?"text-awp-yellow":"text-awp-red"),children:[(o*100).toFixed(0),"%"]})]})}),p&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Task",children:e.jsx("span",{className:"line-clamp-3 text-[10px]",children:p})})}),d&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Reasoning",children:e.jsx("span",{className:"line-clamp-3 text-[10px] italic text-awp-muted",children:d})})}),l&&l.length>0&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Tools",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[l.slice(0,8).map((L,M)=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-md bg-awp-bg/80 px-1.5 py-0.5 text-[9px] text-awp-green font-mono",children:[e.jsx(Y,{className:"h-2 w-2"}),L]},M)),l.length>8&&e.jsxs("span",{className:"text-[9px] text-awp-muted",children:["+",l.length-8]})]})})}),g&&g.length>0&&!l&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Tools",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,6).map((L,M)=>e.jsx("span",{className:"rounded-md bg-awp-bg/80 px-1.5 py-0.5 text-[9px] text-awp-muted font-mono",children:L},M)),g.length>6&&e.jsxs("span",{className:"text-[9px] text-awp-muted",children:["+",g.length-6]})]})})}),f&&f.length>0&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Created",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:f.map((L,M)=>e.jsx("span",{className:"rounded-md bg-awp-purple/10 border border-awp-purple/20 px-1.5 py-0.5 text-[9px] text-awp-purple font-mono",children:L},M))})})}),u!==void 0&&!l&&!g&&e.jsx("div",{className:"pt-1.5",children:e.jsxs(D,{label:"Tools",children:[u," tool call",u!==1?"s":""]})}),W&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Args",children:e.jsx("div",{className:"rounded overflow-hidden line-clamp-4",children:e.jsx(se,{language:"json",style:ae,customStyle:{margin:0,padding:"0.375rem 0.5rem",background:"rgba(13,17,23,0.6)",fontSize:"0.5625rem",lineHeight:"1.4"},wrapLines:!0,wrapLongLines:!0,children:JSON.stringify(W,null,2)})})})}),(I||$)&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Output",children:e.jsx("div",{className:"rounded overflow-hidden line-clamp-4",children:e.jsx(se,{language:"text",style:ae,customStyle:{margin:0,padding:"0.375rem 0.5rem",background:"rgba(13,17,23,0.6)",fontSize:"0.5625rem",lineHeight:"1.4"},wrapLines:!0,wrapLongLines:!0,children:String(I||$)})})})}),B&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Stderr",children:e.jsx("div",{className:"rounded overflow-hidden line-clamp-3",children:e.jsx(se,{language:"text",style:ae,customStyle:{margin:0,padding:"0.375rem 0.5rem",background:"rgba(13,17,23,0.6)",fontSize:"0.5625rem",lineHeight:"1.4"},wrapLines:!0,wrapLongLines:!0,children:B})})})}),(v&&v.length>0||z!==void 0)&&e.jsxs("div",{className:"pt-1.5 flex items-center gap-2",children:[z!==void 0&&e.jsxs("span",{className:y("rounded-md px-1.5 py-0.5 text-[9px] font-medium",z?"bg-awp-blue/10 text-awp-blue":"bg-awp-muted/10 text-awp-muted"),children:["Code: ",z?"ON":"OFF"]}),v&&v.map((L,M)=>e.jsx("span",{className:"rounded-md bg-awp-purple/10 px-1.5 py-0.5 text-[9px] text-awp-purple",children:L},M))]}),(b||S)&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Budget",children:e.jsx("div",{className:"grid grid-cols-2 gap-x-3 gap-y-0.5 text-[9px] font-mono",children:Object.entries(S??b??{}).slice(0,8).map(([L,M])=>e.jsxs("div",{className:"flex justify-between gap-1",children:[e.jsx("span",{className:"text-awp-muted truncate",children:L.replace(/_/g," ")}),e.jsx("span",{className:"text-awp-text font-semibold",children:String(M)})]},L))})})}),C&&C.duration_ms!==void 0&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Duration",children:e.jsxs("span",{className:"font-mono text-[10px]",children:[(C.duration_ms/1e3).toFixed(1),"s"]})})}),G!==void 0&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Iterations",children:e.jsx("span",{className:"font-mono font-bold",children:String(G)})})}),T&&Object.keys(T).length>0&&e.jsx("div",{className:"pt-1.5",children:e.jsx(D,{label:"Output",children:e.jsx("div",{className:"rounded overflow-hidden line-clamp-4",children:e.jsx(se,{language:"json",style:ae,customStyle:{margin:0,padding:"0.375rem 0.5rem",background:"rgba(13,17,23,0.6)",fontSize:"0.5625rem",lineHeight:"1.4"},wrapLines:!0,wrapLongLines:!0,children:JSON.stringify(T,null,2)})})})}),i&&e.jsx("div",{className:"pt-1.5",children:e.jsxs("div",{className:"rounded-md bg-awp-red/10 border border-awp-red/20 px-2.5 py-1.5",children:[e.jsx("div",{className:"text-[9px] text-awp-red/70 uppercase tracking-wider mb-0.5",children:"Error"}),e.jsx("span",{className:"text-[10px] text-awp-red line-clamp-4",children:i})]})})]})]})}function aa({status:t}){const r={running:"bg-awp-blue/15 text-awp-blue border-awp-blue/30",complete:"bg-awp-green/15 text-awp-green border-awp-green/30",error:"bg-awp-red/15 text-awp-red border-awp-red/30",pending:"bg-awp-muted/15 text-awp-muted border-awp-muted/30"};return e.jsxs("span",{className:y("inline-flex items-center rounded-full border px-1.5 py-0.5 text-[9px] font-medium",r[t]??r.pending),children:[t==="running"&&e.jsx("span",{className:"mr-1 h-1.5 w-1.5 rounded-full bg-current animate-pulse"}),t]})}function ra({value:t}){const r=t>=.8?"bg-awp-green":t>=.5?"bg-awp-yellow":"bg-awp-red";return e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-awp-border/40 overflow-hidden min-w-[40px]",children:e.jsx("div",{className:y("h-full rounded-full transition-all duration-500",r),style:{width:`${t*100}%`}})})}function na(){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 text-awp-muted",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-awp-blue/5 blur-3xl scale-150"}),e.jsx("div",{className:"relative rounded-2xl border-2 border-dashed border-awp-border/40 p-8",children:e.jsx(Ae,{className:"h-16 w-16 text-awp-border/60"})})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-awp-text/60",children:"No execution graph yet"}),e.jsx("p",{className:"text-xs text-awp-muted mt-1",children:"Start a workflow to see the interactive visualization"})]})]})}function oa(){const t=F(v=>v.graphNodes),r=F(v=>v.graphEdges),s=F(v=>v.selectNode),n=F(v=>v.currentRunId),a=F(v=>v.runStatus),o=F(v=>v.loadRunGraph),[c,i,l]=gt([]),[u,x,m]=wt([]),[h,d]=w.useState(null),[p,g]=w.useState({x:0,y:0}),[f,b]=w.useState({showTools:!0,showWorkers:!0,showIterations:!0}),[S,R]=w.useState(null);w.useEffect(()=>{n&&t.length===0&&a!=="running"&&o(n)},[n,t.length,a,o]);const E=w.useMemo(()=>{const v=new Set;f.showTools||v.add("toolCall"),f.showWorkers||v.add("worker"),f.showIterations||v.add("iteration");const T=t.filter(A=>{var U;const Z=((U=A.data)==null?void 0:U.nodeType)??A.type;return!v.has(Z)}),k=new Set(T.map(A=>A.id)),_=r.filter(A=>k.has(A.source)&&k.has(A.target));return{nodes:T,edges:_}},[t,r,f]);w.useEffect(()=>{const v=E.nodes.map(k=>{var _;return{...k,type:((_=k.data)==null?void 0:_.nodeType)??"task"}}),T=Js(v,E.edges);i(T),x(Ys(E.edges,T))},[E,i,x]);const j=w.useMemo(()=>Zs(t),[t]),I=w.useCallback((v,T)=>{s(T.id)},[s]),B=w.useCallback(()=>{s(null)},[s]),W=w.useCallback((v,T)=>{d(T)},[]),$=w.useCallback(()=>{d(null)},[]),C=w.useCallback(v=>{g({x:v.clientX,y:v.clientY})},[]),G=w.useCallback(()=>{S==null||S.fitView({padding:.3,duration:400})},[S]),z=w.useMemo(()=>Us,[]);return t.length===0?e.jsx(na,{}):e.jsxs("div",{className:"h-full w-full relative",onMouseMove:C,children:[e.jsx(Xs,{stats:j}),e.jsx(Qs,{filters:f,setFilters:b,onFitView:G}),e.jsx(ta,{}),e.jsxs(bt,{nodes:c,edges:u,onNodesChange:l,onEdgesChange:m,onNodeClick:I,onPaneClick:B,onNodeMouseEnter:W,onNodeMouseLeave:$,onInit:R,nodeTypes:z,fitView:!0,fitViewOptions:{padding:.3},minZoom:.1,maxZoom:3,proOptions:{hideAttribution:!0},defaultEdgeOptions:{type:"smoothstep"},children:[e.jsx(ft,{variant:yt.Dots,color:"#1c2128",gap:24,size:1.5}),e.jsx(jt,{className:"!bg-awp-panel/90 !backdrop-blur-md !border-awp-border/60 !rounded-xl !shadow-xl [&>button]:!bg-transparent [&>button]:!border-awp-border/30 [&>button]:!text-awp-muted [&>button:hover]:!bg-awp-border/40 [&>button:hover]:!text-awp-text [&>button]:!rounded-lg [&>button]:!transition-all [&>button]:!duration-150",showInteractive:!1,position:"bottom-right"}),e.jsx(kt,{className:"!bg-awp-panel/90 !backdrop-blur-md !border-awp-border/60 !rounded-xl !shadow-xl",nodeColor:v=>{var _,A;const T=((_=v.data)==null?void 0:_.nodeType)??v.type,k=(A=v.data)==null?void 0:A.status;if(k==="error")return"#FF1744";if(k==="running")return"#40C4FF";switch(T){case"task":return"#40C4FF";case"manager":return"#E040FB";case"iteration":return"#FFD600";case"worker":return"#18FFFF";case"toolCall":return"#00E676";case"completion":return"#00E676";default:return"#8b949e"}},maskColor:"rgba(13, 17, 23, 0.85)",pannable:!0,zoomable:!0})]}),h&&e.jsx(sa,{node:h,position:p})]})}function la(t,r){var n;if(r){const a=(n=r.split(".").pop())==null?void 0:n.toLowerCase();if(a==="py")return"python";if(a==="js")return"javascript";if(a==="ts"||a==="tsx")return"typescript";if(a==="json")return"json";if(a==="yaml"||a==="yml")return"yaml";if(a==="sh"||a==="bash")return"bash";if(a==="html"||a==="htm")return"html";if(a==="css")return"css";if(a==="sql")return"sql";if(a==="md")return"markdown"}const s=t.trimStart();return s.startsWith("{")||s.startsWith("[")?"json":s.startsWith("import ")||s.startsWith("def ")||s.startsWith("class ")||s.includes("print(")?"python":s.startsWith("function ")||s.startsWith("const ")||s.startsWith("let ")?"javascript":s.startsWith("---")?"yaml":s.startsWith("SELECT ")||s.startsWith("CREATE ")?"sql":"text"}function ne({content:t,language:r,filename:s,maxHeight:n="24rem"}){const a=r??la(t,s);return e.jsxs("div",{className:"rounded-md overflow-hidden border border-awp-border",children:[s?e.jsx("div",{className:"px-3 py-1 bg-awp-panel border-b border-awp-border text-[10px] text-awp-muted font-mono",children:s}):null,e.jsx("div",{style:{maxHeight:n},className:"overflow-y-auto",children:e.jsx(se,{language:a,style:ae,customStyle:{margin:0,padding:"0.75rem",background:"#0d1117",fontSize:"0.75rem",lineHeight:"1.5"},wrapLines:!0,wrapLongLines:!0,children:t})})]})}function K({data:t}){let r;if(typeof t=="string")try{r=JSON.stringify(JSON.parse(t),null,2)}catch{r=t}else r=JSON.stringify(t,null,2);return e.jsx(ne,{content:r,language:"json",maxHeight:"none"})}function ye(t){switch(t){case"running":return"blue";case"complete":return"green";case"error":return"red";default:return"default"}}function ia(t){switch(t){case"running":return e.jsx(we,{className:"h-3.5 w-3.5 animate-spin"});case"complete":return e.jsx(Ee,{className:"h-3.5 w-3.5"});case"error":return e.jsx(Me,{className:"h-3.5 w-3.5"});default:return e.jsx(Te,{className:"h-3.5 w-3.5"})}}function ca(){const{runStatus:t,budget:r,activePanel:s,setActivePanel:n,sidebarOpen:a,toggleSidebar:o,inspectorOpen:c,toggleInspector:i,currentSessionId:l,sessions:u}=F(),x=u.find(g=>g.id===l),m=t==="running",h=[{id:"protocol",label:"Protocol",icon:e.jsx(Ot,{className:"h-4 w-4"})},{id:"output",label:"Output",icon:e.jsx(It,{className:"h-4 w-4"})},{id:"results",label:"Results",icon:e.jsx(ue,{className:"h-4 w-4"})},{id:"graph",label:"Graph",icon:e.jsx(Ae,{className:"h-4 w-4"})},{id:"graphvis",label:"Graph Vis",icon:e.jsx(At,{className:"h-4 w-4"})},{id:"memory",label:"Memory",icon:e.jsx(Qe,{className:"h-4 w-4"})},{id:"history",label:"History",icon:e.jsx(tt,{className:"h-4 w-4"})}],d=r.tokens_max>0?r.tokens_used/r.tokens_max:0,p=r.loops_max>0?r.loops_used/r.loops_max:0;return e.jsxs("header",{className:"flex items-center gap-2 border-b border-awp-border bg-awp-panel px-3 h-12 shrink-0",children:[e.jsx(Je,{tooltip:"Toggle experiments",onClick:o,size:"sm",children:a?e.jsx(Ft,{className:"h-4 w-4"}):e.jsx(Pt,{className:"h-4 w-4"})}),x&&e.jsx("span",{className:"text-xs font-medium text-awp-muted truncate max-w-[160px]",title:x.title,children:x.title}),e.jsxs(J,{variant:ye(t),dot:m,children:[ia(t),e.jsx("span",{className:"ml-1 capitalize",children:t})]}),m&&e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-2 text-xs text-awp-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",title:"Tokens used",children:[e.jsx(Be,{className:"h-3 w-3"}),(r.tokens_used/1e3).toFixed(0),"k",e.jsx(re,{value:d,className:"w-12"})]}),e.jsxs("span",{className:"flex items-center gap-1",title:"Loops",children:[e.jsx(Re,{className:"h-3 w-3"}),r.loops_used,"/",r.loops_max,e.jsx(re,{value:p,className:"w-12"})]}),e.jsxs("span",{className:"flex items-center gap-1",title:"Workers",children:[e.jsx(fe,{className:"h-3 w-3"}),r.workers_used,"/",r.workers_max]})]}),e.jsx("div",{className:"flex-1"}),e.jsx(Ss,{tabs:h,activeId:s,onChange:g=>n(g),className:"border-b-0 bg-transparent"}),e.jsx("div",{className:"flex-1"}),e.jsx(Je,{tooltip:"Toggle settings",onClick:i,size:"sm",children:c?e.jsx(Dt,{className:"h-4 w-4"}):e.jsx(Bt,{className:"h-4 w-4"})})]})}function da(){const{config:t,updateConfig:r,attachedFiles:s,addFiles:n,removeFile:a,runStatus:o,startRun:c,stopRun:i}=F(),l=w.useRef(null),u=w.useRef(null),x=w.useCallback(p=>{p.target.files&&(n(Array.from(p.target.files)),p.target.value="")},[n]),m=o==="running",h=t.task.trim().length>0&&!m,d=w.useCallback(p=>{p.key==="Enter"&&!p.shiftKey&&h&&(p.preventDefault(),c())},[h,c]);return w.useEffect(()=>{const p=u.current;p&&(p.style.height="auto",p.style.height=Math.min(p.scrollHeight,300)+"px")},[t.task]),e.jsxs("div",{className:"border-t border-awp-border bg-awp-panel px-4 py-3 shrink-0",children:[s.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 max-w-3xl mx-auto",children:s.map((p,g)=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-awp-bg border border-awp-border px-2 py-0.5 text-xs text-awp-text",children:[e.jsx(We,{className:"h-3 w-3 text-awp-muted shrink-0"}),e.jsx("span",{className:"truncate max-w-[120px]",children:p.name}),e.jsx("button",{type:"button",onClick:()=>a(g),className:"text-awp-muted hover:text-awp-red transition-colors ml-0.5 shrink-0",children:e.jsx(be,{className:"h-3 w-3"})})]},`${p.name}-${g}`))}),e.jsxs("div",{className:"flex items-end gap-2 max-w-3xl mx-auto",children:[e.jsxs("label",{className:y("inline-flex items-center justify-center h-8 w-8 rounded-md transition-colors cursor-pointer shrink-0","text-awp-muted hover:text-awp-text hover:bg-awp-border/50",m&&"opacity-40 pointer-events-none"),title:"Attach files",children:[e.jsx(We,{className:"h-4 w-4"}),e.jsx("input",{ref:l,type:"file",multiple:!0,onChange:x,disabled:m,className:"sr-only"})]}),e.jsx("div",{className:"flex-1 relative",children:e.jsx("textarea",{ref:u,value:t.task,onChange:p=>r({task:p.target.value}),onKeyDown:d,placeholder:"Describe the task for the agent workflow...",disabled:m,rows:3,className:y("w-full resize-none rounded-lg border border-awp-border bg-awp-bg px-3 py-2.5 pr-10","text-sm text-awp-text placeholder:text-awp-muted/60","focus:outline-none focus:ring-1 focus:ring-awp-blue focus:border-awp-blue","disabled:opacity-50 disabled:cursor-not-allowed")})}),m?e.jsx("button",{type:"button",onClick:i,className:"inline-flex items-center justify-center h-9 w-9 rounded-lg bg-awp-red/15 text-awp-red hover:bg-awp-red/25 transition-colors shrink-0",children:e.jsx(qt,{className:"h-4 w-4"})}):e.jsx("button",{type:"button",onClick:c,disabled:!h,className:y("inline-flex items-center justify-center h-9 w-9 rounded-lg transition-colors shrink-0",h?"bg-awp-blue/15 text-awp-blue hover:bg-awp-blue/25":"bg-awp-border/30 text-awp-muted cursor-not-allowed"),children:e.jsx(Lt,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-center text-[10px] text-awp-muted/50 mt-1.5 max-w-3xl mx-auto",children:"Enter to run · Shift+Enter for new line"})]})}function pa(){const{config:t,updateConfig:r,runStatus:s,secrets:n,addSecret:a,removeSecret:o,selectedNodeId:c,graphNodes:i}=F(),l=s==="running",u=i.find(x=>x.id===c);return e.jsxs("aside",{className:"flex flex-col gap-3 h-full overflow-y-auto p-3",children:[e.jsx(ke,{title:"Settings",icon:e.jsx(Wt,{className:"h-4 w-4 text-awp-green"}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Model"}),e.jsxs("p",{className:"text-[10px] text-awp-muted/70 mt-0.5 mb-1",children:["Auto-routes: ",e.jsx("span",{className:"font-mono",children:"provider/model"})," → OpenRouter, ",e.jsx("span",{className:"font-mono",children:"gpt-*"})," → OpenAI, ",e.jsx("span",{className:"font-mono",children:"claude-*"})," → Anthropic, ",e.jsx("span",{className:"font-mono",children:"ollama/*"})," → local"]}),e.jsx("input",{type:"text",value:t.model,onChange:x=>r({model:x.target.value}),disabled:l,placeholder:"nvidia/nemotron-3-super-120b-a12b:free",className:"w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm font-mono text-awp-text placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Worker model"}),e.jsx("p",{className:"text-[10px] text-awp-muted/70 mt-0.5 mb-1",children:"Used for sub-agents. Leave empty to use the main model."}),e.jsx("input",{type:"text",value:t.worker_model??"",onChange:x=>r({worker_model:x.target.value||void 0}),disabled:l,placeholder:"Same as main model",className:"w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm font-mono text-awp-text placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Sandbox"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsxs("select",{value:t.sandbox,onChange:x=>r({sandbox:x.target.value}),disabled:l,className:"w-full appearance-none rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 pr-8 text-sm text-awp-text focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50",children:[e.jsx("option",{value:"subprocess",children:"Subprocess"}),e.jsx("option",{value:"docker",children:"Docker"}),e.jsx("option",{value:"venv",children:"Virtualenv"}),e.jsx("option",{value:"none",children:"None"})]}),e.jsx(_e,{className:"pointer-events-none absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-awp-muted"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Max loops"}),e.jsx("input",{type:"number",min:1,value:t.max_loops,onChange:x=>r({max_loops:Number(x.target.value)}),disabled:l,className:"mt-1 w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm text-awp-text focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Max workers"}),e.jsx("input",{type:"number",min:1,value:t.max_total_workers,onChange:x=>r({max_total_workers:Number(x.target.value)}),disabled:l,className:"mt-1 w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm text-awp-text focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Max tokens"}),e.jsx("input",{type:"number",min:1e3,step:1e4,value:t.max_total_tokens,onChange:x=>r({max_total_tokens:Number(x.target.value)}),disabled:l,className:"mt-1 w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm text-awp-text focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Wall time (s)"}),e.jsx("input",{type:"number",min:10,value:t.max_wall_time,onChange:x=>r({max_wall_time:Number(x.target.value)}),disabled:l,className:"mt-1 w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm text-awp-text focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-awp-text cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.code_mode,onChange:x=>r({code_mode:x.target.checked}),disabled:l,className:"rounded border-awp-border bg-awp-bg text-awp-blue focus:ring-awp-blue"}),"Code mode"]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-awp-text cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.tool_creation,onChange:x=>r({tool_creation:x.target.checked}),disabled:l,className:"rounded border-awp-border bg-awp-bg text-awp-blue focus:ring-awp-blue"}),"Tool creation"]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-awp-text cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.verbose,onChange:x=>r({verbose:x.target.checked}),disabled:l,className:"rounded border-awp-border bg-awp-bg text-awp-blue focus:ring-awp-blue"}),"Verbose"]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Output directory"}),e.jsx("input",{type:"text",value:t.output_dir,onChange:x=>r({output_dir:x.target.value}),disabled:l,placeholder:"/tmp/awp-output",className:"mt-1 w-full rounded-md border border-awp-border bg-awp-bg px-2.5 py-1.5 text-sm text-awp-text placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue disabled:opacity-50"})]})]})}),e.jsx(ke,{title:"Secrets",icon:e.jsx(ve,{className:"h-4 w-4 text-awp-yellow"}),defaultOpen:!1,children:e.jsx(Ds,{secrets:n,onAdd:a,onDelete:o})}),u&&e.jsx(ke,{title:"Inspector",icon:e.jsx(Re,{className:"h-4 w-4 text-awp-purple"}),children:e.jsx(ua,{node:u})})]})}function ua({node:t}){const r=t.data,s=r.status??"pending";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-awp-text",children:r.label??t.id}),e.jsx(J,{variant:ye(s),className:"mt-1",children:s})]}),r.confidence!==void 0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Confidence"}),e.jsx(re,{value:r.confidence,showLabel:!0,color:"bg-awp-green",className:"mt-1"})]}),Array.isArray(r.tools_used)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Tools"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:r.tools_used.map(n=>e.jsx(J,{variant:"orange",children:n},n))})]}),typeof r.error=="string"&&e.jsx("div",{className:"rounded border border-awp-red/30 bg-awp-red/5 p-2 text-xs text-awp-red",children:String(r.error)}),r.inputs!=null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Inputs"}),e.jsx("div",{className:"mt-1",children:e.jsx(K,{data:r.inputs})})]}),r.outputs!=null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-awp-muted",children:"Outputs"}),e.jsx("div",{className:"mt-1",children:e.jsx(K,{data:r.outputs})})]})]})}function pe(t,r,s,n=800){const a=w.useRef(null),o=w.useRef(s);w.useEffect(()=>{if(!(!t||s===o.current))return o.current=s,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{Ce(t,{[r]:s}).catch(()=>{})},n),()=>{a.current&&clearTimeout(a.current)}},[t,r,s,n])}function xa(){var T;const{currentSessionId:t,sessions:r,runStatus:s,outputBlocks:n,budget:a,config:o,runHistory:c,updateSessionMetadata:i}=F(),l=r.find(k=>k.id===t),[u,x]=P.useState((l==null?void 0:l.title)??""),[m,h]=P.useState((l==null?void 0:l.hypothesis)??""),[d,p]=P.useState((l==null?void 0:l.description)??""),[g,f]=P.useState((l==null?void 0:l.status)??"draft"),[b,S]=P.useState((l==null?void 0:l.tags)??[]),[R,E]=P.useState((l==null?void 0:l.base_dir)??""),[j,I]=P.useState("");w.useEffect(()=>{x((l==null?void 0:l.title)??""),h((l==null?void 0:l.hypothesis)??""),p((l==null?void 0:l.description)??""),f((l==null?void 0:l.status)??"draft"),S((l==null?void 0:l.tags)??[]),E((l==null?void 0:l.base_dir)??"")},[t,l==null?void 0:l.title,l==null?void 0:l.hypothesis,l==null?void 0:l.description,l==null?void 0:l.status,l==null?void 0:l.tags,l==null?void 0:l.base_dir]),pe(t,"title",u),pe(t,"hypothesis",m),pe(t,"description",d),pe(t,"base_dir",R);const B=w.useCallback(k=>{f(k),t&&i(t,{status:k})},[t,i]),W=w.useCallback(()=>{const k=j.trim();if(!k||b.includes(k)){I("");return}const _=[...b,k];S(_),I(""),t&&i(t,{tags:_})},[j,b,t,i]),$=w.useCallback(k=>{const _=b.filter(A=>A!==k);S(_),t&&i(t,{tags:_})},[b,t,i]),C=n.find(k=>k.title==="Final Result"||k.title==="Agent Result"),G=n.find(k=>k.type==="error"),z=c.length,v={draft:"text-awp-muted border-awp-border",running:"text-awp-blue border-awp-blue/50",complete:"text-awp-green border-awp-green/50",failed:"text-awp-red border-awp-red/50",archived:"text-awp-muted border-awp-muted/50"};return t?e.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-4",children:[e.jsx("input",{type:"text",value:u,onChange:k=>x(k.target.value),className:"w-full bg-transparent text-xl font-semibold text-awp-text border-none outline-none placeholder:text-awp-muted/50",placeholder:"Experiment title..."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{value:g,onChange:k=>B(k.target.value),className:y("text-xs font-medium px-2 py-1 rounded border bg-transparent cursor-pointer",v[g]??v.draft),children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"running",children:"Running"}),e.jsx("option",{value:"complete",children:"Complete"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"archived",children:"Archived"})]}),s==="running"&&e.jsxs("div",{className:"flex items-center gap-1 text-awp-blue text-xs",children:[e.jsx(we,{className:"h-3.5 w-3.5 animate-spin"})," Run in progress"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider block mb-1",children:"Hypothesis"}),e.jsx("textarea",{value:m,onChange:k=>h(k.target.value),rows:2,className:"w-full bg-awp-bg border border-awp-border rounded-md px-3 py-2 text-sm text-awp-text resize-y placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue/50",placeholder:"What do you expect to find?"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider block mb-1",children:"Description"}),e.jsx("textarea",{value:d,onChange:k=>p(k.target.value),rows:3,className:"w-full bg-awp-bg border border-awp-border rounded-md px-3 py-2 text-sm text-awp-text resize-y placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue/50",placeholder:"Describe the experiment setup, methodology, context..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider block mb-1",children:"Tags"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[b.map(k=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-awp-blue/10 text-awp-blue text-xs",children:[e.jsx(Gt,{className:"h-2.5 w-2.5"}),k,e.jsx("button",{type:"button",onClick:()=>$(k),className:"hover:text-awp-red transition-colors",children:e.jsx(le,{className:"h-2.5 w-2.5"})})]},k)),e.jsx("div",{className:"inline-flex items-center gap-1",children:e.jsx("input",{type:"text",value:j,onChange:k=>I(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),W())},className:"w-20 bg-transparent border-b border-awp-border text-xs text-awp-text outline-none placeholder:text-awp-muted/40",placeholder:"+ Add"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider block mb-1",children:"Base Directory"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:R,onChange:k=>E(k.target.value),className:"flex-1 bg-awp-bg border border-awp-border rounded-md px-3 py-1.5 text-xs font-mono text-awp-text placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue/50",placeholder:"/path/to/experiments"}),R&&e.jsx("button",{type:"button",onClick:()=>nt(R).catch(()=>{}),className:"shrink-0 flex items-center gap-1 px-2 py-1.5 text-xs text-awp-muted hover:text-awp-blue border border-awp-border rounded-md hover:border-awp-blue/30 hover:bg-awp-blue/5 transition-colors",title:"Open in file explorer",children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg p-4",children:[e.jsx("span",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider block mb-3",children:"Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-awp-muted",children:"Model"}),e.jsx("p",{className:"text-awp-text font-mono truncate",children:((T=o.model)==null?void 0:T.split("/").pop())??"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-awp-muted",children:"Sandbox"}),e.jsx("p",{className:"text-awp-text font-mono",children:o.sandbox})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-awp-muted",children:"Max Loops"}),e.jsx("p",{className:"text-awp-text font-mono",children:o.max_loops})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-awp-muted",children:"Token Budget"}),e.jsxs("p",{className:"text-awp-text font-mono",children:[(o.max_total_tokens/1e3).toFixed(0),"k"]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg p-4",children:[e.jsx("span",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider block mb-3",children:"Statistics"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-awp-text",children:z}),e.jsx("span",{className:"text-awp-muted",children:"Runs"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-awp-text",children:a.tokens_used>0?`${(a.tokens_used/1e3).toFixed(0)}k`:"-"}),e.jsx("span",{className:"text-awp-muted",children:"Tokens"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-awp-text",children:a.wall_time_ms>0?`${(a.wall_time_ms/1e3).toFixed(1)}s`:"-"}),e.jsx("span",{className:"text-awp-muted",children:"Wall Time"})]})]}),a.loops_used>0||a.tokens_used>0?e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs mt-3 pt-3 border-t border-awp-border",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-awp-muted",children:"Iterations"}),e.jsxs("p",{className:"text-awp-text font-mono",children:[a.loops_used," / ",a.loops_max]}),e.jsx(re,{value:a.loops_max>0?a.loops_used/a.loops_max:0,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-awp-muted",children:"Workers"}),e.jsxs("p",{className:"text-awp-text font-mono",children:[a.workers_used," / ",a.workers_max]})]})]}):null]}),C?e.jsxs("div",{className:"rounded-lg border border-awp-green/30 bg-awp-green/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ee,{className:"h-4 w-4 text-awp-green shrink-0"}),e.jsx("span",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider",children:C.title})]}),C.type==="markdown"?e.jsx("div",{className:"prose prose-sm prose-invert max-w-none break-words",children:e.jsx(xe,{remarkPlugins:[he],rehypePlugins:[me],children:C.content})}):e.jsx(K,{data:C.content})]}):null,G&&!C?e.jsxs("div",{className:"rounded-lg border border-awp-red/30 bg-awp-red/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Me,{className:"h-4 w-4 text-awp-red shrink-0"}),e.jsx("span",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider",children:"Error"})]}),e.jsx("p",{className:"text-sm text-awp-red whitespace-pre-wrap break-words",children:G.content})]}):null]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-awp-muted gap-3",children:[e.jsx($e,{className:"h-12 w-12 text-awp-border"}),e.jsx("p",{className:"text-sm",children:"Select or create an experiment to begin"})]})}function ma(){const{currentRunId:t,runStatus:r}=F(),[s,n]=P.useState([]),[a,o]=P.useState({}),[c,i]=P.useState(!1);if(w.useEffect(()=>{t&&(i(!0),ls(t).then(p=>{n(p);const g=p.filter(f=>["text","code","table"].includes(f.kind));Promise.all(g.map(f=>fetch(is(f.path)).then(b=>b.text()).then(b=>[f.path,b]))).then(f=>{o(Object.fromEntries(f))})}).catch(()=>{}).finally(()=>i(!1)))},[t,r]),!t)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-awp-muted gap-3",children:[e.jsx(ue,{className:"h-12 w-12 text-awp-border"}),e.jsx("p",{className:"text-sm",children:"Final outputs will appear here after a run"})]});const l=s.filter(p=>p.kind==="image"),u=s.filter(p=>p.kind==="table"),x=s.filter(p=>p.kind==="html"),m=s.filter(p=>p.kind==="text"),h=s.filter(p=>p.kind==="code"),d=s.length>0?s[0].path.substring(0,s[0].path.lastIndexOf("/")):null;return e.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider",children:["Artifacts (",s.length,")"]}),d&&e.jsx("button",{type:"button",onClick:()=>nt(d).catch(()=>{}),className:"shrink-0 flex items-center gap-1 px-2 py-1.5 text-xs text-awp-muted hover:text-awp-blue border border-awp-border rounded-md hover:border-awp-blue/30 hover:bg-awp-blue/5 transition-colors",title:`Open ${d}`,children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]}),c?e.jsxs("div",{className:"flex items-center gap-2 text-awp-muted text-sm",children:[e.jsx(we,{className:"h-4 w-4 animate-spin"})," Loading artifacts..."]}):null,l.length>0?e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider mb-2",children:["Images (",l.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:l.map(p=>{const g=`/api/files/serve?path=${encodeURIComponent(p.path)}`;return e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg p-2",children:[e.jsx("img",{src:g,alt:p.name,className:"max-w-full rounded"}),e.jsx("p",{className:"text-[10px] text-awp-muted mt-1 truncate",children:p.relative})]},p.path)})})]}):null,x.length>0?e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider mb-2",children:["Visualizations (",x.length,")"]}),x.map(p=>{const g=`/api/files/serve?path=${encodeURIComponent(p.path)}`;return e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg overflow-hidden mb-3",children:[e.jsxs("div",{className:"px-3 py-1.5 border-b border-awp-border flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-awp-muted truncate",children:p.name}),e.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-awp-blue hover:underline",children:"Open"})]}),e.jsx("iframe",{src:g,className:"w-full h-96 border-0",title:p.name,sandbox:"allow-scripts"})]},p.path)})]}):null,u.length>0?e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider mb-2",children:["Tables (",u.length,")"]}),u.map(p=>{var R;const f=(a[p.path]??"").split(`
`).filter(Boolean),b=((R=f[0])==null?void 0:R.split(","))??[],S=f.slice(1,101);return e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg overflow-hidden mb-3",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-awp-border",children:e.jsxs("span",{className:"text-xs text-awp-muted",children:[p.name," (",f.length-1," rows)"]})}),e.jsx("div",{className:"overflow-x-auto max-h-96",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-awp-panel sticky top-0",children:e.jsx("tr",{children:b.map((E,j)=>e.jsx("th",{className:"px-2 py-1.5 text-left text-awp-muted font-medium border-b border-awp-border whitespace-nowrap",children:E.trim()},j))})}),e.jsx("tbody",{children:S.map((E,j)=>e.jsx("tr",{className:"hover:bg-awp-bg/60",children:E.split(",").map((I,B)=>e.jsx("td",{className:"px-2 py-1 text-awp-text border-b border-awp-border/50 whitespace-nowrap",children:I.trim()},B))},j))})]})}),f.length>101?e.jsxs("div",{className:"px-3 py-1 text-[10px] text-awp-muted border-t border-awp-border",children:["Showing first 100 of ",f.length-1," rows"]}):null]},p.path)})]}):null,m.length>0?e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider mb-2",children:["Documents (",m.length,")"]}),m.map(p=>{const g=a[p.path]??"",f=p.name.endsWith(".md"),b=p.name.endsWith(".json"),S=p.name.endsWith(".yaml")||p.name.endsWith(".yml");return e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg p-3 mb-3",children:[e.jsx("span",{className:"text-xs text-awp-muted block mb-2",children:p.relative}),f?e.jsx("div",{className:"prose prose-sm prose-invert max-w-none break-words",children:e.jsx(xe,{remarkPlugins:[he],rehypePlugins:[me],children:g})}):b?e.jsx(K,{data:g}):e.jsx(ne,{content:g,language:S?"yaml":void 0,filename:p.name,maxHeight:"none"})]},p.path)})]}):null,h.length>0?e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider mb-2",children:["Code (",h.length,")"]}),h.map(p=>{const g=a[p.path]??"";return e.jsx("div",{className:"mb-3",children:e.jsx(ne,{content:g,filename:p.relative,maxHeight:"none"})},p.path)})]}):null,!c&&s.length===0&&r!=="running"?e.jsx("div",{className:"text-center text-awp-muted text-sm mt-8",children:"No artifacts generated by this run"}):null]})}function ha(){const{outputBlocks:t,runStatus:r}=F(),s=w.useRef(null);return w.useEffect(()=>{var n;(n=s.current)==null||n.scrollIntoView({behavior:"smooth"})},[t.length]),t.length===0&&r==="idle"?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-awp-muted gap-3",children:[e.jsx(Be,{className:"h-12 w-12 text-awp-border"}),e.jsx("p",{className:"text-sm",children:"Enter a task and click Run to begin"})]}):e.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-3",children:[t.map((n,a)=>e.jsx(ga,{block:n},a)),e.jsx("div",{ref:s})]})}function ga({block:t}){const r=t.type==="error"?"border-awp-red/30 bg-awp-red/5":"border-awp-border bg-awp-bg";return e.jsxs("div",{className:y("rounded-lg border p-4 animate-fade-in",r),children:[t.title&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.type==="error"&&e.jsx(Me,{className:"h-4 w-4 text-awp-red shrink-0"}),e.jsx("span",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider",children:t.title})]}),t.type==="markdown"&&e.jsx("div",{className:"prose prose-sm prose-invert max-w-none break-words",children:e.jsx(xe,{remarkPlugins:[he],rehypePlugins:[me],children:t.content})}),t.type==="code"&&e.jsx(ne,{content:t.content}),t.type==="json"&&e.jsx(K,{data:t.content}),t.type==="error"&&e.jsx("p",{className:"text-sm text-awp-red whitespace-pre-wrap break-words",children:t.content}),t.type==="image"&&e.jsx("img",{src:t.content,alt:t.title??"output",className:"max-w-full rounded"}),(t.type==="table"||t.type==="chart"||t.type==="file")&&e.jsx(ne,{content:t.content,maxHeight:"none"})]})}function wa(t){switch(t){case"manager":return e.jsx(Re,{className:"h-4 w-4 text-awp-purple shrink-0"});case"worker":return e.jsx(fe,{className:"h-4 w-4 text-awp-blue shrink-0"});case"toolCall":return e.jsx(Y,{className:"h-4 w-4 text-awp-orange shrink-0"});case"iteration":return e.jsx(at,{className:"h-4 w-4 text-awp-yellow shrink-0"});case"completion":return e.jsx(Ee,{className:"h-4 w-4 text-awp-green shrink-0"});default:return e.jsx(Te,{className:"h-4 w-4 text-awp-cyan shrink-0"})}}function ba(t,r){const s={},n=new Set;for(const o of r)s[o.source]||(s[o.source]=[]),s[o.source].push(o.target),n.add(o.target);return{roots:t.filter(o=>!n.has(o.id)).map(o=>o.id),children:s}}function V({label:t,children:r}){return e.jsxs("div",{className:"mt-1",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-awp-muted font-medium",children:t}),e.jsx("div",{className:"mt-0.5 text-xs text-awp-text",children:r})]})}function ct({nodeId:t,nodes:r,childMap:s,depth:n}){const[a,o]=P.useState(!0),c=r.get(t);if(!c)return null;const i=c.data,l=i.status??"pending",u=i.nodeType??c.type??"task",x=i.label??t,m=i.confidence,h=i.reasoning,d=i.decision,p=i.details,g=i.outputs,f=i.error,b=Array.isArray(i.tools_used)?i.tools_used.map(String):[],S=Array.isArray(i.tools_created)?i.tools_created.map(String):[],R=i.instructions,E=i.delegations,j=i.arguments,I=i.iteration,B=s[t]??[],W=B.length>0,$=n*20;return e.jsxs("div",{style:{marginLeft:$},children:[e.jsxs("div",{className:y("rounded-lg border p-2.5 mb-1.5 transition-colors",l==="running"&&"border-awp-blue/50 bg-awp-blue/5",l==="complete"&&"border-awp-green/30 bg-awp-green/5",l==="error"&&"border-awp-red/30 bg-awp-red/5",l==="pending"&&"border-awp-border bg-awp-bg"),children:[e.jsx("button",{type:"button",onClick:()=>o(!a),className:"w-full text-left",children:e.jsxs("div",{className:"flex items-center gap-2",children:[W?a?e.jsx(_e,{className:"h-3.5 w-3.5 text-awp-muted shrink-0"}):e.jsx(et,{className:"h-3.5 w-3.5 text-awp-muted shrink-0"}):e.jsx("span",{className:"w-3.5 shrink-0"}),wa(u),e.jsx("span",{className:"text-xs font-medium text-awp-text truncate flex-1",children:x}),l==="running"&&e.jsx(we,{className:"h-3 w-3 text-awp-blue animate-spin shrink-0"}),e.jsx(J,{variant:ye(l),className:"shrink-0 text-[10px]",children:l})]})}),a&&e.jsxs("div",{className:"mt-2 ml-9 space-y-1",children:[m!==void 0&&e.jsx(V,{label:"Confidence",children:e.jsx(re,{value:m,color:m>=.8?"bg-awp-green":m>=.5?"bg-awp-yellow":"bg-awp-red",showLabel:!0})}),d&&e.jsx(V,{label:"Decision",children:e.jsx(J,{variant:d==="complete"?"green":d==="delegate"?"blue":"yellow",className:"text-[10px]",children:d})}),h&&e.jsx(V,{label:"Reasoning",children:e.jsx("p",{className:"text-xs text-awp-muted whitespace-pre-wrap break-words leading-relaxed",children:h})}),b.length>0?e.jsx(V,{label:"Tools",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:b.map(C=>e.jsx(J,{variant:"orange",className:"text-[10px]",children:C},C))})}):null,R?e.jsx(V,{label:"Instructions",children:e.jsx("p",{className:"text-xs text-awp-text whitespace-pre-wrap break-words leading-relaxed bg-awp-bg rounded p-1.5 max-h-32 overflow-y-auto",children:R})}):null,E&&E.length>0?e.jsx(V,{label:`Delegations (${E.length})`,children:e.jsx("div",{className:"space-y-1",children:E.map((C,G)=>e.jsxs("div",{className:"rounded bg-awp-bg p-1.5 text-[11px]",children:[e.jsx("span",{className:"font-mono text-awp-purple",children:String(C.worker)}),e.jsx("p",{className:"text-awp-muted mt-0.5",children:String(C.task)}),Array.isArray(C.tools)&&C.tools.length>0?e.jsx("div",{className:"flex flex-wrap gap-0.5 mt-0.5",children:C.tools.map(z=>e.jsx("span",{className:"text-[9px] bg-awp-orange/10 text-awp-orange rounded px-1",children:z},z))}):null]},G))})}):null,j!=null&&Object.keys(j).length>0?e.jsx(V,{label:"Arguments",children:e.jsx(K,{data:j})}):null,f?e.jsx(V,{label:"Error",children:e.jsx("p",{className:"text-xs text-awp-red whitespace-pre-wrap break-words",children:f})}):null,g!=null&&Object.keys(g).length>0?e.jsx(V,{label:"Output",children:e.jsx(K,{data:g})}):null,S.length>0?e.jsx(V,{label:"Tools Created",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:S.map(C=>e.jsx(J,{variant:"green",className:"text-[10px]",children:C},C))})}):null,I?e.jsxs("span",{className:"inline-block mt-1 text-[10px] text-awp-muted",children:["Iteration ",I]}):null,p!=null&&typeof p.budget=="object"?e.jsx(V,{label:"Budget",children:e.jsx(K,{data:p.budget})}):null]})]}),a&&B.map(C=>e.jsx(ct,{nodeId:C,nodes:r,childMap:s,depth:n+1},C))]})}function fa(){const{graphNodes:t,graphEdges:r,currentRunId:s,loadRunGraph:n,runStatus:a}=F();if(w.useEffect(()=>{s&&t.length===0&&a!=="running"&&n(s)},[s,t.length,a,n]),t.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-awp-muted gap-3",children:[e.jsx(Ae,{className:"h-12 w-12 text-awp-border"}),e.jsx("p",{className:"text-sm",children:"Agent graph will appear here during a run"})]});const o=t,c=r,i=new Map(o.map(d=>[d.id,d])),{roots:l,children:u}=ba(o,c),x=o.filter(d=>(d.data.nodeType??d.type)==="worker").length,m=o.filter(d=>(d.data.nodeType??d.type)==="toolCall").length,h=o.filter(d=>(d.data.nodeType??d.type)==="iteration").length;return e.jsxs("div",{className:"h-full overflow-y-auto p-4",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-3 text-xs text-awp-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Te,{className:"h-3 w-3"})," ",t.length," nodes"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(at,{className:"h-3 w-3"})," ",h," iterations"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fe,{className:"h-3 w-3"})," ",x," workers"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Y,{className:"h-3 w-3"})," ",m," tool calls"]})]}),l.map(d=>e.jsx(ct,{nodeId:d,nodes:i,childMap:u,depth:0},d))]})}const Ye={finding:{label:"FINDING",color:"text-awp-green",dotColor:"bg-awp-green"},note:{label:"NOTE",color:"text-awp-blue",dotColor:"bg-awp-blue"},observation:{label:"OBSERVATION",color:"text-yellow-400",dotColor:"bg-yellow-400"},decision:{label:"DECISION",color:"text-purple-400",dotColor:"bg-purple-400"}};function ya(){const{currentSessionId:t,experimentMemory:r,addMemoryEntry:s,updateMemoryEntry:n,deleteMemoryEntry:a,loadExperimentMemory:o}=F(),[c,i]=P.useState(!1),[l,u]=P.useState("note"),[x,m]=P.useState(""),[h,d]=P.useState(null),[p,g]=P.useState(""),[f,b]=P.useState("all");w.useEffect(()=>{t&&o()},[t,o]);const S=w.useCallback(()=>{x.trim()&&(s(l,x.trim()),m(""),i(!1))},[l,x,s]),R=w.useCallback(j=>{p.trim()&&(n(j,p.trim()),d(null))},[p,n]),E=f==="all"?r:r.filter(j=>j.type===f);return t?e.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{value:f,onChange:j=>b(j.target.value),className:"text-xs bg-awp-bg border border-awp-border rounded px-2 py-1 text-awp-text",children:[e.jsxs("option",{value:"all",children:["All (",r.length,")"]}),e.jsx("option",{value:"finding",children:"Findings"}),e.jsx("option",{value:"note",children:"Notes"}),e.jsx("option",{value:"observation",children:"Observations"}),e.jsx("option",{value:"decision",children:"Decisions"})]})}),e.jsxs("button",{type:"button",onClick:()=>i(!c),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-awp-blue hover:bg-awp-blue/10 rounded transition-colors",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"})," Add Note"]})]}),c&&e.jsxs("div",{className:"rounded-lg border border-awp-blue/30 bg-awp-blue/5 p-3 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{value:l,onChange:j=>u(j.target.value),className:"text-xs bg-awp-bg border border-awp-border rounded px-2 py-1 text-awp-text",children:[e.jsx("option",{value:"note",children:"Note"}),e.jsx("option",{value:"observation",children:"Observation"}),e.jsx("option",{value:"finding",children:"Finding"}),e.jsx("option",{value:"decision",children:"Decision"})]})}),e.jsx("textarea",{value:x,onChange:j=>m(j.target.value),rows:3,className:"w-full bg-awp-bg border border-awp-border rounded-md px-3 py-2 text-sm text-awp-text resize-y placeholder:text-awp-muted/50 focus:outline-none focus:ring-1 focus:ring-awp-blue/50",placeholder:"Write your note... (Markdown supported)",autoFocus:!0}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{i(!1),m("")},className:"px-2 py-1 text-xs text-awp-muted hover:text-awp-text transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:S,disabled:!x.trim(),className:"px-3 py-1 text-xs font-medium bg-awp-blue text-white rounded hover:bg-awp-blue/80 disabled:opacity-50 transition-colors",children:"Save"})]})]}),E.length===0?e.jsx("div",{className:"text-center text-awp-muted text-sm py-8",children:"No memory entries yet. Run an experiment or add notes manually."}):E.map(j=>{const I=Ye[j.type]??Ye.note,B=h===j.id;return e.jsxs("div",{className:"rounded-lg border border-awp-border bg-awp-bg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:y("w-2 h-2 rounded-full",I.dotColor)}),e.jsx("span",{className:y("text-[10px] font-bold uppercase tracking-wider",I.color),children:I.label}),e.jsxs("span",{className:"text-[10px] text-awp-muted",children:["(",j.source,j.run_id?`, Run ${j.run_id.slice(0,8)}`:"",")"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:j.source==="user"&&!B&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{d(j.id),g(j.content)},className:"p-0.5 text-awp-muted hover:text-awp-text transition-colors",children:e.jsx(st,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:()=>a(j.id),className:"p-0.5 text-awp-muted hover:text-awp-red transition-colors",children:e.jsx(be,{className:"h-3 w-3"})})]})})]}),B?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:p,onChange:W=>g(W.target.value),rows:3,className:"w-full bg-awp-panel border border-awp-border rounded-md px-3 py-2 text-sm text-awp-text resize-y focus:outline-none focus:ring-1 focus:ring-awp-blue/50",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>d(null),className:"px-2 py-1 text-xs text-awp-muted hover:text-awp-text",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>R(j.id),className:"px-2 py-1 text-xs font-medium bg-awp-blue text-white rounded hover:bg-awp-blue/80",children:"Save"})]})]}):e.jsx("div",{className:"prose prose-sm prose-invert max-w-none text-sm break-words",children:e.jsx(xe,{remarkPlugins:[he],rehypePlugins:[me],children:j.content})}),e.jsx("div",{className:"text-[10px] text-awp-muted",children:new Date(j.created_at).toLocaleString()})]},j.id)})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-awp-muted gap-3",children:[e.jsx(Qe,{className:"h-12 w-12 text-awp-border"}),e.jsx("p",{className:"text-sm",children:"Select an experiment to view its memory"})]})}function ja(){const{runHistory:t,loadHistory:r,currentRunId:s,currentSessionId:n,loadRunGraph:a}=F();w.useEffect(()=>{r()},[r,n]);const o=w.useCallback(c=>{F.setState({currentRunId:c,activePanel:"graph"}),a(c)},[a]);return t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-awp-muted gap-3",children:[e.jsx(tt,{className:"h-12 w-12 text-awp-border"}),e.jsx("p",{className:"text-sm",children:n?"No runs in this experiment yet":"No previous runs"})]}):e.jsxs("div",{className:"h-full overflow-y-auto p-4 space-y-2",children:[e.jsxs("div",{className:"text-xs font-medium text-awp-muted uppercase tracking-wider mb-3",children:["Experiment Runs (",t.length,")"]}),t.map(c=>e.jsxs("button",{type:"button",onClick:()=>o(c.run_id),className:y("w-full text-left rounded-lg border p-3 transition-colors",c.run_id===s?"border-awp-blue/50 bg-awp-blue/5":"border-awp-border bg-awp-bg hover:bg-awp-bg/60"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-mono text-awp-muted",children:c.run_id.slice(0,8)}),e.jsx(J,{variant:ye(c.status),children:c.status})]}),e.jsx("p",{className:"text-sm text-awp-text line-clamp-2",children:c.task}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-awp-muted",children:[e.jsx(Oe,{className:"h-3 w-3"}),new Date(c.created_at).toLocaleString()]})]},c.run_id))]})}function ka(){const{currentRunId:t,_wsStatus:r,events:s,budget:n}=F(),a=r==="open",o=n.wall_time_ms>0?(n.wall_time_ms/1e3).toFixed(1)+"s":"--";return e.jsxs("footer",{className:"flex items-center gap-3 border-t border-awp-border bg-awp-panel px-3 h-7 text-xs text-awp-muted shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[a?e.jsx(Kt,{className:"h-3 w-3 text-awp-green"}):e.jsx(Jt,{className:"h-3 w-3 text-awp-muted"}),r]}),t&&e.jsxs("span",{className:"font-mono",children:["Run: ",t.slice(0,12)]}),e.jsxs("span",{children:[s.length," events"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oe,{className:"h-3 w-3"}),o]})]})}function Na(){const{sidebarOpen:t,inspectorOpen:r,activePanel:s,sessions:n,currentSessionId:a,selectSession:o,createSession:c,deleteSession:i,renameSession:l,loadSessions:u,loadSecrets:x,loadPersistedSettings:m,saveCurrentSettings:h,config:d}=F();w.useEffect(()=>{u(),x(),m()},[u,x,m]);const p=w.useRef(null),g=w.useRef(!0);w.useEffect(()=>{if(g.current){g.current=!1;return}return p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{h()},1500),()=>{p.current&&clearTimeout(p.current)}},[d.model,d.worker_model,d.max_loops,d.max_total_tokens,d.max_wall_time,d.max_tool_calls,d.max_total_workers,d.max_depth,d.sandbox,d.code_mode,d.tool_creation,d.verbose,t,r,s,a,h]);const f=w.useCallback(()=>{c()},[c]);return e.jsxs("div",{className:"flex flex-col h-screen bg-awp-bg text-awp-text",children:[e.jsx(ca,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t&&e.jsx("div",{className:"w-60 shrink-0 border-r border-awp-border bg-awp-panel overflow-hidden animate-slide-in-left",children:e.jsx(Fs,{sessions:n,currentSessionId:a,onSelectSession:o,onNewSession:f,onDeleteSession:i,onRenameSession:l})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("main",{className:"flex-1 min-h-0 overflow-hidden",children:[s==="protocol"&&e.jsx(xa,{}),s==="output"&&e.jsx(ha,{}),s==="results"&&e.jsx(ma,{}),s==="graph"&&e.jsx(fa,{}),s==="graphvis"&&e.jsx(oa,{}),s==="memory"&&e.jsx(ya,{}),s==="history"&&e.jsx(ja,{})]}),e.jsx(da,{})]}),r&&e.jsx("div",{className:"w-80 shrink-0 border-l border-awp-border bg-awp-panel overflow-hidden animate-slide-in-right",children:e.jsx(pa,{})})]}),e.jsx(ka,{})]})}const dt=document.getElementById("root");if(!dt)throw new Error("Root element not found");St.createRoot(dt).render(e.jsx(P.StrictMode,{children:e.jsx(Na,{})}));
//# sourceMappingURL=index-CVu2EanC.js.map
