import _extends from "@babel/runtime/helpers/esm/extends";
import React, { memo } from 'react';
import Button from './button';
import { useTheme } from '@helpdice/theme';
var CompactButton = function CompactButton(_ref) {
  var _color = _ref.color,
    _ref$to = _ref.to,
    to = _ref$to === void 0 ? '/' : _ref$to,
    children = _ref.children,
    iconRight = _ref.iconRight,
    icon = _ref.icon,
    _ref$scale = _ref.scale,
    scale = _ref$scale === void 0 ? 2 / 3 : _ref$scale,
    type = _ref.type,
    style = _ref.style,
    a = _ref.a,
    _ref$target = _ref.target,
    target = _ref$target === void 0 ? "_self" : _ref$target,
    onClick = _ref.onClick;
  var theme = useTheme();
  if (a) {
    return /*#__PURE__*/React.createElement(Button, {
      icon: icon,
      style: _extends({}, style, {
        backgroundColor: theme.palette.background
      }),
      type: type,
      onClick: function onClick() {
        return window.open(to, target);
      },
      auto: true,
      scale: scale,
      px: 0.6,
      iconRight: iconRight
    }, children);
  }
  return /*#__PURE__*/React.createElement(Button, {
    icon: icon,
    style: _extends({}, style, {
      backgroundColor: theme.palette.background
    }),
    type: type,
    onClick: onClick,
    auto: true,
    scale: scale,
    px: 0.6,
    iconRight: iconRight
  }, children);
};
export default /*#__PURE__*/memo(CompactButton);