"use strict";

exports.__esModule = true;
exports.addWrappedAddons = addWrappedAddons;
var _lodash = require("lodash");
var _rangeUtils = require("@teselagen/range-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); }
function addWrappedAddons(anns, seqLen) {
  return (0, _lodash.flatMap)(anns, function (ann) {
    if (ann.overlapsSelf) {
      return [ann, _extends({}, ann, {
        start: (0, _rangeUtils.normalizePositionByRangeLength)(ann.end + 1, seqLen),
        end: (0, _rangeUtils.normalizePositionByRangeLength)(ann.start - 1, seqLen),
        isWrappedAddon: true,
        rangeTypeOverride: "middle" //we add this rangeTypeOverride here to get the wrapping piece to draw differently than normal
      })];
    }

    return [ann];
  });
}