"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Building2, Mail, MousePointerClick, Pencil, Users } from "lucide-react";
import { Button } from "@open-mercato/ui/primitives/button";
import { cn } from "@open-mercato/shared/lib/utils";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function DocumentCustomerCard({
  label,
  name,
  email,
  kind = "company",
  onEditSnapshot,
  onSelectCustomer,
  className
}) {
  const t = useT();
  const Icon = kind === "person" ? Users : Building2;
  const interactiveProps = onSelectCustomer ? {
    role: "button",
    tabIndex: 0,
    onClick: onSelectCustomer,
    onKeyDown: (event) => {
      if (event.key === "Enter" || event.key === " ") {
        event.preventDefault();
        onSelectCustomer();
      }
    }
  } : {};
  return /* @__PURE__ */ jsx(
    "div",
    {
      className: cn(
        "group rounded-lg border bg-card p-3",
        onSelectCustomer ? "cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" : null,
        className
      ),
      ...interactiveProps,
      children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
        /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2 min-w-0", children: [
          label ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground", children: [
            /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, className: "h-3.5 w-3.5" }),
            label
          ] }) : null,
          /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
            /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-muted", children: /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, className: "h-5 w-5 text-muted-foreground" }) }),
            /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 min-w-0", children: [
              name ? /* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-tight text-foreground", children: name }) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("sales.documents.detail.customerSnapshot.noCustomer") }),
              email ? /* @__PURE__ */ jsxs("p", { className: "flex w-full items-center gap-1 text-xs text-muted-foreground min-w-0", children: [
                /* @__PURE__ */ jsx(Mail, { className: "h-3.5 w-3.5", "aria-hidden": true }),
                /* @__PURE__ */ jsx("span", { className: "truncate", title: email, children: email })
              ] }) : null
            ] })
          ] })
        ] }),
        /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
          /* @__PURE__ */ jsxs(
            Button,
            {
              type: "button",
              variant: "ghost",
              size: "icon",
              onClick: (event) => {
                event.stopPropagation();
                if (onEditSnapshot) onEditSnapshot();
              },
              className: cn(
                "opacity-0 transition-opacity duration-150 group-hover:opacity-100 hover:opacity-100 focus-visible:opacity-100",
                !onEditSnapshot ? "cursor-default opacity-0" : null
              ),
              disabled: !onEditSnapshot,
              children: [
                /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4", "aria-hidden": true }),
                /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("sales.documents.detail.customerSnapshot.edit") })
              ]
            }
          ),
          /* @__PURE__ */ jsxs(
            Button,
            {
              type: "button",
              variant: "ghost",
              size: "icon",
              onClick: (event) => {
                event.stopPropagation();
                if (onSelectCustomer) onSelectCustomer();
              },
              className: cn(
                "opacity-0 transition-opacity duration-150 group-hover:opacity-100 hover:opacity-100 focus-visible:opacity-100",
                !onSelectCustomer ? "cursor-default opacity-0" : null
              ),
              disabled: !onSelectCustomer,
              children: [
                /* @__PURE__ */ jsx(MousePointerClick, { className: "h-4 w-4", "aria-hidden": true }),
                /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("sales.documents.detail.customerSnapshot.select") })
              ]
            }
          )
        ] })
      ] })
    }
  );
}
export {
  DocumentCustomerCard
};
//# sourceMappingURL=DocumentCustomerCard.js.map
