import { useStudio } from "../../providers/StudioProvider.js";
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card.js";
import RunList_default from "./RunList.js";
import { c } from "react/compiler-runtime";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { Link } from "react-router-dom";
function Dashboard(f) {
	let p = c(43), { dashboardStats: m } = f, { router: h } = useStudio();
	if (!m) {
		let t;
		return p[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ jsx("div", {
			className: "p-4",
			children: "No data available"
		}), p[0] = t) : t = p[0], t;
	}
	let g;
	p[1] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, {
		className: "text-lg",
		children: "Quick Links"
	}) }), p[1] = g) : g = p[1];
	let _;
	p[2] === h ? _ = p[3] : (_ = h.getWorkspaces(), p[2] = h, p[3] = _);
	let v;
	p[4] === _ ? v = p[5] : (v = /* @__PURE__ */ jsx(CardContent, {
		className: "space-y-3",
		children: /* @__PURE__ */ jsx(Link, {
			to: _,
			className: "text-primary hover:text-primary/80 hover:bg-muted block rounded p-2 text-sm font-medium transition-colors",
			children: "My Workspaces"
		})
	}), p[4] = _, p[5] = v);
	let y;
	p[6] === h ? y = p[7] : (y = h.getDebugWorkflows(), p[6] = h, p[7] = y);
	let b;
	p[8] === y ? b = p[9] : (b = /* @__PURE__ */ jsx(CardContent, {
		className: "space-y-3",
		children: /* @__PURE__ */ jsx(Link, {
			to: y,
			className: "text-primary hover:text-primary/80 hover:bg-muted block rounded p-2 text-sm font-medium transition-colors",
			children: "Debug Workflows"
		})
	}), p[8] = y, p[9] = b);
	let x;
	p[10] !== v || p[11] !== b ? (x = /* @__PURE__ */ jsx("div", {
		className: "md:col-span-1",
		children: /* @__PURE__ */ jsxs(Card, {
			className: "h-full",
			children: [
				g,
				v,
				b
			]
		})
	}), p[10] = v, p[11] = b, p[12] = x) : x = p[12];
	let S;
	p[13] === Symbol.for("react.memo_cache_sentinel") ? (S = /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, {
		className: "text-lg",
		children: "Executions"
	}) }), p[13] = S) : S = p[13];
	let C;
	p[14] === m.totalAutomationRuns ? C = p[15] : (C = /* @__PURE__ */ jsxs(Card, { children: [S, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("p", {
		className: "text-3xl font-bold",
		children: m.totalAutomationRuns
	}) })] }), p[14] = m.totalAutomationRuns, p[15] = C);
	let w;
	p[16] === Symbol.for("react.memo_cache_sentinel") ? (w = /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, {
		className: "text-lg",
		children: "Completed"
	}) }), p[16] = w) : w = p[16];
	let T;
	p[17] === m.completedRuns ? T = p[18] : (T = /* @__PURE__ */ jsxs(Card, { children: [w, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("p", {
		className: "text-3xl font-bold text-green-600",
		children: m.completedRuns
	}) })] }), p[17] = m.completedRuns, p[18] = T);
	let E;
	p[19] === Symbol.for("react.memo_cache_sentinel") ? (E = /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, {
		className: "text-lg",
		children: "Failed"
	}) }), p[19] = E) : E = p[19];
	let D;
	p[20] === m.errorRuns ? D = p[21] : (D = /* @__PURE__ */ jsxs(Card, { children: [E, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("p", {
		className: "text-destructive text-3xl font-bold",
		children: m.errorRuns
	}) })] }), p[20] = m.errorRuns, p[21] = D);
	let O;
	p[22] !== T || p[23] !== D || p[24] !== C ? (O = /* @__PURE__ */ jsxs("div", {
		className: "grid grid-cols-1 gap-4 md:col-span-3 md:grid-cols-3",
		children: [
			C,
			T,
			D
		]
	}), p[22] = T, p[23] = D, p[24] = C, p[25] = O) : O = p[25];
	let k;
	p[26] !== O || p[27] !== x ? (k = /* @__PURE__ */ jsxs("div", {
		className: "mb-8 grid grid-cols-1 gap-6 md:grid-cols-4",
		children: [x, O]
	}), p[26] = O, p[27] = x, p[28] = k) : k = p[28];
	let A;
	p[29] === Symbol.for("react.memo_cache_sentinel") ? (A = /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Recently Completed" }) }), p[29] = A) : A = p[29];
	let j;
	p[30] !== m.recentRuns || p[31] !== h ? (j = /* @__PURE__ */ jsxs(Card, { children: [A, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(RunList_default, {
		type: "runs",
		runs: m.recentRuns,
		router: h,
		emptyMessage: "No recent runs."
	}) })] }), p[30] = m.recentRuns, p[31] = h, p[32] = j) : j = p[32];
	let M;
	p[33] === Symbol.for("react.memo_cache_sentinel") ? (M = /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Recently Failed" }) }), p[33] = M) : M = p[33];
	let N;
	p[34] !== m.recentErrors || p[35] !== h ? (N = /* @__PURE__ */ jsxs(Card, { children: [M, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(RunList_default, {
		type: "errors",
		runs: m.recentErrors,
		router: h,
		emptyMessage: "No recent errors."
	}) })] }), p[34] = m.recentErrors, p[35] = h, p[36] = N) : N = p[36];
	let P;
	p[37] !== j || p[38] !== N ? (P = /* @__PURE__ */ jsxs("div", {
		className: "grid grid-cols-1 gap-6 md:grid-cols-2",
		children: [j, N]
	}), p[37] = j, p[38] = N, p[39] = P) : P = p[39];
	let F;
	return p[40] !== k || p[41] !== P ? (F = /* @__PURE__ */ jsxs(Fragment, { children: [k, P] }), p[40] = k, p[41] = P, p[42] = F) : F = p[42], F;
}
export { Dashboard as default };
