import { useStudio as e, useStudioOptional as t } from "../../providers/StudioProvider.js";
import { useFilterWorkflows as n } from "../../hooks/useWorkflows.js";
import { useComponentOverrides as r } from "../../providers/ComponentOverridesProvider.js";
import { cn as i } from "../../lib/utils.js";
import { Button as a } from "../ui/button.js";
import { Sidebar as o, SidebarContent as s, SidebarFooter as c, SidebarGroup as l, SidebarGroupContent as u, SidebarGroupLabel as d, SidebarHeader as f, SidebarMenu as p, SidebarMenuBadge as m, SidebarMenuButton as h, SidebarMenuItem as g, useSidebar as _ } from "../ui/sidebar.js";
import { motion as v } from "../../node_modules/motion/dist/es/react.js";
import { useState as y } from "react";
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
import { Link as C, useLocation as w } from "react-router-dom";
import { CircleAlert as T, Info as E, LayoutDashboard as D, LayoutGrid as O, PanelLeftIcon as k, Play as A, Workflow as j } from "lucide-react";
//#region src/components/layout/StudioSidebar.tsx
var M = () => {
	let { state: e, toggleSidebar: t } = _(), [n, r] = y(!1);
	return /* @__PURE__ */ S(f, {
		className: i("border-sidebar-border h-12 w-full flex-row items-center border-b px-1.5 py-0", e === "collapsed" ? "justify-center" : "justify-between"),
		children: [e === "expanded" && /* @__PURE__ */ S("div", {
			className: "flex items-center gap-2 overflow-hidden px-1.5",
			children: [/* @__PURE__ */ x("img", {
				src: "/loopstack.svg",
				alt: "Loopstack",
				className: "h-6 w-6"
			}), /* @__PURE__ */ x(v.span, {
				className: "whitespace-nowrap text-sm font-semibold",
				initial: {
					opacity: 0,
					x: -6
				},
				animate: {
					opacity: 1,
					x: 0
				},
				transition: {
					opacity: {
						duration: .18,
						delay: .12,
						ease: "easeOut"
					},
					x: {
						duration: .18,
						delay: .12,
						ease: "easeOut"
					}
				},
				children: "Loopstack Studio"
			})]
		}), /* @__PURE__ */ S(a, {
			"data-sidebar": "trigger",
			"data-slot": "sidebar-trigger",
			variant: "ghost",
			size: "icon",
			className: i("relative size-10 text-muted-foreground hover:cursor-pointer hover:bg-accent/50 hover:text-accent-foreground"),
			onClick: t,
			onMouseEnter: () => r(!0),
			onMouseLeave: () => r(!1),
			children: [e === "collapsed" ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(v.img, {
				src: "/loopstack.svg",
				alt: "Loopstack",
				className: "absolute top-1/2 left-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2",
				initial: { opacity: 1 },
				animate: { opacity: +!n },
				transition: { duration: .2 }
			}), /* @__PURE__ */ x(v.div, {
				className: "absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center",
				initial: { opacity: 0 },
				animate: { opacity: +!!n },
				transition: { duration: .2 },
				children: /* @__PURE__ */ x(k, { className: "size-5" })
			})] }) : /* @__PURE__ */ x(k, { className: "size-5" }), /* @__PURE__ */ x("span", {
				className: "sr-only",
				children: "Toggle Sidebar"
			})]
		})]
	});
}, N = () => {
	let t = w(), { router: r } = e(), i = r.getRuns(), a = r.getRunsActionRequired(), o = n(void 0, {
		parentId: null,
		status: "paused"
	}, "createdAt", "DESC", 0, 1).data?.total ?? 0;
	return /* @__PURE__ */ S(l, { children: [/* @__PURE__ */ x(d, { children: "Runs" }), /* @__PURE__ */ x(u, { children: /* @__PURE__ */ S(p, { children: [/* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(h, {
		asChild: !0,
		isActive: t.pathname === i || t.pathname === i + "/",
		tooltip: "Overview",
		children: /* @__PURE__ */ S(C, {
			to: i,
			children: [/* @__PURE__ */ x(A, {}), /* @__PURE__ */ x("span", { children: "Overview" })]
		})
	}) }), /* @__PURE__ */ S(g, { children: [/* @__PURE__ */ x(h, {
		asChild: !0,
		isActive: t.pathname === a,
		tooltip: "Action Required",
		children: /* @__PURE__ */ S(C, {
			to: a,
			children: [/* @__PURE__ */ x(T, {}), /* @__PURE__ */ x("span", { children: "Action Required" })]
		})
	}), o > 0 && /* @__PURE__ */ x(m, { children: o })] })] }) })] });
}, P = () => {
	let t = w(), { router: n } = e(), r = n.getWorkspaces();
	return /* @__PURE__ */ S(l, { children: [/* @__PURE__ */ x(d, { children: "Workspaces" }), /* @__PURE__ */ x(u, { children: /* @__PURE__ */ x(p, { children: /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(h, {
		asChild: !0,
		isActive: t.pathname === r || t.pathname.startsWith(r + "/"),
		tooltip: "My Workspaces",
		children: /* @__PURE__ */ S(C, {
			to: r,
			children: [/* @__PURE__ */ x(O, {}), /* @__PURE__ */ x("span", { children: "My Workspaces" })]
		})
	}) }) }) })] });
}, F = () => {
	let t = w(), { router: n } = e(), r = [{
		label: "Dashboard",
		href: n.getDashboard(),
		icon: D
	}, {
		label: "Workflows",
		href: n.getDebugWorkflows(),
		icon: j
	}];
	return /* @__PURE__ */ S(l, { children: [/* @__PURE__ */ x(d, { children: "Insights" }), /* @__PURE__ */ x(u, { children: /* @__PURE__ */ x(p, { children: r.map((e) => /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(h, {
		asChild: !0,
		isActive: t.pathname === e.href,
		tooltip: e.label,
		children: /* @__PURE__ */ S(C, {
			to: e.href,
			children: [/* @__PURE__ */ x(e.icon, {}), /* @__PURE__ */ x("span", { children: e.label })]
		})
	}) }, e.href)) }) })] });
}, I = () => {
	let t = w(), { router: n } = e(), r = n.getEnvironmentInfo();
	return /* @__PURE__ */ x(c, { children: /* @__PURE__ */ x(p, { children: /* @__PURE__ */ x(g, { children: /* @__PURE__ */ x(h, {
		asChild: !0,
		isActive: t.pathname === r,
		size: "sm",
		tooltip: "Info",
		children: /* @__PURE__ */ S(C, {
			to: r,
			children: [/* @__PURE__ */ x(E, {}), /* @__PURE__ */ x("span", { children: "Info" })]
		})
	}) }) }) });
}, L = () => {
	let e = r(), n = t(), i = e.SidebarHeader ?? M, a = e.SidebarFooter ?? I;
	return /* @__PURE__ */ S(o, {
		collapsible: "icon",
		children: [
			/* @__PURE__ */ x(i, {}),
			/* @__PURE__ */ x(s, { children: n && /* @__PURE__ */ S(b, { children: [
				/* @__PURE__ */ x(N, {}),
				/* @__PURE__ */ x(P, {}),
				/* @__PURE__ */ x(F, {})
			] }) }),
			n && /* @__PURE__ */ x(a, {})
		]
	});
};
//#endregion
export { L as StudioSidebar };
