"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import Link from "next/link";
import { hasAllFeatures } from "@open-mercato/shared/security/features";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function SettingsNavigation({ sections, userFeatures }) {
  const t = useT();
  const grantedFeatureList = React.useMemo(() => userFeatures ? Array.from(userFeatures) : [], [userFeatures]);
  const hasRequiredFeatures = (card) => {
    if (!card.requireFeatures || card.requireFeatures.length === 0) return true;
    if (!userFeatures) return true;
    return hasAllFeatures(grantedFeatureList, card.requireFeatures);
  };
  const renderCard = (card) => /* @__PURE__ */ jsxs(
    Link,
    {
      href: card.href,
      className: "group flex flex-col gap-2 rounded-lg border bg-background p-4 shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",
      children: [
        /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
          /* @__PURE__ */ jsx("span", { className: "text-muted-foreground group-hover:text-accent-foreground", children: card.icon }),
          /* @__PURE__ */ jsx("h3", { className: "font-medium", children: t(card.titleKey, card.title) })
        ] }),
        /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground group-hover:text-accent-foreground/80", children: t(card.descriptionKey, card.description) })
      ]
    },
    card.href
  );
  const renderSection = (section) => {
    const visibleCards = section.cards.filter(hasRequiredFeatures);
    if (visibleCards.length === 0) return null;
    return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
      /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: t(section.titleKey, section.title) }),
      /* @__PURE__ */ jsx("div", { className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3", children: visibleCards.map(renderCard) })
    ] }, section.id);
  };
  return /* @__PURE__ */ jsx(Fragment, { children: sections.map(renderSection) });
}
export {
  SettingsNavigation
};
//# sourceMappingURL=SettingsNavigation.js.map
