var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
function _extends() {
  _extends = Object.assign ? Object.assign.bind() : function(target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];
      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }
    return target;
  };
  return _extends.apply(this, arguments);
}
import React, { useContext, useMemo } from "react";
import classnames from "classnames";
import { addUnit } from "../utils";
import Badge from "../badge";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
function isImage(name) {
  return name ? name.indexOf("/") !== -1 : false;
}
const Icon = (props) => {
  const {
    iconPrefix
  } = useContext(ConfigProviderContext);
  const {
    dot,
    tag,
    name,
    className,
    onClick,
    onTouchStart
  } = props;
  const imageIcon = isImage(name);
  const classPrefix = useMemo(() => props.classPrefix || iconPrefix, [props.classPrefix, iconPrefix]);
  return /* @__PURE__ */ React.createElement(Badge, _extends({
    dot,
    tag,
    className: classnames(className, classPrefix, imageIcon ? "" : `${classPrefix}-${name}`),
    style: __spreadValues({
      color: props.color,
      fontSize: addUnit(props.size)
    }, props.style),
    onClick,
    onTouchStart
  }, props.badge), props == null ? void 0 : props.children, imageIcon && /* @__PURE__ */ React.createElement("img", {
    className: classnames("rc-icon__image"),
    src: name,
    alt: name
  }));
};
Icon.defaultProps = {
  tag: "i"
};
var stdin_default = Icon;
export {
  stdin_default as default
};
