import { registerEditorCommand } from "../../../browser/editorExtensions.mjs";
import { WordPartOperations } from "../../../common/cursor/cursorWordOperations.mjs";
import { Range } from "../../../common/core/range.mjs";
import { EditorContextKeys } from "../../../common/editorContextKeys.mjs";
import { DeleteWordCommand, MoveWordCommand } from "../../wordOperations/browser/wordOperations.mjs";
import { CommandsRegistry } from "../../../../platform/commands/common/commands.mjs";
class DeleteWordPartLeft extends DeleteWordCommand {
  constructor() {
    super({
      whitespaceHeuristics: true,
      wordNavigationType: 0,
      id: "deleteWordPartLeft",
      precondition: EditorContextKeys.writable,
      kbOpts: {
        kbExpr: EditorContextKeys.textInputFocus,
        primary: 0,
        mac: {
          primary: 256 | 512 | 1
          /* Backspace */
        },
        weight: 100
        /* EditorContrib */
      }
    });
  }
  _delete(ctx, wordNavigationType) {
    let r = WordPartOperations.deleteWordPartLeft(ctx);
    if (r) {
      return r;
    }
    return new Range(1, 1, 1, 1);
  }
}
class DeleteWordPartRight extends DeleteWordCommand {
  constructor() {
    super({
      whitespaceHeuristics: true,
      wordNavigationType: 2,
      id: "deleteWordPartRight",
      precondition: EditorContextKeys.writable,
      kbOpts: {
        kbExpr: EditorContextKeys.textInputFocus,
        primary: 0,
        mac: {
          primary: 256 | 512 | 20
          /* Delete */
        },
        weight: 100
        /* EditorContrib */
      }
    });
  }
  _delete(ctx, wordNavigationType) {
    let r = WordPartOperations.deleteWordPartRight(ctx);
    if (r) {
      return r;
    }
    const lineCount = ctx.model.getLineCount();
    const maxColumn = ctx.model.getLineMaxColumn(lineCount);
    return new Range(lineCount, maxColumn, lineCount, maxColumn);
  }
}
class WordPartLeftCommand extends MoveWordCommand {
  _move(wordSeparators, model, position, wordNavigationType) {
    return WordPartOperations.moveWordPartLeft(wordSeparators, model, position);
  }
}
class CursorWordPartLeft extends WordPartLeftCommand {
  constructor() {
    super({
      inSelectionMode: false,
      wordNavigationType: 0,
      id: "cursorWordPartLeft",
      precondition: void 0,
      kbOpts: {
        kbExpr: EditorContextKeys.textInputFocus,
        primary: 0,
        mac: {
          primary: 256 | 512 | 15
          /* LeftArrow */
        },
        weight: 100
        /* EditorContrib */
      }
    });
  }
}
CommandsRegistry.registerCommandAlias("cursorWordPartStartLeft", "cursorWordPartLeft");
class CursorWordPartLeftSelect extends WordPartLeftCommand {
  constructor() {
    super({
      inSelectionMode: true,
      wordNavigationType: 0,
      id: "cursorWordPartLeftSelect",
      precondition: void 0,
      kbOpts: {
        kbExpr: EditorContextKeys.textInputFocus,
        primary: 0,
        mac: {
          primary: 256 | 512 | 1024 | 15
          /* LeftArrow */
        },
        weight: 100
        /* EditorContrib */
      }
    });
  }
}
CommandsRegistry.registerCommandAlias("cursorWordPartStartLeftSelect", "cursorWordPartLeftSelect");
class WordPartRightCommand extends MoveWordCommand {
  _move(wordSeparators, model, position, wordNavigationType) {
    return WordPartOperations.moveWordPartRight(wordSeparators, model, position);
  }
}
class CursorWordPartRight extends WordPartRightCommand {
  constructor() {
    super({
      inSelectionMode: false,
      wordNavigationType: 2,
      id: "cursorWordPartRight",
      precondition: void 0,
      kbOpts: {
        kbExpr: EditorContextKeys.textInputFocus,
        primary: 0,
        mac: {
          primary: 256 | 512 | 17
          /* RightArrow */
        },
        weight: 100
        /* EditorContrib */
      }
    });
  }
}
class CursorWordPartRightSelect extends WordPartRightCommand {
  constructor() {
    super({
      inSelectionMode: true,
      wordNavigationType: 2,
      id: "cursorWordPartRightSelect",
      precondition: void 0,
      kbOpts: {
        kbExpr: EditorContextKeys.textInputFocus,
        primary: 0,
        mac: {
          primary: 256 | 512 | 1024 | 17
          /* RightArrow */
        },
        weight: 100
        /* EditorContrib */
      }
    });
  }
}
registerEditorCommand(new DeleteWordPartLeft());
registerEditorCommand(new DeleteWordPartRight());
registerEditorCommand(new CursorWordPartLeft());
registerEditorCommand(new CursorWordPartLeftSelect());
registerEditorCommand(new CursorWordPartRight());
registerEditorCommand(new CursorWordPartRightSelect());
export {
  CursorWordPartLeft,
  CursorWordPartLeftSelect,
  CursorWordPartRight,
  CursorWordPartRightSelect,
  DeleteWordPartLeft,
  DeleteWordPartRight,
  WordPartLeftCommand,
  WordPartRightCommand
};
