"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import { ExternalLink, Star } from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { buildAttachmentImageUrl, slugifyAttachmentFileName } from "@open-mercato/core/modules/attachments/lib/imageUrls";
function VariantMediaReadonlyGallery({ groups }) {
  const t = useT();
  const nonEmptyGroups = groups.filter((group) => group.items.length > 0);
  if (!nonEmptyGroups.length) {
    return null;
  }
  return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
    /* @__PURE__ */ jsx("label", { className: "text-sm font-medium text-muted-foreground", children: t("catalog.products.variantMedia.title", "Variant media") }),
    nonEmptyGroups.map((group) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
      /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
        /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: group.variantName }),
        /* @__PURE__ */ jsxs(
          Link,
          {
            href: group.editUrl,
            className: "inline-flex items-center gap-0.5 text-xs text-muted-foreground hover:text-foreground",
            children: [
              /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" }),
              /* @__PURE__ */ jsx("span", { children: t("catalog.products.variantMedia.editVariant", "Edit variant") })
            ]
          }
        )
      ] }),
      /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2 sm:grid-cols-3", children: group.items.map((item) => {
        const isDefault = group.defaultMediaId === item.id;
        const slug = slugifyAttachmentFileName(item.fileName);
        const thumbnail = item.thumbnailUrl || buildAttachmentImageUrl(item.id, { width: 360, height: 360, slug });
        return /* @__PURE__ */ jsxs("div", { className: "flex flex-col rounded-md border bg-card", children: [
          /* @__PURE__ */ jsxs("div", { className: "relative aspect-square overflow-hidden rounded-t-md bg-muted", children: [
            /* @__PURE__ */ jsx("img", { src: thumbnail, alt: item.fileName, className: "h-full w-full object-cover" }),
            isDefault ? /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx("div", { className: "flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Star, { className: "h-3.5 w-3.5" }) }) }) : null
          ] }),
          /* @__PURE__ */ jsx("div", { className: "p-2", children: /* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-xs text-muted-foreground", children: item.fileName }) })
        ] }, item.id);
      }) })
    ] }, group.variantId))
  ] });
}
export {
  VariantMediaReadonlyGallery
};
//# sourceMappingURL=VariantMediaReadonlyGallery.js.map
