import { jsx as n } from "react/jsx-runtime";
import { MINTLIFY_ICONS_CDN_URL as C } from "../../constants/index.js";
import { Classes as N } from "../../constants/selectors.js";
import { cn as i } from "../../utils/cn.js";
import { getIconUrl as y, ICON_TYPES as M, isBrandsIcon as $ } from "../../utils/icon-utils.js";
import { isAbsoluteUrl as v } from "../../utils/is-absolute-url.js";
const x = ({
  icon: t,
  iconType: a,
  color: e,
  colorLight: g,
  colorDark: p,
  size: k,
  className: f,
  iconLibrary: d = "fontawesome",
  basePath: c,
  pageType: h,
  overrideColor: l,
  overrideSize: I
}) => {
  const b = {
    ...!I && { width: k || 16, height: k || 16 },
    display: "inline-block",
    verticalAlign: "middle"
  }, s = g && p, r = s ? {
    ...b,
    "--color-light": g,
    "--color-dark": p
  } : b, o = i(
    N.Icon,
    "inline",
    !(e || s || l) && "bg-primary dark:bg-primary-light",
    s && "bg-(--color-light) dark:bg-(--color-dark)",
    f
  ), W = h === "pdf", m = y(t.toLowerCase(), a, d);
  if (a && !M.includes(a))
    return console.log(
      `Invalid iconType ${a} expected a string equal to one of: brands, duotone, light, regular, sharp-solid, solid, thin`
    ), null;
  if (typeof t == "string" && (v(t) || t.startsWith("/"))) {
    if (t.startsWith(C) || t.startsWith("https://mintlify.b-cdn.net"))
      return /* @__PURE__ */ n(
        "svg",
        {
          className: o,
          "data-component-part": "icon-svg",
          style: {
            WebkitMaskImage: `url(${t})`,
            WebkitMaskRepeat: "no-repeat",
            WebkitMaskPosition: "center",
            maskImage: `url(${t})`,
            maskRepeat: "no-repeat",
            maskPosition: "center",
            maskSize: "100%",
            ...!s && { backgroundColor: "currentColor" },
            ...r
          }
        }
      );
    let u = t;
    return t.startsWith("/") && c && (u = `${c}${t}`), // biome-ignore lint/correctness/useImageSize: TODO
    /* @__PURE__ */ n(
      "img",
      {
        alt: t,
        className: i(o, "bg-transparent dark:bg-transparent"),
        "data-component-part": "icon-image",
        src: u,
        style: r
      }
    );
  }
  return W ? (
    // biome-ignore lint/correctness/useImageSize: TODO
    /* @__PURE__ */ n(
      "img",
      {
        alt: t,
        className: i(
          o,
          !(e || l || s) && "bg-stone-800 dark:bg-stone-100"
        ),
        "data-component-part": "icon-image",
        src: m,
        style: {
          backgroundColor: "transparent",
          ...r
        }
      }
    )
  ) : /* @__PURE__ */ n(
    "svg",
    {
      className: i(
        o,
        !(e || l || s) && "bg-stone-800 dark:bg-stone-100"
      ),
      "data-component-part": "icon-svg",
      style: {
        WebkitMaskImage: `url(${m})`,
        WebkitMaskRepeat: "no-repeat",
        WebkitMaskPosition: "center",
        maskImage: `url(${m})`,
        maskRepeat: "no-repeat",
        maskPosition: "center",
        maskSize: d === "lucide" && !$(t) ? "100%" : void 0,
        backgroundColor: e,
        ...r
      }
    }
  );
};
export {
  x as Icon
};
