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





































function (api, browserHistory) {var forEmbed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  var reducers = (0, _reducers2.default)();
  var middleware = (0, _middleware2.default)(api, browserHistory, forEmbed);
  var store = _redux.applyMiddleware.apply(undefined, _toConsumableArray(middleware))(storeCreation)(reducers);

  // Add the `api` to the Redux Store
  store.dispatch({ type: 'initAll', api: api });
  store.dispatch((0, _apiActions.setApi)(api));

  // Initialise the Store Providers
  _providers.Balances.init(store);
  _providers.Personal.init(store);
  _providers.Status.init(store);
  _providers.Tokens.init(store);

  new _providers.Signer(store, api).start();

  store.dispatch((0, _walletActions.load)(api));
  store.dispatch((0, _requestsActions.init)(api));
  (0, _workerWrapper.setupWorker)(store);

  var start = function start() {
    return Promise.resolve().
    then(function () {return console.log('starting Status Provider...');}).
    then(function () {return _providers.Status.start();}).
    then(function () {return console.log('started Status Provider');}).

    then(function () {return console.log('starting Personal Provider...');}).
    then(function () {return _providers.Personal.start();}).
    then(function () {return console.log('started Personal Provider');}).

    then(function () {return console.log('starting Balances Provider...');}).
    then(function () {return _providers.Balances.start();}).
    then(function () {return console.log('started Balances Provider');}).

    then(function () {return console.log('starting Tokens Provider...');}).
    then(function () {return _providers.Tokens.start();}).
    then(function () {return console.log('started Tokens Provider');});
  };

  var stop = function stop() {
    return _providers.Status.stop().
    then(function () {return _providers.Personal.stop();}).
    then(function () {return _providers.Tokens.stop();}).
    then(function () {return _providers.Balances.stop();});
  };

  // On connecting, stop all subscriptions
  api.on('connecting', stop);

  // On connected, start the subscriptions
  api.on('connected', start);

  // On disconnected, stop all subscriptions
  api.on('disconnected', stop);

  if (api.isConnected) {
    start();
  }

  return store;
};var _redux = require('redux');var _middleware = require('./middleware');var _middleware2 = _interopRequireDefault(_middleware);var _reducers = require('./reducers');var _reducers2 = _interopRequireDefault(_reducers);var _walletActions = require('./providers/walletActions');var _requestsActions = require('./providers/requestsActions');var _workerWrapper = require('./providers/workerWrapper');var _apiActions = require('./providers/apiActions');var _providers = require('./providers');function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _toConsumableArray(arr) {if (Array.isArray(arr)) {for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {arr2[i] = arr[i];}return arr2;} else {return Array.from(arr);}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity.  If not, see <http://www.gnu.org/licenses/>.
var storeCreation = window.devToolsExtension ? window.devToolsExtension()(_redux.createStore) : _redux.createStore;