/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{detachToolFromView as r}from"./toolLifecycleUtils.js";import{ViewshedEditTool as n}from"./ViewshedEditTool.js";import{ViewshedPlacementController as d}from"./ViewshedPlacementController.js";let c=class extends e{constructor(t){super(t),this._editTool=null}initialize(){const{view:t}=this;this._placementController=new d({analysis:this.analysis,analysisViewData:this.analysisViewData,view:t,callbacks:{cancelTool:()=>{null!=t.activeTool&&(t.activeTool=null)},findViewshedComputedData:t=>this._findViewshedComputedData(t),isToolDestroyed:()=>this.destroyed,setSelectedViewshed:t=>{this.analysisViewData.selectedViewshed=t}}}),this.addHandles([o(()=>({creationState:this._placementController.creationState,interactive:this.analysisViewData.interactive}),({creationState:e,interactive:i})=>{if(!i)return this._placementController.cancelPlaceOperation(),void this._destroyEditTool();null==e?this._editTool||(this._editTool=new n({analysis:this.analysis,analysisViewData:this.analysisViewData,view:t}),t.tools.add(this._editTool)):this._destroyEditTool()},s),o(()=>t.activeTool,t=>{null!=t&&t!==this._editTool&&null==this._placementController.creationState&&(this.analysisViewData.selectedViewshed=null)})])}destroy(){this._destroyEditTool(),i(this._placementController)}get selectedViewshedComputedData(){return this._editTool?.selectedViewshedComputedData}get stagedViewshed(){return this._placementController.stagedViewshed}get active(){return this._placementController.active||(this._editTool?.active??!1)}get updating(){return this._placementController.updating||!!this._editTool?.updating}get creating(){return null!=this._placementController.creationState}async place(t,e){if(this.analysisViewData.interactive=!0,this._destroyEditTool(),await this._placementController.startPlaceOperation(t,e),"single"===t)return{}}_findViewshedComputedData(t){return this.analysisViewData.viewshedComputedDataHandles?.find(e=>e.viewshedComputedData.viewshed===t)?.viewshedComputedData}_destroyEditTool(){const t=this._editTool;this._editTool=null,null!=t&&(r(this.view,t),i(t))}get test(){}};t([a({constructOnly:!0})],c.prototype,"view",void 0),t([a({constructOnly:!0})],c.prototype,"analysis",void 0),t([a({constructOnly:!0})],c.prototype,"analysisViewData",void 0),t([a()],c.prototype,"_placementController",void 0),t([a()],c.prototype,"_editTool",void 0),t([a()],c.prototype,"selectedViewshedComputedData",null),t([a()],c.prototype,"stagedViewshed",null),t([a()],c.prototype,"active",null),t([a()],c.prototype,"updating",null),t([a()],c.prototype,"creating",null),c=t([l("esri.views.3d.analysis.Viewshed.ViewshedTool2")],c);const p=c;export{p as default};
