"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _lodash = require("lodash");
var _reselect = require("reselect");
var _sequenceUtils = require("@teselagen/sequence-utils");
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _default = (0, _reselect.createSelector)(function () {
  return _sequenceUtils.defaultEnzymesByName;
}, function (state, additionalEnzymes) {
  return additionalEnzymes;
}, function () {
  return localStorage.getItem("enzymeGroups");
},
//it should recompute if the enzyme groups change in localstorage
function (defaultEnzymesByName, additionalEnzymes) {
  var enzymesFromGroups = {};
  (0, _lodash.forEach)(window.getExistingEnzymeGroups(), function (group) {
    (0, _lodash.forEach)(group, function (enzymeName) {
      var enzyme = _extends({}, _sequenceUtils.aliasedEnzymesByName, additionalEnzymes)[enzymeName.toLowerCase()];
      if (!enzyme) {
        console.warn("ruh roh, no enzyme found for: ", enzymeName);
      } else {
        enzymesFromGroups[enzymeName.toLowerCase()] = enzyme;
      }
    });
  });
  return _extends({}, defaultEnzymesByName, additionalEnzymes, enzymesFromGroups);
});
exports["default"] = _default;
module.exports = exports.default;