import { __exports as commands } from '../../../../_virtual/commands.js';
import { __require as requireActions } from './actions.js';

var hasRequiredCommands;

function requireCommands () {
	if (hasRequiredCommands) return commands;
	hasRequiredCommands = 1;
	(function (exports$1) {
		Object.defineProperty(exports$1, "__esModule", { value: true });
		exports$1.getAllMappings = exports$1.unregisterKey = exports$1.registerGlobalCommand = exports$1.executeCommand = exports$1.COMMANDS = exports$1.prefixPreservingKeys = void 0;
		var Actions = requireActions();
		exports$1.prefixPreservingKeys = {
		    "M-g": true,
		    "C-x": true,
		    "C-q": true,
		    "C-u": true,
		};
		var setMarkAction = new Actions.SetMark();
		var undoAction = new Actions.UndoAction();
		var moveCursorDown = new Actions.MoveCursorDown();
		var moveCursorUp = new Actions.MoveCursorUp();
		var moveCursorRight = new Actions.MoveCursorRight();
		var moveCursorLeft = new Actions.MoveCursorLeft();
		exports$1.COMMANDS = {
		    'M-/': {
		        description: '',
		        action: 'editor.action.triggerSuggest',
		    },
		    'C-\'': {
		        description: '',
		        action: 'editor.action.triggerSuggest',
		    },
		    'M-;': {
		        description: '',
		        action: 'editor.action.commentLine',
		    },
		    'C-t': {
		        description: '',
		        action: 'editor.action.transposeLetters',
		    },
		    'C-x C-p': {
		        description: '',
		        action: 'editor.action.selectAll',
		    },
		    'Tab': {
		        description: '',
		        action: 'editor.action.formatDocument',
		    },
		    'C-Backspace': {
		        description: '',
		        action: 'deleteWordLeft',
		    },
		    'C-d': {
		        description: '',
		        action: 'deleteRight',
		    },
		    'M-Backspace': {
		        description: '',
		        action: 'deleteWordLeft',
		    },
		    'M-Delete': {
		        description: '',
		        action: 'deleteWordLeft',
		    },
		    'C-x C-u': {
		        description: '',
		        action: 'editor.action.transformToUppercase',
		    },
		    'C-x C-l': {
		        description: '',
		        action: 'editor.action.transformToLowercase',
		    },
		    'C-v': {
		        description: '',
		        action: 'cursorPageDown',
		    },
		    'PageDown': {
		        description: '',
		        action: 'cursorPageDown',
		    },
		    'M-v': {
		        description: '',
		        action: 'cursorPageUp',
		    },
		    'PageUp': {
		        description: '',
		        action: 'cursorPageUp',
		    },
		    'M-g n': {
		        description: '',
		        action: 'editor.action.marker.next',
		    },
		    'M-g p': {
		        description: '',
		        action: 'editor.action.marker.prev',
		    },
		    'M-C-n': {
		        description: '',
		        action: 'editor.action.addSelectionToNextFindMatch',
		    },
		    'C-h': {
		        description: '',
		        action: 'deleteLeft',
		    },
		    'M-d': {
		        description: '',
		        action: 'deleteWordRight',
		    },
		    'S-C-': {
		        description: '',
		        action: 'editor.action.triggerParameterHints',
		    },
		    'C-SPC': setMarkAction,
		    'S-C-2': setMarkAction,
		    'C-/': undoAction,
		    'S-C--': undoAction,
		    'C-z': undoAction,
		    'C-x u': undoAction,
		    'C-n': moveCursorDown,
		    'C-p': moveCursorUp,
		    'C-f': moveCursorRight,
		    'C-b': moveCursorLeft,
		    'S-C-Backspace': new Actions.DeleteLines(),
		    'M-f': new Actions.MoveCursorWordRight(),
		    'M-b': new Actions.MoveCursorWordLeft(),
		    'C-k': new Actions.KillLines(),
		    'C-m': new Actions.InsertLineAfter(),
		    'C-w': new Actions.KillSelection(),
		    'C-o': new Actions.InsertLineBelow(),
		    'C-g': new Actions.KeyBoardQuit(),
		    'C-e': new Actions.MoveCursorToLineEnd(),
		    'C-a': new Actions.MoveCursorToLineStart(),
		    'C-y': new Actions.Yank(),
		    'M-w': new Actions.YankSelectionToRing(),
		    'M-y': new Actions.YankRotate(),
		    'C-l': new Actions.RevealToCenterAction(),
		    'C-q Tab': new Actions.InsertTabs(),
		    'M-r': new Actions.RotateCursorOnScreen(),
		    'M-g g': new Actions.GotoLine(),
		    'M-g M-g': new Actions.GotoLine(),
		    'C-x C-x': new Actions.InvertSelection(),
		    'S-M-.': new Actions.MoveCursorBottom(),
		    'S-M-,': new Actions.MoveCursorTop(),
		    'C-s': new Actions.Search(),
		    'C-r': new Actions.Search(),
		    'S-M-5': new Actions.SearchReplace(),
		};
		function executeCommand(ext, command, inputBuffer, repeatedTrigger) {
		    var editor = ext.getEditor();
		    var repeat = parseInt(inputBuffer) || 1;
		    if (command.run) {
		        command.run(editor, ext, repeat, repeatedTrigger);
		        return;
		    }
		    if (typeof command.action === 'string') {
		        for (var i = 0; i < repeat; i++) {
		            editor.trigger(Actions.SOURCE, command.action, null);
		        }
		    }
		    else if (Array.isArray(command.action)) {
		        for (var i = 0; i < repeat; i++) {
		            command.action.forEach(function (cmd) {
		                editor.trigger(Actions.SOURCE, cmd, null);
		            });
		        }
		    }
		}
		exports$1.executeCommand = executeCommand;
		function registerGlobalCommand(key, command) {
		    exports$1.COMMANDS[key] = command;
		}
		exports$1.registerGlobalCommand = registerGlobalCommand;
		function unregisterKey(key) {
		    if (exports$1.COMMANDS[key]) {
		        delete exports$1.COMMANDS[key];
		    }
		}
		exports$1.unregisterKey = unregisterKey;
		function getAllMappings() {
		    var result = {};
		    Object.keys(exports$1.COMMANDS).forEach(function (key) {
		        result[key] = exports$1.COMMANDS[key].description;
		    });
		    return result;
		}
		exports$1.getAllMappings = getAllMappings; 
	} (commands));
	return commands;
}

export { requireCommands as __require };
