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

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InlineCardUnauthorizedView = void 0;
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _reactIntlNext = require("react-intl-next");
var _lockLocked = _interopRequireDefault(require("@atlaskit/icon/core/lock-locked"));
var _lockFilled = _interopRequireDefault(require("@atlaskit/icon/glyph/lock-filled"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _colors = require("@atlaskit/theme/colors");
var _useAnalyticsEvents2 = require("../../../common/analytics/generated/use-analytics-events");
var _messages = require("../../../messages");
var _HoverCard = require("../../HoverCard");
var _actionButton = require("../common/action-button");
var _Frame = require("../Frame");
var _IconAndTitleLayout = require("../IconAndTitleLayout");
var fallbackUnauthorizedIcon = function fallbackUnauthorizedIcon() {
  return /*#__PURE__*/_react.default.createElement(_lockLocked.default, {
    color: "var(--ds-icon-danger, #C9372C)",
    label: "error",
    LEGACY_fallbackIcon: _lockFilled.default,
    LEGACY_size: "small"
  });
};
var InlineCardUnauthorizedView = exports.InlineCardUnauthorizedView = function InlineCardUnauthorizedView(_ref) {
  var url = _ref.url,
    id = _ref.id,
    icon = _ref.icon,
    onAuthorise = _ref.onAuthorise,
    onClick = _ref.onClick,
    isSelected = _ref.isSelected,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'inline-card-unauthorized-view' : _ref$testId,
    _ref$showHoverPreview = _ref.showHoverPreview,
    showHoverPreview = _ref$showHoverPreview === void 0 ? false : _ref$showHoverPreview,
    truncateInline = _ref.truncateInline,
    context = _ref.context;
  var frameRef = _react.default.useRef(null);
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
    fireEvent = _useAnalyticsEvents.fireEvent;
  var handleConnectAccount = _react.default.useCallback(function (event) {
    event.preventDefault();
    event.stopPropagation();
    if (onAuthorise) {
      fireEvent('track.applicationAccount.authStarted', {});
      onAuthorise();
    }
  }, [fireEvent, onAuthorise]);
  var renderActionButton = _react.default.useCallback(function () {
    return /*#__PURE__*/_react.default.createElement(_actionButton.ActionButton, {
      onClick: handleConnectAccount,
      viewType: 'unauthorised',
      testId: "button-connect-account"
    }, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.messages.connect_link_account_card_name, {
      values: {
        context: context
      }
    })));
  }, [handleConnectAccount, context]);
  var inlineCardUnauthenticatedView = /*#__PURE__*/_react.default.createElement(_Frame.Frame, {
    testId: testId,
    isSelected: isSelected,
    ref: frameRef,
    truncateInline: truncateInline,
    viewType: "unauthorised"
  }, /*#__PURE__*/_react.default.createElement(_IconAndTitleLayout.IconAndTitleLayout, {
    icon: icon ? icon : fallbackUnauthorizedIcon(),
    title: url,
    link: url,
    onClick: onClick,
    titleColor: "var(--ds-text-subtle, ".concat(_colors.N500, ")")
  }), (0, _platformFeatureFlags.fg)('navx-2479-sl-fix-inilne-card-show-connect-button') ? onAuthorise && renderActionButton() : renderActionButton());
  if (onAuthorise && showHoverPreview) {
    return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
      url: url,
      id: id
    }, inlineCardUnauthenticatedView);
  }
  return inlineCardUnauthenticatedView;
};