import React from 'react';
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
import useInlineActionNudgeExperiment from '../../../state/hooks/use-inline-action-nudge-experiment';
import { HoverCard } from '../../HoverCard';
import { RovoActionsCta } 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,
  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,
    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,
  icon,
  link,
  testId = 'inline-card-resolved-view',
  titleTextColor,
  titlePrefix,
  showHoverPreview = false,
  hoverPreviewOptions,
  actionOptions,
  truncateInline,
  type,
  hideIconLoadingSkeleton,
  lozenge
}) {
  const {
    isEnabled
  } = useInlineActionNudgeExperiment(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,
    truncateInline: truncateInline
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), renderLozenge(lozenge), isEnabled && /*#__PURE__*/React.createElement(RovoActionsCta, {
    testId: `${testId}-rovo-actions-cta`
  }));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/React.createElement(HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
export const InlineCardResolvedViewFunctional = componentWithFG('rovogrowth-640-inline-action-nudge-fg', InlineCardResolvedViewFunctionalWithRovoActions, InlineCardResolvedViewBase);