import { jsx as _jsx } from "react/jsx-runtime";
function getRealSize(size) {
    switch (size) {
        case 'xs': return 'size-4';
        case 'sm': return 'size-6';
        case 'md': return 'size-8';
        case 'lg': return 'size-10';
        case 'xl': return 'size-12';
        case '2xl': return 'size-14';
        default: throw new Error('Unexpected size: ' + size);
    }
}
export function Avatar({ size, src, name, shape = "circle", color = 'bg-gray-500', className }) {
    const rounded = shape === 'circle' ? 'rounded-full' : 'rounded-md';
    const sizeClass = getRealSize(size || 'md');
    if (src) {
        return (_jsx("img", { className: `inline-block ${sizeClass} ${rounded} ${color} ${className}`, src: src, alt: name || src, title: name }));
    }
    if (name) {
        const [first, second] = name.split(' ');
        let text = second ? `${first[0]}${second[0]}` : `${first[0]}${first[1]}`;
        return (_jsx("span", { className: `inline-flex ${sizeClass} items-center justify-center ${rounded} ${color} ${className}`, title: name, children: _jsx("span", { className: `${(size != 'xs') ? 'text-xs' : 'text-[0.6rem]'} font-medium leading-none text-white`, children: text }) }));
    }
    return (_jsx("span", { className: `inline-block ${sizeClass} overflow-hidden ${rounded} ${color}`, children: _jsx("svg", { className: "h-full w-full text-gray-300", fill: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { d: "M24 20.993V24H0v-2.996A14.977 14.977 0 0112.004 15c4.904 0 9.26 2.354 11.996 5.993zM16.002 8.999a4 4 0 11-8 0 4 4 0 018 0z" }) }) }));
}
export function SvgAvatar({ size, shape = "circle", color = 'bg-gray-500', className, children }) {
    const rounded = shape === 'circle' ? 'rounded-full' : 'rounded-md';
    const sizeClass = getRealSize(size || 'md');
    return (_jsx("span", { className: `inline-block ${sizeClass} overflow-hidden ${rounded} ${color} ${className}`, children: children }));
}
//# sourceMappingURL=Avatar.js.map