import { jsx as e, jsxs as b } from "react/jsx-runtime";
import { useDynamicImport as $ } from "./index-use-dynamic-import.js";
import { classNames as i } from "./index-classNames.js";
import { generateColorFromInitials as z } from "./index-color-helpers.js";
import { getNameInitials as C } from "./index-string-helpers.js";
import { updateImageUrlWithBaseRequest as H } from "./index-update-image-url-with-base-request.js";
import { AvatarIconMap as j } from "./index-Avatar.enum.js";
import { Text as D, FontWeights as R, TextTypes as W } from "./index-Text.js";
import "react";
import { StyledSVG as q } from "./index-StyledSVG.js";
import t from "./index-Avatar.module.scss.js";
const X = (n) => {
  const {
    size: l = "medium",
    hasNotifications: x = !1,
    name: c,
    fullName: m,
    bgColor: d,
    noHover: f,
    translate: A = !1,
    greyScale: r = !1,
    clearIcon: S
  } = n, {
    icon: v = "",
    image: g
  } = n, u = `${j[v]}`, s = x && l !== "small";
  let {
    SvgIcon: o,
    loading: F,
    error: M
  } = $(`avatarIcons/listings/${u}.svg`, {
    shouldRequest: !!u
  });
  S && (o = "");
  let a = 0;
  switch (l) {
    case "large":
      a = 56;
      break;
    case "medium-large":
      a = 48;
      break;
    case "medium-40":
      a = 40;
      break;
    case "medium":
      a = 32;
      break;
    case "small":
      a = 24;
      break;
    case "xs":
      a = 16;
      break;
  }
  const h = () => {
    if (c)
      return C(c);
  }, k = () => {
    var I;
    let y = "";
    return (I = h()) == null || I.forEach((w) => {
      y += w;
    }), y;
  };
  if (g)
    return e("div", {
      "data-testid": "avatar-image-test-id",
      className: i(t.rcAvatar, t.rcAvatarImage, f ? t.noHover : null, r ? t.greyScale : void 0),
      style: {
        backgroundImage: `url(${H(g)})`,
        width: a,
        height: a
      },
      children: s && e("div", {
        "data-testid": "avatar-notifications-test-id",
        className: i(t.rcAvatarNotification)
      })
    });
  if (v && o)
    return b("div", {
      "data-testid": "avatar-icon-test-id",
      className: i(t.rcAvatar, r ? t.greyScale : void 0),
      children: [s && e("div", {
        "data-testid": "avatar-notifications-test-id",
        className: i(t.rcAvatarNotification)
      }), e(q, {
        width: a,
        height: a,
        src: o,
        className: t.avatarSvg
      })]
    });
  const T = d || z(h() ?? []), p = m || k(), N = 2 * Math.log1p(p.length);
  return b("div", {
    "data-testid": "avatar-name-test-id",
    className: i(t.rcAvatar, t.rcAvatarName, f ? t.noHover : null, r ? t.greyScale : void 0),
    style: {
      backgroundColor: `var(${T})`,
      width: a,
      height: a,
      borderRadius: "50%"
    },
    children: [s && e("div", {
      "data-testid": "avatar-notifications-test-id",
      className: i(t.rcAvatarNotification)
    }), e(D, {
      type: W.textHelp,
      fontSize: N ? a / N : a,
      fontWeight: R.bold,
      color: "--n000",
      translate: A,
      children: p
    })]
  });
};
export {
  X as Avatar
};
