"use strict";
/**
 * 数值型组件（NumberPicker、Range、Rating 等）的 value 校验与过滤
 * 用于：getList payload 过滤、tag 初始值、展示层「未填写」判断等
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNumericColumnType = isNumericColumnType;
exports.filterValueForNumericColumn = filterValueForNumericColumn;
const NUMERIC_COLUMN_TYPES = new Set([
    'NumberPicker',
    'CnNumberPicker',
    'Range',
    'CnRange',
    'Rating',
    'CnRating',
    'RangeNumberPicker',
]);
function isNumericColumnType(columnType) {
    return !!columnType && NUMERIC_COLUMN_TYPES.has(columnType);
}
/**
 * 只保留可解析为数字的值，非法值（如后端误返的 label 字符串）返回 undefined
 */
function filterValueForNumericColumn(value) {
    if (value === null || value === undefined)
        return undefined;
    const toNumber = (v) => {
        if (typeof v === 'number' && !Number.isNaN(v))
            return v;
        if (typeof v === 'string') {
            const trimmed = v.trim();
            if (trimmed === '')
                return undefined;
            const n = Number(trimmed);
            return Number.isNaN(n) ? undefined : n;
        }
        return undefined;
    };
    if (Array.isArray(value)) {
        const numbers = value.map(toNumber).filter((n) => n !== undefined);
        if (numbers.length === 0)
            return undefined;
        return numbers.length === 1 ? numbers[0] : numbers;
    }
    const single = toNumber(value);
    return single === undefined ? undefined : single;
}
