/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { v as vector3 } from './bundle-DfdVaPrt.js';
import { E as EventDispatcher, b as uuid } from './bundle-DLfw87TV.js';

class MeasurementOverlayManager {
    constructor() {
        this.overlays = new Map();
        this.overlaysChanged = new EventDispatcher();
    }
    addLineFromResult(result) {
        return this.addLine(result.point1, result.point2);
    }
    addLine(start, end) {
        const id = uuid.create();
        const overlay = {
            type: 'line',
            id: id,
            start,
            end,
            dispose: () => this.remove(id),
        };
        this.addOverlay(overlay);
        return overlay;
    }
    addDistanceVectorFromResult(result) {
        return this.addDistanceVector(result.point1, result.point2);
    }
    addDistanceVector(start, end) {
        const id = uuid.create();
        const v = vector3.subtract(start, end);
        const ye = vector3.add(start, vector3.create(0, -v.y, 0));
        const y = { start: start, end: ye };
        const ze = vector3.add(ye, vector3.create(0, 0, -v.z));
        const z = { start: ye, end: ze };
        const xe = vector3.add(ze, vector3.create(-v.x, 0, 0));
        const x = { start: ze, end: xe };
        const overlay = {
            type: 'distance-vector',
            id,
            x,
            y,
            z,
            dispose: () => this.remove(id),
        };
        this.addOverlay(overlay);
        return overlay;
    }
    addOverlay(overlay) {
        if (!this.overlays.has(overlay.id)) {
            this.overlays.set(overlay.id, overlay);
            this.overlaysChanged.emit(this.getOverlays());
        }
    }
    getOverlays() {
        return Array.from(this.overlays.values());
    }
    remove(id) {
        if (this.overlays.has(id)) {
            this.overlays.delete(id);
            this.overlaysChanged.emit(this.getOverlays());
            return true;
        }
        else {
            return false;
        }
    }
    onOverlaysChanged(listener) {
        return this.overlaysChanged.on(listener);
    }
}

export { MeasurementOverlayManager as M };
//# sourceMappingURL=overlays-BlZ9sQii.js.map

//# sourceMappingURL=overlays-BlZ9sQii.js.map