"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Building2, Globe, Mail, MapPin, Phone } from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { Avatar } from "../../primitives/avatar.js";
import { KeyValueList, RecordCardShell, TagRow, statusToTagVariant } from "./RecordCardShell.js";
function normalizeWebsite(value) {
  const trimmed = value.trim();
  if (/^https?:\/\//i.test(trimmed)) {
    return { href: trimmed, label: trimmed.replace(/^https?:\/\//i, "") };
  }
  return { href: `https://${trimmed}`, label: trimmed };
}
function CompanyCard(props) {
  const t = useT();
  const status = props.status ? { label: props.status, variant: statusToTagVariant(props.status) } : null;
  const websiteEntry = props.website ? normalizeWebsite(props.website) : null;
  const location = [props.city, props.country].filter(Boolean).join(", ");
  const items = [
    props.industry ? { label: t("ai_assistant.chat.records.fields.industry", "Industry"), value: props.industry } : null,
    websiteEntry ? {
      label: t("ai_assistant.chat.records.fields.website", "Website"),
      value: /* @__PURE__ */ jsx(
        "a",
        {
          href: websiteEntry.href,
          target: "_blank",
          rel: "noopener noreferrer",
          className: "text-primary hover:underline",
          onClick: (event) => event.stopPropagation(),
          children: websiteEntry.label
        }
      )
    } : null,
    props.email ? {
      label: t("ai_assistant.chat.records.fields.email", "Email"),
      value: /* @__PURE__ */ jsx(
        "a",
        {
          href: `mailto:${props.email}`,
          className: "text-primary hover:underline",
          onClick: (event) => event.stopPropagation(),
          children: props.email
        }
      )
    } : null,
    props.phone ? { label: t("ai_assistant.chat.records.fields.phone", "Phone"), value: props.phone } : null,
    location ? { label: t("ai_assistant.chat.records.fields.location", "Location"), value: location } : null,
    props.ownerName ? { label: t("ai_assistant.chat.records.fields.owner", "Owner"), value: props.ownerName } : null
  ].filter(Boolean);
  return /* @__PURE__ */ jsx(
    RecordCardShell,
    {
      kindLabel: t("ai_assistant.chat.records.kinds.company", "Company"),
      kindIcon: /* @__PURE__ */ jsx(Building2, { className: "size-4", "aria-hidden": true }),
      leading: /* @__PURE__ */ jsx(Avatar, { label: props.name, src: props.logoUrl ?? void 0, size: "md", variant: "monochrome" }),
      title: props.name,
      subtitle: [props.industry, location].filter(Boolean).join(" \u2022 ") || void 0,
      status,
      href: props.href,
      id: props.id,
      className: props.className,
      dataKind: "company",
      children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
        /* @__PURE__ */ jsx(KeyValueList, { items }),
        props.tags && props.tags.length > 0 ? /* @__PURE__ */ jsx(TagRow, { tags: props.tags }) : null
      ] })
    }
  );
}
var CompanyCard_default = CompanyCard;
export {
  Building2,
  CompanyCard,
  Globe,
  Mail,
  MapPin,
  Phone,
  CompanyCard_default as default
};
//# sourceMappingURL=CompanyCard.js.map
