import{j as e}from"./vendor-motion-k_x_E260.js";import{a as d,j as v,H as h,k as y,l as _,m as w,T as R,P as k}from"./vendor-icons-BDy0XSiX.js";import{u as T,a as C,b as P,L as $,I as n,C as x,B as p,s as A,f as G,c as M}from"./index-Buswmged.js";import"./vendor-react-BaJ9Uc06.js";function L(){const a=T(),i=C(),j=P(),m=d.useRef([]),o=d.useRef([]),t=i.local_gpus;if(d.useEffect(()=>{if(!t.length)return;const s=t.reduce((l,r)=>l+r.utilization_pct,0)/t.length;m.current=[...m.current.slice(-19),s]},[i]),d.useEffect(()=>{a.queue_depth!=null&&(o.current=[...o.current.slice(-19),a.queue_depth])},[a]),a._loading&&i._loading)return e.jsx($,{label:"Loading overview…"});const c=i.heartbeats,f=t.length>0?Math.round(t.reduce((s,l)=>s+l.utilization_pct,0)/t.length):0,N=t.length>0?Math.round(t.reduce((s,l)=>s+l.memory_used_mib/l.memory_total_mib*100,0)/t.length):0,b=t.length>0?Math.max(...t.map(s=>s.temperature_c)):0,u=j.active;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-6",children:[e.jsx(n,{icon:v,label:"GPU Util",value:`${f}%`,spark:m.current}),e.jsx(n,{icon:h,label:"VRAM",value:`${N}%`}),e.jsx(n,{icon:y,label:"Temp Peak",value:`${b}C`}),e.jsx(n,{icon:_,label:"Queue",value:a.queue_depth,spark:o.current}),e.jsx(n,{icon:w,label:"Completed",value:a.completed}),e.jsx(n,{icon:R,label:"Failed",value:a.failed})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(x,{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-bold",children:"Nodes"}),e.jsxs(p,{color:c.length>0?"green":"gray",children:[c.length," hosts"]})]}),e.jsxs("div",{className:"space-y-2",children:[c.length===0&&e.jsx("p",{className:"text-xs text-gray-500",children:"No heartbeats received yet"}),c.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`h-2 w-2 rounded-full ${s.status==="online"?"bg-emerald-400":s.status==="degraded"?"bg-amber-400":"bg-red-400"}`}),e.jsx("span",{className:"text-xs font-medium",children:s.host})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[s.free_gpus.length," free GPU",s.free_gpus.length!==1?"s":""]}),e.jsx(p,{color:A(s.status),children:s.status})]})]},s.host))]})]}),e.jsxs(x,{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-bold",children:"Active Runs"}),e.jsxs(p,{color:"blue",children:[u.length," running"]})]}),e.jsxs("div",{className:"space-y-2",children:[u.length===0&&e.jsx("p",{className:"text-xs text-gray-500",children:"No active runs"}),u.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{size:12,className:"text-blue-400"}),e.jsx("span",{className:"text-xs font-medium",children:G(s.idea_id,s.title)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:["GPU ",s.gpu]}),e.jsx("span",{className:"text-[10px] text-gray-500",children:M(s.elapsed_min)}),e.jsx("span",{className:"text-[10px] text-gray-500",children:s.host})]})]},`${s.idea_id}-${s.gpu}`))]})]})]}),a.top_results.length>0&&e.jsxs(x,{children:[e.jsx("h2",{className:"mb-3 text-sm font-bold",children:"Top Results"}),e.jsx("div",{className:"space-y-1",children:a.top_results.slice(0,5).map((s,l)=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:["#",l+1]}),e.jsx("span",{className:"text-xs font-medium",children:s.idea_id}),s.title&&e.jsx("span",{className:"text-[10px] text-gray-500 truncate max-w-[200px]",children:s.title})]}),e.jsx("span",{className:"text-xs font-mono text-emerald-400",children:(()=>{for(const[r,g]of Object.entries(s))if(r!=="idea_id"&&r!=="title"&&typeof g=="number")return g.toFixed(4);return"-"})()})]},s.idea_id))})]}),e.jsxs(x,{className:"max-w-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(h,{size:14,className:"text-gray-400"}),e.jsx("span",{className:"text-xs font-medium",children:"Disk"})]}),e.jsxs("span",{className:"text-lg font-bold",children:[a.disk_free_gb.toFixed(0)," GB"]}),e.jsx("span",{className:"text-[10px] text-gray-500 ml-1",children:"free"})]})]})}export{L as default};
