"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = ConstantStateHandler;

var _constantsHandler = _interopRequireDefault(require("./constantsHandler"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function ConstantStateHandler(state, modifiedState, dispatchVal, type, applyHook, actionVal) {
  var component = type.split("_").length > 2 ? type.split("_") : null;
  var type1 = component.length ? (0, _constantsHandler["default"])(type, component[component.length - 1].toLowerCase()) : type;
  dispatchVal({
    type: type1,
    data: modifiedState
  }, actionVal && actionVal(modifiedState));

  if (applyHook) {
    var newState = applyHook(state, modifiedState, type);
    dispatchVal({
      type: type1,
      data: newState
    }, actionVal && actionVal(newState));
  }
}