"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShortcutApiImpl = void 0;
const tslib_1 = require("tslib");
const ShortcutRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/ShortcutRedux"));
const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
const ApiBase_1 = require("./ApiBase");
class ShortcutApiImpl extends ApiBase_1.ApiBase {
    getShortcutState() {
        return this.getAdaptableState().Shortcut;
    }
    getShortcuts(config) {
        return (this.handleLayoutExtensionObjects(this.getShortcutState().Shortcuts, 'Shortcut', config) ?? []);
    }
    getShortcutById(id, config) {
        return this.getShortcuts(config).find((shortcut) => shortcut?.Uuid === id);
    }
    getActiveShortcuts(config) {
        return this.getShortcuts(config).filter((shortcut) => !shortcut.IsSuspended);
    }
    getSuspendedShortcuts(config) {
        return this.getShortcuts(config).filter((shortcut) => shortcut.IsSuspended);
    }
    addShortcut(shortcut) {
        this.addUidToAdaptableObject(shortcut);
        this.dispatchAction(ShortcutRedux.ShortcutAdd(shortcut));
        return this.getShortcutById(shortcut.Uuid);
    }
    deleteShortcut(shortcut) {
        this.dispatchAction(ShortcutRedux.ShortcutDelete(shortcut));
    }
    deleteAllShortcuts() {
        this.getShortcuts().forEach((s) => {
            this.deleteShortcut(s);
        });
    }
    suspendShortcut(shortcut) {
        this.dispatchAction(ShortcutRedux.ShortcutSuspend(shortcut));
        return this.getShortcutById(shortcut.Uuid);
    }
    unSuspendShortcut(shortcut) {
        this.dispatchAction(ShortcutRedux.ShortcutUnSuspend(shortcut));
        return this.getShortcutById(shortcut.Uuid);
    }
    suspendAllShortcut() {
        this.dispatchAction(ShortcutRedux.ShortcutSuspendAll());
    }
    unSuspendAllShortcut() {
        this.dispatchAction(ShortcutRedux.ShortcutUnSuspendAll());
    }
    openShortcutSettingsPanel() {
        this.showModulePopup(ModuleConstants.ShortcutModuleId);
    }
}
exports.ShortcutApiImpl = ShortcutApiImpl;
