import { isEmpty } from "../../../utils";
const getLabel = ({ value, valueToItemMap, renderValue })=>{
    const label = valueToItemMap.get(value)?.label || value.toString();
    return renderValue ? renderValue(valueToItemMap.get(value) || {
        value,
        label
    }) : label;
};
export const getButtonLabel = ({ value, valueToItemMap, label, renderValue, multiselect, isTargetAmount })=>{
    if (isEmpty(value) && typeof value !== 'number') {
        return label || '';
    }
    if (multiselect && Array.isArray(value) && isTargetAmount) {
        return `Выбрано ${value.length}`;
    }
    if (multiselect && Array.isArray(value)) {
        return value?.map((itemValue)=>getLabel({
                value: itemValue,
                valueToItemMap,
                renderValue
            })).join(', ');
    }
    return getLabel({
        value,
        valueToItemMap,
        renderValue
    });
};
