"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSetSelector = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Radio_1 = tslib_1.__importDefault(require("../../components/Radio"));
const AdaptableContext_1 = require("../AdaptableContext");
const DataSetSelector = ({ data }) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const dataSets = adaptable.api.dataSetApi.getDataSets();
    const selectedDataSet = adaptable.api.dataSetApi.getCurrentDataSet();
    const isDisabled = dataSets?.length === 1;
    const isSelected = selectedDataSet?.name === data?.name;
    const handleToggle = React.useCallback(() => {
        adaptable.api.dataSetApi.setDataSet(data.name);
    }, [isSelected]);
    return (React.createElement(Radio_1.default, { "data-name": "select-dataset-button", "data-value": data.name, disabled: isDisabled, checked: isSelected, onClick: handleToggle }));
};
exports.DataSetSelector = DataSetSelector;
