/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { p as point, l as line3 } from './bundle-DfdVaPrt.js';

function translateWorldLineToViewport(line, params) {
    const { camera, viewport } = params;
    const isStartBehindCamera = camera.isPointBehindNear(line.start);
    const isEndBehindCamera = camera.isPointBehindNear(line.end);
    // If either the start or end of the line is behind the camera, then we need
    // to truncate the line so it can be presented correctly. You cannot use a
    // projection matrix to compute a point behind the near plane.
    if (isStartBehindCamera || isEndBehindCamera) {
        const pt = camera.intersectLineWithNear(line);
        const newLine = line3.create({
            start: isStartBehindCamera && pt != null ? pt : line.start,
            end: isEndBehindCamera && pt != null ? pt : line.end,
        });
        const ndc = line3.transformMatrix(newLine, camera.projectionViewMatrix);
        return {
            start: viewport.transformVectorToViewport(ndc.start),
            end: viewport.transformVectorToViewport(ndc.end),
            hideStart: isStartBehindCamera,
            hideEnd: isEndBehindCamera,
        };
    }
    else {
        const ndc = line3.transformMatrix(line, camera.projectionViewMatrix);
        return {
            start: viewport.transformVectorToViewport(ndc.start),
            end: viewport.transformVectorToViewport(ndc.end),
            hideStart: false,
            hideEnd: false,
        };
    }
}
function getViewingElementPositions(line, interactingAnchor, params) {
    const { start: startPt, end: endPt, hideStart, hideEnd, } = translateWorldLineToViewport(line, params);
    const labelPt = point.lerp(startPt, endPt, 0.5);
    const indicatorPt = interactingAnchor !== 'none'
        ? getIndicatorPtForAnchor(line, interactingAnchor, params)
        : undefined;
    return { startPt, endPt, labelPt, indicatorPt, hideStart, hideEnd };
}
function getIndicatorPtForAnchor(line, anchor, params) {
    return params.viewport.transformWorldToViewport(anchor === 'start' ? line.start : line.end, params.camera.projectionViewMatrix);
}

export { getViewingElementPositions as g, translateWorldLineToViewport as t };
//# sourceMappingURL=utils-ZqsjY8Af.js.map

//# sourceMappingURL=utils-ZqsjY8Af.js.map