"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _reselect = require("reselect");
var _partsSelector = _interopRequireDefault(require("./partsSelector"));
var _tagsToBoldSelector = _interopRequireDefault(require("./tagsToBoldSelector"));
var _lodash = require("lodash");
var _sequenceLengthSelector = _interopRequireDefault(require("./sequenceLengthSelector"));
var _editorUtils = require("../utils/editorUtils");
var _addWrappedAddons = require("../utils/addWrappedAddons");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function filteredPartsSelector(parts, seqLen, partIndividualToHide, tagsToBold, lengthsToHide) {
  if (tagsToBold) {
    var keyedTagsToBold = (0, _lodash.keyBy)(tagsToBold, "value");
    return (0, _lodash.map)(parts || {}, function (p) {
      if (p.tags) {
        if ((0, _lodash.some)(p.tags, function (tagId) {
          return keyedTagsToBold[tagId];
        })) {
          return _extends({}, p, {
            className: "partWithSelectedTag",
            labelClassName: "partWithSelectedTag",
            highPriorityLabel: true
          });
        } else {
          return p;
        }
      }
    });
  }
  var toRet = (0, _lodash.map)((0, _lodash.omitBy)(parts, function (ann) {
    var hideIndividually = partIndividualToHide[ann.id];
    return (0, _editorUtils.hideAnnByLengthFilter)(lengthsToHide, ann, seqLen) || hideIndividually;
  }));
  return (0, _addWrappedAddons.addWrappedAddons)(toRet, seqLen);
}
var _default = (0, _reselect.createSelector)(_partsSelector["default"], _sequenceLengthSelector["default"], function (state) {
  return state.annotationVisibility.partIndividualToHide;
}, _tagsToBoldSelector["default"], function (state) {
  return state.partLengthsToHide;
}, filteredPartsSelector);
exports["default"] = _default;
module.exports = exports.default;