"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.countListItemsInSelection = void 0;
var _utils = require("../utils");
var countListItemsInSelection = exports.countListItemsInSelection = function countListItemsInSelection(tr) {
  var _tr$selection = tr.selection,
    from = _tr$selection.from,
    to = _tr$selection.to;
  if (from === to) {
    return 1;
  }
  var count = 0;
  var listSlice = tr.doc.cut(from, to);
  listSlice.content.nodesBetween(0, listSlice.content.size, function (node, pos, parent, index) {
    if (parent && (0, _utils.isListItemNode)(parent) && !(0, _utils.isListNode)(node) && index === 0) {
      count++;
    }
  });
  return count;
};