/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../../analysis/LineOfSightAnalysisTarget.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as o,sync as r}from"../../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{getLineOfSightMapPointIntersection as n,updateLineOfSightItemFromIntersection as l}from"./LineOfSightAuthoringUtils.js";import{LineOfSightRayIntersector as p}from"./LineOfSightRayIntersector.js";import{PluginBase as c}from"../../../draw/plugins/PluginBase.js";var u;const h=Symbol("line-of-sight-target-vertex"),d=Symbol("line-of-sight-target-plugin-marker");let f=class extends c{constructor(){super(...arguments),this[u]=!0,this.target=null,this.defaultElevationInfo=null,this.defaultCaptureMode="capture-always",this.inputMapPosition=null,this.sourceElevationInfo=null,this._interactiveHandle=null,this._intersector=null}static{u=d}initialize(){this._intersector=new p({view:this.view})}destroy(){this._intersector=i(this._intersector)}start(t){super.start(t);const{positionOfLastUserInput:s,session:a}=t,p="grabbable-object"===this.defaultCaptureMode?this.inputMapPosition??this._interactiveHandle?.outputMapPosition??s:this.inputMapPosition??s;!p||"grabbable-object"!==this.defaultCaptureMode&&this._interactiveHandle||a.appendOrReplacePoint(h,p),this._interactiveHandle&&this._clearCursorTarget(),this._interactiveHandle||(this._interactiveHandle=t.createInteractiveHandle({defaultCaptureMode:this.defaultCaptureMode,inputMapPosition:"grabbable-object"===this.defaultCaptureMode?p??void 0:void 0}),this.addHandles(o(()=>this._interactiveHandle?.outputMapPosition,t=>{if(!t||this._isComplete)return;const o=this.analysisViewData.cursorTarget??new e,r=this._intersector&&n(this._intersector,this.view,t,this.sourceElevationInfo);this._session?.appendOrReplacePoint(h,t),r?(this.analysisViewData.cursorTarget=o,l(this.view,o,r,t,this.defaultElevationInfo,this.sourceElevationInfo)):this.analysisViewData.cursorTarget=i(this.analysisViewData.cursorTarget)},r),this._ownHandlesKey))}complete(){this._clearCursorTarget(),super.complete()}cancel(){this._clearCursorTarget()}_clearCursorTarget(){this.analysisViewData.cursorTarget=i(this.analysisViewData.cursorTarget)}};function v(t){return!!t&&d in t}function y(t){return{uniqueId:Symbol("line-of-sight-target-plugin"),kind:["vertex"],geometryType:"point",hidden:!0,localizationKey:"leaf-point-segment",icon:"point",create:()=>new f(t)}}t([s({constructOnly:!0})],f.prototype,"analysis",void 0),t([s({constructOnly:!0})],f.prototype,"analysisViewData",void 0),t([s({constructOnly:!0})],f.prototype,"view",void 0),t([s({constructOnly:!0})],f.prototype,"target",void 0),t([s({constructOnly:!0})],f.prototype,"defaultElevationInfo",void 0),t([s()],f.prototype,"defaultCaptureMode",void 0),t([s()],f.prototype,"inputMapPosition",void 0),t([s({constructOnly:!0})],f.prototype,"sourceElevationInfo",void 0),t([s()],f.prototype,"_interactiveHandle",void 0),t([s()],f.prototype,"_intersector",void 0),f=t([a("esri.views.3d.analysis.LineOfSight.LineOfSightTargetPlugin")],f);export{f as LineOfSightTargetPlugin,y as createLineOfSightTargetPluginConfiguration,v as isLineOfSightTargetPlugin,d as lineOfSightTargetPluginMarker};
