import React from "react";
import style from "./Avatar.module.css";
import getCompliedClassName from "../../utils/getCompliedClassName";
import avatarPropTypes, { defaultProps, propsDescription } from "./Avatar.propTypes";
import constantProps from "./Avatar.constantProps";
export default function Avatar(props) {
  let {
    shape,
    size,
    color,
    text,
    photoUrl,
    floatingLayer,
    floatingLayerText,
    floatingLayerAlign,
    customClassName,
    onError,
    onLoad,
    showAvatar,
    getContent
  } = props; // icon-support , getContent

  let className = getCompliedClassName(customClassName, {
    [style.base]: true,
    [style[color]]: !!color,
    [style[shape]]: !!shape,
    [style[size]]: !!size
  }, {
    [customClassName.shape]: !!customClassName.shape,
    [customClassName.size]: !!customClassName.size,
    [customClassName.color]: !!customClassName.color
  });

  if ((floatingLayer || floatingLayerText) && showAvatar) {
    return /*#__PURE__*/React.createElement("span", {
      className: style.container
    }, /*#__PURE__*/React.createElement("span", {
      className: `${floatingLayerText ? style.floatinglayer : null} ${floatingLayerText ? style[floatingLayerAlign + "_" + size] : null}`
    }, floatingLayer ? null : floatingLayerText, floatingLayer ? floatingLayer : null), photoUrl ? /*#__PURE__*/React.createElement("img", {
      src: photoUrl,
      onError: onError && onError,
      className: className,
      onLoad: onLoad && onLoad
    }) : /*#__PURE__*/React.createElement("span", {
      className: className
    }, getContent(text, "upperCase")));
  } else if (photoUrl && showAvatar) {
    return /*#__PURE__*/React.createElement("img", {
      src: photoUrl,
      onError: onError && onError,
      className: className,
      onLoad: onLoad && onLoad
    });
  }

  return /*#__PURE__*/React.createElement("span", {
    className: className
  }, getContent(text, "upperCase"));
}
Avatar.propTypes = avatarPropTypes;
Avatar.defaultProps = defaultProps;
Avatar.propsDescription = propsDescription;
Avatar.constantProps = constantProps;