function unwrapCoordinateListLikeInput(coordinateList) {
    if (Array.isArray(coordinateList)) {
        if (Array.isArray(coordinateList[0])) return coordinateList[0];
    }
    return coordinateList;
}
function parseCoordinateList(input, label) {
    const unwrapped = unwrapCoordinateListLikeInput(input);
    const values = 'string' == typeof unwrapped ? unwrapped.trim().split(/[\s,]+/).filter(Boolean) : unwrapped;
    if (!Array.isArray(values)) throw new Error(`invalid ${label} data: ${JSON.stringify(input)} `);
    const numericValues = values.map((value)=>'number' == typeof value ? value : Number(value));
    if (!numericValues.every((value)=>Number.isFinite(value))) throw new Error(`invalid ${label} data: ${JSON.stringify(input)} `);
    return numericValues;
}
function parseNumericLocateResult(resolvedCoordinates, input) {
    if ('point' === resolvedCoordinates.shape) {
        const point = parseCoordinateList(input, 'point');
        if (point.length < 2) throw new Error(`invalid point data: ${JSON.stringify(input)} `);
        return {
            type: 'point',
            coordinates: [
                point[0],
                point[1]
            ]
        };
    }
    const bbox = parseCoordinateList(input, 'bbox');
    if (4 !== bbox.length) throw new Error(`invalid bbox data: ${JSON.stringify(input)} `);
    return {
        type: 'bbox',
        coordinates: [
            bbox[0],
            bbox[1],
            bbox[2],
            bbox[3]
        ]
    };
}
export { parseNumericLocateResult, unwrapCoordinateListLikeInput };

//# sourceMappingURL=parse.mjs.map