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); }
import { createSelector } from "reselect";
import partsSelector from "./partsSelector";
import tagsToBoldSelector from "./tagsToBoldSelector";
import { some, keyBy, omitBy } from "lodash";
import { map } from "lodash";
import sequenceLengthSelector from "./sequenceLengthSelector";
import { hideAnnByLengthFilter } from "../utils/editorUtils";
import { addWrappedAddons } from "../utils/addWrappedAddons";
function filteredPartsSelector(parts, seqLen, partIndividualToHide, tagsToBold, lengthsToHide) {
  if (tagsToBold) {
    var keyedTagsToBold = keyBy(tagsToBold, "value");
    return map(parts || {}, function (p) {
      if (p.tags) {
        if (some(p.tags, function (tagId) {
          return keyedTagsToBold[tagId];
        })) {
          return _extends({}, p, {
            className: "partWithSelectedTag",
            labelClassName: "partWithSelectedTag",
            highPriorityLabel: true
          });
        } else {
          return p;
        }
      }
    });
  }
  var toRet = map(omitBy(parts, function (ann) {
    var hideIndividually = partIndividualToHide[ann.id];
    return hideAnnByLengthFilter(lengthsToHide, ann, seqLen) || hideIndividually;
  }));
  return addWrappedAddons(toRet, seqLen);
}
export default createSelector(partsSelector, sequenceLengthSelector, function (state) {
  return state.annotationVisibility.partIndividualToHide;
}, tagsToBoldSelector, function (state) {
  return state.partLengthsToHide;
}, filteredPartsSelector);