import { fg } from '@atlaskit/platform-feature-flags';
import { ActionName, InternalActionName } from '../../../constants';
import { extractAISummaryAction } from './extract-ai-summary-action';
import { extractAutomationAction } from './extract-automation-action';
import { extractCopyLinkClientAction } from './extract-copy-link-action';
import { extractDownloadClientAction } from './extract-download-action';
import extractFollowAction from './extract-follow-action';
import { extractPreviewClientAction } from './extract-preview-action';
import extractRovoChatAction from './extract-rovo-chat-action';
import { extractViewRelatedLinksAction } from './extract-view-related-links-action';
export const extractFlexibleCardActions = ({
  actionOptions,
  aiSummaryConfig,
  appearance,
  fireEvent,
  id,
  origin,
  product,
  response,
  rovoConfig,
  transformUrl,
  url,
  isPreviewPanelAvailable,
  openPreviewPanel
}) => {
  const action = {
    [ActionName.CopyLinkAction]: extractCopyLinkClientAction({
      actionOptions,
      appearance,
      id,
      response
    }),
    [ActionName.DownloadAction]: extractDownloadClientAction({
      actionOptions,
      appearance,
      id,
      response
    }),
    [ActionName.FollowAction]: extractFollowAction(response, actionOptions, id),
    [ActionName.PreviewAction]: extractPreviewClientAction({
      actionOptions,
      appearance,
      fireEvent,
      id,
      origin,
      response,
      isPreviewPanelAvailable,
      openPreviewPanel,
      ...(fg('platform_smartlink_xpc_url_wrapping') ? {
        transformUrl
      } : undefined)
    }),
    [ActionName.AutomationAction]: extractAutomationAction(response),
    [InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig),
    [ActionName.RovoChatAction]: extractRovoChatAction({
      actionOptions,
      appearance,
      id,
      product,
      response,
      rovoConfig
    }),
    [InternalActionName.ViewRelatedLinksAction]: extractViewRelatedLinksAction(response)
  };
  return Object.values(action).some(value => Boolean(value)) ? action : undefined;
};