import{E as e,O as t,b as n,t as r,y as i}from"./jsx-runtime-DLhMyTcm.js";import{t as a}from"./createLucideIcon-BkDu6nzg.js";import{n as o,t as s}from"./StatCard-C8w-yqEh.js";import{t as c}from"./zap-BWlR9dm3.js";import{t as l}from"./use-document-meta-Bjf8eIPh.js";import{a as u,c as d,i as f,n as p,o as m,r as h,t as g}from"./table-CIpVHo1F.js";import{a as _,i as v,n as y,o as b,t as x}from"./TimeAgo-w4fFLVhp.js";import{t as S}from"./TriggerBadge-BCgQF3Wi.js";var C=a(`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`}]]),w=a(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),T=r();function E({stats:e}){return(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,T.jsx)(s,{label:`Total Runs`,value:e.total_runs,icon:C,iconClassName:`bg-blue-100 text-blue-600 dark:bg-blue-950 dark:text-blue-400`}),(0,T.jsx)(s,{label:`Success Rate`,value:b(e.success_rate_percent),icon:w,iconClassName:`bg-emerald-100 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400`}),(0,T.jsx)(s,{label:`Active`,value:e.active_runs,icon:c,iconClassName:`bg-amber-100 text-amber-600 dark:bg-amber-950 dark:text-amber-400`}),(0,T.jsx)(s,{label:`Total Cost`,value:v(e.total_cost_usd),icon:o,iconClassName:`bg-violet-100 text-violet-600 dark:bg-violet-950 dark:text-violet-400`})]})}function D({runs:e}){let r=t(),i=e=>{r(`/runs/${e}`)};return(0,T.jsxs)(`div`,{className:`mt-8`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,T.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Recent Runs`}),(0,T.jsx)(n,{to:`/runs`,className:`text-sm text-blue-600 hover:text-blue-700`,children:`View All`})]}),e.length===0?(0,T.jsx)(`div`,{className:`text-center py-12 text-muted-foreground border rounded-lg bg-muted/20`,children:`No runs yet. Trigger a workflow to see results here.`}):(0,T.jsx)(`div`,{className:`rounded-lg border`,children:(0,T.jsxs)(g,{children:[(0,T.jsx)(u,{children:(0,T.jsxs)(m,{children:[(0,T.jsx)(f,{children:`Status`}),(0,T.jsx)(f,{children:`Workflow`}),(0,T.jsx)(f,{children:`Trigger`}),(0,T.jsx)(f,{children:`Duration`}),(0,T.jsx)(f,{children:`Cost`}),(0,T.jsx)(f,{children:`Started`})]})}),(0,T.jsx)(p,{children:e.map(e=>(0,T.jsxs)(m,{onClick:()=>i(e.id),className:`cursor-pointer hover:bg-muted/50`,children:[(0,T.jsx)(h,{children:(0,T.jsx)(y,{status:e.status})}),(0,T.jsx)(h,{className:`font-medium`,children:e.workflow_name}),(0,T.jsx)(h,{children:(0,T.jsx)(S,{trigger:e.trigger})}),(0,T.jsx)(h,{children:_(e.duration_ms)}),(0,T.jsx)(h,{children:v(e.cost_usd)}),(0,T.jsx)(h,{children:(0,T.jsx)(x,{date:e.started_at||e.created_at})})]},e.id))})]})})]})}async function O(){let[e,t]=await Promise.all([i.get(`/stats`),i.get(`/runs?page=1&per_page=5`)]);return{stats:e.data,recentRuns:t.data}}function k(){let{stats:t,recentRuns:n}=e();return l({title:`Dashboard`,description:`Overview of your workflow executions.`}),(0,T.jsx)(d,{title:`Dashboard`,description:`Overview of your workflow executions.`,children:(0,T.jsxs)(`div`,{className:`space-y-6`,children:[(0,T.jsx)(E,{stats:t}),(0,T.jsx)(D,{runs:n})]})})}export{k as Component,O as loader};