import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';

// src/lib/utils.ts
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function ProductCardBody({ product }) {
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx("div", { className: "aspect-square overflow-hidden rounded-xl bg-muted [&_img]:size-full [&_img]:object-cover [&_img]:transition-transform [&_img]:duration-200 [&_img]:ease-out group-hover:[&_img]:scale-105", children: product.image }),
    /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
      /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
        /* @__PURE__ */ jsx("h3", { className: "truncate text-sm font-medium text-foreground", children: product.name }),
        product.meta ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: product.meta }) : null
      ] }),
      /* @__PURE__ */ jsx("span", { className: "flex-none text-sm font-medium text-foreground", children: product.price })
    ] })
  ] });
}
function CommerceProductGrid({
  products,
  title,
  columns = "four",
  className
}) {
  return /* @__PURE__ */ jsx("section", { className: cn("bg-background py-16 sm:py-20", className), children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-7xl px-6 lg:px-8", children: [
    title ? /* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold tracking-tight text-foreground", children: title }) : null,
    /* @__PURE__ */ jsx(
      "div",
      {
        className: cn(
          "grid grid-cols-2 gap-x-6 gap-y-10 sm:grid-cols-3",
          columns === "four" ? "lg:grid-cols-4" : "lg:grid-cols-3",
          title && "mt-8"
        ),
        children: products.map(
          (product, index) => product.href ? /* @__PURE__ */ jsx(
            "a",
            {
              href: product.href,
              className: "group flex flex-col gap-3 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
              children: /* @__PURE__ */ jsx(ProductCardBody, { product })
            },
            index
          ) : /* @__PURE__ */ jsx("div", { className: "group flex flex-col gap-3", children: /* @__PURE__ */ jsx(ProductCardBody, { product }) }, index)
        )
      }
    )
  ] }) });
}

export { CommerceProductGrid };
//# sourceMappingURL=commerce-product-grid.js.map
//# sourceMappingURL=commerce-product-grid.js.map