'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.reducer = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _lodash = require('lodash');

const INIT_STATE = {};

function _ref() {
  return true;
}

const reducer = exports.reducer = (state = INIT_STATE, { type, value: { scope, opts, keys } = {}, content }) => {
  switch (type) {
    case '@@initIPC':
      {
        return _extends({}, state, content);
      }
    case '@@registerIPC':
      {
        return _extends({}, state, {
          [scope]: (0, _lodash.mapValues)(opts, _ref)
        });
      }
    case '@@unregisterIPC':
      {
        return _extends({}, state, {
          [scope]: (0, _lodash.omit)(state[scope], keys)
        });
      }
    case '@@unregisterAllIPC':
      {
        return (0, _lodash.omit)(state, scope);
      }
  }
  return state;
};