"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.IconButton = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _BaseButton = _interopRequireDefault(require("../BaseButton"));
var _excluded = ["size", "delayLoadingSpinnerAnimation", "children", "onClick"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var SIZE = {
  s: 7,
  m: 8,
  l: 10
};
var StyledIconButton = (0, _styledComponents.default)(_BaseButton.default).withConfig({
  displayName: "IconButton__StyledIconButton",
  componentId: "sc-1ydp4ea-0"
})(["background-color:", ";border-radius:50%;box-sizing:border-box;color:", ";display:inline-flex;justify-content:center;align-items:center;height:", "px;width:", "px;border:none;padding:0;min-height:0;", ""], function (p) {
  return p.theme.color.pillButtonBackgroundTertiary;
}, function (p) {
  return p.theme.color.pillButtonTertiary;
}, function (p) {
  return p.theme.spacing.unit(SIZE[p.size || 'm']);
}, function (p) {
  return p.theme.spacing.unit(SIZE[p.size || 'm']);
}, function (p) {
  return p.disabled ? "color: ".concat(p.theme.color.buttonTextDisabled, ";") : "\n    &:hover {\n      background-color: ".concat(p.theme.color.pillButtonBackgroundTertiary, ";\n      color: ").concat(p.theme.color.pillButtonHoverSecondary, ";\n    }\n    &:active {\n      background-color: ").concat(p.theme.color.pillButtonBackgroundTertiary, ";\n      color: ").concat(p.theme.color.pillButtonActiveSecondary, ";\n    }\n  ");
});
var IconButton = exports.IconButton = _react.default.forwardRef(function (props, ref) {
  var _props$size = props.size,
    size = _props$size === void 0 ? 'm' : _props$size,
    _props$delayLoadingSp = props.delayLoadingSpinnerAnimation,
    delayLoadingSpinnerAnimation = _props$delayLoadingSp === void 0 ? true : _props$delayLoadingSp,
    children = props.children,
    onClick = props.onClick,
    rest = _objectWithoutProperties(props, _excluded);
  var trackClick = function trackClick(e) {
    if (onClick) onClick(e);
  };
  return _react.default.createElement(StyledIconButton, _extends({}, rest, {
    ref: ref,
    size: size,
    type: "button",
    onClick: trackClick,
    variant: "secondary",
    delayLoadingSpinnerAnimation: delayLoadingSpinnerAnimation
  }), children);
});
IconButton.displayName = 'Button.Icon';