"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ButtonBase = ButtonBase;
exports.Button = Button;
exports.default = void 0;

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));

var _react = _interopRequireDefault(require("react"));

var _getValue = _interopRequireDefault(require("get-value"));

var _Button = _interopRequireDefault(require("@material-ui/core/Button"));

var _styles = require("@material-ui/core/styles");

var _core = require("@material-ui/core");

var useStyles = function useStyles(props) {
  return (0, _styles.makeStyles)(function (theme) {
    return {
      base: {
        textTransform: 'none',
        borderRadius: '1000px'
      },
      contained: {},
      outlined: {
        borderColor: getMainColor(props, theme)
      },
      text: {},
      info: {
        backgroundColor: (0, _getValue.default)(theme.palette, props.infoBackground) || getMainColor(props, theme),
        pointerEvents: 'none',
        "&:hover": {
          backgroundColor: (0, _getValue.default)(theme.palette, props.infoBackground) || getMainColor(props, theme)
        }
      }
    };
  });
};

var getMainColor = function getMainColor(props, theme) {
  return theme.palette[props.color] ? theme.palette[props.color].main : theme.palette.primary.main;
};

function ButtonBase(_ref) {
  var children = _ref.children,
      props = (0, _objectWithoutProperties2.default)(_ref, ["children"]);
  var classes = useStyles(props)();
  var classNames = "".concat(classes.base, " ").concat(props.className);
  return /*#__PURE__*/_react.default.createElement(_Button.default, Object.assign({}, props, {
    className: classNames,
    disableelevation: true,
    centerRipple: true,
    disableFocusRipple: true
  }), children);
}

function Button(_ref2) {
  var children = _ref2.children,
      props = (0, _objectWithoutProperties2.default)(_ref2, ["children"]);
  var classes = useStyles(props)();
  var classNames = "".concat(classes[props.variant], " ").concat(props.info ? classes.info : '', " ").concat(props.className);
  if (props.info) props.onClick = function () {}; // override onClick

  return /*#__PURE__*/_react.default.createElement(ButtonBase, Object.assign({}, props, {
    className: classNames
  }), children);
}

Button.defaultProps = {
  color: 'primary',
  variant: 'contained',
  size: 'medium',
  info: false,
  disabled: false,
  onClick: function onClick() {}
};
var _default = Button;
exports.default = _default;