/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import{h as e,F as t,t as r,p as s,H as a,e as n}from"./p-DmsAWRoU.js";import"./p-Cc_lzbST.js";import"./p-FRKLa468.js";import"./p-ux1ckSDN.js";import"./p-DsZcVdq8.js";import"./p-DxRQdGXU.js";import{M as i}from"./p-CI-uemp_.js";import{l as o,p as l}from"./p-Tvs4yxd5.js";import{d as m}from"./p-Xr7Oa6iw.js";function v(e,t){const{camera:r,viewport:s}=t;const a=r.isPointBehindNear(e.start);const n=r.isPointBehindNear(e.end);if(a||n){const t=r.intersectLineWithNear(e);const i=o.create({start:a&&t!=null?t:e.start,end:n&&t!=null?t:e.end});const l=o.transformMatrix(i,r.projectionViewMatrix);return{start:s.transformVectorToViewport(l.start),end:s.transformVectorToViewport(l.end),hideStart:a,hideEnd:n}}else{const t=o.transformMatrix(e,r.projectionViewMatrix);return{start:s.transformVectorToViewport(t.start),end:s.transformVectorToViewport(t.end),hideStart:false,hideEnd:false}}}function d(e,t,r){const{start:s,end:a,hideStart:n,hideEnd:i}=v(e,r);const o=l.lerp(s,a,.5);const m=t!=="none"?c(e,t,r):undefined;return{startPt:s,endPt:a,labelPt:o,indicatorPt:m,hideStart:n,hideEnd:i}}function c(e,t,r){return r.viewport.transformWorldToViewport(t==="start"?e.start:e.end,r.camera.projectionViewMatrix)}const u=({overlay:t,viewport:r,camera:s})=>{if(t.type==="line"){return e(h,{overlay:t,viewport:r,camera:s})}else{return e(p,{overlay:t,viewport:r,camera:s})}};const h=({overlay:t,camera:r,viewport:s})=>{const{start:a,end:n}=v(t,{camera:r,viewport:s});return e("vertex-viewer-measurement-line",{class:"measurement-line",start:a,end:n})};const p=({overlay:{x:r,y:s,z:a},camera:n,viewport:i})=>{const o={camera:n,viewport:i};const{start:l,end:m}=v(r,o);const{start:d,end:c}=v(s,o);const{start:u,end:h}=v(a,o);return e(t,null,e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-x",start:l,end:m}),e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-y",start:d,end:c}),e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-z",start:u,end:h}))};const w=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;--viewer-measurement-overlays-x-axis-color:var(--x-axis-color);--viewer-measurement-overlays-y-axis-color:var(--y-axis-color);--viewer-measurement-overlays-z-axis-color:var(--z-axis-color)}.measurement-line{position:absolute;width:100%;height:100%}.measurement-line.distance-vector-x{--viewer-measurement-line-fill:var(     --viewer-measurement-overlays-x-axis-color   )}.measurement-line.distance-vector-y{--viewer-measurement-line-fill:var(     --viewer-measurement-overlays-y-axis-color   )}.measurement-line.distance-vector-z{--viewer-measurement-line-fill:var(     --viewer-measurement-overlays-z-axis-color   )}`;const y=s(class t extends a{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.measurementOverlays=new i;this.overlays=[];this.updateCamera=()=>{var e,t;this.camera=(t=(e=this.viewer)===null||e===void 0?void 0:e.frame)===null||t===void 0?void 0:t.scene.camera}}handleMeasurementOverlaysChanged(){this.removeModelListeners();this.addModelListeners();this.updateOverlays()}handleViewerChanged(e,t){this.removeViewerListeners(t);this.addViewerListeners();this.updateCamera()}componentWillLoad(){this.addModelListeners();this.addViewerListeners();this.updateOverlays();this.updateCamera()}addModelListeners(){this.onOverlaysChangedListener=this.measurementOverlays.onOverlaysChanged((()=>this.updateOverlays()))}removeModelListeners(){var e;(e=this.onOverlaysChangedListener)===null||e===void 0?void 0:e.dispose();this.onOverlaysChangedListener=undefined}addViewerListeners(){var e;(e=this.viewer)===null||e===void 0?void 0:e.addEventListener("frameReceived",this.updateCamera)}removeViewerListeners(e){e===null||e===void 0?void 0:e.removeEventListener("frameReceived",this.updateCamera)}updateOverlays(){this.overlays=this.measurementOverlays.getOverlays()}render(){return e(n,{key:"fbda189899fa87c57b11615693d1319eee341fea"},this.overlays.map((t=>{if(this.camera!=null&&this.viewer!=null){return e(u,{overlay:t,viewport:this.viewer.viewport,camera:this.camera})}})))}static get watchers(){return{measurementOverlays:[{handleMeasurementOverlaysChanged:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return w()}},[1,"vertex-viewer-measurement-overlays",{measurementOverlays:[16],camera:[1040],viewer:[16],overlays:[32]},undefined,{measurementOverlays:[{handleMeasurementOverlaysChanged:0}],viewer:[{handleViewerChanged:0}]}]);function f(){if(typeof customElements==="undefined"){return}const e=["vertex-viewer-measurement-overlays","vertex-viewer-measurement-line"];e.forEach((e=>{switch(e){case"vertex-viewer-measurement-overlays":if(!customElements.get(r(e))){customElements.define(r(e),y)}break;case"vertex-viewer-measurement-line":if(!customElements.get(r(e))){m()}break}}))}f();export{y as V,f as d,d as g};
//# sourceMappingURL=p-kSfe_kB5.js.map