"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolPanelApiImpl = void 0;
const tslib_1 = require("tslib");
const ApiBase_1 = require("./ApiBase");
const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
const ToolPanelRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/ToolPanelRedux"));
const ToolPanelRedux_1 = require("../../Redux/ActionsReducers/ToolPanelRedux");
class ToolPanelApiImpl extends ApiBase_1.ApiBase {
    getToolPanelState() {
        return this.getAdaptableState().ToolPanel;
    }
    showToolPanelPopup() {
        this.showModulePopup(ModuleConstants.ToolPanelModuleId);
    }
    openAdapTableToolPanel() {
        const agGridApi = this.getAgGridApi();
        if (agGridApi) {
            agGridApi.openToolPanel('adaptable');
        }
    }
    closeAdapTableToolPanel() {
        const agGridApi = this.getAgGridApi();
        if (agGridApi) {
            agGridApi.closeToolPanel();
        }
    }
    getCustomToolPanels() {
        var _a;
        return (_a = this.getToolPanelOptions().customToolPanels) !== null && _a !== void 0 ? _a : [];
    }
    getCustomToolPanelButtons() {
        var _a;
        return (_a = this.getToolPanelOptions().customButtons) !== null && _a !== void 0 ? _a : [];
    }
    getCustomToolPanelByName(name) {
        return this.getCustomToolPanels().find((customToolPanel) => customToolPanel.name === name);
    }
    setAdaptableToolPanelVisibilityMode(adaptableToolPanel, visibilityMode) {
        if (visibilityMode === 'expanded') {
            this.setExpandedToolPanelVisibility(adaptableToolPanel);
        }
        else {
            this.setCollapsedToolPanelVisibility(adaptableToolPanel);
        }
    }
    setCustomToolPanelVisibilityMode(customToolPanelName, visibilityMode) {
        if (visibilityMode === 'expanded') {
            this.setExpandedToolPanelVisibility(customToolPanelName);
        }
        else {
            this.setCollapsedToolPanelVisibility(customToolPanelName);
        }
    }
    setModuleButtons(moduleButtons) {
        this.dispatchAction((0, ToolPanelRedux_1.ToolPanelSetModuleButtons)(moduleButtons));
    }
    getModuleButtons() {
        var _a, _b;
        return (_b = (_a = this.getToolPanelState()) === null || _a === void 0 ? void 0 : _a.ModuleButtons) !== null && _b !== void 0 ? _b : [];
    }
    setExpandedToolPanelVisibility(toolPanelName) {
        this.dispatchAction(ToolPanelRedux.ToolPanelExpandToolPanel(toolPanelName));
    }
    setCollapsedToolPanelVisibility(toolPanelName) {
        this.dispatchAction(ToolPanelRedux.ToolPanelCollapseToolPanel(toolPanelName));
    }
}
exports.ToolPanelApiImpl = ToolPanelApiImpl;
