import { Button as e } from "../../../components/ui/button.js";
import { Label as t } from "../../../components/ui/label.js";
import { Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "../../../components/ui/select.js";
import { useMemo as s } from "react";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
import { Info as u, Loader2 as d, Plus as f } from "lucide-react";
//#region src/features/workspaces/components/EnvironmentSlotSelector.tsx
function p({ slot: p, environments: m, selectedEnvironmentId: h, onSelect: g, onCreateEnvironment: _, isCreating: v, error: y }) {
	let b = s(() => m.filter((e) => p.type ? e.type === p.type : !0), [m, p.type]), x = b.length > 0;
	return /* @__PURE__ */ l("div", {
		className: "space-y-2",
		children: [
			/* @__PURE__ */ l(t, { children: [p.title ?? p.id, p.optional && /* @__PURE__ */ c("span", {
				className: "text-muted-foreground ml-1 font-normal",
				children: "(optional)"
			})] }),
			x ? /* @__PURE__ */ l(n, {
				value: h,
				onValueChange: g,
				children: [/* @__PURE__ */ c(a, {
					className: "w-full",
					children: /* @__PURE__ */ c(o, { placeholder: "Select an environment" })
				}), /* @__PURE__ */ l(r, { children: [p.optional && /* @__PURE__ */ c(i, {
					value: "__none__",
					children: /* @__PURE__ */ c("span", {
						className: "text-muted-foreground",
						children: "None"
					})
				}), b.map((e) => /* @__PURE__ */ c(i, {
					value: e.id,
					children: /* @__PURE__ */ l("span", {
						className: "flex items-center gap-2",
						children: [e.name, e.local && /* @__PURE__ */ c("span", {
							className: "bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px] font-medium",
							children: "Local"
						})]
					})
				}, e.id))] })]
			}) : /* @__PURE__ */ l("div", {
				className: `flex items-center gap-3 rounded-md border border-dashed bg-background p-3 ${y ? "border-destructive" : ""}`,
				children: [
					/* @__PURE__ */ c(u, { className: `h-4 w-4 shrink-0 ${y ? "text-destructive" : "text-muted-foreground"}` }),
					/* @__PURE__ */ c("p", {
						className: `text-sm flex-1 ${y ? "text-destructive" : "text-muted-foreground"}`,
						children: "No matching environment available."
					}),
					_ && /* @__PURE__ */ l(e, {
						type: "button",
						size: "sm",
						variant: "outline",
						disabled: v,
						onClick: () => _(),
						children: [v ? /* @__PURE__ */ c(d, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ c(f, { className: "mr-1.5 h-3.5 w-3.5" }), "Create"]
					})
				]
			}),
			y && /* @__PURE__ */ c("p", {
				className: "text-sm text-destructive",
				children: y
			})
		]
	});
}
//#endregion
export { p as EnvironmentSlotSelector };
