import { forwardRef, type HTMLAttributes } from 'react'
import { cn } from '../../lib/utils'
export type AvatarProps = HTMLAttributes & {
name?: string
src?: string
}
function initials(name?: string) {
if (!name) return '?'
return name
.split(/\s+/)
.filter(Boolean)
.slice(0, 2)
.map((part) => part[0]?.toUpperCase() ?? '')
.join('')
}
export const Avatar = forwardRef(
({ className, name, src, ...props }, ref) => {
return (
{src ? (

) : (
initials(name)
)}
)
},
)
Avatar.displayName = 'Avatar'