import { t as e } from "../../utils-B7XIe3qq.js";
import { t } from "../../dist-BCCeHAQm.js";
import * as n from "react";
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
//#region src/react/primitives/detection-status.tsx
var o = {
	active: "Active",
	disabled: "Disabled",
	testing: "Testing",
	error: "Error"
};
function s(e) {
	return (e instanceof Date ? e : new Date(e)).toLocaleDateString(void 0, {
		year: "numeric",
		month: "short",
		day: "numeric",
		hour: "2-digit",
		minute: "2-digit"
	});
}
var c = t("inline-block size-2 shrink-0 rounded-full", {
	variants: { status: {
		active: "bg-accent-emerald",
		disabled: "bg-foreground-muted",
		testing: "bg-accent-amber",
		error: "bg-accent-rose"
	} },
	defaultVariants: { status: "active" }
}), l = t("text-xs font-medium", {
	variants: { status: {
		active: "text-accent-emerald",
		disabled: "text-foreground-muted",
		testing: "text-accent-amber",
		error: "text-accent-rose"
	} },
	defaultVariants: { status: "active" }
}), u = t("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-bold", {
	variants: { severity: {
		critical: "bg-accent-rose/15 text-accent-rose",
		high: "bg-accent-rose/10 text-accent-rose/80",
		medium: "bg-accent-amber/10 text-accent-amber",
		low: "bg-accent-cyan/10 text-accent-cyan",
		info: "bg-foreground-muted/10 text-foreground-secondary"
	} },
	defaultVariants: { severity: "info" }
});
function d({ status: t }) {
	let n = "size-4";
	switch (t) {
		case "active": return /* @__PURE__ */ a("svg", {
			xmlns: "http://www.w3.org/2000/svg",
			viewBox: "0 0 24 24",
			fill: "none",
			stroke: "currentColor",
			strokeWidth: 2,
			strokeLinecap: "round",
			strokeLinejoin: "round",
			className: e(n, "text-accent-emerald"),
			children: [/* @__PURE__ */ i("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10" }), /* @__PURE__ */ i("path", { d: "m9 12 2 2 4-4" })]
		});
		case "disabled": return /* @__PURE__ */ a("svg", {
			xmlns: "http://www.w3.org/2000/svg",
			viewBox: "0 0 24 24",
			fill: "none",
			stroke: "currentColor",
			strokeWidth: 2,
			strokeLinecap: "round",
			strokeLinejoin: "round",
			className: e(n, "text-foreground-muted"),
			children: [/* @__PURE__ */ i("circle", {
				cx: "12",
				cy: "12",
				r: "10"
			}), /* @__PURE__ */ i("line", {
				x1: "4.93",
				y1: "4.93",
				x2: "19.07",
				y2: "19.07"
			})]
		});
		case "testing": return /* @__PURE__ */ i("svg", {
			xmlns: "http://www.w3.org/2000/svg",
			viewBox: "0 0 24 24",
			fill: "none",
			stroke: "currentColor",
			strokeWidth: 2,
			strokeLinecap: "round",
			strokeLinejoin: "round",
			className: e(n, "text-accent-amber"),
			children: /* @__PURE__ */ i("path", { d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" })
		});
		case "error": return /* @__PURE__ */ a("svg", {
			xmlns: "http://www.w3.org/2000/svg",
			viewBox: "0 0 24 24",
			fill: "none",
			stroke: "currentColor",
			strokeWidth: 2,
			strokeLinecap: "round",
			strokeLinejoin: "round",
			className: e(n, "text-accent-rose"),
			children: [
				/* @__PURE__ */ i("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
				/* @__PURE__ */ i("line", {
					x1: "12",
					y1: "9",
					x2: "12",
					y2: "13"
				}),
				/* @__PURE__ */ i("line", {
					x1: "12",
					y1: "17",
					x2: "12.01",
					y2: "17"
				})
			]
		});
	}
}
function f({ className: t, status: n, showIcon: r = !0, showLabel: s = !0, ...c }) {
	return /* @__PURE__ */ a("span", {
		"data-slot": "detection-status-badge",
		role: "status",
		"aria-label": `Status: ${o[n]}`,
		className: e("inline-flex items-center gap-1.5", t),
		...c,
		children: [r && /* @__PURE__ */ i(d, { status: n }), s && /* @__PURE__ */ i("span", {
			className: l({ status: n }),
			children: o[n]
		})]
	});
}
function p({ className: t, rule: n, onClick: r, ...d }) {
	return /* @__PURE__ */ a("div", {
		"data-slot": "detection-status-row",
		role: "listitem",
		className: e("flex items-center gap-4 rounded-lg border border-border-glass bg-glass px-4 py-3 backdrop-blur-[20px]", "transition-all duration-200 hover:bg-glass-hover", r && "cursor-pointer", t),
		onClick: r ? () => r(n) : void 0,
		...d,
		children: [
			/* @__PURE__ */ a("div", {
				className: "flex min-w-0 flex-1 items-center gap-3",
				children: [/* @__PURE__ */ i("span", {
					"aria-hidden": "true",
					className: c({ status: n.status })
				}), /* @__PURE__ */ a("div", {
					className: "min-w-0 flex-1",
					children: [/* @__PURE__ */ i("div", {
						className: "truncate text-sm font-medium text-foreground",
						children: n.name
					}), /* @__PURE__ */ i("div", {
						className: "truncate text-xs text-foreground-muted",
						children: n.source
					})]
				})]
			}),
			n.severity && /* @__PURE__ */ i("span", {
				className: u({ severity: n.severity }),
				children: n.severity.charAt(0).toUpperCase() + n.severity.slice(1)
			}),
			/* @__PURE__ */ i("span", {
				className: e(l({ status: n.status }), "shrink-0 text-xs"),
				children: o[n.status]
			}),
			/* @__PURE__ */ i("span", {
				className: "shrink-0 text-xs tabular-nums text-foreground-secondary",
				children: n.triggerCount ?? 0
			}),
			/* @__PURE__ */ i("span", {
				className: "shrink-0 text-xs text-foreground-muted",
				children: n.lastTriggered ? s(n.lastTriggered) : "Never"
			}),
			n.tags && n.tags.length > 0 && /* @__PURE__ */ i("div", {
				className: "hidden items-center gap-1 lg:flex",
				children: n.tags.map((e) => /* @__PURE__ */ i("span", {
					className: "rounded-full border border-border-glass bg-surface-secondary px-2 py-0.5 text-[10px] text-foreground-muted",
					children: e
				}, e))
			})
		]
	});
}
function m({ className: t, rules: o, showSearch: s = !1, showFilters: c = !1, onRuleClick: l, ...u }) {
	let [d, f] = n.useState(""), [m, h] = n.useState("all"), [g, _] = n.useState("all"), v = n.useMemo(() => {
		let e = o;
		if (m !== "all" && (e = e.filter((e) => e.status === m)), g !== "all" && (e = e.filter((e) => e.severity === g)), d.length > 0) {
			let t = d.toLowerCase();
			e = e.filter((e) => e.name.toLowerCase().includes(t) || e.source.toLowerCase().includes(t));
		}
		return e;
	}, [
		o,
		m,
		g,
		d
	]), y = "rounded-lg border border-border-glass bg-glass px-3 py-1.5 text-xs text-foreground backdrop-blur-[20px] outline-none focus:ring-1 focus:ring-accent-cyan/40";
	return /* @__PURE__ */ a("div", {
		"data-slot": "detection-status-list",
		className: e("flex flex-col gap-3", t),
		...u,
		children: [(s || c) && /* @__PURE__ */ a("div", {
			className: "flex flex-wrap items-center gap-2",
			children: [s && /* @__PURE__ */ i("input", {
				type: "text",
				placeholder: "Search rules...",
				"aria-label": "Search detection rules",
				value: d,
				onChange: (e) => f(e.target.value),
				className: e("flex-1 rounded-lg border border-border-glass bg-glass px-3 py-1.5 text-sm text-foreground backdrop-blur-[20px]", "placeholder:text-foreground-muted outline-none focus:ring-1 focus:ring-accent-cyan/40")
			}), c && /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("select", {
				"aria-label": "Filter by status",
				value: m,
				onChange: (e) => h(e.target.value),
				className: y,
				children: [
					/* @__PURE__ */ i("option", {
						value: "all",
						children: "All Statuses"
					}),
					/* @__PURE__ */ i("option", {
						value: "active",
						children: "Active"
					}),
					/* @__PURE__ */ i("option", {
						value: "disabled",
						children: "Disabled"
					}),
					/* @__PURE__ */ i("option", {
						value: "testing",
						children: "Testing"
					}),
					/* @__PURE__ */ i("option", {
						value: "error",
						children: "Error"
					})
				]
			}), /* @__PURE__ */ a("select", {
				"aria-label": "Filter by severity",
				value: g,
				onChange: (e) => _(e.target.value),
				className: y,
				children: [
					/* @__PURE__ */ i("option", {
						value: "all",
						children: "All Severities"
					}),
					/* @__PURE__ */ i("option", {
						value: "critical",
						children: "Critical"
					}),
					/* @__PURE__ */ i("option", {
						value: "high",
						children: "High"
					}),
					/* @__PURE__ */ i("option", {
						value: "medium",
						children: "Medium"
					}),
					/* @__PURE__ */ i("option", {
						value: "low",
						children: "Low"
					}),
					/* @__PURE__ */ i("option", {
						value: "info",
						children: "Info"
					})
				]
			})] })]
		}), /* @__PURE__ */ i("div", {
			role: "list",
			className: "flex flex-col gap-2",
			children: v.length === 0 ? /* @__PURE__ */ i("div", {
				className: "rounded-lg border border-border-glass bg-glass px-4 py-8 text-center text-sm text-foreground-muted backdrop-blur-[20px]",
				children: "No detection rules found"
			}) : v.map((e) => /* @__PURE__ */ i(p, {
				rule: e,
				onClick: l ?? void 0
			}, e.id))
		})]
	});
}
//#endregion
export { f as DetectionStatusBadge, m as DetectionStatusList, p as DetectionStatusRow, u as severityBadgeVariants, c as statusDotVariants, l as statusLabelVariants };

//# sourceMappingURL=detection-status.js.map