import React from 'react';
import { fg } from '@atlaskit/platform-feature-flags';
import { HoverCard } from '../../HoverCard';
import InlineLozenge from '../common/inline-lozenge';
import { Frame } from '../Frame';
import { IconAndTitleLayout } from '../IconAndTitleLayout';
export class InlineCardResolvedView extends React.Component {
  renderLozenge() {
    var _lozenge$style, _lozenge$style2;
    const {
      lozenge
    } = this.props;
    if (!lozenge) {
      return null;
    }
    const appearance = lozenge.appearance || 'default';
    return /*#__PURE__*/React.createElement(InlineLozenge, {
      testId: "inline-card-resolved-view-lozenge",
      appearance: appearance,
      style: {
        backgroundColor: lozenge === null || lozenge === void 0 ? void 0 : (_lozenge$style = lozenge.style) === null || _lozenge$style === void 0 ? void 0 : _lozenge$style.backgroundColor,
        color: lozenge === null || lozenge === void 0 ? void 0 : (_lozenge$style2 = lozenge.style) === null || _lozenge$style2 === void 0 ? void 0 : _lozenge$style2.color
      },
      isBold: fg('platform-component-visual-refresh') ? lozenge.isBold !== false : lozenge.isBold
    }, lozenge.text);
  }
  render() {
    const {
      id,
      title = '',
      isSelected,
      isHovered,
      onClick,
      icon,
      link,
      testId = 'inline-card-resolved-view',
      titleTextColor,
      titlePrefix,
      showHoverPreview = false,
      hoverPreviewOptions,
      actionOptions,
      truncateInline,
      type,
      hideIconLoadingSkeleton
    } = this.props;
    const inlineCardResolvedView = /*#__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
    }), this.renderLozenge());
    if (showHoverPreview && link) {
      return /*#__PURE__*/React.createElement(HoverCard, {
        id: id,
        url: link,
        actionOptions: actionOptions,
        hoverPreviewOptions: hoverPreviewOptions
      }, inlineCardResolvedView);
    }
    return inlineCardResolvedView;
  }
}