"use strict";

exports.__esModule = true;
exports.default = void 0;
var _immutable = _interopRequireDefault(require("immutable"));
var _toasts = require("../actions/toasts");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(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.fromJS({
  queue: []
});
var toastReducer = function toastReducer(state, action) {
  if (state === void 0) {
    state = initialState;
  }
  switch (action.type) {
    case _toasts.PUSH_TOAST:
      return state.withMutations(function (s) {
        var latestToast = s.get("queue").last() || _immutable.default.Map({
          key: 0
        });
        var latestKey = latestToast.get("key");
        var toast = _immutable.default.fromJS(action.payload).set("key", latestKey + 1);
        s.set("queue", s.get("queue").push(toast));
      });
    case _toasts.SHIFT_TOAST:
      return state.withMutations(function (s) {
        s.set("queue", s.get("queue").shift());
      });
    default:
      return state;
  }
};
var _default = toastReducer;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/toasts.js");
  reactHotLoader.register(toastReducer, "toastReducer", "/home/vsts/work/1/s/src/reducers/toasts.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/reducers/toasts.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/toasts.js");
  reactHotLoader.register(toastReducer, "toastReducer", "/home/vsts/work/1/s/src/reducers/toasts.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/reducers/toasts.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();