import { t as e } from "../../utils-B7XIe3qq.js";
import "react";
import { jsx as t, jsxs as n } from "react/jsx-runtime";
//#region src/react/primitives/uptime-bar.tsx
function r(e) {
	if (e.length === 0) return "0.0";
	let t = 0;
	for (let n of e) n.status === "up" && (t += 1);
	return (t / e.length * 100).toFixed(1);
}
var i = {
	up: "bg-accent-emerald",
	down: "bg-accent-rose",
	degraded: "bg-accent-amber",
	unknown: "bg-foreground-muted/40"
};
function a({ className: a, segments: o, showLabel: s = !0, height: c = 32, ...l }) {
	let u = r(o);
	return /* @__PURE__ */ n("div", {
		"data-slot": "uptime-bar",
		role: "img",
		"aria-label": `Uptime status bar: ${u}% uptime`,
		className: e("flex flex-col gap-2", a),
		...l,
		children: [/* @__PURE__ */ n("div", {
			className: "flex w-full gap-[2px] overflow-hidden rounded-md",
			style: { height: c },
			children: [o.map((n, r) => /* @__PURE__ */ t("div", {
				title: n.tooltip,
				className: e("flex-1 transition-colors duration-200", "first:rounded-l-md last:rounded-r-md", "hover:opacity-80", i[n.status])
			}, r)), o.length === 0 && /* @__PURE__ */ t("div", { className: "flex-1 rounded-md bg-surface-secondary" })]
		}), s && /* @__PURE__ */ n("div", {
			className: "flex items-center justify-between text-xs text-foreground-secondary",
			children: [/* @__PURE__ */ n("span", { children: [u, "% uptime"] }), /* @__PURE__ */ n("span", {
				className: "text-foreground-muted",
				children: [o.length, " checks"]
			})]
		})]
	});
}
//#endregion
export { a as UptimeBar };

//# sourceMappingURL=uptime-bar.js.map