"use strict";

exports.__esModule = true;
exports.isEnzymeFilterAndUpdate = exports.filteredRestrictionEnzymesUpdate = exports.filteredRestrictionEnzymesReset = exports.filteredRestrictionEnzymesAdd = exports["default"] = void 0;
var _redux = require("redux");
var _reduxAct = require("redux-act");
var _createMetaAction = _interopRequireDefault(require("./utils/createMetaAction"));
var _specialCutsiteFilterOptions = _interopRequireDefault(require("../constants/specialCutsiteFilterOptions"));
var _createReducer, _createReducer2;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// ------------------------------------
// Actions
// ------------------------------------
var filteredRestrictionEnzymesUpdate = (0, _createMetaAction["default"])("FILTERED_RESTRICTION_ENZYMES_UPDATE");
exports.filteredRestrictionEnzymesUpdate = filteredRestrictionEnzymesUpdate;
var isEnzymeFilterAndUpdate = (0, _createMetaAction["default"])("IS_ENZYME_FILTER_AND");
exports.isEnzymeFilterAndUpdate = isEnzymeFilterAndUpdate;
var filteredRestrictionEnzymesReset = (0, _createMetaAction["default"])("FILTERED_RESTRICTION_ENZYMES_RESET");
exports.filteredRestrictionEnzymesReset = filteredRestrictionEnzymesReset;
var filteredRestrictionEnzymesAdd = (0, _createMetaAction["default"])("FILTERED_RESTRICTION_ENZYMES_ADD");
// ------------------------------------
// Reducer
// ------------------------------------
exports.filteredRestrictionEnzymesAdd = filteredRestrictionEnzymesAdd;
var defaultInitialState = [_specialCutsiteFilterOptions["default"].single];
// let initialState = defaultInitialState;
// const localDefault = window.localStorage.getItem("tgInitialCutsiteFilter");

// if (localDefault) {
//   try {
//     initialState = JSON.parse(localDefault);
//     if (!Array.isArray(initialState)) throw new Error("Must be an array");
//   } catch (e) {
//     initialState = defaultInitialState;
//   }
// }
var _default = (0, _redux.combineReducers)({
  //filteredRestrictionEnzymes refer to the enzymes actively included in the react-select filter component
  isEnzymeFilterAnd: (0, _reduxAct.createReducer)((_createReducer = {}, _createReducer[isEnzymeFilterAndUpdate] = function (state, payload) {
    return payload;
  }, _createReducer), false),
  filteredRestrictionEnzymes: (0, _reduxAct.createReducer)((_createReducer2 = {}, _createReducer2[filteredRestrictionEnzymesReset] = function () {
    return defaultInitialState;
  }, _createReducer2[filteredRestrictionEnzymesUpdate] = function (state, payload) {
    return payload;
  }, _createReducer2[filteredRestrictionEnzymesAdd] = function (state, payload) {
    return [].concat(state, [payload]);
  }, _createReducer2), defaultInitialState)
});
exports["default"] = _default;