"use client";
import { cn as e } from "./lib/utils.js";
import { t } from "./dist-Ber_p4PA.js";
import { i as n, n as r, t as i } from "./tooltip-34vRSwJG.js";
import { Badge as a } from "./components/ui/atoms/badge.js";
import { ByocBadge as o } from "./components/ui/atoms/byoc-badge.js";
import { Card as s, CardContent as c } from "./components/ui/atoms/card.js";
import { t as l } from "./checkbox-CfF6tabe.js";
import { ProBadge as u } from "./components/ui/atoms/pro-badge.js";
import { areStringArraysEqual as d, createPropsComparator as f } from "./components/ui/utils/memo.js";
import { ViewToolsControl as p } from "./components/ui/atoms/view-tools-control.js";
import * as m from "react";
import { jsx as h, jsxs as g } from "react/jsx-runtime";
import { Fingerprint as _, Key as v, Package as y, Wrench as b } from "lucide-react";
//#region lib/components/ui/molecules/requirement-badges.tsx
var x = ({ secrets: t, className: o }) => {
	let s = (t.pending?.length ?? 0) > 0, c = /* @__PURE__ */ g("div", {
		className: "space-y-3",
		children: [
			/* @__PURE__ */ h("div", {
				className: "font-medium text-gray-900 dark:text-gray-100",
				children: "API Keys & Secrets"
			}),
			(t.configured?.length ?? 0) > 0 && /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("div", {
				className: "mb-1.5 font-medium text-emerald-700 text-xs dark:text-emerald-300",
				children: "Configured"
			}), /* @__PURE__ */ h("ul", {
				className: "list-disc space-y-1 pl-4 text-gray-700 text-xs dark:text-gray-300",
				children: t.configured?.map((e) => /* @__PURE__ */ h("li", { children: e }, `cfg-${e}`))
			})] }),
			(t.pending?.length ?? 0) > 0 && /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("div", {
				className: "mb-1.5 font-medium text-red-700 text-xs dark:text-red-300",
				children: "Pending"
			}), /* @__PURE__ */ h("ul", {
				className: "list-disc space-y-1 pl-4 text-gray-700 text-xs dark:text-gray-300",
				children: t.pending?.map((e) => /* @__PURE__ */ h("li", { children: e }, `pen-${e}`))
			})] })
		]
	});
	return /* @__PURE__ */ g(i, { children: [/* @__PURE__ */ g(n, {
		render: /* @__PURE__ */ h(a, {
			className: e("gap-1.5 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-200", s && "border-l-2 border-l-yellow-600", o),
			variant: "secondary"
		}),
		children: [/* @__PURE__ */ h(v, { className: "h-3.5 w-3.5" }), "Secrets"]
	}), /* @__PURE__ */ h(r, {
		className: "max-w-xs p-4 text-sm",
		sideOffset: 12,
		children: c
	})] });
}, S = ({ oauth: t, className: o }) => {
	let s = t.providers.filter((e) => e.status === "active").length, c = t.providers.length - s > 0, l = /* @__PURE__ */ g("div", {
		className: "space-y-3",
		children: [/* @__PURE__ */ h("div", {
			className: "font-medium text-gray-900 dark:text-gray-100",
			children: "OAuth Authorization"
		}), t.providers.map((e) => /* @__PURE__ */ g("div", {
			className: "text-gray-700 text-xs dark:text-gray-300",
			children: [
				/* @__PURE__ */ h("span", {
					className: "font-medium",
					children: e.id
				}),
				" ",
				e.status === "active" ? /* @__PURE__ */ h("span", {
					className: "text-emerald-700 dark:text-emerald-300",
					children: "(active)"
				}) : /* @__PURE__ */ h("span", {
					className: "text-red-700 dark:text-red-300",
					children: "(inactive)"
				}),
				e.scopes.length > 0 && /* @__PURE__ */ h("div", {
					className: "mt-1 pl-3 text-gray-600 dark:text-gray-400",
					children: e.scopes.join(", ")
				})
			]
		}, e.id))]
	});
	return /* @__PURE__ */ g(i, { children: [/* @__PURE__ */ g(n, {
		render: /* @__PURE__ */ h(a, {
			className: e("gap-1.5 bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-200", c && "border-l-2 border-l-yellow-600", o),
			variant: "secondary"
		}),
		children: [/* @__PURE__ */ h(_, { className: "h-3.5 w-3.5" }), "OAuth"]
	}), /* @__PURE__ */ h(r, {
		className: "max-w-xs p-4 text-sm",
		sideOffset: 12,
		children: l
	})] });
};
function C({ requirementsSummary: t, isByoc: n = !1, isPro: r = !1, badgeClassName: i }) {
	if (!(t?.secrets || t?.oauth || n || r)) return null;
	let { secrets: a, oauth: s } = t;
	return /* @__PURE__ */ g("div", {
		className: "flex w-full flex-wrap items-center gap-1.5",
		children: [
			a && /* @__PURE__ */ h(w, {
				className: i,
				secrets: a
			}),
			s && /* @__PURE__ */ h(T, {
				className: i,
				oauth: s
			}),
			n && /* @__PURE__ */ h(o, { className: e("gap-1.5 rounded-md", i) }),
			r && /* @__PURE__ */ h(u, { className: e("gap-1.5 rounded-md", i) })
		]
	});
}
var w = m.memo(x, (e, t) => e.className === t.className ? e.secrets === t.secrets ? !0 : !(!(e.secrets && t.secrets) || !d(e.secrets.configured, t.secrets.configured) || !d(e.secrets.pending, t.secrets.pending)) : !1), T = m.memo(S, (e, t) => {
	if (e.className !== t.className) return !1;
	if (e.oauth === t.oauth) return !0;
	if (!(e.oauth && t.oauth)) return !1;
	let n = e.oauth.providers, r = t.oauth.providers;
	if (n === r) return !0;
	if (n.length !== r.length) return !1;
	for (let e = 0; e < n.length; e++) {
		let t = n[e], i = r[e];
		if (!(t.id === i.id && t.status === i.status) || !d(t.scopes, i.scopes)) return !1;
	}
	return !0;
}), E = m.memo(C, f([
	"requirementsSummary",
	"isByoc",
	"isPro",
	"badgeClassName"
])), D = t("", {
	variants: {
		selected: {
			true: "border-2 border-emerald-600 dark:border-emerald-400",
			false: ""
		},
		partial: {
			true: "border-2 border-emerald-600 border-dashed dark:border-emerald-400",
			false: ""
		}
	},
	compoundVariants: [{
		selected: !1,
		partial: !1,
		class: "border-neutral-200 hover:border-neutral-300 dark:border-neutral-800 dark:hover:border-neutral-700"
	}]
}), O = (e, t, n, r) => e && !t && n > 0 ? `${n}/${r} tools` : `${r} tool${r === 1 ? "" : "s"}`, k = t("inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-xs", { variants: { indeterminate: {
	true: "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-200",
	false: "bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-200"
} } });
function A({ name: t, version: n, toolsCount: r, Icon: i = (e) => /* @__PURE__ */ h(y, { ...e }), isSelected: a = !1, isPartiallySelected: o = !1, selectedToolsCount: u = 0, requirementsSummary: d, onSelect: f, onView: _, hideCheckbox: v = !1, isByoc: x, isPro: S, ...C }) {
	let w = m.useCallback(() => {
		if (v && _) {
			_();
			return;
		}
		f?.(!(a || o));
	}, [
		v,
		a,
		o,
		f,
		_
	]), T = (e) => {
		let t = e.key === "Enter" || e.code === "Enter", n = e.key === " " || e.key === "Spacebar" || e.code === "Space";
		(t || n) && (e.preventDefault(), w()), (e.key === "ArrowRight" || e.code === "ArrowRight") && _ && (e.preventDefault(), _());
	}, A = o && !a;
	return /* @__PURE__ */ h(s, {
		...C,
		"aria-description": "Click card to select this toolkit. Use the View tools control to see its tools.",
		"aria-label": `Select toolkit ${t}`,
		className: e("group", "relative", "h-full", "cursor-pointer", "overflow-hidden", "rounded-lg", "border", "py-3.5", "transition-all", "duration-200", "bg-white/50", "hover:bg-white/70", "dark:bg-neutral-900/50", "dark:hover:bg-neutral-900/70", "hover:shadow-lg", D({
			selected: a,
			partial: o
		})),
		onClick: (e) => {
			e.target.closest("[data-slot=\"checkbox-wrapper\"]") || w();
		},
		onKeyDown: T,
		tabIndex: 0,
		children: /* @__PURE__ */ h(c, {
			className: "px-3",
			children: /* @__PURE__ */ g("div", {
				className: "space-y-3",
				children: [/* @__PURE__ */ g("div", {
					className: e("grid items-center gap-2", "grid-cols-[20px_1fr_auto]", v && "grid-cols-[1fr_auto]"),
					children: [
						!v && /* @__PURE__ */ h("div", {
							className: "flex items-center justify-center",
							"data-slot": "checkbox-wrapper",
							children: /* @__PURE__ */ h(l, {
								checked: a,
								indeterminate: o && !a,
								onCheckedChange: (e) => {
									f?.(e === !0);
								},
								tabIndex: -1
							})
						}),
						/* @__PURE__ */ h("div", {
							className: "mr-1.5 min-w-0",
							children: /* @__PURE__ */ g("div", {
								className: "flex min-w-0 items-center gap-3",
								children: [/* @__PURE__ */ h("div", {
									className: "flex size-9 items-center justify-center rounded bg-gradient-to-b from-neutral-200 to-neutral-100 ring-1 ring-black/5 dark:from-neutral-800 dark:to-neutral-900 dark:ring-white/5",
									children: /* @__PURE__ */ h(i, { className: "size-6 text-neutral-700 dark:text-neutral-200" })
								}), /* @__PURE__ */ g("div", {
									className: "flex h-9 min-w-0 flex-col justify-center space-y-0.5",
									children: [/* @__PURE__ */ h("h3", {
										className: "truncate font-semibold text-base text-neutral-900 leading-tight dark:text-neutral-100",
										children: t
									}), n && /* @__PURE__ */ g("span", {
										className: "font-medium text-neutral-500 text-xs leading-tight dark:text-neutral-400",
										children: ["v", n]
									})]
								})]
							})
						}),
						/* @__PURE__ */ h("div", {
							className: "mt-0.5 self-center justify-self-end",
							children: _ ? /* @__PURE__ */ h(p, {
								indeterminate: A,
								name: t,
								onClick: () => _(),
								selectedCount: u,
								toolsCount: r
							}) : /* @__PURE__ */ g("div", {
								className: k({ indeterminate: A }),
								children: [/* @__PURE__ */ h(b, { className: "h-3 w-3" }), /* @__PURE__ */ h("span", { children: O(o, a, u, r) })]
							})
						})
					]
				}), /* @__PURE__ */ h("div", {
					className: e(v ? "ml-0" : "ml-8"),
					children: /* @__PURE__ */ h(E, {
						isByoc: x,
						isPro: S,
						requirementsSummary: d
					})
				})]
			})
		})
	});
}
var j = f([
	"name",
	"version",
	"description",
	"toolsCount",
	"isSelected",
	"isPartiallySelected",
	"selectedToolsCount",
	"Icon",
	"requirementsSummary",
	"isByoc",
	"isPro",
	"hideCheckbox"
]), M = m.memo(A, j);
//#endregion
export { w as i, T as n, E as r, M as t };
