"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.setFakeStore = setFakeStore;
exports.unsetFakeStore = unsetFakeStore;
exports.default = void 0;

var _config = _interopRequireDefault(require("./config"));

var _persistedState = _interopRequireDefault(require("./common/util/persistedState"));

var _persistedStorageMiddleware = _interopRequireDefault(require("./common/middleware/persistedStorageMiddleware"));

var _configureStore = _interopRequireDefault(require("./configureStore"));

var store = (0, _configureStore.default)({
  extraMiddleware: [(0, _persistedStorageMiddleware.default)()],
  inDevelopment: _config.default.inDevelopment(),
  initialState: _persistedState.default.load()
});

if (_config.default.inDevelopment()) {
  window.store = store;
  window.getState = store.getState;
  window.dispatch = store.dispatch;
}

function setFakeStore(fakeState) {
  store.useFakeState = true;
  store.fakeState = fakeState;
}

function unsetFakeStore(fakeState) {
  store.useFakeState = false;
  store.fakeState = null;
}

store.getAppState = function () {
  var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
  return store.useFakeState || opts.useFakeState ? store.fakeState : store.getState();
};

var _default = store;
exports.default = _default;