import { useStudio } from "../providers/StudioProvider.js";
import { useWorkspace } from "../hooks/useWorkspaces.js";
import MainLayout_default from "../components/layout/MainLayout.js";
import ErrorSnackbar_default from "../components/snackbars/ErrorSnackbar.js";
import LoadingCentered_default from "../components/LoadingCentered.js";
import { usePipeline } from "../hooks/usePipelines.js";
import Workbench from "../features/workbench/Workbench.js";
import { requireParam } from "../lib/requireParam.js";
import { c } from "react/compiler-runtime";
import { jsx, jsxs } from "react/jsx-runtime";
import { useParams } from "react-router-dom";
import { Home } from "lucide-react";
function WorkbenchPage() {
	let m = c(37), { router: h } = useStudio(), g = useParams(), _;
	m[0] === g ? _ = m[1] : (_ = requireParam(g, "pipelineId"), m[0] = g, m[1] = _);
	let v = usePipeline(_), y = v.data?.workspaceId, b = useWorkspace(y), x;
	m[2] === h ? x = m[3] : (x = h.getDashboard(), m[2] = h, m[3] = x);
	let S;
	m[4] === Symbol.for("react.memo_cache_sentinel") ? (S = /* @__PURE__ */ jsx(Home, { className: "h-4 w-4" }), m[4] = S) : S = m[4];
	let C;
	m[5] === x ? C = m[6] : (C = {
		label: "Dashboard",
		href: x,
		icon: S
	}, m[5] = x, m[6] = C);
	let w;
	m[7] === h ? w = m[8] : (w = h.getWorkspaces(), m[7] = h, m[8] = w);
	let T;
	m[9] === w ? T = m[10] : (T = {
		label: "Workspaces",
		href: w
	}, m[9] = w, m[10] = T);
	let E = b.data?.title ?? "", D;
	m[11] !== h || m[12] !== y ? (D = y ? h.getWorkspace(y) : void 0, m[11] = h, m[12] = y, m[13] = D) : D = m[13];
	let O;
	m[14] !== E || m[15] !== D ? (O = {
		label: E,
		href: D
	}, m[14] = E, m[15] = D, m[16] = O) : O = m[16];
	let k = `Run #${v.data?.run}${v.data?.title ? ` (${v.data.title})` : ""}`, A;
	m[17] === k ? A = m[18] : (A = { label: k }, m[17] = k, m[18] = A);
	let j;
	m[19] !== A || m[20] !== C || m[21] !== T || m[22] !== O ? (j = [
		C,
		T,
		O,
		A
	], m[19] = A, m[20] = C, m[21] = T, m[22] = O, m[23] = j) : j = m[23];
	let M = j, N;
	m[24] === v.error ? N = m[25] : (N = /* @__PURE__ */ jsx(ErrorSnackbar_default, { error: v.error }), m[24] = v.error, m[25] = N);
	let P;
	m[26] !== v.data || m[27] !== v.error || m[28] !== v.isLoading ? (P = v.data ? /* @__PURE__ */ jsx(Workbench, { pipeline: v.data }) : !v.isLoading && !v.error ? /* @__PURE__ */ jsx("p", {
		className: "text-muted-foreground py-8 text-center text-sm",
		children: "Pipeline not found."
	}) : null, m[26] = v.data, m[27] = v.error, m[28] = v.isLoading, m[29] = P) : P = m[29];
	let F;
	m[30] !== v.isLoading || m[31] !== P ? (F = /* @__PURE__ */ jsx(LoadingCentered_default, {
		loading: v.isLoading,
		children: P
	}), m[30] = v.isLoading, m[31] = P, m[32] = F) : F = m[32];
	let I;
	return m[33] !== M || m[34] !== N || m[35] !== F ? (I = /* @__PURE__ */ jsxs(MainLayout_default, {
		breadcrumbsData: M,
		children: [N, F]
	}), m[33] = M, m[34] = N, m[35] = F, m[36] = I) : I = m[36], I;
}
export { WorkbenchPage as default };
