import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import { jsx } from '@emotion/core';
import { Fragment, forwardRef } from 'react';
import _pt from 'prop-types';
import { MdRefresh } from 'react-icons/md';
import { BaseButton } from '../BaseButton/BaseButton.esm.js';
import { getButtonCss } from '../../theme/styles/button.esm.js';

function getButtonStyles(_ref) {
  var children = _ref.children,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? "L" : _ref$size,
      _ref$tone = _ref.tone,
      tone = _ref$tone === void 0 ? "BRAND" : _ref$tone,
      _ref$variant = _ref.variant,
      variant = _ref$variant === void 0 ? "PRIMARY" : _ref$variant,
      loading = _ref.loading,
      leftIcon = _ref.leftIcon,
      rightIcon = _ref.rightIcon,
      _ref$textVariant = _ref.textVariant,
      textVariant = _ref$textVariant === void 0 ? "DEFAULT" : _ref$textVariant,
      width = _ref.width;
  return {
    css: getButtonCss({
      size: size,
      variant: variant,
      tone: tone,
      loading: loading,
      leftIcon: leftIcon,
      rightIcon: rightIcon,
      textVariant: textVariant,
      width: width
    }),
    children: leftIcon || rightIcon ? jsx(Fragment, null, leftIcon, children, rightIcon) : children
  };
}
var Button = forwardRef(function (props, ref) {
  var children = props.children,
      loading = props.loading,
      _props$LoadingIcon = props.LoadingIcon,
      LoadingIcon = _props$LoadingIcon === void 0 ? MdRefresh : _props$LoadingIcon,
      size = props.size,
      tone = props.tone,
      variant = props.variant,
      leftIcon = props.leftIcon,
      rightIcon = props.rightIcon,
      textVariant = props.textVariant,
      width = props.width,
      rest = _objectWithoutProperties(props, ["children", "loading", "LoadingIcon", "size", "tone", "variant", "leftIcon", "rightIcon", "textVariant", "width"]);

  return jsx(BaseButton, _extends({}, getButtonStyles({
    children: children,
    loading: loading,
    size: size,
    tone: tone,
    variant: variant,
    leftIcon: leftIcon,
    rightIcon: rightIcon,
    textVariant: textVariant,
    width: width
  }), {
    loading: loading,
    LoadingIcon: LoadingIcon
  }, rest, {
    ref: ref
  }));
});
Button.propTypes = {
  leftIcon: _pt.node,
  rightIcon: _pt.node
};
Button.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "Button"
};

if (typeof STORYBOOK_REACT_CLASSES !== "undefined") {
  STORYBOOK_REACT_CLASSES["src/components/Button/Button.tsx"] = {
    name: "Button",
    docgenInfo: Button.__docgenInfo,
    path: "src/components/Button/Button.tsx"
  };
}

export { Button, getButtonStyles };
//# sourceMappingURL=Button.esm.js.map
