'use strict';

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

var _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

var _redux = require('redux');

var _middlewares = require('./middlewares');

var _middlewares2 = _interopRequireDefault(_middlewares);

var _reducers = require('./reducers');

var _reducers2 = _interopRequireDefault(_reducers);

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

if (process.env.NODE_ENV === 'development') {
  const createLogger = require('redux-logger'); // eslint-disable-line global-require

  const logger = createLogger({
    stateTransformer: state => Object.keys(state).reduce((prev, key) => Object.assign({}, prev, { [key]: _immutable2.default.Iterable.isIterable(state[key]) ? state[key].toJS() : state[key] }), {})
  });
  _middlewares2.default.push(logger);
}

function configureStore(initialState) {
  return (0, _redux.createStore)(_reducers2.default, initialState, (0, _redux.applyMiddleware)(..._middlewares2.default));
}