function _extends() {
  return _extends = Object.assign ? Object.assign.bind() : function(n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var r in t)
        ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }, _extends.apply(null, arguments);
}
import React, { isValidElement, useContext } from "react";
import classnames from "classnames";
import { Icon } from "../icon";
import Badge from "../badge";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
const ActionBarIcon = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("action-bar-icon", prefixCls);
  const renderIcon = () => {
    const {
      badge,
      icon,
      color,
      iconClass,
      iconPrefix
    } = props;
    if (typeof icon === "string") {
      return /* @__PURE__ */ React.createElement(Icon, {
        tag: "div",
        name: icon,
        badge,
        color,
        className: classnames(bem("icon"), iconClass),
        classPrefix: iconPrefix
      });
    }
    if (/* @__PURE__ */ isValidElement(icon)) {
      return /* @__PURE__ */ React.createElement(Badge, _extends({}, badge, {
        className: classnames(bem("icon"))
      }), icon);
    }
    return null;
  };
  const handleClick = (e) => {
    var _a;
    (_a = props.onClick) == null ? void 0 : _a.call(props, e);
  };
  return /* @__PURE__ */ React.createElement("div", {
    role: "button",
    className: classnames(props.className, bem()),
    style: props.style,
    tabIndex: 0,
    onClick: handleClick
  }, renderIcon(), props.children || props.text);
};
var stdin_default = ActionBarIcon;
export {
  stdin_default as default
};
