import "./dist-RakiOObV.mjs";
import { a as setSelectedNode } from "./dist-DFMBprYi.mjs";
import { t as DocumentToolbar } from "./connect-B9rqkBQW.mjs";
import { i as useSelectedPipelineQueueDocument } from "./pipeline-queue-CioH53De.mjs";
import { t as TOOLBAR_CLASS } from "./theme-context-DeP5ztQx.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
//#region editors/pipeline-queue-editor/editor.tsx
const STATUS_COLORS = {
	PENDING: "text-gray-400",
	IN_PROGRESS: "text-blue-400",
	BLOCKED: "text-red-400",
	DONE: "text-emerald-400",
	FAILED: "text-red-500"
};
const PHASE_COLORS = {
	create: "bg-amber-400",
	reflect: "bg-blue-400",
	reweave: "bg-purple-400",
	verify: "bg-emerald-400",
	enrich: "bg-sky-400"
};
function Editor() {
	const [document, dispatch] = useSelectedPipelineQueueDocument();
	const state = document.state.global;
	const tasks = state.tasks ?? [];
	const pending = tasks.filter((t) => t.status === "PENDING").length;
	const inProgress = tasks.filter((t) => t.status === "IN_PROGRESS").length;
	const blocked = tasks.filter((t) => t.status === "BLOCKED").length;
	const done = tasks.filter((t) => t.status === "DONE").length;
	const failed = tasks.filter((t) => t.status === "FAILED").length;
	return /* @__PURE__ */ jsx("div", {
		className: "min-h-screen",
		style: {
			backgroundColor: "var(--bai-bg)",
			color: "var(--bai-text)"
		},
		children: /* @__PURE__ */ jsxs("div", {
			className: "mx-auto max-w-5xl",
			children: [/* @__PURE__ */ jsx(DocumentToolbar, { toolbarClassName: TOOLBAR_CLASS }), /* @__PURE__ */ jsxs("div", {
				className: "p-6 space-y-6",
				children: [
					/* @__PURE__ */ jsxs("div", {
						className: "rounded-xl p-6",
						style: {
							backgroundColor: "var(--bai-surface)",
							border: "1px solid var(--bai-border)"
						},
						children: [/* @__PURE__ */ jsx("h1", {
							className: "text-xl font-bold mb-1",
							style: { color: "var(--bai-text)" },
							children: "Processing Pipeline"
						}), /* @__PURE__ */ jsxs("p", {
							className: "text-sm",
							style: { color: "var(--bai-text-muted)" },
							children: [
								"Schema v",
								state.schemaVersion,
								" · ",
								tasks.length,
								" total tasks · Last processed:",
								" ",
								state.lastProcessedAt ? new Date(state.lastProcessedAt).toLocaleString() : "Never"
							]
						})]
					}),
					/* @__PURE__ */ jsx("div", {
						className: "grid grid-cols-5 gap-3",
						children: [
							{
								label: "Pending",
								value: pending,
								color: "text-gray-400"
							},
							{
								label: "In Progress",
								value: inProgress,
								color: "text-blue-400"
							},
							{
								label: "Blocked",
								value: blocked,
								color: "text-red-400"
							},
							{
								label: "Done",
								value: done,
								color: "text-emerald-400"
							},
							{
								label: "Failed",
								value: failed,
								color: "text-red-500"
							}
						].map((s) => /* @__PURE__ */ jsxs("div", {
							className: "rounded-xl p-4",
							style: {
								backgroundColor: "var(--bai-surface)",
								boxShadow: "0 0 0 1px var(--bai-ring)"
							},
							children: [/* @__PURE__ */ jsx("p", {
								className: `text-2xl font-bold ${s.color}`,
								children: s.value
							}), /* @__PURE__ */ jsx("p", {
								className: "text-[10px]",
								style: { color: "var(--bai-text-faint)" },
								children: s.label
							})]
						}, s.label))
					}),
					/* @__PURE__ */ jsxs("div", {
						className: "rounded-xl p-6",
						style: {
							backgroundColor: "var(--bai-surface)",
							border: "1px solid var(--bai-border)"
						},
						children: [/* @__PURE__ */ jsx("h3", {
							className: "mb-3 text-xs font-semibold uppercase tracking-wider",
							style: { color: "var(--bai-text-muted)" },
							children: "Phase Order"
						}), /* @__PURE__ */ jsx("div", {
							className: "space-y-2",
							children: (state.phaseOrder ?? []).map((entry, i) => /* @__PURE__ */ jsxs("div", {
								className: "flex items-center gap-3",
								children: [/* @__PURE__ */ jsx("span", {
									className: "rounded px-2 py-0.5 text-xs font-medium",
									style: {
										backgroundColor: "var(--bai-hover)",
										color: "var(--bai-text-tertiary)"
									},
									children: entry.taskType
								}), /* @__PURE__ */ jsx("div", {
									className: "flex gap-1",
									children: (entry.phases ?? []).map((phase, j) => /* @__PURE__ */ jsxs("span", {
										className: "flex items-center gap-1",
										children: [
											j > 0 && /* @__PURE__ */ jsx("span", {
												style: { color: "var(--bai-text-faint)" },
												children: "→"
											}),
											/* @__PURE__ */ jsx("span", {
												className: `h-2 w-6 rounded-full ${PHASE_COLORS[phase] ?? "bg-gray-500"}`,
												title: phase
											}),
											/* @__PURE__ */ jsx("span", {
												className: "text-[10px]",
												style: { color: "var(--bai-text-muted)" },
												children: phase
											})
										]
									}, j))
								})]
							}, i))
						})]
					}),
					/* @__PURE__ */ jsxs("div", {
						className: "rounded-xl p-6",
						style: {
							backgroundColor: "var(--bai-surface)",
							border: "1px solid var(--bai-border)"
						},
						children: [/* @__PURE__ */ jsxs("h3", {
							className: "mb-3 text-xs font-semibold uppercase tracking-wider",
							style: { color: "var(--bai-text-muted)" },
							children: [
								"Tasks (",
								tasks.length,
								")"
							]
						}), tasks.length === 0 ? /* @__PURE__ */ jsx("p", {
							className: "text-sm py-4 text-center",
							style: { color: "var(--bai-text-faint)" },
							children: "No tasks. Use /seed to ingest sources and start the pipeline."
						}) : /* @__PURE__ */ jsx("div", {
							className: "space-y-1",
							children: tasks.map((task) => /* @__PURE__ */ jsxs("div", {
								className: "flex items-center gap-3 rounded-lg px-4 py-3",
								style: {
									backgroundColor: "var(--bai-bg)",
									boxShadow: "0 0 0 1px var(--bai-ring)"
								},
								children: [
									/* @__PURE__ */ jsx("span", {
										className: `w-20 shrink-0 text-xs font-semibold ${STATUS_COLORS[task.status] ?? "text-gray-500"}`,
										children: task.status
									}),
									task.documentRef ? /* @__PURE__ */ jsxs("button", {
										type: "button",
										onClick: () => setSelectedNode(task.documentRef),
										className: "flex-1 truncate text-left text-sm transition-colors",
										style: { color: "var(--bai-text-secondary)" },
										title: `Open source: ${task.target}`,
										children: [task.target, /* @__PURE__ */ jsxs("svg", {
											className: "ml-1 inline h-3 w-3",
											style: { color: "var(--bai-text-faint)" },
											viewBox: "0 0 24 24",
											fill: "none",
											stroke: "currentColor",
											strokeWidth: "2",
											children: [
												/* @__PURE__ */ jsx("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
												/* @__PURE__ */ jsx("path", { d: "M15 3h6v6" }),
												/* @__PURE__ */ jsx("path", { d: "M10 14L21 3" })
											]
										})]
									}) : /* @__PURE__ */ jsx("span", {
										className: "flex-1 truncate text-sm",
										style: { color: "var(--bai-text-secondary)" },
										children: task.target
									}),
									/* @__PURE__ */ jsxs("div", {
										className: "flex items-center gap-1",
										children: [(task.completedPhases ?? []).map((p) => /* @__PURE__ */ jsx("span", {
											className: `h-2 w-6 rounded-full ${PHASE_COLORS[p] ?? "bg-gray-500"} opacity-60`,
											title: `${p} (done)`
										}, p)), task.currentPhase && /* @__PURE__ */ jsx("span", {
											className: `h-2 w-6 rounded-full ${PHASE_COLORS[task.currentPhase] ?? "bg-gray-500"} animate-pulse`,
											title: `${task.currentPhase} (current)`
										})]
									}),
									/* @__PURE__ */ jsx("span", {
										className: "rounded px-1.5 py-0.5 text-[10px]",
										style: {
											backgroundColor: "var(--bai-hover)",
											color: "var(--bai-text-muted)"
										},
										children: task.taskType
									}),
									task.assignedTo && /* @__PURE__ */ jsx("span", {
										className: "text-[10px]",
										style: { color: "var(--bai-text-faint)" },
										children: task.assignedTo
									}),
									(task.handoffs ?? []).length > 0 && /* @__PURE__ */ jsxs("span", {
										className: "text-[10px]",
										style: { color: "var(--bai-text-faint)" },
										children: [
											task.handoffs.length,
											" handoff",
											task.handoffs.length !== 1 ? "s" : ""
										]
									})
								]
							}, task.id))
						})]
					})
				]
			})]
		})
	});
}
//#endregion
export { Editor as default };

//# sourceMappingURL=editor-B0DwJ8Zc.mjs.map