import clamp from 'lodash/clamp';
export var getStepRange = function getStepRange(transaction) {
  var from = -1;
  var to = -1;
  transaction.mapping.maps.forEach(function (stepMap, index) {
    stepMap.forEach(function (oldStart, oldEnd) {
      var newStart = transaction.mapping.slice(index).map(oldStart, -1);
      var newEnd = transaction.mapping.slice(index).map(oldEnd);
      var docSize = transaction.doc.content.size;
      from = clamp(newStart < from || from === -1 ? newStart : from, 0, docSize);
      to = clamp(newEnd > to || to === -1 ? newEnd : to, 0, docSize);
    });
  });
  if (from !== -1) {
    return {
      from: from,
      to: to
    };
  }
  return null;
};