import { useFetchWorkflowsByPipeline } from "../../../hooks/useWorkflows.js";
import WorkflowHistoryItem_default from "./WorkflowHistoryItem.js";
import { c } from "react/compiler-runtime";
import React, { useMemo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { Clock, Loader2 } from "lucide-react";
var PipelineHistoryList_default = (s) => {
	let l = c(10), { pipeline: u } = s, d = useFetchWorkflowsByPipeline(u?.id ?? ""), f;
	l[0] === d.data ? f = l[1] : (f = d.data ?? [], l[0] = d.data, l[1] = f);
	let p = f;
	if (!u) {
		let e;
		return l[2] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx("div", {
			className: "text-muted-foreground flex items-center justify-center py-8 text-sm",
			children: "No pipeline selected"
		}), l[2] = e) : e = l[2], e;
	}
	if (d.isLoading) {
		let e;
		return l[3] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx("div", {
			className: "flex items-center justify-center py-8",
			children: /* @__PURE__ */ jsx(Loader2, { className: "text-muted-foreground h-5 w-5 animate-spin" })
		}), l[3] = e) : e = l[3], e;
	}
	if (d.error) {
		let e;
		return l[4] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx("div", {
			className: "text-destructive px-2 py-4 text-sm",
			children: "Failed to load history"
		}), l[4] = e) : e = l[4], e;
	}
	if (p.length === 0) {
		let e;
		return l[5] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsxs("div", {
			className: "text-muted-foreground flex flex-col items-center justify-center gap-2 py-8",
			children: [/* @__PURE__ */ jsx(Clock, { className: "h-6 w-6" }), /* @__PURE__ */ jsx("span", {
				className: "text-sm",
				children: "No workflow history"
			})]
		}), l[5] = e) : e = l[5], e;
	}
	let m;
	l[6] === p ? m = l[7] : (m = p.map(_temp), l[6] = p, l[7] = m);
	let h;
	return l[8] === m ? h = l[9] : (h = /* @__PURE__ */ jsx("div", {
		className: "flex flex-col gap-1 py-2",
		children: m
	}), l[8] = m, l[9] = h), h;
};
function _temp(e) {
	return /* @__PURE__ */ jsx(WorkflowHistoryItem_default, {
		workflowId: e.id,
		workflow: e
	}, e.id);
}
export { PipelineHistoryList_default as default };
