import { useStudio } from "../../providers/StudioProvider.js";
import { useFetchWorkflowsByNamespace } from "../../hooks/useWorkflows.js";
import { Skeleton } from "../../components/ui/skeleton.js";
import { SidebarMenuSubItem } from "../../components/ui/sidebar.js";
import { WorkbenchContextProvider } from "./providers/WorkbenchContextProvider.js";
import NavigationItem_default from "./components/NavigationItem.js";
import { useScroll } from "./providers/ScrollProvider.js";
import { c } from "react/compiler-runtime";
import React, { useContext } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { useParams } from "react-router-dom";
var NavigationItems_default = (m) => {
	let h = c(17), { namespace: g } = m, { router: _ } = useStudio(), { pipelineId: v, clickId: y } = useParams(), b = useContext(WorkbenchContextProvider), x = useFetchWorkflowsByNamespace(g.id), { setScrollTo: S } = useScroll(), C;
	h[0] !== y || h[1] !== v || h[2] !== _ || h[3] !== S ? (C = (e) => {
		S(!0), v && _.navigateToWorkflow(v, e, y);
	}, h[0] = y, h[1] = v, h[2] = _, h[3] = S, h[4] = C) : C = h[4];
	let w = C;
	if (x.isPending) {
		let e;
		h[5] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxs("div", {
			className: "flex items-center gap-2 p-2",
			children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 rounded" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" })]
		}) }), h[5] = e) : e = h[5];
		let f;
		h[6] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxs("div", {
			className: "flex items-center gap-2 p-2",
			children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 rounded" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" })]
		}) }), h[6] = f) : f = h[6];
		let p;
		return h[7] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ jsxs(Fragment$1, { children: [
			e,
			f,
			/* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxs("div", {
				className: "flex items-center gap-2 p-2",
				children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 rounded" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" })]
			}) })
		] }), h[7] = p) : p = h[7], p;
	}
	if (!v || !x.data?.length) return null;
	let T;
	if (h[8] !== x.data || h[9] !== w || h[10] !== b?.state) {
		let e;
		h[12] !== w || h[13] !== b?.state ? (e = (e) => /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(NavigationItem_default, {
			workflow: e,
			isSelected: b?.state.activeSectionId?.endsWith(e.id) ?? !1,
			navigateTo: w
		}) }, `wf-${e.id}`), h[12] = w, h[13] = b?.state, h[14] = e) : e = h[14], T = x.data.map(e), h[8] = x.data, h[9] = w, h[10] = b?.state, h[11] = T;
	} else T = h[11];
	let E;
	return h[15] === T ? E = h[16] : (E = /* @__PURE__ */ jsx(Fragment$1, { children: T }), h[15] = T, h[16] = E), E;
};
export { NavigationItems_default as default };
