import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
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 var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
  function InlineCardResolvedView() {
    _classCallCheck(this, InlineCardResolvedView);
    return _callSuper(this, InlineCardResolvedView, arguments);
  }
  _inherits(InlineCardResolvedView, _React$Component);
  return _createClass(InlineCardResolvedView, [{
    key: "renderLozenge",
    value: function renderLozenge() {
      var _lozenge$style, _lozenge$style2;
      var lozenge = this.props.lozenge;
      if (!lozenge) {
        return null;
      }
      var appearance = lozenge.appearance || 'default';
      return /*#__PURE__*/React.createElement(InlineLozenge, {
        testId: "inline-card-resolved-view-lozenge",
        appearance: appearance,
        style: {
          backgroundColor: lozenge === null || lozenge === void 0 || (_lozenge$style = lozenge.style) === null || _lozenge$style === void 0 ? void 0 : _lozenge$style.backgroundColor,
          color: lozenge === null || lozenge === 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);
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
        id = _this$props.id,
        _this$props$title = _this$props.title,
        title = _this$props$title === void 0 ? '' : _this$props$title,
        isSelected = _this$props.isSelected,
        isHovered = _this$props.isHovered,
        onClick = _this$props.onClick,
        icon = _this$props.icon,
        link = _this$props.link,
        _this$props$testId = _this$props.testId,
        testId = _this$props$testId === void 0 ? 'inline-card-resolved-view' : _this$props$testId,
        titleTextColor = _this$props.titleTextColor,
        titlePrefix = _this$props.titlePrefix,
        _this$props$showHover = _this$props.showHoverPreview,
        showHoverPreview = _this$props$showHover === void 0 ? false : _this$props$showHover,
        hoverPreviewOptions = _this$props.hoverPreviewOptions,
        actionOptions = _this$props.actionOptions,
        truncateInline = _this$props.truncateInline,
        type = _this$props.type,
        hideIconLoadingSkeleton = _this$props.hideIconLoadingSkeleton;
      var 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;
    }
  }]);
}(React.Component);