"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.extractFlexibleCardActions = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _constants = require("../../../constants");
var _extractAiSummaryAction = require("./extract-ai-summary-action");
var _extractAutomationAction = require("./extract-automation-action");
var _extractCopyLinkAction = require("./extract-copy-link-action");
var _extractDownloadAction = require("./extract-download-action");
var _extractFollowAction = _interopRequireDefault(require("./extract-follow-action"));
var _extractPreviewAction = require("./extract-preview-action");
var _extractRovoChatAction = _interopRequireDefault(require("./extract-rovo-chat-action"));
var _extractViewRelatedLinksAction = require("./extract-view-related-links-action");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var extractFlexibleCardActions = exports.extractFlexibleCardActions = function extractFlexibleCardActions(_ref) {
  var actionOptions = _ref.actionOptions,
    aiSummaryConfig = _ref.aiSummaryConfig,
    appearance = _ref.appearance,
    fireEvent = _ref.fireEvent,
    id = _ref.id,
    origin = _ref.origin,
    product = _ref.product,
    response = _ref.response,
    rovoConfig = _ref.rovoConfig,
    url = _ref.url,
    isPreviewPanelAvailable = _ref.isPreviewPanelAvailable,
    openPreviewPanel = _ref.openPreviewPanel;
  var action = _objectSpread(_objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.ActionName.CopyLinkAction, (0, _extractCopyLinkAction.extractCopyLinkClientAction)({
    actionOptions: actionOptions,
    appearance: appearance,
    id: id,
    response: response
  })), _constants.ActionName.DownloadAction, (0, _extractDownloadAction.extractDownloadClientAction)({
    actionOptions: actionOptions,
    appearance: appearance,
    id: id,
    response: response
  })), _constants.ActionName.FollowAction, (0, _extractFollowAction.default)(response, actionOptions, id)), _constants.ActionName.PreviewAction, (0, _extractPreviewAction.extractPreviewClientAction)({
    actionOptions: actionOptions,
    appearance: appearance,
    fireEvent: fireEvent,
    id: id,
    origin: origin,
    response: response,
    isPreviewPanelAvailable: isPreviewPanelAvailable,
    openPreviewPanel: openPreviewPanel
  })), _constants.ActionName.AutomationAction, (0, _extractAutomationAction.extractAutomationAction)(response)), _constants.InternalActionName.AISummaryAction, (0, _extractAiSummaryAction.extractAISummaryAction)(response, url, actionOptions, aiSummaryConfig)), (0, _platformFeatureFlags.fg)('platform_sl_3p_auth_rovo_action_kill_switch') ? (0, _defineProperty2.default)({}, _constants.InternalActionName.RovoChatAction, (0, _extractRovoChatAction.default)({
    actionOptions: actionOptions,
    appearance: appearance,
    id: id,
    product: product,
    response: response,
    rovoConfig: rovoConfig
  })) : undefined), {}, (0, _defineProperty2.default)({}, _constants.InternalActionName.ViewRelatedLinksAction, (0, _extractViewRelatedLinksAction.extractViewRelatedLinksAction)(response)));
  return Object.values(action).some(function (value) {
    return Boolean(value);
  }) ? action : undefined;
};