import { Selection } from "./../../pm/state.js";
import { ReplaceAroundStep, ReplaceStep } from "./../../pm/transform.js";
function selectionToInsertionEnd(tr, startLen, bias) {
  const last = tr.steps.length - 1;
  if (last < startLen) {
    return;
  }
  const step = tr.steps[last];
  if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
    return;
  }
  const map = tr.mapping.maps[last];
  let end = 0;
  map.forEach((_from, _to, _newFrom, newTo) => {
    if (end === 0) {
      end = newTo;
    }
  });
  tr.setSelection(Selection.near(tr.doc.resolve(end), bias));
}
export {
  selectionToInsertionEnd
};
//# sourceMappingURL=selection-to-insertion-end.js.map
