/* RovoUnauthorisedView.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./RovoUnauthorisedView.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { useCallback, useMemo } from 'react';
import { FormattedMessage } from 'react-intl-next';
import Button from '@atlaskit/button/new';
import { IconTile } from '@atlaskit/icon';
import AiSparkleIcon from '@atlaskit/icon/core/ai-sparkle';
import AppSwitcherIcon from '@atlaskit/icon/core/app-switcher';
import GlobeIcon from '@atlaskit/icon/core/globe';
import SearchIcon from '@atlaskit/icon/core/search';
import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
import { Box, Inline, Stack, Text } from '@atlaskit/primitives/compiled';
import { useAnalyticsEvents } from '../../../../../common/analytics/generated/use-analytics-events';
import { CardDisplay } from '../../../../../constants';
import { messages } from '../../../../../messages';
import { useSmartCardActions } from '../../../../../state/actions';
var ROVO_FEATURES = [{
  icon: GlobeIcon,
  appearance: 'blue',
  titleMessage: messages.rovo_unauthorised_feature_document_summaries_title,
  descMessage: messages.rovo_unauthorised_feature_document_summaries_desc,
  testIdSuffix: 'document-summaries'
}, {
  icon: SearchIcon,
  appearance: 'purple',
  titleMessage: messages.rovo_unauthorised_feature_related_content_title,
  descMessage: messages.rovo_unauthorised_feature_related_content_desc,
  testIdSuffix: 'related-content'
}, {
  icon: AiSparkleIcon,
  appearance: 'orange',
  titleMessage: messages.rovo_unauthorised_feature_smart_suggestions_title,
  descMessage: messages.rovo_unauthorised_feature_smart_suggestions_desc,
  testIdSuffix: 'smart-suggestions'
}, {
  icon: AppSwitcherIcon,
  appearance: 'teal',
  titleMessage: messages.rovo_unauthorised_feature_cross_reference_title,
  descMessage: messages.rovo_unauthorised_feature_cross_reference_desc,
  testIdSuffix: 'cross-reference'
}];
var layoutStyles = {
  header: "_bfhkomb0 _syaz15cr _ca0qutpp _u5f3pxbi _n3tdutpp _19bvpxbi _13li1mok _qrwq1mok",
  body: "_ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi",
  footer: "_19pkpxbi _ca0qutpp",
  footerActions: "_zulputpp _1e0c1txw _4cvr1h6o _1bahesu3 _1n261g80"
};
var RovoUnauthorisedView = function RovoUnauthorisedView(_ref) {
  var _ref$id = _ref.id,
    id = _ref$id === void 0 ? '' : _ref$id,
    flexibleCardProps = _ref.flexibleCardProps,
    onDismiss = _ref.onDismiss,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'hover-card-rovo-unauthorised-view' : _ref$testId,
    url = _ref.url;
  var providerName = useMemo(function () {
    var _extractSmartLinkProv;
    return (_extractSmartLinkProv = extractSmartLinkProvider(flexibleCardProps.cardState.details)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text;
  }, [flexibleCardProps.cardState.details]);
  var _useSmartCardActions = useSmartCardActions(id, url),
    authorize = _useSmartCardActions.authorize;
  var _useAnalyticsEvents = useAnalyticsEvents(),
    fireEvent = _useAnalyticsEvents.fireEvent;
  var handleAuthorize = useCallback(function () {
    if (authorize) {
      fireEvent('track.applicationAccount.authStarted', {});
      authorize(CardDisplay.HoverCardPreview);
    }
  }, [authorize, fireEvent]);
  return /*#__PURE__*/React.createElement(Box, {
    testId: testId
  }, /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.header
  }, /*#__PURE__*/React.createElement(Text, {
    weight: "bold",
    size: "medium",
    color: "color.text.inverse"
  }, providerName ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.rovo_unauthorised_title, {
    values: {
      context: providerName
    }
  })) : /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_title_no_provider))), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.body
  }, /*#__PURE__*/React.createElement(Stack, {
    space: "space.050"
  }, /*#__PURE__*/React.createElement(Stack, {
    space: "space.200"
  }, ROVO_FEATURES.map(function (feature) {
    return /*#__PURE__*/React.createElement(Inline, {
      key: feature.testIdSuffix,
      space: "space.100",
      alignBlock: "center",
      testId: "".concat(testId, "-feature-row-").concat(feature.testIdSuffix)
    }, /*#__PURE__*/React.createElement(IconTile, {
      icon: feature.icon,
      label: '',
      appearance: feature.appearance,
      size: "medium",
      testId: "".concat(testId, "-feature-").concat(feature.testIdSuffix)
    }), /*#__PURE__*/React.createElement(Stack, {
      space: "space.025"
    }, /*#__PURE__*/React.createElement(Text, {
      size: "small",
      weight: "bold"
    }, /*#__PURE__*/React.createElement(FormattedMessage, feature.titleMessage)), /*#__PURE__*/React.createElement(Text, {
      size: "small",
      color: "color.text.subtlest"
    }, /*#__PURE__*/React.createElement(FormattedMessage, feature.descMessage))));
  })), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.footer
  }, /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.footerActions
  }, /*#__PURE__*/React.createElement(Button, {
    appearance: "subtle",
    onClick: onDismiss,
    testId: "".concat(testId, "-not-now")
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_not_now)), /*#__PURE__*/React.createElement(Button, {
    appearance: "primary",
    onClick: handleAuthorize,
    testId: "".concat(testId, "-connect-account")
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_connect_account)))))));
};
export default RovoUnauthorisedView;