/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("./index.compiled.css");
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _reactIntlNext = require("react-intl-next");
var _linkExtractors = require("@atlaskit/link-extractors");
var _useAnalyticsEvents2 = require("../../../../../common/analytics/generated/use-analytics-events");
var _constants = require("../../../../../constants");
var _messages = require("../../../../../messages");
var _actions = require("../../../../../state/actions");
var _helpers = require("../../../../../state/helpers");
var _UnauthorisedViewContent = _interopRequireDefault(require("../../../../common/UnauthorisedViewContent"));
var _FlexibleCard = _interopRequireDefault(require("../../../../FlexibleCard"));
var _blocks = require("../../../../FlexibleCard/components/blocks");
var _actionGroup = _interopRequireDefault(require("../../../../FlexibleCard/components/blocks/action-group"));
var _elements = require("../../../../FlexibleCard/components/elements");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var connectButtonStyles = null;
var titleBlockStyles = null;
var mainTextStyles = null;
var HoverCardUnauthorisedView = function HoverCardUnauthorisedView(_ref) {
  var _extractSmartLinkProv;
  var _ref$id = _ref.id,
    id = _ref$id === void 0 ? '' : _ref$id,
    flexibleCardProps = _ref.flexibleCardProps,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'hover-card-unauthorised-view' : _ref$testId,
    url = _ref.url;
  var cardState = flexibleCardProps.cardState;
  var providerName = (_extractSmartLinkProv = (0, _linkExtractors.extractSmartLinkProvider)(cardState.details)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text;
  var isProductIntegrationSupported = (0, _helpers.hasAuthScopeOverrides)(cardState.details);
  var _useSmartCardActions = (0, _actions.useSmartCardActions)(id, url),
    authorize = _useSmartCardActions.authorize;
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
    fireEvent = _useAnalyticsEvents.fireEvent;
  var handleAuthorize = (0, _react.useCallback)(function () {
    if (authorize) {
      fireEvent('track.applicationAccount.authStarted', {});
      authorize(_constants.CardDisplay.HoverCardPreview);
    }
  }, [authorize, fireEvent]);
  var actions = (0, _react.useMemo)(function () {
    return [{
      name: _constants.ActionName.CustomAction,
      content: /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.messages.connect_unauthorised_account_action, {
        values: {
          context: providerName
        }
      })),
      onClick: handleAuthorize
    }];
  }, [handleAuthorize, providerName]);
  return /*#__PURE__*/React.createElement(_FlexibleCard.default, (0, _extends2.default)({}, flexibleCardProps, {
    testId: testId
  }), /*#__PURE__*/React.createElement(_blocks.CustomBlock, {
    testId: "".concat(testId, "-title"),
    className: (0, _runtime.ax)(["_zulpu2gc _13mh1pd9"])
  }, /*#__PURE__*/React.createElement(_elements.LinkIcon, null), /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.messages.connect_link_account_card_name, {
    values: {
      context: providerName
    }
  }))), /*#__PURE__*/React.createElement(_blocks.CustomBlock, {
    testId: "".concat(testId, "-content"),
    className: (0, _runtime.ax)(["_11c8dcr7 _19pku2gc"])
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_UnauthorisedViewContent.default, {
    providerName: providerName,
    isProductIntegrationSupported: isProductIntegrationSupported
  }))), /*#__PURE__*/React.createElement(_blocks.CustomBlock, {
    testId: "".concat(testId, "-button"),
    className: (0, _runtime.ax)(["_1bahesu3 _19pku2gc"])
  }, /*#__PURE__*/React.createElement(_actionGroup.default, {
    items: actions,
    appearance: "primary"
  })));
};
var _default = exports.default = HoverCardUnauthorisedView;