/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import{r as e,c as t,h as n,H as r,a as i}from"./p-EpnuuCxl.js";import{s}from"./p-DRh4_Z-g.js";import{F as o,C as a,A as l}from"./p-yEqopnut.js";import{b as h,a as d,i as u}from"./p-CR7q8bhh.js";import"./p-DfdVaPrt.js";import"./p-BuOEMGyM.js";import"./p-CG9AChtV.js";const c=()=>`:host{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}:host([elevated=""]){z-index:100}`;const f=class{constructor(n){e(this,n);this.markupBegin=t(this,"markupBegin");this.markupEnd=t(this,"markupEnd");this.tool="arrow";this.disabled=false;this.startLineAnchorStyle="none";this.endLineAnchorStyle="arrow-triangle";this.centeringBehavior="none";this.scale=1;this.stateMap={};this.handleMarkupInteractionBegin=()=>{this.markupBegin.emit()};this.handleMarkupInteractionEnd=()=>{const{markupElement:e}=this.stateMap;if(h(e)){const{points:t,bounds:n}=e;if(t!=null&&t.length>0&&n!=null){this.markupEnd.emit(new o({points:t,bounds:n}))}}else if(d(e)){const{bounds:t}=e;if(t!=null){this.markupEnd.emit(new a({bounds:t}))}}else if(u(e)){const{start:t,end:n}=e;if(t!=null&&n!=null){this.markupEnd.emit(new l({start:t,end:n}))}}}}async handleViewerChanged(){if(this.stateMap.markupElement!=null){this.stateMap.markupElement.viewer=this.viewer}}handlePropertyChanged(){this.updateMarkupElement()}handleScalingConfigurationChanged(){this.updateMarkupElement()}componentDidLoad(){this.updateMarkupElement()}async reset(){const{markupElement:e}=this.stateMap;if(h(e)){e.points=undefined;e.bounds=undefined;e.mode="create"}else if(d(e)){e.bounds=undefined;e.mode="create"}else if(u(e)){e.start=undefined;e.end=undefined;e.mode="create"}}render(){if(!this.disabled){if(this.tool==="arrow"||this.tool==="circle"||this.tool==="freeform"){return n(r,null,n("slot",null))}else{return n(r,null,`Unsupported tool type '${this.tool}'.`)}}else{return n(r,null)}}createArrowMarkupElement(){if(this.arrowTemplateId!=null){const e=s(window.document.body,this.arrowTemplateId,u,(()=>console.warn(`Arrow template with ID ${this.arrowTemplateId} not found. Using default arrow element.`)),(()=>console.warn(`Arrow template does not contain a vertex-viewer-markup-arrow. Using default arrow element.`)));if(e!=null){return e}}return document.createElement("vertex-viewer-markup-arrow")}createCircleMarkupElement(){if(this.circleTemplateId!=null){const e=s(window.document.body,this.circleTemplateId,d,(()=>console.warn(`Circle template with ID ${this.circleTemplateId} not found. Using default circle element.`)),(()=>console.warn(`Circle template does not contain a vertex-viewer-markup-circle. Using default circle element.`)));if(e!=null){return e}}return document.createElement("vertex-viewer-markup-circle")}createFreeformMarkupElement(){if(this.freeformTemplateId!=null){const e=s(window.document.body,this.freeformTemplateId,h,(()=>console.warn(`Freeform template with ID ${this.freeformTemplateId} not found. Using default freeform element.`)),(()=>console.warn(`Freeform template does not contain a vertex-viewer-markup-freeform. Using default freeform element.`)));if(e!=null){return e}}return document.createElement("vertex-viewer-markup-freeform")}createNewMarkupElement(){switch(this.tool){case"arrow":return this.createArrowMarkupElement();case"circle":return this.createCircleMarkupElement();case"freeform":return this.createFreeformMarkupElement()}}updateMarkupElement(){const{markupElement:e}=this.stateMap;if(e!=null){e.remove();e.dispose();e.viewer=undefined;e.removeEventListener("interactionBegin",this.handleMarkupInteractionBegin);e.removeEventListener("interactionEnd",this.handleMarkupInteractionEnd)}if(!this.disabled){const e=this.createNewMarkupElement();this.hostEl.append(e);if(this.tool==="arrow"){e.startLineAnchorStyle=this.startLineAnchorStyle;e.endLineAnchorStyle=this.endLineAnchorStyle}e.mode="create";e.viewer=this.viewer;e.originatingViewport=this.originatingViewport;e.centeringBehavior=this.centeringBehavior;e.offset=this.offset;e.scale=this.scale;e.addEventListener("interactionBegin",this.handleMarkupInteractionBegin);e.addEventListener("interactionEnd",this.handleMarkupInteractionEnd);this.stateMap.markupElement=e}}get hostEl(){return i(this)}static get watchers(){return{viewer:[{handleViewerChanged:0}],arrowTemplateId:[{handlePropertyChanged:0}],circleTemplateId:[{handlePropertyChanged:0}],disabled:[{handlePropertyChanged:0}],endLineAnchorStyle:[{handlePropertyChanged:0}],freeformTemplateId:[{handlePropertyChanged:0}],startLineAnchorStyle:[{handlePropertyChanged:0}],tool:[{handlePropertyChanged:0}],scale:[{handleScalingConfigurationChanged:0}],offset:[{handleScalingConfigurationChanged:0}],originatingViewport:[{handleScalingConfigurationChanged:0}],centeringBehavior:[{handleScalingConfigurationChanged:0}]}}};f.style=c();export{f as vertex_viewer_markup_tool};
//# sourceMappingURL=p-1edd160b.entry.js.map