/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./index.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { FormattedMessage } from 'react-intl-next';
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
import Button from '@atlaskit/button/new';
import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
import { extractRequestAccessContextImproved } from '../../../../../extractors/common/context/extractAccessContext';
import extractHostname from '../../../../../extractors/common/hostname/extractHostname';
import { messages } from '../../../../../messages';
import FlexibleCard from '../../../../FlexibleCard';
import { CustomBlock, PreviewBlock } from '../../../../FlexibleCard/components/blocks';
var titleBlockStyles = null;
var mainTextStyles = null;
var connectButtonStyles = null;
var basePreviewStyles = null;
var HoverCardForbiddenView = function HoverCardForbiddenView(_ref) {
  var _cardState$details, _extractSmartLinkProv, _extractSmartLinkProv2, _extractRequestAccess;
  var flexibleCardProps = _ref.flexibleCardProps,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'hover-card-forbidden-view' : _ref$testId;
  var _useAnalyticsEvents = useAnalyticsEvents(),
    createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
  var cardState = flexibleCardProps.cardState,
    url = flexibleCardProps.url;
  var meta = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.meta;
  var product = (_extractSmartLinkProv = (_extractSmartLinkProv2 = extractSmartLinkProvider(cardState.details)) === null || _extractSmartLinkProv2 === void 0 ? void 0 : _extractSmartLinkProv2.text) !== null && _extractSmartLinkProv !== void 0 ? _extractSmartLinkProv : '';
  var hostname = /*#__PURE__*/React.createElement("b", null, extractHostname(url));
  var _ref2 = (_extractRequestAccess = extractRequestAccessContextImproved({
      jsonLd: meta,
      url: url,
      product: product,
      createAnalyticsEvent: createAnalyticsEvent
    })) !== null && _extractRequestAccess !== void 0 ? _extractRequestAccess : {},
    action = _ref2.action,
    descriptiveMessageKey = _ref2.descriptiveMessageKey,
    titleMessageKey = _ref2.titleMessageKey,
    buttonDisabled = _ref2.buttonDisabled;
  if (!titleMessageKey || !descriptiveMessageKey) {
    return null;
  }
  return /*#__PURE__*/React.createElement(FlexibleCard, _extends({}, flexibleCardProps, {
    testId: testId
  }), /*#__PURE__*/React.createElement(PreviewBlock, {
    ignoreContainerPadding: true,
    testId: testId,
    className: ax(["_13li1mok _qrwq1mok _otyru2gc"])
  }), /*#__PURE__*/React.createElement(CustomBlock, {
    testId: "".concat(testId, "-title"),
    className: ax(["_1bah1h6o _k48p1pd9 _19pku2gc"])
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[titleMessageKey], {
    values: {
      product: product
    }
  }))), /*#__PURE__*/React.createElement(CustomBlock, {
    testId: "".concat(testId, "-content"),
    className: ax(["_11c8dcr7 _1e0c1nu9 _1bah1h6o _19pkze3t _y3gn1h6o"])
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[descriptiveMessageKey], {
    values: {
      product: product,
      hostname: hostname
    }
  }))), action && /*#__PURE__*/React.createElement(CustomBlock, {
    className: ax(["_1bah1h6o _19pku2gc"])
  }, /*#__PURE__*/React.createElement(Button, {
    testId: "".concat(testId, "-button"),
    onClick: action === null || action === void 0 ? void 0 : action.promise,
    appearance: "primary",
    isDisabled: buttonDisabled
  }, action === null || action === void 0 ? void 0 : action.text)));
};
export default HoverCardForbiddenView;