"use strict";

exports.__esModule = true;
exports.searchableTypes = exports["default"] = void 0;
var _reselect = require("reselect");
var _lodash = require("lodash");
var searchableTypes = ["parts", "features", "primers"];
exports.searchableTypes = searchableTypes;
function annotationSearchSelector(isOpen, searchString) {
  for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
    rest[_key - 2] = arguments[_key];
  }
  if (!searchString || !isOpen) {
    return [];
  }
  return searchableTypes.map(function (type, i) {
    var annotations = rest[i];
    return (0, _lodash.filter)(annotations, function (ann) {
      return ann.name.toLowerCase().includes(searchString ? searchString.toLowerCase() : "");
    });
  });
}
var _default = _reselect.createSelector.apply(void 0, [function (state) {
  return state.findTool && state.findTool.isOpen;
}, function (state) {
  return state.findTool && state.findTool.searchText;
}].concat(searchableTypes.map(function (type) {
  return function (state) {
    return state.sequenceData[type];
  };
}), [annotationSearchSelector]));
exports["default"] = _default;