/* action-button.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("./action-button.compiled.css");
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _css = require("@atlaskit/css");
var _compiled = require("@atlaskit/primitives/compiled");
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
var _utils = require("../../../utils");
var _actionIcon = _interopRequireDefault(require("../action-icon"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var styles = {
  button: "_bfhksm61 _ca0q1b66 _u5f31b66 _n3td1b66 _19bv1b66 _1bsb1osq _1ah31i6y _irr31dpa _1di6fcek",
  content: "_11c81o8v _syazi7uo"
};
var ActionButton = function ActionButton(_ref) {
  var content = _ref.content,
    iconOption = _ref.icon,
    isDisabled = _ref.isDisabled,
    isLoading = _ref.isLoading,
    onClickCallback = _ref.onClick,
    size = _ref.size,
    spaceOption = _ref.space,
    testId = _ref.testId,
    tooltipProps = _ref.tooltipProps,
    style = _ref.style;
  var space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : (0, _utils.getPrimitivesInlineSpaceBySize)(size);
  var onClick = (0, _react.useCallback)(function () {
    if (!isDisabled && !isLoading && onClickCallback) {
      onClickCallback();
    }
  }, [isDisabled, isLoading, onClickCallback]);
  var icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(_actionIcon.default, {
    asStackItemIcon: true,
    icon: /*#__PURE__*/React.createElement(_spinner.default, {
      testId: "".concat(testId, "-loading")
    }),
    size: size
  }) : iconOption;
  return /*#__PURE__*/React.createElement(_compiled.Pressable, (0, _extends2.default)({
    xcss: (0, _css.cx)(styles.button)
  }, tooltipProps, {
    onClick: onClick,
    testId: testId
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
    ,
    style: style
  }), /*#__PURE__*/React.createElement(_compiled.Inline, {
    alignBlock: "center",
    grow: "fill",
    space: space
  }, icon, /*#__PURE__*/React.createElement(_compiled.Box, {
    xcss: (0, _css.cx)(styles.content)
  }, content)));
};
var _default = exports.default = ActionButton;