import { keyType, Shortcut } from '@journeyapps-labs/reactor-mod';
import { MonacoMap } from './MonacoShortcutMap';
import { KeyCodeChord } from 'monaco-editor/esm/vs/base/common/keybindings.js';
export class MonacoShortcut extends Shortcut {
    dispose() {
        this.action.handler.store.unbindAction(this.action.id, [this.getAsMonacoPrimitive(true), this.getAsMonacoPrimitive(false)].filter((p) => !!p));
    }
    getMonacoStoreAction() {
        return this.action.handler.store.getActionFromID(this.action.id);
    }
    getAsMonacoPrimitive(primary) {
        var _a;
        if (!primary && this.chord.secondary.length === 0) {
            return null;
        }
        return new KeyCodeChord(!!this.chord.getShortcutKey(keyType.CTRL, primary), !!this.chord.getShortcutKey(keyType.SHIFT, primary), !!this.chord.getShortcutKey(keyType.ALT, primary), !!this.chord.getShortcutKey(keyType.META, primary), MonacoMap[((_a = this.chord.getShortcutKey(keyType.STANDARD, primary)) === null || _a === void 0 ? void 0 : _a.key) || undefined]);
    }
    setChord(chord, fire = true) {
        super.setChord(chord, fire);
        this.action.handler.store.updateAction({
            action: this.getMonacoStoreAction(),
            binding: this.getAsMonacoPrimitive(true),
            binding2: this.getAsMonacoPrimitive(false)
        });
    }
}
//# sourceMappingURL=MonacoShortcut.js.map