import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants';
import * as InternalRedux from '../../Redux/ActionsReducers/InternalRedux';
import { ApiBase } from './ApiBase';
import { DataSetInternalApi } from '../Internal/DataSetInternalApi';
export class DataSetApiImpl extends ApiBase {
    internalApi;
    constructor(_adaptable) {
        super(_adaptable);
        this.internalApi = new 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);
    }
}
