"use strict";

exports.__esModule = true;
exports.default = void 0;

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

var _spawnerMiddleware = _interopRequireDefault(require("../spawnerMiddleware"));

var _locale = require("../actions/locale");

var _applications = require("../actions/applications");

var _scopes = require("../actions/scopes");

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);
})();

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 initialState = _immutable.default.Map({
  defaultApp: 0,
  defaultScope: null
});

var settingsReducer = function settingsReducer(state, action) {
  if (state === void 0) {
    state = initialState;
  }

  switch (action.type) {
    case _applications.GET_MY_APPLICATION_SUCCESS:
      return state.set("defaultApp", action.payload.id);

    case _applications.SET_MY_APPLICATION_SUCCESS:
      return state.set("defaultApp", action.meta.appId);

    case _scopes.GET_MY_SCOPE_SUCCESS:
      return state.set("defaultScope", action.payload.id);

    default:
      return state;
  }
}; // No need to store default culture separately,
// just set the current locale accordingly.


(0, _spawnerMiddleware.default)(_locale.GET_MY_CULTURE_SUCCESS,
/* istanbul ignore next */
function (action) {
  return (0, _locale.changeLocale)(action.payload.cultureIso);
});
var _default = settingsReducer;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

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

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/settings.js");
  reactHotLoader.register(settingsReducer, "settingsReducer", "/home/vsts/work/1/s/src/reducers/settings.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/reducers/settings.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(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/settings.js");
  reactHotLoader.register(settingsReducer, "settingsReducer", "/home/vsts/work/1/s/src/reducers/settings.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/reducers/settings.js");
})();

;

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