/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
'use strict';

var bundle$1 = require('./bundle-BhTmftd-.js');
var bundle = require('./bundle-96sYCpzz.js');

class MeasurementOverlayManager {
    constructor() {
        this.overlays = new Map();
        this.overlaysChanged = new bundle.EventDispatcher();
    }
    addLineFromResult(result) {
        return this.addLine(result.point1, result.point2);
    }
    addLine(start, end) {
        const id = bundle.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 = bundle.uuid.create();
        const v = bundle$1.vector3.subtract(start, end);
        const ye = bundle$1.vector3.add(start, bundle$1.vector3.create(0, -v.y, 0));
        const y = { start: start, end: ye };
        const ze = bundle$1.vector3.add(ye, bundle$1.vector3.create(0, 0, -v.z));
        const z = { start: ye, end: ze };
        const xe = bundle$1.vector3.add(ze, bundle$1.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);
    }
}

exports.MeasurementOverlayManager = MeasurementOverlayManager;
//# sourceMappingURL=overlays-CxiJArpE.js.map

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