import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["className", "onClick", "disabled", "ariaLabel", "href", "target", "type", "icon", "outlined", "color"];

/* eslint-disable react/no-unused-prop-types */
import React from "react";
import PropTypes from "prop-types";
import classnames from "classnames";
import IconButton from "@material-ui/core/IconButton";
import getClasses from "./styles";
var CleverIconButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var className = props.className,
      onClick = props.onClick,
      disabled = props.disabled,
      ariaLabel = props.ariaLabel,
      href = props.href,
      target = props.target,
      type = props.type,
      icon = props.icon,
      outlined = props.outlined,
      color = props.color,
      restProps = _objectWithoutProperties(props, _excluded);

  var shade = color === "neutral" ? 400 : 500;
  var classes = getClasses({
    disabled: disabled,
    outlined: outlined,
    color: color,
    shade: shade
  });

  var getStyles = function getStyles() {
    var classNames = [];
    classNames.push(className);

    if (outlined && disabled) {
      classNames.push(classes.disabledOutlined);
    } else if (outlined) {
      classNames.push(classes.rootOutlined);
    } else if (disabled) {
      classNames.push(classes.disabled);
    } else {
      classNames.push(classes.root);
    }

    return classnames(classNames);
  };

  return /*#__PURE__*/React.createElement(IconButton, _extends({
    className: getStyles(),
    onClick: onClick,
    disabled: disabled,
    "aria-label": ariaLabel,
    href: href,
    target: target,
    ref: ref,
    type: type
  }, restProps), icon);
});
CleverIconButton.propTypes = {
  className: PropTypes.string,
  onClick: PropTypes.func,
  disabled: PropTypes.bool,
  icon: PropTypes.element.isRequired,
  href: PropTypes.string,
  target: PropTypes.string,
  active: PropTypes.bool,
  ariaLabel: PropTypes.string,
  outlined: PropTypes.bool,
  type: PropTypes.oneOf(["button", "reset", "submit"]),
  color: PropTypes.oneOf(["neutral", "blue", "danger"])
};
CleverIconButton.defaultProps = {
  className: "",
  onClick: function onClick() {},
  disabled: false,
  href: "",
  target: "",
  active: false,
  ariaLabel: "",
  outlined: true,
  type: "button",
  color: "neutral"
};
export default CleverIconButton;