"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSetApiImpl = void 0;
const tslib_1 = require("tslib");
const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
const InternalRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/InternalRedux"));
const ApiBase_1 = require("./ApiBase");
const DataSetInternalApi_1 = require("../Internal/DataSetInternalApi");
class DataSetApiImpl extends ApiBase_1.ApiBase {
    internalApi;
    constructor(_adaptable) {
        super(_adaptable);
        this.internalApi = new DataSetInternalApi_1.DataSetInternalApi(_adaptable);
    }
    getDataSets() {
        return this.getDataSetOptions()?.dataSets ?? [];
    }
    getCurrentDataSet() {
        let currentDataSetName = this.getAdaptableState().Internal.CurrentDataSet;
        return this.getDataSetByName(currentDataSetName);
    }
    getDataSetByName(dataSetName) {
        return this.getDataSets().find((a) => a.name == dataSetName);
    }
    setDataSet(dataSetName) {
        const dataSet = this.getDataSetByName(dataSetName);
        if (this.checkItemExists(dataSet, dataSetName, 'Data Source')) {
            this.dispatchAction(InternalRedux.DataSetSelect(dataSet));
        }
    }
    clearCurrentDataSet() {
        this.dispatchAction(InternalRedux.DataSetSelect(null));
    }
    openDataSetSettingsPanel() {
        this.showModulePopup(ModuleConstants.DataSetModuleId);
    }
}
exports.DataSetApiImpl = DataSetApiImpl;
