"use strict";

exports.__esModule = true;
exports.useDispatchWithModulesData = exports.default = void 0;
var _react = require("react");
var _reactRedux = require("react-redux");
var _navigation = require("./../selectors/navigation");
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
// if n is number of parameters passed to action then
// currentSection will be passed as (n - 1)th parameter if includeCurrentSection is true
// currentModule always will be passed as (n)th parameter
var useDispatchWithModulesData = exports.useDispatchWithModulesData = function useDispatchWithModulesData() {
  var baseDispatch = (0, _reactRedux.useDispatch)();
  var currentModuleName = (0, _reactRedux.useSelector)(_navigation.selectCurrentModuleName);
  var currentSectionName = (0, _reactRedux.useSelector)(_navigation.selectCurrentSectionName);
  var dispatch = (0, _react.useCallback)(function (action, params, options) {
    var predefinedParams = [];
    if ((options == null ? void 0 : options.includeCurrentSection) === true) {
      predefinedParams.push(currentSectionName);
    }
    predefinedParams.push(currentModuleName);
    if (params != null) {
      var actionParams = params.concat(predefinedParams);
      baseDispatch(action.apply(null, actionParams));
    } else {
      baseDispatch(action.apply(null, predefinedParams));
    }
  }, [baseDispatch, currentModuleName, currentSectionName]);
  return dispatch;
};
__signature__(useDispatchWithModulesData, "useDispatch{baseDispatch}\nuseSelector{currentModuleName}\nuseSelector{currentSectionName}\nuseCallback{dispatch}", function () {
  return [_reactRedux.useDispatch, _reactRedux.useSelector, _reactRedux.useSelector];
});
__signature__(useDispatchWithModulesData, "useDispatch{baseDispatch}\nuseSelector{currentModuleName}\nuseSelector{currentSectionName}\nuseCallback{dispatch}", function () {
  return [_reactRedux.useDispatch, _reactRedux.useSelector, _reactRedux.useSelector];
});
var _default = useDispatchWithModulesData;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useDispatchWithModulesData, "useDispatchWithModulesData", "/home/vsts/work/1/s/src/hooks/useDispatchWithModulesData.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/hooks/useDispatchWithModulesData.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useDispatchWithModulesData, "useDispatchWithModulesData", "/home/vsts/work/1/s/src/hooks/useDispatchWithModulesData.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/hooks/useDispatchWithModulesData.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();