import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { createContext } from 'react';
import { connect as connectRedux } from 'react-redux';
import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { createReduxHistoryContext, reachify } from 'redux-first-history';
import { history } from '@kineticdata/react';
import reducers from './reducers';
import sagas from './sagas';
console.log('Configuring techbar package redux store');
var composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
  name: 'TECHBAR'
}) : compose;
var sagaMiddlware = createSagaMiddleware();

var _createReduxHistoryCo = createReduxHistoryContext({
  history: history
}),
    createReduxHistory = _createReduxHistoryCo.createReduxHistory,
    routerMiddleware = _createReduxHistoryCo.routerMiddleware,
    routerReducer = _createReduxHistoryCo.routerReducer;

export var store = createStore(combineReducers(_objectSpread(_objectSpread({}, reducers), {}, {
  router: routerReducer
})), composeEnhancers(applyMiddleware(routerMiddleware, sagaMiddlware)));
export var connectedHistory = reachify(createReduxHistory(store));
sagaMiddlware.run(sagas);
export var context = createContext(null);
export var connect = function connect() {
  var mapStateToProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  var mapDispatchToProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  var mergeProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  return connectRedux(mapStateToProps, mapDispatchToProps, mergeProps, _objectSpread(_objectSpread({}, options), {}, {
    context: context
  }));
};