"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeCascaderAndTreeValue = normalizeCascaderAndTreeValue;
const extract_primitive_value_1 = require("./extract-primitive-value");
/**
 * 标准化级联选择器/树形选择器的值
 */
function normalizeCascaderAndTreeValue(value, componentProps) {
    const isMultiple = (componentProps === null || componentProps === void 0 ? void 0 : componentProps.multiple) === true;
    if (isMultiple) {
        // 多选：确保返回数组
        if (!Array.isArray(value)) {
            return [(0, extract_primitive_value_1.extractPrimitiveValue)(value)];
        }
        return value.map(extract_primitive_value_1.extractPrimitiveValue);
    }
    else {
        // 单选：返回单个值
        if (Array.isArray(value)) {
            return value.length > 0 ? (0, extract_primitive_value_1.extractPrimitiveValue)(value[0]) : undefined;
        }
        return (0, extract_primitive_value_1.extractPrimitiveValue)(value);
    }
}
