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/vulnerability-card.tsx
var o = {
	critical: "Critical",
	high: "High",
	medium: "Medium",
	low: "Low",
	info: "Info"
}, s = {
	open: "Open",
	in_progress: "In Progress",
	resolved: "Resolved",
	accepted: "Accepted",
	false_positive: "False Positive"
};
function c(e) {
	return (e instanceof Date ? e : new Date(e)).toLocaleDateString(void 0, {
		year: "numeric",
		month: "short",
		day: "numeric"
	});
}
var l = t("inline-flex items-center rounded-full px-2.5 py-0.5 text-[11px] font-bold shrink-0", {
	variants: { severity: {
		critical: "bg-accent-rose/20 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" }
}), u = t("inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium shrink-0", {
	variants: { status: {
		open: "bg-accent-rose/10 text-accent-rose",
		in_progress: "bg-accent-amber/10 text-accent-amber",
		resolved: "bg-accent-emerald/10 text-accent-emerald",
		accepted: "bg-accent-cyan/10 text-accent-cyan",
		false_positive: "bg-foreground-muted/10 text-foreground-muted"
	} },
	defaultVariants: { status: "open" }
});
function d({ className: t, data: d, compact: p = !1, showReferences: m = !0, onClick: h, ...g }) {
	let [_, v] = n.useState(!1), y = p && d.description.length > 150 ? d.description.slice(0, 150) + "..." : d.description, b = m && d.references && d.references.length > 0;
	return /* @__PURE__ */ a("div", {
		"data-slot": "vulnerability-card",
		className: e("flex flex-col gap-3 rounded-xl border border-border-glass bg-glass p-5 backdrop-blur-[20px]", "transition-all duration-300 hover:shadow-glow", h && "cursor-pointer", t),
		onClick: h ? () => h(d) : void 0,
		...g,
		children: [
			/* @__PURE__ */ a("div", {
				className: "flex flex-wrap items-center gap-2",
				children: [
					/* @__PURE__ */ i("span", {
						className: l({ severity: d.severity }),
						children: o[d.severity]
					}),
					/* @__PURE__ */ i("span", {
						className: "text-sm font-bold font-mono text-foreground",
						children: d.id
					}),
					/* @__PURE__ */ i("span", {
						className: "flex-1 truncate text-sm font-medium text-foreground-secondary",
						children: d.title
					}),
					d.status && /* @__PURE__ */ i("span", {
						className: u({ status: d.status }),
						children: s[d.status]
					})
				]
			}),
			/* @__PURE__ */ i("p", {
				className: "text-xs leading-relaxed text-foreground-secondary",
				title: p && d.description.length > 150 ? d.description : void 0,
				children: y
			}),
			d.cvss !== void 0 && /* @__PURE__ */ a("div", {
				className: "flex items-center gap-2",
				children: [
					/* @__PURE__ */ i("span", {
						className: "text-xs font-medium text-foreground-muted",
						children: "CVSS:"
					}),
					/* @__PURE__ */ i("span", {
						className: "text-xs font-bold tabular-nums text-foreground",
						children: d.cvss.toFixed(1)
					}),
					d.cvssVector && /* @__PURE__ */ i("span", {
						className: "max-w-[200px] truncate text-[11px] font-mono text-foreground-muted",
						title: d.cvssVector,
						children: d.cvssVector
					})
				]
			}),
			d.cwe && /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i("a", {
				href: `https://cwe.mitre.org/data/definitions/${d.cwe.replace("CWE-", "")}.html`,
				target: "_blank",
				rel: "noopener noreferrer",
				className: "text-xs font-mono text-accent-cyan hover:underline",
				onClick: (e) => e.stopPropagation(),
				children: d.cwe
			}) }),
			/* @__PURE__ */ a("div", {
				className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-foreground-muted",
				children: [d.published && /* @__PURE__ */ a("span", { children: ["Published: ", c(d.published)] }), d.modified && /* @__PURE__ */ a("span", { children: ["Modified: ", c(d.modified)] })]
			}),
			d.affected && d.affected.length > 0 && /* @__PURE__ */ a("div", {
				className: "flex flex-wrap items-center gap-1.5",
				children: [/* @__PURE__ */ i("span", {
					className: "text-xs font-medium text-foreground-muted",
					children: "Affected:"
				}), d.affected.map((e) => /* @__PURE__ */ i("span", {
					className: "rounded-full border border-border-glass bg-surface-secondary px-2 py-0.5 text-[10px] text-foreground-secondary",
					children: e
				}, e))]
			}),
			d.tags && d.tags.length > 0 && /* @__PURE__ */ i("div", {
				className: "flex flex-wrap gap-1",
				children: d.tags.map((e) => /* @__PURE__ */ i("span", {
					className: "rounded-full border border-accent-violet/20 bg-accent-violet/5 px-2 py-0.5 text-[10px] font-medium text-accent-violet",
					children: e
				}, e))
			}),
			b && /* @__PURE__ */ i("div", {
				className: "flex flex-col gap-2 border-t border-border-glass pt-3",
				children: p ? /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("button", {
					type: "button",
					className: "text-left text-xs font-medium text-accent-cyan hover:underline",
					onClick: (e) => {
						e.stopPropagation(), v(!_);
					},
					children: _ ? `Hide References (${d.references.length})` : `Show References (${d.references.length})`
				}), _ && /* @__PURE__ */ i(f, { references: d.references })] }) : /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("div", {
					className: "text-xs font-medium text-foreground-secondary",
					children: [
						"References (",
						d.references.length,
						")"
					]
				}), /* @__PURE__ */ i(f, { references: d.references })] })
			})
		]
	});
}
function f({ references: e }) {
	return /* @__PURE__ */ i("ul", {
		className: "flex flex-col gap-1",
		children: e.map((e) => /* @__PURE__ */ i("li", { children: /* @__PURE__ */ i("a", {
			href: e.url,
			target: "_blank",
			rel: "noopener noreferrer",
			className: "text-xs text-accent-cyan hover:underline",
			onClick: (e) => e.stopPropagation(),
			children: e.title
		}) }, e.url))
	});
}
//#endregion
export { d as VulnerabilityCard, l as severityBadgeVariants, u as statusBadgeVariants };

//# sourceMappingURL=vulnerability-card.js.map