/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import{a as t}from"./p-Cnqnt1lk.js";import{E as s}from"./p-BuOEMGyM.js";import{p as i,g as e}from"./p-DfdVaPrt.js";class n{constructor(t,i){this.model=t;this.viewer=i;this.additionalTransforms=[];this.operationInFlight=false;this.operationAborted=false;this.executeStarted=new s;this.executeComplete=new s;this.executeAborted=new s;this.additionalTransforms=[t=>t.items.where((t=>t.all())).deselect()];this.operationTransform=t=>t.select()}setStartPoint(t){this.previousViewerCameraControls=this.viewer.cameraControls;this.viewer.cameraControls=false;this.model.setStartPoint(t)}setEndPoint(t){this.model.setEndPoint(t)}setOperationTransform(t){this.operationTransform=t}setAdditionalTransforms(t){this.additionalTransforms=t}onExecuteStarted(t){return this.executeStarted.on(t)}onExecuteComplete(t){return this.executeComplete.on(t)}onExecuteAborted(t){return this.executeAborted.on(t)}async execute(){var s,i,e;const n=this.model.getScreenBounds();const h=this.model.getType();if(n!=null&&!this.operationInFlight){this.model.complete();try{this.operationInFlight=true;this.executeStarted.emit();const t=t=>this.additionalTransforms.map((s=>s(t))).flat();const s=t=>[this.operationTransform(t.items.where((t=>t.withVolumeIntersection(n,h==="exclusive"))))].flat();const i=await this.viewer.scene();await i.elements((i=>[...t(i),...s(i)])).execute({skipAwaitCorrelatedFrame:true})}catch(i){if(i instanceof t&&((s=i.summary)===null||s===void 0?void 0:s.toLocaleLowerCase().includes("operation aborted"))){this.executeAborted.emit(i);this.operationAborted=true}else{console.error("Failed to perform volume intersection query",i);throw i}}finally{this.viewer.cameraControls=(i=this.previousViewerCameraControls)!==null&&i!==void 0?i:true;this.previousViewerCameraControls=undefined;this.operationInFlight=false;this.executeComplete.emit({aborted:this.operationAborted});this.operationAborted=false}}else if(this.operationInFlight){this.model.cancel();throw new Error(`Unable to perform volume intersection query as there is already one in-flight.`)}else{this.model.cancel();this.viewer.cameraControls=(e=this.previousViewerCameraControls)!==null&&e!==void 0?e:true}}}class h{constructor(t){this.mode=t;this.dragStarted=new s;this.dragComplete=new s;this.dragCancelled=new s;this.screenBoundsChanged=new s}setStartPoint(t){this.startPoint=t;this.dragStarted.emit()}setEndPoint(t){if(this.startPoint!=null&&i.distance(this.startPoint,t)>=2){this.endPoint=t;this.updateQueryType();this.screenBoundsChanged.emit(this.getQueryDetails())}}setMode(t){this.mode=t}complete(){if(this.startPoint!=null&&this.endPoint!=null){this.screenBoundsChanged.emit(undefined);this.dragComplete.emit(this.getQueryDetails());this.reset()}}cancel(){this.screenBoundsChanged.emit(undefined);this.dragCancelled.emit();this.reset()}reset(){this.startPoint=undefined;this.endPoint=undefined;this.type=undefined}getScreenBounds(){return this.startPoint!=null&&this.endPoint!=null?e.fromPoints(this.startPoint,this.endPoint):undefined}getType(){return this.type}onScreenBoundsChanged(t){return this.screenBoundsChanged.on(t)}onDragStarted(t){return this.dragStarted.on(t)}onDragComplete(t){return this.dragComplete.on(t)}onDragCancelled(t){return this.dragCancelled.on(t)}getQueryDetails(){if(this.startPoint!=null&&this.endPoint!=null&&this.type!=null){return{screenBounds:e.fromPoints(this.startPoint,this.endPoint),type:this.type}}else{throw new Error("Failed to create query details, the start and end points must be set.")}}updateQueryType(){var t;if(this.startPoint!=null&&this.endPoint!=null){const s=i.subtract(this.endPoint,this.startPoint).x>0?"exclusive":"inclusive";this.type=(t=this.mode)!==null&&t!==void 0?t:s}}}export{n as V,h as a};
//# sourceMappingURL=p-DS3wSKLL.js.map