import React from 'react';
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
import useInlineTailoredActionExperiment from '../../../state/hooks/use-inline-tailored-action-experiment';
import { HoverCard } from '../../HoverCard';
import { InlineRovoActionButton } from '../common/rovo-actions-cta';
import { Frame } from '../Frame';
import { IconAndTitleLayout } from '../IconAndTitleLayout';
import { renderLozenge } from './renderLozenge';
export function InlineCardResolvedViewBase({
  id,
  title = '',
  isSelected,
  isHovered,
  onClick,
  onAuxClick,
  onContextMenu,
  icon,
  link,
  testId = 'inline-card-resolved-view',
  titleTextColor,
  titlePrefix,
  showHoverPreview = false,
  hoverPreviewOptions,
  actionOptions,
  truncateInline,
  type,
  hideIconLoadingSkeleton,
  lozenge
}) {
  const frame = /*#__PURE__*/React.createElement(Frame, {
    testId: testId,
    link: link,
    isSelected: isSelected,
    isHovered: isHovered,
    onClick: onClick,
    onAuxClick: onAuxClick,
    onContextMenu: onContextMenu,
    truncateInline: truncateInline
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), renderLozenge(lozenge));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/React.createElement(HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
export function InlineCardResolvedViewFunctionalWithRovoActions({
  id,
  title = '',
  isSelected,
  isHovered,
  onClick,
  onAuxClick,
  onContextMenu,
  icon,
  link,
  testId = 'inline-card-resolved-view',
  titleTextColor,
  titlePrefix,
  showHoverPreview = false,
  hoverPreviewOptions,
  actionOptions,
  truncateInline,
  type,
  hideIconLoadingSkeleton,
  lozenge
}) {
  const {
    isEnabled: isInlineTailoredRovoActionEnabled
  } = useInlineTailoredActionExperiment(link, showHoverPreview, actionOptions);

  // TODO https://hello.jira.atlassian.cloud/browse/NAVX-4436: fire analytics with cohort
  const frame = /*#__PURE__*/React.createElement(Frame, {
    testId: testId,
    link: link,
    isSelected: isSelected,
    isHovered: isHovered,
    onClick: onClick,
    onAuxClick: onAuxClick,
    onContextMenu: onContextMenu,
    truncateInline: truncateInline
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), renderLozenge(lozenge), isInlineTailoredRovoActionEnabled && /*#__PURE__*/React.createElement(InlineRovoActionButton, {
    testId: `${testId}-rovo-actions-cta`,
    url: link,
    actionOptions: actionOptions
  }));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/React.createElement(HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
export const InlineCardResolvedViewFunctional = componentWithFG('platform_sl_3p_auth_inline_tailored_cta_killswitch', InlineCardResolvedViewFunctionalWithRovoActions, InlineCardResolvedViewBase);