/* action-button.tsx generated by @compiled/babel-plugin v0.39.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 _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _compiled = require("@atlaskit/primitives/compiled");
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
var _constants = require("../../../../../../constants");
var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
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",
  pillButton: "_2rko1qi0 _189ee4h9 _1dqonqa1 _1h6d1l7x _kqswh2mm _bfhksm61 _u5f3u2gc _19bvv77o _1bsb1osq _1ah31i6y _irr31dpa _1di6fcek",
  content: "_11c8wadc _syazi7uo",
  pillContent: "_11c8wadc _syazi7uo _o5721q9c",
  spinner: "_1bsb1tcg _4t3i1tcg _1e0c116y _4cvr1h6o _1bah1h6o"
};
var pillIconWrapperStyles = null;
var ActionButton = function ActionButton(_ref) {
  var _flexibleUiContext$ac;
  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,
    ariaLabel = _ref.ariaLabel;
  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 is3pExperimentEnabled =
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
  (0, _platformFeatureFlags.fg)('platform_sl_3p_auth_rovo_action_kill_switch') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_sl_3p_auth_rovo_action', 'isEnabled', true) ||
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
  (0, _platformFeatureFlags.fg)('rovogrowth-640-inline-action-nudge-fg') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('rovogrowth-640-inline-action-nudge-exp', 'isEnabled', true);

  /**
   * NOTE: We only apply the pill variant when there's text label
   * (textual `content`). Icon-only stack-item buttons (e.g. the link/expand
   * icons in the hover card footer) are also rendered with `as="stack-item"`
   * but pass `content=""` and should keep their original borderless styling.
   */
  var hasTextualContent = typeof content === 'string' ? content.trim().length > 0 : Boolean(content);
  var flexibleUiContext = (0, _flexibleUiContext.useFlexibleUiContext)();
  var isInRovoActionStack = !!(flexibleUiContext !== null && flexibleUiContext !== void 0 && (_flexibleUiContext$ac = flexibleUiContext.actions) !== null && _flexibleUiContext$ac !== void 0 && _flexibleUiContext$ac[_constants.ActionName.RovoChatAction]);
  var isInlineActionNudgeExperiment = hasTextualContent && isInRovoActionStack && (0, _platformFeatureFlags.fg)('rovogrowth-640-inline-action-nudge-fg') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('rovogrowth-640-inline-action-nudge-exp', 'isEnabled', true);
  var icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(_actionIcon.default, {
    icon: is3pExperimentEnabled ? /*#__PURE__*/React.createElement(_compiled.Box, {
      xcss: styles.spinner
    }, /*#__PURE__*/React.createElement(_spinner.default, {
      size: 16,
      testId: "".concat(testId, "-loading")
    })) : /*#__PURE__*/React.createElement(_spinner.default, {
      testId: "".concat(testId, "-loading")
    })
  }) : iconOption;
  return /*#__PURE__*/React.createElement(_compiled.Pressable, (0, _extends2.default)({
    xcss: (0, _css.cx)(isInlineActionNudgeExperiment ? styles.pillButton : styles.button)
  }, tooltipProps, {
    onClick: onClick,
    testId: testId
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
    ,
    style: style
  }, (0, _platformFeatureFlags.fg)('platform_sl_3p_auth_rovo_action_kill_switch') || (0, _expValEqualsNoExposure.expValEqualsNoExposure)('rovogrowth-640-inline-action-nudge-exp', 'isEnabled', true) ? {
    'aria-label': ariaLabel
  } : {}), /*#__PURE__*/React.createElement(_compiled.Inline, {
    alignBlock: "center",
    grow: isInlineActionNudgeExperiment ? 'hug' : 'fill',
    space: isInlineActionNudgeExperiment ? 'space.050' : space
  }, isInlineActionNudgeExperiment ? /*#__PURE__*/React.createElement("span", {
    className: (0, _runtime.ax)(["_1e0c116y _4cvr1h6o _1bah1h6o _1bsb1tcg _4t3i1tcg _1o9zidpf"])
  }, icon) : icon, /*#__PURE__*/React.createElement(_compiled.Box, {
    xcss: (0, _css.cx)(isInlineActionNudgeExperiment ? styles.pillContent : styles.content)
  }, content)));
};
var _default = exports.default = ActionButton;