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, { 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
};
