import { t as e } from "../utils-B7XIe3qq.js";
import { Table as t, TableBody as n, TableCell as r, TableHead as i, TableHeader as a, TableRow as o } from "../react/primitives/table.js";
import "react";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
//#region src/composites/per-case-stats-table.tsx
var l = "—";
function u(e, t) {
	if (e === void 0 || !Number.isFinite(e)) return l;
	switch (t) {
		case "percent": return `${(Math.abs(e) <= 1 ? e * 100 : e).toFixed(1)}%`;
		case "number": return e.toLocaleString();
		default: return String(e);
	}
}
function d({ rows: d, columnDefs: f, currentId: p, emptyMessage: m = "No test cases yet.", className: h, ...g }) {
	return d.length === 0 ? /* @__PURE__ */ s("div", {
		"data-slot": "per-case-stats-table-empty",
		className: e("rounded-md border border-border bg-muted/40 p-4 text-sm text-muted-foreground", h),
		...g,
		children: m
	}) : /* @__PURE__ */ s("div", {
		"data-slot": "per-case-stats-table",
		className: e("w-full", h),
		...g,
		children: /* @__PURE__ */ c(t, { children: [/* @__PURE__ */ s(a, { children: /* @__PURE__ */ c(o, { children: [
			/* @__PURE__ */ s(i, {
				className: "w-[40%]",
				children: "Case"
			}),
			/* @__PURE__ */ s(i, {
				className: "w-[15%]",
				children: "Runs"
			}),
			f.map((e) => /* @__PURE__ */ s(i, {
				className: "text-right tabular-nums",
				children: e.label
			}, e.key))
		] }) }), /* @__PURE__ */ s(n, { children: d.map((t) => {
			let n = p !== void 0 && t.id === p, i = typeof t.runs == "number" ? typeof t.runsTotal == "number" ? `${String(t.runs)} / ${String(t.runsTotal)}` : String(t.runs) : l;
			return /* @__PURE__ */ c(o, {
				"data-current": n ? "true" : void 0,
				"aria-current": n ? "true" : void 0,
				className: e(n && "bg-accent/40 font-medium"),
				children: [
					/* @__PURE__ */ s(r, {
						className: "truncate",
						title: t.id,
						children: t.id
					}),
					/* @__PURE__ */ s(r, {
						className: "tabular-nums",
						children: i
					}),
					f.map((e) => /* @__PURE__ */ s(r, {
						className: "text-right tabular-nums",
						children: u(t.columns[e.key], e.format)
					}, e.key))
				]
			}, t.id);
		}) })] })
	});
}
//#endregion
export { d as PerCaseStatsTable };

//# sourceMappingURL=per-case-stats-table.js.map