
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { isMacintosh } from '../../../../base/common/platform.js';
import { localize2, localize } from '../../../../nls.js';
import { Action2, registerAction2, MenuRegistry, MenuId } from '../../../../platform/actions/common/actions.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.service.js';
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.service.js';
import { Registry } from '../../../../platform/registry/common/platform.js';
import { Extensions } from '../../../common/contributions.js';
import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';

class ToggleMultiCursorModifierAction extends Action2 {
    static {
        this.ID = "workbench.action.toggleMultiCursorModifier";
    }
    static {
        this.multiCursorModifierConfigurationKey = "editor.multiCursorModifier";
    }
    constructor() {
        super({
            id: ToggleMultiCursorModifierAction.ID,
            title: ( localize2(8486, "Toggle Multi-Cursor Modifier")),
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        const editorConf = configurationService.getValue("editor");
        const newValue = (editorConf.multiCursorModifier === "ctrlCmd" ? "alt" : "ctrlCmd");
        return configurationService.updateValue(
            ToggleMultiCursorModifierAction.multiCursorModifierConfigurationKey,
            newValue
        );
    }
}
const multiCursorModifier = ( new RawContextKey("multiCursorModifier", "altKey"));
let MultiCursorModifierContextKeyController = class MultiCursorModifierContextKeyController extends Disposable {
    constructor(configurationService, contextKeyService) {
        super();
        this.configurationService = configurationService;
        this._multiCursorModifier = multiCursorModifier.bindTo(contextKeyService);
        this._update();
        this._register(configurationService.onDidChangeConfiguration(e => {
            if (e.affectsConfiguration("editor.multiCursorModifier")) {
                this._update();
            }
        }));
    }
    _update() {
        const editorConf = this.configurationService.getValue("editor");
        const value = (editorConf.multiCursorModifier === "ctrlCmd" ? "ctrlCmd" : "altKey");
        this._multiCursorModifier.set(value);
    }
};
MultiCursorModifierContextKeyController = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IContextKeyService))], MultiCursorModifierContextKeyController));
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(MultiCursorModifierContextKeyController, LifecyclePhase.Restored);
registerAction2(ToggleMultiCursorModifierAction);
MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, {
    group: "4_config",
    command: {
        id: ToggleMultiCursorModifierAction.ID,
        title: ( localize(8487, "Switch to Alt+Click for Multi-Cursor"))
    },
    when: ( multiCursorModifier.isEqualTo("ctrlCmd")),
    order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, {
    group: "4_config",
    command: {
        id: ToggleMultiCursorModifierAction.ID,
        title: (isMacintosh ? ( localize(8488, "Switch to Cmd+Click for Multi-Cursor")) : ( localize(8489, "Switch to Ctrl+Click for Multi-Cursor")))
    },
    when: ( multiCursorModifier.isEqualTo("altKey")),
    order: 1
});

export { ToggleMultiCursorModifierAction };
