"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactIntl = require("react-intl");

var _immutable = _interopRequireDefault(require("immutable"));

var _QuickSearchFormContainer = _interopRequireDefault(require("../../containers/search/QuickSearchFormContainer"));

var _NavBar = _interopRequireDefault(require("../navigation/NavBar"));

var _UserMenu = _interopRequireDefault(require("../user/UserMenu"));

var _Logo = _interopRequireDefault(require("./Logo"));

var _withConfig = _interopRequireDefault(require("../../enhancers/withConfig"));

var _Banner = _interopRequireDefault(require("../../../styles/cspace-ui/Banner.css"));

var _BannerMain = _interopRequireDefault(require("../../../styles/cspace-ui/BannerMain.css"));

var _BannerRight = _interopRequireDefault(require("../../../styles/cspace-ui/BannerRight.css"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const propTypes = {
  screenName: _propTypes.default.string.isRequired,
  history: _propTypes.default.shape({
    push: _propTypes.default.func
  }),
  intl: _reactIntl.intlShape,
  // eslint-disable-next-line react/forbid-prop-types
  config: _propTypes.default.object,
  perms: _propTypes.default.instanceOf(_immutable.default.Map),
  userPrefsLoaded: _propTypes.default.bool
};

function Header(props) {
  const {
    history,
    intl,
    config,
    perms,
    screenName,
    userPrefsLoaded
  } = props;
  let quickSearch;

  if (userPrefsLoaded) {
    // Wait for user prefs to load, so that the record type selector will reflect the user's
    // preference.
    quickSearch = /*#__PURE__*/_react.default.createElement(_QuickSearchFormContainer.default, {
      history: history,
      intl: intl,
      config: config,
      perms: perms
    });
  }

  return /*#__PURE__*/_react.default.createElement("header", null, /*#__PURE__*/_react.default.createElement("div", {
    className: _Banner.default.common
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _BannerMain.default.common
  }, /*#__PURE__*/_react.default.createElement(_Logo.default, {
    config: config
  }), quickSearch), /*#__PURE__*/_react.default.createElement("div", {
    className: _BannerRight.default.common
  }, /*#__PURE__*/_react.default.createElement(_UserMenu.default, {
    screenName: screenName
  }))), /*#__PURE__*/_react.default.createElement(_NavBar.default, {
    perms: perms
  }));
}

Header.propTypes = propTypes;

var _default = (0, _reactIntl.injectIntl)((0, _withConfig.default)(Header));

exports.default = _default;