"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = require("react");
var _reactRedux = require("react-redux");
var _utils = require("../utils");
var _view = require("../actions/view");
(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;
};
var useViewState = function useViewState(name) {
  var viewState = (0, _utils.unwrapImmutable)((0, _reactRedux.useSelector)(function (state) {
    return state.getIn(["view", name]);
  })) || {};
  var dispatch = (0, _reactRedux.useDispatch)();
  var updateViewState = (0, _react.useCallback)(function (fieldName, value) {
    return dispatch((0, _view.setStateField)(name, fieldName, value));
  }, [dispatch, name]);
  var resetViewState = (0, _react.useCallback)(function (defaultValue) {
    return dispatch((0, _view.setValue)(name, defaultValue || {}));
  }, [dispatch, name]);
  return [viewState, updateViewState, resetViewState];
};
__signature__(useViewState, "useSelector{}\nuseDispatch{dispatch}\nuseCallback{updateViewState}\nuseCallback{resetViewState}", function () {
  return [_reactRedux.useSelector, _reactRedux.useDispatch];
});
__signature__(useViewState, "useSelector{}\nuseDispatch{dispatch}\nuseCallback{updateViewState}\nuseCallback{resetViewState}", function () {
  return [_reactRedux.useSelector, _reactRedux.useDispatch];
});
var _default = useViewState;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useViewState, "useViewState", "/home/vsts/work/1/s/src/hooks/useViewState.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/hooks/useViewState.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(useViewState, "useViewState", "/home/vsts/work/1/s/src/hooks/useViewState.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/hooks/useViewState.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();