"use client";
import { jsx, jsxs } from 'react/jsx-runtime';
import { memo } from 'react';
import { User } from 'lucide-react';
import { Avatar, AvatarFallback, AvatarImage } from '../../../../../../../ui/src/components/avatar.mjs';

function getInitials(name) {
  const parts = name.trim().split(/\s+/);
  if (parts.length === 1) {
    return parts[0]?.charAt(0).toUpperCase() || "";
  }
  return ((parts[0]?.charAt(0) || "") + (parts[parts.length - 1]?.charAt(0) || "")).toUpperCase();
}
function UserAvatarComponent({
  user,
  size = "sm",
  className
}) {
  if (!user) {
    return /* @__PURE__ */ jsx(Avatar, { size, className, title: "Unassigned", children: /* @__PURE__ */ jsx(AvatarFallback, { children: /* @__PURE__ */ jsx(User, { className: "size-3 group-data-[size=default]/avatar:size-4 group-data-[size=lg]/avatar:size-5" }) }) });
  }
  const initials = getInitials(user.name);
  return /* @__PURE__ */ jsxs(Avatar, { size, className, title: user.name, children: [
    user.avatarUrl && /* @__PURE__ */ jsx(AvatarImage, { src: user.avatarUrl, alt: user.name }),
    /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-primary/10 text-primary font-medium", children: initials })
  ] });
}
const UserAvatar = memo(UserAvatarComponent);

export { UserAvatar };
