import { jsxs as r, jsx as e } from "react/jsx-runtime";
import { Link as y } from "react-router-dom";
import { Building2 as w, User as C, Check as k, Crown as P, Star as p, Users as j, Link2 as A, UserCheck as g, ArrowRight as S, Trash2 as G } from "lucide-react";
import { useTranslation as $ } from "react-i18next";
const h = {
  Pending: {
    bg: "var(--info-bg)",
    text: "var(--info-text)",
    dot: "var(--info-dot)"
  },
  Active: {
    bg: "var(--success-bg)",
    text: "var(--success-text)",
    dot: "var(--success-dot)"
  },
  Suspended: {
    bg: "var(--warning-bg)",
    text: "var(--warning-text)",
    dot: "var(--warning-dot)"
  },
  Archived: {
    bg: "var(--error-bg)",
    text: "var(--error-text)",
    dot: "var(--error-dot)"
  }
};
function T({
  tenant: t,
  isSelected: c = !1,
  isDisabled: i = !1,
  disabledReason: n,
  onSelect: d,
  onSetDefault: m,
  onEnter: u,
  onManage: B,
  onRemove: x,
  showActions: f = !0,
  navigateTo: v
}) {
  const { t: a } = $("navigation"), b = t.type === "Business", o = t.status === "Active", l = h[t.status] || h.Active, N = f && !i;
  return /* @__PURE__ */ r(
    "div",
    {
      className: `group relative bg-[var(--bg-card)] border overflow-hidden transition-all duration-200 ${c ? "border-emerald-500 ring-2 ring-emerald-500/20" : "border-[var(--border-color)] hover:border-[var(--color-accent-300)]"} ${o ? "" : "opacity-60"} ${i ? "opacity-50 grayscale" : ""}`,
      style: { borderRadius: "var(--radius-card)" },
      title: i && n ? n : void 0,
      children: [
        /* @__PURE__ */ r("div", { className: "p-5", children: [
          /* @__PURE__ */ r("div", { className: "flex items-start justify-between mb-4", children: [
            /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
              /* @__PURE__ */ e(
                "div",
                {
                  className: `w-12 h-12 rounded-xl flex items-center justify-center ${b ? "bg-gradient-to-br from-blue-500/20 to-blue-600/20" : "bg-gradient-to-br from-violet-500/20 to-violet-600/20"}`,
                  children: b ? /* @__PURE__ */ e(w, { className: "w-6 h-6 text-blue-500" }) : /* @__PURE__ */ e(C, { className: "w-6 h-6 text-violet-500" })
                }
              ),
              /* @__PURE__ */ r("div", { children: [
                /* @__PURE__ */ e("h3", { className: "font-semibold text-[var(--text-primary)] line-clamp-1", children: v ? /* @__PURE__ */ e(
                  y,
                  {
                    to: v,
                    className: "hover:text-[var(--color-accent-600)] hover:underline transition-colors",
                    onClick: (s) => s.stopPropagation(),
                    children: t.name
                  }
                ) : t.name }),
                /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-tertiary)]", children: t.slug })
              ] })
            ] }),
            c && /* @__PURE__ */ e("div", { className: "w-6 h-6 rounded-full bg-emerald-500 flex items-center justify-center", children: /* @__PURE__ */ e(k, { className: "w-4 h-4 text-white" }) })
          ] }),
          t.organisationName && /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-secondary)] mb-3 line-clamp-1", children: t.organisationName }),
          /* @__PURE__ */ r("div", { className: "flex items-center gap-2 flex-wrap mb-4", children: [
            /* @__PURE__ */ r(
              "span",
              {
                className: "inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full",
                style: { backgroundColor: l.bg, color: l.text },
                children: [
                  /* @__PURE__ */ e(
                    "span",
                    {
                      className: "w-1.5 h-1.5 rounded-full",
                      style: { backgroundColor: l.dot }
                    }
                  ),
                  a(`tenants.status.${t.status.toLowerCase()}`, { defaultValue: t.status })
                ]
              }
            ),
            t.isOwner && /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/10 text-amber-600", children: [
              /* @__PURE__ */ e(P, { className: "w-3 h-3" }),
              a("tenants.owner", "Owner")
            ] }),
            t.isDefault && /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)]", children: [
              /* @__PURE__ */ e(p, { className: "w-3 h-3 fill-current" }),
              a("tenants.default", "Default")
            ] })
          ] }),
          t.membershipSource && t.membershipSource !== "Direct" && /* @__PURE__ */ r("div", { className: "mb-4 p-2 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-subtle)]", children: [
            /* @__PURE__ */ r("div", { className: "flex items-center gap-2 mb-1", children: [
              t.membershipSource === "Group" ? /* @__PURE__ */ e(j, { className: "w-3.5 h-3.5 text-blue-500" }) : /* @__PURE__ */ e(A, { className: "w-3.5 h-3.5 text-violet-500" }),
              /* @__PURE__ */ e("span", { className: "text-xs font-medium text-[var(--text-secondary)]", children: t.membershipSource === "Group" ? a("tenants.viaGroup", "Via groupe") : a("tenants.directAndGroup", "Direct + Groupe") })
            ] }),
            (t.groupPaths?.length ?? 0) > 0 && /* @__PURE__ */ r("div", { className: "mt-1 space-y-1", children: [
              t.groupPaths?.slice(0, 2).map((s) => /* @__PURE__ */ r("div", { className: "text-xs text-[var(--text-tertiary)] flex items-center gap-1", children: [
                /* @__PURE__ */ e(g, { className: "w-3 h-3" }),
                /* @__PURE__ */ e("span", { className: "truncate", title: s.lineage, children: s.lineage })
              ] }, s.lineage)),
              (t.groupPaths?.length ?? 0) > 2 && /* @__PURE__ */ r("span", { className: "text-xs text-[var(--text-tertiary)]", children: [
                "+",
                (t.groupPaths?.length ?? 0) - 2,
                " ",
                a("common.more", "autres")
              ] })
            ] })
          ] }),
          t.membershipSource === "Direct" && /* @__PURE__ */ r("div", { className: "mb-4 flex items-center gap-1.5 text-xs text-[var(--text-tertiary)]", children: [
            /* @__PURE__ */ e(g, { className: "w-3.5 h-3.5 text-green-500" }),
            a("tenants.directMember", "Membre direct")
          ] }),
          N && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 pt-3 border-t border-[var(--border-color)]", children: [
            !t.isDefault && o && m && /* @__PURE__ */ e(
              "button",
              {
                onClick: (s) => {
                  s.stopPropagation(), m();
                },
                className: "flex items-center justify-center px-3 py-2 text-[var(--text-secondary)] hover:text-amber-500 hover:bg-[var(--bg-tertiary)] transition-colors",
                style: { borderRadius: "var(--radius-button)" },
                title: a("tenants.setDefault", "Set default"),
                children: /* @__PURE__ */ e(p, { className: "w-4 h-4" })
              }
            ),
            o && u && /* @__PURE__ */ r(
              "button",
              {
                onClick: (s) => {
                  s.stopPropagation(), u();
                },
                className: "flex items-center justify-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-[var(--color-accent-500)] hover:bg-[var(--color-accent-600)] transition-colors",
                style: { borderRadius: "var(--radius-button)" },
                children: [
                  a("tenants.enter", "Enter"),
                  /* @__PURE__ */ e(S, { className: "w-4 h-4" })
                ]
              }
            ),
            x && /* @__PURE__ */ e(
              "button",
              {
                onClick: (s) => {
                  s.stopPropagation(), x();
                },
                className: "flex items-center justify-center gap-1.5 px-3 py-2 text-sm font-medium text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",
                style: { borderRadius: "var(--radius-button)" },
                title: a("tenants.remove", "Retirer"),
                children: /* @__PURE__ */ e(G, { className: "w-4 h-4" })
              }
            )
          ] })
        ] }),
        d && o && /* @__PURE__ */ e(
          "button",
          {
            onClick: d,
            className: "absolute inset-0 z-10",
            "aria-label": a("tenants.select", "Select tenant")
          }
        )
      ]
    }
  );
}
export {
  T
};
//# sourceMappingURL=TenantCard-D0O2ivhU.js.map
