"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Slate = require("slate");
const index = require("../../../../ContemberEditor/index.cjs");
const indentListItem = (editor, listItem, listItemPath) => {
  const previousListEntry = index.ContemberEditor.getPreviousSibling(
    editor,
    listItem,
    listItemPath
  );
  if (previousListEntry === void 0) {
    return false;
  }
  Slate.Editor.withoutNormalizing(editor, () => {
    const [parentListElement] = Slate.Editor.parent(editor, listItemPath);
    let [previousListItem, previousListItemPath] = previousListEntry;
    const lastPreviousListItemChild = previousListItem.children[previousListItem.children.length - 1];
    const previousEndsWithCompatibleList = Slate.Element.isElement(lastPreviousListItemChild) && index.ContemberEditor.isElementType(
      lastPreviousListItemChild,
      parentListElement.type,
      index.ContemberEditor.elementToSpecifics(parentListElement)
    );
    if (previousEndsWithCompatibleList) {
      const newListItemPath = [
        ...previousListItemPath,
        previousListItem.children.length - 1,
        lastPreviousListItemChild.children.length
      ];
      Slate.Transforms.moveNodes(editor, {
        at: listItemPath,
        to: newListItemPath
      });
    } else {
      const previousContainsInlines = Slate.Editor.hasInlines(editor, previousListItem);
      if (previousContainsInlines) {
        const [previousStart, previousEnd] = Slate.Editor.edges(editor, previousListItemPath);
        Slate.Transforms.wrapNodes(editor, editor.createDefaultElement([]), {
          match: (node) => Slate.Text.isText(node) || Slate.Element.isElement(node) && editor.isInline(node),
          at: {
            anchor: previousStart,
            focus: previousEnd
          }
        });
      }
      previousListItem = Slate.Node.get(editor, previousListItemPath);
      const newListItemPath = [...previousListItemPath, previousListItem.children.length];
      Slate.Transforms.moveNodes(editor, {
        at: listItemPath,
        to: newListItemPath
      });
      Slate.Transforms.wrapNodes(editor, { ...parentListElement, children: [] }, { at: newListItemPath });
    }
  });
  return true;
};
exports.indentListItem = indentListItem;
//# sourceMappingURL=indentListItem.cjs.map
