"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Boxes, FolderTree, PackageCheck, Tags } from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import {
  defaultAiUiPartRegistry
} from "@open-mercato/ui/ai";
function formatCount(value) {
  if (typeof value === "number" && Number.isFinite(value)) {
    return value.toLocaleString();
  }
  return "\u2014";
}
function StatTile({
  icon,
  label,
  value
}) {
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 rounded-md border border-border bg-card p-3", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground", children: [
      icon,
      /* @__PURE__ */ jsx("span", { children: label })
    ] }),
    /* @__PURE__ */ jsx("div", { className: "text-2xl font-semibold leading-none", children: value })
  ] });
}
function CatalogStatsCard({ payload }) {
  const t = useT();
  const data = payload ?? {};
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: "rounded-lg border border-border bg-muted/30 p-3",
      "data-ai-ui-part": "catalog.stats-card",
      children: [
        /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 text-sm font-medium", children: [
          /* @__PURE__ */ jsx(Boxes, { className: "size-4 text-primary", "aria-hidden": true }),
          /* @__PURE__ */ jsx("span", { children: t("catalog.stats.title", "Catalog overview") })
        ] }),
        /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 sm:grid-cols-4", children: [
          /* @__PURE__ */ jsx(
            StatTile,
            {
              icon: /* @__PURE__ */ jsx(Boxes, { className: "size-3", "aria-hidden": true }),
              label: t("catalog.stats.products", "Products"),
              value: formatCount(data.products)
            }
          ),
          /* @__PURE__ */ jsx(
            StatTile,
            {
              icon: /* @__PURE__ */ jsx(PackageCheck, { className: "size-3", "aria-hidden": true }),
              label: t("catalog.stats.active", "Active"),
              value: formatCount(data.activeProducts)
            }
          ),
          /* @__PURE__ */ jsx(
            StatTile,
            {
              icon: /* @__PURE__ */ jsx(FolderTree, { className: "size-3", "aria-hidden": true }),
              label: t("catalog.stats.categories", "Categories"),
              value: formatCount(data.categories)
            }
          ),
          /* @__PURE__ */ jsx(
            StatTile,
            {
              icon: /* @__PURE__ */ jsx(Tags, { className: "size-3", "aria-hidden": true }),
              label: t("catalog.stats.tags", "Tags"),
              value: formatCount(data.tags)
            }
          )
        ] }),
        data.note ? /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: data.note }) : null,
        data.generatedAt ? /* @__PURE__ */ jsx("p", { className: "mt-2 text-[10px] text-muted-foreground", children: t("catalog.stats.snapshotAt", "Snapshot at {time}").replace("{time}", new Date(data.generatedAt).toLocaleString()) }) : null
      ]
    }
  );
}
let registered = false;
function registerCatalogStatsCard() {
  if (registered) return;
  registered = true;
  defaultAiUiPartRegistry.register("catalog.stats-card", CatalogStatsCard);
}
registerCatalogStatsCard();
export {
  CatalogStatsCard,
  registerCatalogStatsCard
};
//# sourceMappingURL=CatalogStatsCard.js.map
