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

// src/lib/utils.ts
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function CommerceOrderHistory({
  orders,
  title,
  description,
  emptyState,
  className
}) {
  const hasHeading = Boolean(title || description);
  return /* @__PURE__ */ jsxs("section", { className: cn("flex flex-col gap-4", className), children: [
    hasHeading ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
      title ? /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-foreground", children: title }) : null,
      description ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }) : null
    ] }) : null,
    orders.length === 0 ? emptyState ?? /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-border bg-card p-8 text-center text-sm text-muted-foreground", children: "No orders yet." }) : /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl border border-border bg-card", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm text-card-foreground", children: [
      /* @__PURE__ */ jsx("thead", { className: "border-b border-border bg-muted/40 text-xs uppercase tracking-wide text-muted-foreground", children: /* @__PURE__ */ jsxs("tr", { children: [
        /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-3 text-left font-medium", children: "Order" }),
        /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-3 text-left font-medium", children: "Date" }),
        /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-3 text-left font-medium", children: "Total" }),
        /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-3 text-left font-medium", children: "Status" }),
        /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-3 text-right font-medium", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "View" }) })
      ] }) }),
      /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-border", children: orders.map((order, index) => /* @__PURE__ */ jsxs("tr", { className: "hover:bg-muted/30", children: [
        /* @__PURE__ */ jsx("td", { className: "px-4 py-3 font-medium text-foreground", children: order.id }),
        /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-muted-foreground", children: order.date }),
        /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-foreground", children: order.total }),
        /* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: order.status }),
        /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-right", children: order.href ? /* @__PURE__ */ jsxs(
          "a",
          {
            href: order.href,
            className: "text-sm font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
            children: [
              "View",
              /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
                " order ",
                order.id
              ] })
            ]
          }
        ) : null })
      ] }, index)) })
    ] }) })
  ] });
}

export { CommerceOrderHistory };
//# sourceMappingURL=commerce-order-history.js.map
//# sourceMappingURL=commerce-order-history.js.map