import { jsxs as N, jsx as i } from "react/jsx-runtime";
import { useState as m, useRef as v, useEffect as E } from "react";
import { a as h } from "./index.CfQlFjZU.js";
import { c as A } from "./index.CfM2L_w0.js";
var D = /* @__PURE__ */ ((s) => (s.MD = "md", s.SM = "sm", s))(D || {}), L = /* @__PURE__ */ ((s) => (s.LOADING = "loading", s.LOADED = "loaded", s))(L || {});
const j = ({
  url: s,
  username: o,
  size: a = "md"
  /* MD */
}) => {
  const [n, r] = m(!!s), [e, t] = m(!1), c = v(null), l = () => r(!1), f = () => {
    r(!1), t(!0);
  }, p = o || "avatar", d = !!(s && !e), u = C(o), g = A("profile-img-container", {
    loading: n,
    faceless: !d,
    md: a === "md",
    sm: a === "sm"
    /* SM */
  });
  return E(() => {
    c.current?.complete && r(!1);
  }, []), {
    alt: p,
    ref: c,
    url: s,
    onLoad: l,
    onError: f,
    containerClassName: g,
    initials: u
  };
}, x = ({
  alt: s,
  ref: o,
  url: a,
  onLoad: n,
  onError: r,
  containerClassName: e,
  initials: t
}) => /* @__PURE__ */ N("div", { className: e, children: [
  /* @__PURE__ */ i(
    "img",
    {
      ref: o,
      className: "profile-img",
      onLoad: n,
      onError: r,
      src: a,
      alt: s
    }
  ),
  /* @__PURE__ */ i("span", { className: "initials", children: t })
] }), G = h(x, j);
function C(s, o = 2) {
  return s ? s.split(" ").slice(0, o).map((a) => a && a[0].toUpperCase()).join("") : "";
}
export {
  D as A,
  L as a,
  x as b,
  G as c,
  C as i,
  j as u
};
