"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("../_vendor/@codemirror/state/dist-index.cjs");
const createAddCursor = (direction) => (view) => {
  const forward = direction === "down";
  let selection = view.state.selection;
  for (const r of selection.ranges) {
    selection = selection.addRange(view.moveVertically(r, forward));
  }
  view.dispatch({ selection });
  return true;
};
const addCursorUp = createAddCursor("up");
const addCursorDown = createAddCursor("down");
const addCursorAtEachSelectionLine = (view) => {
  let selection = null;
  for (const r of view.state.selection.ranges) {
    if (r.empty) {
      continue;
    }
    for (let pos = r.from; pos <= r.to; ) {
      const line = view.state.doc.lineAt(pos);
      const anchor = Math.min(line.to, r.to);
      if (selection) {
        selection = selection.addRange(index.EditorSelection.range(anchor, anchor));
      } else {
        selection = index.EditorSelection.single(anchor);
      }
      pos = line.to + 1;
    }
  }
  if (!selection) {
    return false;
  }
  view.dispatch({ selection });
  return true;
};
exports.addCursorAtEachSelectionLine = addCursorAtEachSelectionLine;
exports.addCursorDown = addCursorDown;
exports.addCursorUp = addCursorUp;
//# sourceMappingURL=multi-cursor.cjs.map
