"use strict";

exports.__esModule = true;
exports.getGaps = void 0;
var _getGapMap = require("./getGapMap");
/**
 * this function is used to calculate the number of spaces that come before or inside a range
 */
var getGaps = function getGaps() {
  return {
    gapsBefore: 0,
    gapsInside: 0
  };
};
exports.getGaps = getGaps;
exports.getGaps = getGaps = function getGaps(rangeOrCaretPosition, sequence) {
  var gapMap = (0, _getGapMap.getGapMap)(sequence);
  if (typeof rangeOrCaretPosition !== "object") {
    return {
      gapsBefore: gapMap[Math.min(rangeOrCaretPosition, gapMap.length - 1)]
    };
  }
  //otherwise it is a range!
  var start = rangeOrCaretPosition.start,
    end = rangeOrCaretPosition.end;
  var toReturn = {
    gapsBefore: gapMap[start],
    gapsInside: gapMap[Math.min(end, gapMap.length - 1)] - gapMap[Math.min(start, gapMap.length - 1)]
  };
  return toReturn;
};