/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { Mapper as M } from "@vertexvis/utils";
import { fromPbPlane, fromPbVector3f } from "../mappers";
const mapPlanePair = M.defineMapper(M.read(M.mapRequiredProp('start', fromPbPlane), M.mapRequiredProp('end', fromPbPlane)), ([start, end]) => ({ start, end }));
const mapPlanarDistance = M.defineMapper(M.read(M.getProp('distance'), M.mapRequiredProp('planes', M.compose(mapPlanePair, M.requiredProp('start'))), M.mapRequiredProp('planes', M.compose(mapPlanePair, M.requiredProp('end')))), ([distance, plane1, plane2]) => ({
    type: 'planar-distance',
    distance,
    plane1,
    plane2,
}));
const mapPlanarAngle = M.defineMapper(M.read(M.getProp('angleInRadians'), M.mapRequiredProp('planes', M.compose(mapPlanePair, M.requiredProp('start'))), M.mapRequiredProp('planes', M.compose(mapPlanePair, M.requiredProp('end')))), ([angle, plane1, plane2]) => ({
    type: 'planar-angle',
    angle,
    plane1,
    plane2,
}));
const mapMinimumDistance = M.defineMapper(M.read(M.getProp('distance'), M.mapRequiredProp('closestPoint1', fromPbVector3f), M.mapRequiredProp('closestPoint2', fromPbVector3f)), ([distance, point1, point2]) => ({
    type: 'minimum-distance',
    distance,
    point1,
    point2,
}));
const mapSurfaceArea = M.defineMapper(M.read(M.getProp('area')), ([area]) => ({
    type: 'surface-area',
    area,
}));
const mapPlanarDistanceFromResult = M.mapProp('planarDistance', M.ifDefined(mapPlanarDistance));
const mapPlanarAngleFromResult = M.mapProp('planarAngle', M.ifDefined(mapPlanarAngle));
const mapMinimumDistanceFromResult = M.mapProp('minimumDistance', M.ifDefined(mapMinimumDistance));
const mapSurfaceAreaFromResult = M.mapProp('totalSurfaceArea', M.ifDefined(mapSurfaceArea));
const mapMeasurementResult = M.compose(M.pickFirst(mapPlanarDistanceFromResult, mapPlanarAngleFromResult, mapMinimumDistanceFromResult, mapSurfaceAreaFromResult), M.required('Result field'));
export const mapMeasureResponse = M.defineMapper(M.read(M.mapRequiredProp('outcome', M.mapRequiredProp('resultsList', M.mapArray(mapMeasurementResult))), M.mapRequiredProp('outcome', M.getProp('isApproximate'))), ([results, isApproximate]) => ({ results, isApproximate }));
export const mapMeasureResponseOrThrow = M.ifInvalidThrow(mapMeasureResponse);
//# sourceMappingURL=mapper.js.map
