/* 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';
import Button from '@atlaskit/button/new';
import AiGenerativeTextSummaryIcon from '@atlaskit/icon/core/ai-generative-text-summary';
import CoreLinkIcon from '@atlaskit/icon/core/link';
import RovoChatIcon from '@atlaskit/icon/core/rovo-chat';
import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
import { AtlassianIcon } from '@atlaskit/logo';
import { Box, Inline, Stack, Text } from '@atlaskit/primitives/compiled';
import { useAnalyticsEvents } from '../../../../../common/analytics/generated/use-analytics-events';
import { CardDisplay, SmartLinkSize } from '../../../../../constants';
import { messages } from '../../../../../messages';
import { useSmartCardActions } from '../../../../../state/actions';
import FlexibleCard from '../../../../FlexibleCard';
import { LinkIcon } from '../../../../FlexibleCard/components/elements';
import { DenseSparkle, SparseSparkle, SquiglyArrow } from './graphics';
const ROVO_FEATURES = [{
  icon: CoreLinkIcon,
  message: messages.rovo_unauthorised_feature_clear_link_names,
  testIdSuffix: 'clear-link-names'
}, {
  icon: AiGenerativeTextSummaryIcon,
  message: messages.rovo_unauthorised_feature_understand_linked_docs,
  testIdSuffix: 'understand-linked-docs'
}, {
  icon: RovoChatIcon,
  message: messages.rovo_unauthorised_feature_go_deeper_smart_suggestions,
  testIdSuffix: 'go-deeper-smart-suggestions'
}];
const sparkleWrapBase = null;
const sparkleLeftWrap = null;
const sparkleGreyRightWrap = null;
const sparkleVioletRightWrap = null;
const layoutStyles = {
  connectorStroke: "_syaz1fxt _1e0c1txw _1o9zidpf",
  atlassianIconTile: "_2rko1mok _1e0c1txw _4cvr1h6o _1bah1h6o _1bsbzwfg _4t3izwfg _bfhk16e3",
  header: "_bfhk11bn _ca0q1ejb _u5f3pxbi _n3tdutpp _19bvpxbi _13li1mok _qrwq1mok _kqswh2mm",
  headerGraphicRow: "_zulpu2gc _1e0c1txw _4cvr1h6o _1bah1h6o _otyrutpp",
  headerTitle: "_y3gn1h6o",
  body: "_ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi",
  featureIconCell: "_1e0c1txw _4cvr1h6o _1bah1h6o _1o9zidpf _1bsb7vkz",
  footer: "_zulputpp _19pkutpp _ca0q1b66 _1e0c1txw _4cvr1h6o _1bahesu3 _1n261g80"
};
const RovoUnauthorisedView = ({
  id = '',
  flexibleCardProps,
  onDismiss,
  testId = 'hover-card-rovo-unauthorised-view',
  url
}) => {
  const providerName = useMemo(() => {
    var _extractSmartLinkProv;
    return (_extractSmartLinkProv = extractSmartLinkProvider(flexibleCardProps.cardState.details)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text;
  }, [flexibleCardProps.cardState.details]);
  const {
    authorize
  } = useSmartCardActions(id, url);
  const {
    fireEvent
  } = useAnalyticsEvents();
  const handleAuthorize = useCallback(() => {
    if (authorize) {
      fireEvent('track.applicationAccount.authStarted', {});
      authorize(CardDisplay.HoverCardPreview);
    }
  }, [authorize, fireEvent]);
  const handleDismiss = useCallback(() => {
    if (onDismiss) {
      fireEvent('ui.button.clicked.dismiss', {});
      onDismiss();
    }
  }, [fireEvent, onDismiss]);
  return /*#__PURE__*/React.createElement(FlexibleCard, _extends({}, flexibleCardProps, {
    testId: testId,
    ui: {
      hideElevation: true,
      hideBackground: true,
      removeBlockRestriction: true,
      hidePadding: true
    }
  }), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.header
  }, /*#__PURE__*/React.createElement("div", {
    className: ax(["_1o9zidpf _1e0c1txw _kqswstnw", "_syaz1yjp _154i1ul9 _1ltv1v6z"])
  }, /*#__PURE__*/React.createElement(DenseSparkle, null)), /*#__PURE__*/React.createElement("div", {
    className: ax(["_1o9zidpf _1e0c1txw _kqswstnw", "_syazwejn _154i1crf _1xi2qslr"])
  }, /*#__PURE__*/React.createElement(SparseSparkle, null)), /*#__PURE__*/React.createElement("div", {
    className: ax(["_1o9zidpf _1e0c1txw _kqswstnw", "_syazuq3u _1bsbqslr _154i1ylp _1xi21v6z"])
  }, /*#__PURE__*/React.createElement(DenseSparkle, null)), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.headerGraphicRow
  }, /*#__PURE__*/React.createElement(LinkIcon, {
    size: SmartLinkSize.Medium,
    isTiledIcon: true
  }), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.connectorStroke
  }, /*#__PURE__*/React.createElement(SquiglyArrow, null)), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.atlassianIconTile
  }, /*#__PURE__*/React.createElement(AtlassianIcon, {
    appearance: "inverse",
    size: "small"
  }))), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.headerTitle
  }, /*#__PURE__*/React.createElement(Text, {
    weight: "bold",
    size: "medium",
    color: "color.text"
  }, 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(feature => {
    const FeatureIcon = feature.icon;
    return /*#__PURE__*/React.createElement(Inline, {
      key: feature.testIdSuffix,
      space: "space.150",
      alignBlock: "center",
      testId: `${testId}-feature-${feature.testIdSuffix}`
    }, /*#__PURE__*/React.createElement(Box, {
      xcss: layoutStyles.featureIconCell
    }, /*#__PURE__*/React.createElement(FeatureIcon, {
      label: ""
    })), /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement(FormattedMessage, feature.message)));
  })), /*#__PURE__*/React.createElement(Box, {
    xcss: layoutStyles.footer
  }, /*#__PURE__*/React.createElement(Inline, {
    space: "space.050"
  }, /*#__PURE__*/React.createElement(Button, {
    appearance: "subtle",
    spacing: "compact",
    onClick: handleDismiss,
    testId: `${testId}-not-now`
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_not_now)), /*#__PURE__*/React.createElement(Button, {
    appearance: "primary",
    onClick: handleAuthorize,
    testId: `${testId}-connect-account`
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_connect_account)))))));
};
export default RovoUnauthorisedView;