import { useWorkflowCheckpoints as e } from "../../../hooks/useWorkflows.js";
import { cn as t } from "../../../lib/utils.js";
import { Collapsible as n, CollapsibleContent as r, CollapsibleTrigger as i } from "../../../components/ui/collapsible.js";
import "react";
import { jsx as a, jsxs as o } from "react/jsx-runtime";
import { ChevronRight as s, Clock as c, Loader2 as l, Play as u } from "lucide-react";
import { format as d } from "date-fns";
//#region src/features/workbench/components/WorkflowHistoryItem.tsx
var f = ({ workflowId: f, workflow: p }) => {
	let m = e(f), h = m.data;
	return m.isLoading ? /* @__PURE__ */ a("li", {
		className: "group/menu-item relative list-none",
		children: /* @__PURE__ */ o("div", {
			className: "flex w-full items-center gap-2 rounded-md p-2 text-sm opacity-50",
			children: [/* @__PURE__ */ a(l, { className: "h-3 w-3 animate-spin" }), /* @__PURE__ */ a("span", {
				className: "text-sm",
				children: "Loading..."
			})]
		})
	}) : h?.length ? /* @__PURE__ */ a(n, {
		defaultOpen: !0,
		className: "group/collapsible",
		children: /* @__PURE__ */ o("li", {
			className: "group/menu-item relative list-none",
			children: [/* @__PURE__ */ a(i, {
				asChild: !0,
				children: /* @__PURE__ */ o("button", {
					className: "hover:bg-accent hover:text-accent-foreground group/trigger flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium",
					children: [
						/* @__PURE__ */ a(u, { className: "text-primary h-3.5 w-3.5 fill-current" }),
						/* @__PURE__ */ a("span", {
							className: "truncate text-sm",
							children: p.title ?? p.alias
						}),
						/* @__PURE__ */ a(s, { className: "text-muted-foreground ml-auto h-3.5 w-3.5 transition-transform group-data-[state=open]/collapsible:rotate-90" })
					]
				})
			}), /* @__PURE__ */ a(r, { children: /* @__PURE__ */ a("ul", {
				className: "ml-2 flex min-w-0 flex-col gap-1 pl-0",
				children: /* @__PURE__ */ o("div", {
					className: "relative py-2",
					children: [
						/* @__PURE__ */ a("div", { className: "from-primary/60 via-primary/30 to-muted/20 absolute top-7 bottom-3 left-1.75 w-0.5 rounded-full bg-linear-to-b" }),
						/* @__PURE__ */ o("div", {
							className: "group/entry relative flex gap-3 py-1 pl-0",
							children: [/* @__PURE__ */ a("div", {
								className: "relative z-10 flex shrink-0 items-center justify-center",
								children: /* @__PURE__ */ a("div", { className: "border-primary/60 bg-primary/20 flex h-4 w-4 items-center justify-center rounded-full border-2" })
							}), /* @__PURE__ */ a("div", {
								className: "flex min-w-0 flex-1 items-center gap-1.5",
								children: /* @__PURE__ */ a("span", {
									className: "bg-muted text-foreground w-fit truncate rounded px-1.5 py-0.5 font-mono text-xs font-medium",
									children: "start"
								})
							})]
						}),
						h.map((e, n) => {
							let r = n === h.length - 1, i = e.place ?? "unknown", s = e.transitionId;
							return /* @__PURE__ */ o("div", {
								className: "group/entry relative flex gap-3 py-1 pl-0",
								children: [/* @__PURE__ */ a("div", {
									className: "relative z-10 flex shrink-0 items-center justify-center",
									children: /* @__PURE__ */ a("div", {
										className: t("flex h-4 w-4 items-center justify-center rounded-full border-2 transition-all", r ? "border-primary bg-primary shadow-primary/40 shadow-sm" : "border-muted-foreground/30 bg-background"),
										children: r && /* @__PURE__ */ a("div", { className: "bg-primary-foreground h-1.5 w-1.5 animate-pulse rounded-full" })
									})
								}), /* @__PURE__ */ o("div", {
									className: "flex min-w-0 flex-1 flex-col gap-0.5",
									children: [/* @__PURE__ */ o("div", {
										className: "flex items-baseline gap-1.5",
										children: [/* @__PURE__ */ a("span", {
											className: t("w-fit truncate rounded px-1.5 py-0.5 font-mono text-xs font-medium", r ? "bg-primary/15 text-primary" : "bg-muted/60 text-muted-foreground"),
											children: i
										}), s && /* @__PURE__ */ o("span", {
											className: "text-muted-foreground truncate text-[10px] italic",
											children: [
												"(via ",
												s,
												")"
											]
										})]
									}), /* @__PURE__ */ a("div", {
										className: "text-muted-foreground flex items-center gap-2 text-[10px]",
										children: /* @__PURE__ */ o("div", {
											className: "flex items-center gap-0.5",
											children: [/* @__PURE__ */ a(c, { className: "h-3 w-3" }), /* @__PURE__ */ a("span", {
												className: "tabular-nums",
												children: d(new Date(e.createdAt), "HH:mm:ss")
											})]
										})
									})]
								})]
							}, e.version);
						})
					]
				})
			}) })]
		})
	}) : null;
};
//#endregion
export { f as default };
