/* RelatedLinksBaseModal.tsx generated by @compiled/babel-plugin v0.40.0 */
"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;
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _reactIntl = require("react-intl");
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
var _useAnalyticsEvents2 = require("../../../common/analytics/generated/use-analytics-events");
var _messages = require("../../../messages");
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 fixedWidth = 'small'; // pre-defined 400px by Atlaskit

var RelatedLinksBaseModal = function RelatedLinksBaseModal(_ref) {
  var onClose = _ref.onClose,
    showModal = _ref.showModal,
    children = _ref.children;
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
    fireEvent = _useAnalyticsEvents.fireEvent;
  var modalOpenTimeRef = (0, _react.useRef)(Date.now());
  var openCompleteHandler = (0, _react.useCallback)(function (el) {
    el.focus();
    modalOpenTimeRef.current = Date.now();
    fireEvent('ui.modal.opened.relatedLinks', {});
  }, [fireEvent]);
  var closeHandler = (0, _react.useCallback)(function () {
    fireEvent('ui.modal.closed.relatedLinks', {
      dwellTime: Date.now() - modalOpenTimeRef.current
    });
    onClose === null || onClose === void 0 || onClose();
  }, [fireEvent, onClose]);
  return /*#__PURE__*/React.createElement(_modalDialog.ModalTransition, null, showModal && /*#__PURE__*/React.createElement(_modalDialog.default, {
    testId: "related-links-modal",
    onClose: closeHandler,
    width: fixedWidth,
    shouldReturnFocus: false,
    onOpenComplete: openCompleteHandler,
    height: '504px'
  }, /*#__PURE__*/React.createElement(_modalDialog.ModalHeader, {
    hasCloseButton: true
  }, /*#__PURE__*/React.createElement(_modalDialog.ModalTitle, null, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, _messages.messages.related_links_modal_title))), /*#__PURE__*/React.createElement(_modalDialog.ModalBody, null, children), /*#__PURE__*/React.createElement(_modalDialog.ModalFooter, null, /*#__PURE__*/React.createElement(_new.default, {
    appearance: "primary",
    onClick: closeHandler
  }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, _messages.messages.close)))));
};
var _default = exports.default = RelatedLinksBaseModal;