"use strict";var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;exports.__esModule = true;exports.useButtonArrow = useButtonArrow;var _react = _interopRequireWildcard(require("react"));

var _Emotion = require("../../lib/theming/Emotion");
var _ThemeContext = require("../../lib/theming/ThemeContext");


var _ArrowRightIcon = require("./ArrowRightIcon");
var _ArrowLeftIcon = require("./ArrowLeftIcon");

var _Button = require("./Button.styles");








var ButtonArrow = function ButtonArrow(_ref) {var arrow = _ref.arrow,size = _ref.size;
  var theme = (0, _react.useContext)(_ThemeContext.ThemeContext);

  var getArrowIconRootClassName = function getArrowIconRootClassName() {var _cx;
    return (0, _Emotion.cx)(_Button.styles.arrowIconRoot(), _Button.globalClasses.arrow, (_cx = {}, _cx[
    _Button.styles.arrowIconRootSmall(theme)] = size === 'small', _cx[
    _Button.styles.arrowIconRootMedium(theme)] = size === 'medium', _cx[
    _Button.styles.arrowIconRootLarge(theme)] = size === 'large', _cx[
    _Button.styles.arrowIconLeft()] = arrow === 'left', _cx)
    );
  };

  var arrowIcons = {
    right: _ArrowRightIcon.ArrowRightIcon,
    left: _ArrowLeftIcon.ArrowLeftIcon
  };
  var side = arrow === 'left' ? 'left' : 'right';
  var ArrowIcon = arrowIcons[side];
  var arrowNode = /*#__PURE__*/
  _react.default.createElement("div", { className: getArrowIconRootClassName() }, /*#__PURE__*/
  _react.default.createElement(ArrowIcon, { size: size })
  );


  return arrowNode;
};

function useButtonArrow(props, theme) {
  var arrow = props.arrow,size = props.size,use = props.use;

  var canRender = use !== 'link' && (arrow === true || arrow === 'left');

  var rootClassName = canRender ?
  (0, _Emotion.cx)(
    arrow === true && size === 'small' && _Button.styles.withArrowIconRightSmall(theme),
    arrow === true && size === 'medium' && _Button.styles.withArrowIconRightMedium(theme),
    arrow === true && size === 'large' && _Button.styles.withArrowIconRightLarge(theme),
    arrow === 'left' && size === 'small' && _Button.styles.withArrowIconLeftSmall(theme),
    arrow === 'left' && size === 'medium' && _Button.styles.withArrowIconLeftMedium(theme),
    arrow === 'left' && size === 'large' && _Button.styles.withArrowIconLeftLarge(theme)
  ) :
  '';

  var arrowNode = canRender ? /*#__PURE__*/_react.default.createElement(ButtonArrow, props) : null;

  return [rootClassName, arrowNode];
}