"use strict";

exports.__esModule = true;
exports.default = exports.CurrentApp = exports.AppLogo = exports.AppLabel = exports.AppBox = exports.Menu = exports.useMenuProps = exports.Wrapper = void 0;

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _reactRedux = require("react-redux");

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

var _utils = require("../../utils");

var _authentication = require("../../selectors/authentication");

var _view = require("../../actions/view");

var _authentication2 = require("../../actions/authentication");

var _Preferences = require("./Preferences");

var _About = require("./About");

var _ApplicationSelector = _interopRequireDefault(require("./ApplicationSelector"));

var _DropMenu = _interopRequireDefault(require("../DropMenu"));

var _Anchor = _interopRequireDefault(require("./Anchor"));

var _Help = _interopRequireDefault(require("./Help"));

var _sharedMessages = _interopRequireDefault(require("./../../sharedMessages"));

var _excluded = ["menuLabel"],
    _excluded2 = ["applications", "applicationId", "currentApplication", "onClick", "helpUrl"];

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

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var Wrapper = _styledComponents.default.div.withConfig({
  displayName: "Topbar__Wrapper",
  componentId: "sc-15ckfuy-0"
})(["height:40px;color:", ";display:flex;justify-content:space-between;"], (0, _utils.getThemeProp)(["colors", "textMedium"], "#999999"));

exports.Wrapper = Wrapper;

var useMenuProps = function useMenuProps() {
  var intl = (0, _reactIntl.useIntl)();
  var dispatch = (0, _reactRedux.useDispatch)();
  return {
    id: "userMenu",
    menuLabel: (0, _reactRedux.useSelector)(_authentication.selectCurrentUsername),
    menuItems: [{
      id: "userMenuSignOut",
      label: intl.formatMessage(_sharedMessages.default.signOut),
      handler: function handler() {
        return dispatch((0, _authentication2.signOut)());
      },
      icon: "logout"
    }, {
      id: "userMenuPrefsMenu",
      label: intl.formatMessage(_sharedMessages.default.preferences),
      handler: function handler() {
        return dispatch((0, _view.setStateField)(_Preferences.PREFS_NAME, "show", true));
      },
      icon: "cogwheel"
    }, {
      id: "userMenuAbout",
      label: intl.formatMessage(_sharedMessages.default.about),
      handler: function handler() {
        return dispatch((0, _view.setStateField)(_About.ABOUT_NAME, "show", true));
      },
      icon: "info"
    }]
  };
};

exports.useMenuProps = useMenuProps;

__signature__(useMenuProps, "useIntl{intl}\nuseDispatch{dispatch}\nuseSelector{}", function () {
  return [_reactIntl.useIntl, _reactRedux.useDispatch, _reactRedux.useSelector];
});

__signature__(useMenuProps, "useIntl{intl}\nuseDispatch{dispatch}\nuseSelector{}", function () {
  return [_reactIntl.useIntl, _reactRedux.useDispatch, _reactRedux.useSelector];
});

var Menu = function Menu() {
  var _useMenuProps = useMenuProps(),
      menuLabel = _useMenuProps.menuLabel,
      menuProps = _objectWithoutProperties(_useMenuProps, _excluded);

  return /*#__PURE__*/_react.default.createElement(_DropMenu.default, menuProps, /*#__PURE__*/_react.default.createElement(_Anchor.default, {
    menuLabel: menuLabel
  }));
};

exports.Menu = Menu;

__signature__(Menu, "useMenuProps{{ menuLabel, ...menuProps }}", function () {
  return [useMenuProps];
});

__signature__(Menu, "useMenuProps{{ menuLabel, ...menuProps }}", function () {
  return [useMenuProps];
});

var AppBox = _styledComponents.default.div.withConfig({
  displayName: "Topbar__AppBox",
  componentId: "sc-15ckfuy-1"
})(["height:100%;display:flex;flex:1;align-items:stretch;"]);

exports.AppBox = AppBox;

var AppLabel = _styledComponents.default.div.withConfig({
  displayName: "Topbar__AppLabel",
  componentId: "sc-15ckfuy-2"
})(["background-color:#000000;color:", ";font-family:", ";font-size:14px;text-transform:uppercase;padding-right:20px;padding-left:6px;display:flex;align-items:center;"], (0, _utils.getThemeProp)(["colors", "application", "primary"], "#ffffff"), (0, _utils.getThemeProp)(["fonts", "header"], "sans-serif"));

exports.AppLabel = AppLabel;

var AppLogo = _styledComponents.default.img.attrs(function () {
  return {
    alt: ""
  };
}).withConfig({
  displayName: "Topbar__AppLogo",
  componentId: "sc-15ckfuy-3"
})(["height:30px;margin-right:10px;"]);

exports.AppLogo = AppLogo;

var CurrentApp = function CurrentApp(_ref) {
  var displayName = _ref.displayName,
      iconUri = _ref.iconUri;
  return /*#__PURE__*/_react.default.createElement(AppLabel, null, /*#__PURE__*/_react.default.createElement(AppLogo, {
    src: iconUri
  }), displayName);
};

exports.CurrentApp = CurrentApp;
CurrentApp.displayName = "CurrentApp";

var Topbar = function Topbar(_ref2) {
  var applications = _ref2.applications,
      applicationId = _ref2.applicationId,
      currentApplication = _ref2.currentApplication,
      onClick = _ref2.onClick,
      helpUrl = _ref2.helpUrl,
      config = _objectWithoutProperties(_ref2, _excluded2);

  return /*#__PURE__*/_react.default.createElement(Wrapper, {
    onClick: onClick
  }, /*#__PURE__*/_react.default.createElement(AppBox, null, /*#__PURE__*/_react.default.createElement(_ApplicationSelector.default, {
    applications: applications,
    applicationId: applicationId
  }), /*#__PURE__*/_react.default.createElement(CurrentApp, currentApplication || {})), /*#__PURE__*/_react.default.createElement(Menu, config), /*#__PURE__*/_react.default.createElement(_Help.default, {
    helpUrl: helpUrl
  }));
};

var _default = Topbar;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(Wrapper, "Wrapper", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(useMenuProps, "useMenuProps", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Menu, "Menu", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(AppBox, "AppBox", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(AppLabel, "AppLabel", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(AppLogo, "AppLogo", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(CurrentApp, "CurrentApp", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Topbar, "Topbar", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(Wrapper, "Wrapper", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(useMenuProps, "useMenuProps", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Menu, "Menu", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(AppBox, "AppBox", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(AppLabel, "AppLabel", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(AppLogo, "AppLogo", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(CurrentApp, "CurrentApp", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Topbar, "Topbar", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();