/* index.tsx generated by @compiled/babel-plugin v0.39.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';
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';
const titleBlockStyles = null;
const mainTextStyles = null;
const connectButtonStyles = null;
const basePreviewStyles = null;
const HoverCardForbiddenView = ({
  flexibleCardProps,
  testId = 'hover-card-forbidden-view'
}) => {
  var _cardState$details, _extractSmartLinkProv, _extractSmartLinkProv2, _extractRequestAccess;
  const {
    createAnalyticsEvent
  } = useAnalyticsEvents();
  const {
    cardState,
    url
  } = flexibleCardProps;
  const meta = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.meta;
  const product = (_extractSmartLinkProv = (_extractSmartLinkProv2 = extractSmartLinkProvider(cardState.details)) === null || _extractSmartLinkProv2 === void 0 ? void 0 : _extractSmartLinkProv2.text) !== null && _extractSmartLinkProv !== void 0 ? _extractSmartLinkProv : '';
  const hostname = /*#__PURE__*/React.createElement("b", null, extractHostname(url));
  const {
    action,
    descriptiveMessageKey,
    titleMessageKey,
    buttonDisabled
  } = (_extractRequestAccess = extractRequestAccessContextImproved({
    jsonLd: meta,
    url,
    product,
    createAnalyticsEvent
  })) !== null && _extractRequestAccess !== void 0 ? _extractRequestAccess : {};
  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: `${testId}-title`,
    className: ax(["_1bah1h6o _k48p1pd9 _19pku2gc"])
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[titleMessageKey], {
    values: {
      product
    }
  }))), /*#__PURE__*/React.createElement(CustomBlock, {
    testId: `${testId}-content`,
    className: ax(["_11c8wadc _1e0c1nu9 _1bah1h6o _19pkze3t _y3gn1h6o"])
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[descriptiveMessageKey], {
    values: {
      product,
      hostname
    }
  }))), action && /*#__PURE__*/React.createElement(CustomBlock, {
    className: ax(["_1bah1h6o _19pku2gc"])
  }, /*#__PURE__*/React.createElement(Button, {
    testId: `${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;