"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.overlayHideAll = exports.OVERLAY_HIDE_ALL = exports.overlayHide = exports.OVERLAY_HIDE = exports.overlayShow = exports.OVERLAY_SHOW = void 0;

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var OVERLAY_SHOW = 'OVERLAY_SHOW';
exports.OVERLAY_SHOW = OVERLAY_SHOW;

var overlayShow = function overlayShow() {
  return {
    type: OVERLAY_SHOW
  };
};

exports.overlayShow = overlayShow;
var OVERLAY_HIDE = 'OVERLAY_HIDE';
exports.OVERLAY_HIDE = OVERLAY_HIDE;

var overlayHide = function overlayHide() {
  return {
    type: OVERLAY_HIDE
  };
};

exports.overlayHide = overlayHide;
var OVERLAY_HIDE_ALL = 'OVERLAY_HIDE_ALL';
exports.OVERLAY_HIDE_ALL = OVERLAY_HIDE_ALL;

var overlayHideAll = function overlayHideAll() {
  return {
    type: OVERLAY_HIDE_ALL
  };
};

exports.overlayHideAll = overlayHideAll;
var INITIAL_STATE = {
  activeOverlays: []
};

var _default = function _default() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;
  var action = arguments.length > 1 ? arguments[1] : undefined;

  switch (action.type) {
    case OVERLAY_SHOW:
      {
        var id = state.activeOverlays.length;
        return _objectSpread({}, state, {
          activeOverlays: [].concat(_toConsumableArray(state.activeOverlays), [id])
        });
      }

    case OVERLAY_HIDE:
      {
        return _objectSpread({}, state, {
          activeOverlays: state.activeOverlays.slice(0, -1)
        });
      }

    case OVERLAY_HIDE_ALL:
      {
        return _objectSpread({}, state, {
          activeOverlays: []
        });
      }

    default:
      return state;
  }
};

exports.default = _default;