"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const React = require('react');
const LucideIcons = require('lucide-react');
const avatar = require('../../../../../../../ui/src/components/avatar.cjs');

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__ */ jsxRuntime.jsx(avatar.Avatar, { size, className, title: "Unassigned", children: /* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.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__ */ jsxRuntime.jsxs(avatar.Avatar, { size, className, title: user.name, children: [
    user.avatarUrl && /* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarImage, { src: user.avatarUrl, alt: user.name }),
    /* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { className: "bg-primary/10 text-primary font-medium", children: initials })
  ] });
}
const UserAvatar = React.memo(UserAvatarComponent);

exports.UserAvatar = UserAvatar;
