"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import {
  Activity as ActivityIcon,
  CalendarClock,
  CheckCircle2,
  ListChecks,
  Mail,
  MessageSquare,
  Phone,
  StickyNote
} from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { KeyValueList, RecordCardShell, TagRow, statusToTagVariant } from "./RecordCardShell.js";
function formatDate(value) {
  if (!value) return null;
  const d = new Date(value);
  if (Number.isNaN(d.getTime())) return value;
  return d.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
}
function pickActivityIcon(type) {
  if (!type) return ActivityIcon;
  const t = type.toLowerCase();
  if (t.includes("call")) return Phone;
  if (t.includes("mail") || t.includes("email")) return Mail;
  if (t.includes("meeting") || t.includes("chat")) return MessageSquare;
  if (t.includes("task") || t.includes("todo")) return ListChecks;
  if (t.includes("note")) return StickyNote;
  if (t.includes("done") || t.includes("complete")) return CheckCircle2;
  return ActivityIcon;
}
function ActivityCard(props) {
  const t = useT();
  const Icon = pickActivityIcon(props.type);
  const status = props.status ? { label: props.status, variant: statusToTagVariant(props.status) } : null;
  const dueDate = formatDate(props.dueDate);
  const completedAt = formatDate(props.completedAt);
  const items = [
    props.type ? { label: t("ai_assistant.chat.records.fields.type", "Type"), value: props.type } : null,
    dueDate ? {
      label: t("ai_assistant.chat.records.fields.due", "Due"),
      value: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
        /* @__PURE__ */ jsx(CalendarClock, { className: "size-3 text-muted-foreground", "aria-hidden": true }),
        dueDate
      ] })
    } : null,
    completedAt ? {
      label: t("ai_assistant.chat.records.fields.completed", "Completed"),
      value: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
        /* @__PURE__ */ jsx(CheckCircle2, { className: "size-3 text-status-success-icon", "aria-hidden": true }),
        completedAt
      ] })
    } : null,
    props.relatedTo ? { label: t("ai_assistant.chat.records.fields.related", "Related"), value: props.relatedTo } : null,
    props.ownerName ? { label: t("ai_assistant.chat.records.fields.owner", "Owner"), value: props.ownerName } : null
  ].filter(Boolean);
  const subtitle = [props.type, props.relatedTo].filter(Boolean).join(" \u2022 ");
  return /* @__PURE__ */ jsx(
    RecordCardShell,
    {
      kindLabel: t("ai_assistant.chat.records.kinds.activity", "Activity"),
      kindIcon: /* @__PURE__ */ jsx(Icon, { className: "size-4", "aria-hidden": true }),
      title: props.title,
      subtitle: subtitle || void 0,
      status,
      href: props.href,
      id: props.id,
      className: props.className,
      dataKind: "activity",
      children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
        /* @__PURE__ */ jsx(KeyValueList, { items }),
        props.description ? /* @__PURE__ */ jsx("p", { className: "line-clamp-3 text-muted-foreground", children: props.description }) : null,
        props.tags && props.tags.length > 0 ? /* @__PURE__ */ jsx(TagRow, { tags: props.tags }) : null
      ] })
    }
  );
}
var ActivityCard_default = ActivityCard;
export {
  ActivityCard,
  ActivityCard_default as default
};
//# sourceMappingURL=ActivityCard.js.map
