"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InlineCardResolvedViewBase = InlineCardResolvedViewBase;
exports.InlineCardResolvedViewFunctional = void 0;
exports.InlineCardResolvedViewFunctionalWithRovoActions = InlineCardResolvedViewFunctionalWithRovoActions;
var _react = _interopRequireDefault(require("react"));
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
var _useInlineTailoredActionExperiment = _interopRequireDefault(require("../../../state/hooks/use-inline-tailored-action-experiment"));
var _HoverCard = require("../../HoverCard");
var _rovoActionsCta = require("../common/rovo-actions-cta");
var _Frame = require("../Frame");
var _IconAndTitleLayout = require("../IconAndTitleLayout");
var _renderLozenge = require("./renderLozenge");
function InlineCardResolvedViewBase(_ref) {
  var id = _ref.id,
    _ref$title = _ref.title,
    title = _ref$title === void 0 ? '' : _ref$title,
    isSelected = _ref.isSelected,
    isHovered = _ref.isHovered,
    onClick = _ref.onClick,
    onAuxClick = _ref.onAuxClick,
    onContextMenu = _ref.onContextMenu,
    icon = _ref.icon,
    link = _ref.link,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'inline-card-resolved-view' : _ref$testId,
    titleTextColor = _ref.titleTextColor,
    titlePrefix = _ref.titlePrefix,
    _ref$showHoverPreview = _ref.showHoverPreview,
    showHoverPreview = _ref$showHoverPreview === void 0 ? false : _ref$showHoverPreview,
    hoverPreviewOptions = _ref.hoverPreviewOptions,
    actionOptions = _ref.actionOptions,
    truncateInline = _ref.truncateInline,
    type = _ref.type,
    hideIconLoadingSkeleton = _ref.hideIconLoadingSkeleton,
    lozenge = _ref.lozenge;
  var frame = /*#__PURE__*/_react.default.createElement(_Frame.Frame, {
    testId: testId,
    link: link,
    isSelected: isSelected,
    isHovered: isHovered,
    onClick: onClick,
    onAuxClick: onAuxClick,
    onContextMenu: onContextMenu,
    truncateInline: truncateInline
  }, /*#__PURE__*/_react.default.createElement(_IconAndTitleLayout.IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), (0, _renderLozenge.renderLozenge)(lozenge));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
function InlineCardResolvedViewFunctionalWithRovoActions(_ref2) {
  var id = _ref2.id,
    _ref2$title = _ref2.title,
    title = _ref2$title === void 0 ? '' : _ref2$title,
    isSelected = _ref2.isSelected,
    isHovered = _ref2.isHovered,
    onClick = _ref2.onClick,
    onAuxClick = _ref2.onAuxClick,
    onContextMenu = _ref2.onContextMenu,
    icon = _ref2.icon,
    link = _ref2.link,
    _ref2$testId = _ref2.testId,
    testId = _ref2$testId === void 0 ? 'inline-card-resolved-view' : _ref2$testId,
    titleTextColor = _ref2.titleTextColor,
    titlePrefix = _ref2.titlePrefix,
    _ref2$showHoverPrevie = _ref2.showHoverPreview,
    showHoverPreview = _ref2$showHoverPrevie === void 0 ? false : _ref2$showHoverPrevie,
    hoverPreviewOptions = _ref2.hoverPreviewOptions,
    actionOptions = _ref2.actionOptions,
    truncateInline = _ref2.truncateInline,
    type = _ref2.type,
    hideIconLoadingSkeleton = _ref2.hideIconLoadingSkeleton,
    lozenge = _ref2.lozenge;
  var _useInlineTailoredAct = (0, _useInlineTailoredActionExperiment.default)(link, showHoverPreview, actionOptions),
    isInlineTailoredRovoActionEnabled = _useInlineTailoredAct.isEnabled;

  // TODO https://hello.jira.atlassian.cloud/browse/NAVX-4436: fire analytics with cohort
  var frame = /*#__PURE__*/_react.default.createElement(_Frame.Frame, {
    testId: testId,
    link: link,
    isSelected: isSelected,
    isHovered: isHovered,
    onClick: onClick,
    onAuxClick: onAuxClick,
    onContextMenu: onContextMenu,
    truncateInline: truncateInline
  }, /*#__PURE__*/_react.default.createElement(_IconAndTitleLayout.IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), (0, _renderLozenge.renderLozenge)(lozenge), isInlineTailoredRovoActionEnabled && /*#__PURE__*/_react.default.createElement(_rovoActionsCta.InlineRovoActionButton, {
    testId: "".concat(testId, "-rovo-actions-cta"),
    url: link,
    actionOptions: actionOptions
  }));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
var InlineCardResolvedViewFunctional = exports.InlineCardResolvedViewFunctional = (0, _platformFeatureFlagsReact.componentWithFG)('platform_sl_3p_auth_inline_tailored_cta_killswitch', InlineCardResolvedViewFunctionalWithRovoActions, InlineCardResolvedViewBase);