"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.insertContentDeleteRange = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _state = require("@atlaskit/editor-prosemirror/state");
var insertContentDeleteRange = exports.insertContentDeleteRange = function insertContentDeleteRange(tr, getSelectionResolvedPos, insertions, deletions) {
  insertions.forEach(function (contentInsert) {
    var _contentInsert = (0, _slicedToArray2.default)(contentInsert, 2),
      content = _contentInsert[0],
      pos = _contentInsert[1];
    tr.insert(tr.mapping.map(pos), content);
  });
  deletions.forEach(function (deleteRange) {
    var _deleteRange = (0, _slicedToArray2.default)(deleteRange, 2),
      firstPos = _deleteRange[0],
      lastPos = _deleteRange[1];
    tr.delete(tr.mapping.map(firstPos), tr.mapping.map(lastPos));
  });
  tr.setSelection(new _state.TextSelection(getSelectionResolvedPos(tr)));
};