"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.store = exports.context = exports.connectedHistory = exports.connect = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
var _react = require("react");
var _reactRedux = require("react-redux");
var _redux = require("redux");
var _reduxSaga = _interopRequireDefault(require("redux-saga"));
var _reduxFirstHistory = require("redux-first-history");
var _react2 = require("@kineticdata/react");
var _reducers = _interopRequireDefault(require("./reducers"));
var _sagas = _interopRequireDefault(require("./sagas"));
console.log('Configuring techbar package redux store');
var composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
  name: 'TECHBAR'
}) : _redux.compose;
var sagaMiddlware = (0, _reduxSaga["default"])();
var _createReduxHistoryCo = (0, _reduxFirstHistory.createReduxHistoryContext)({
    history: _react2.history
  }),
  createReduxHistory = _createReduxHistoryCo.createReduxHistory,
  routerMiddleware = _createReduxHistoryCo.routerMiddleware,
  routerReducer = _createReduxHistoryCo.routerReducer;
var store = exports.store = (0, _redux.createStore)((0, _redux.combineReducers)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _reducers["default"]), {}, {
  router: routerReducer
})), composeEnhancers((0, _redux.applyMiddleware)(routerMiddleware, sagaMiddlware)));
var connectedHistory = exports.connectedHistory = (0, _reduxFirstHistory.reachify)(createReduxHistory(store));
sagaMiddlware.run(_sagas["default"]);
var context = exports.context = /*#__PURE__*/(0, _react.createContext)(null);
var connect = exports.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 (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps, mergeProps, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, options), {}, {
    context: context
  }));
};