"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportNameSelector = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const rebass_1 = require("rebass");
const Select_1 = require("../../components/Select");
const AdaptableContext_1 = require("../AdaptableContext");
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
const ReportNameSelector = (props) => {
    const { reportName, onReportNameSelected, size = 'normal' } = props;
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const exportApi = adaptable.api.exportApi;
    const allReportNames = exportApi.internalApi.getAllAvailableReportNames();
    const reportItems = allReportNames.map((report) => {
        return {
            label: report,
            value: report,
        };
    });
    const elementType = props.viewType === 'Toolbar' ? 'DashboardToolbar' : 'ToolPanel';
    return (react_1.default.createElement(rebass_1.Flex, { flex: 1, minWidth: props.viewType !== 'StatusBar' ? 160 : undefined },
        react_1.default.createElement(Select_1.Select, { style: { width: '100%' }, size: size, "data-name": "report-name-selector", placeholder: GeneralConstants_1.SELECT_REPORT_STRING, disabled: !allReportNames.length, className: `ab-${elementType}__Export__report-select`, options: reportItems, onChange: (report) => onReportNameSelected(report), value: reportName, isClearable: true })));
};
exports.ReportNameSelector = ReportNameSelector;
