/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import"../../../core/has.js";import{abortMaybe as t,destroyMaybe as s}from"../../../core/maybe.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import{getDefaultUnitForView as r}from"../../../support/getDefaultUnitForView.js";import o from"./AnalysisView3D.js";import{AreaMeasurementController as n}from"./AreaMeasurement/support/AreaMeasurementController.js";import{AreaMeasurement3DPathHelper as l}from"./AreaMeasurement/support/AreaMeasurementPathHelper.js";import{AreaMeasurementVisualization as u}from"./AreaMeasurement/support/AreaMeasurementVisualization.js";import{toPreferredLengthUnit as p,toPreferredAreaUnit as m}from"./AreaMeasurement/support/utils.js";import y from"../interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js";import{connectAnalysisViewToTool as h,removeAnalysisViewTool as d,startPlaceOperation as g}from"../../analysis/analysisViewUtils.js";import{loadGeodesicAreaMeasurementUtils as c}from"../../support/geodesicAreaMeasurementUtils.js";import{loadGeodesicLengthMeasurementUtils as v}from"../../support/geodesicLengthMeasurementUtils.js";let M=class extends o{constructor(e){super(e),this.type="area-measurement-view-3d",this.analysis=null,this.measurementData=null,this.lastDraggedVertex=null,this.stagedPoint=null,this.mode=0,this.tool=null,this.userOperation=null}initialize(){const{analysis:e,view:t}=this;this.path=new l({view:t,areaMeasurement:e}),this._analysisVisualization=new u({view:t,analysis:e,analysisViewData:this}),this.addResolvingPromise(Promise.all([c(),v()]).then(([s,i])=>{this.destroyed||(this._analysisController=new n({view:t,analysis:e,analysisViewData:this,geodesicAreaMeasurementUtils:s,geodesicLengthMeasurementUtils:i}))})),this.addHandles(h(this,y))}destroy(){d(this),this.userOperation=t(this.userOperation),this._analysisController=s(this._analysisController),this._analysisVisualization=s(this._analysisVisualization),this.path.destroy()}get visible(){return super.visible}set visible(e){super.visible=e}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return!!this._analysisVisualization?.loadingMessages}get result(){const{measurementData:e}=this;if(!e)return null;const{unit:t}=this;if("euclidean"===e.actualMeasurementMode){const{area:s,perimeterLength:i}=e;return{area:s?m(s,t):null,perimeter:i?p(i,t):null,mode:"euclidean"}}const{geodesicArea:s,pathLength:i}=e;return{area:s?m(s,t):null,perimeter:i?p(i,t):null,mode:"geodesic"}}get viewData(){return this._analysisVisualization.viewData}get areaLabel(){return this._analysisVisualization.areaLabel}get perimeterLengthLabel(){return this._analysisVisualization.perimeterLengthLabel}get validMeasurement(){return this.path.isValidPolygon}get unit(){return this.analysis.unit??r(this.view)}get testData(){}place(e){return g(this,{placementOptions:e})}};e([i()],M.prototype,"_analysisVisualization",void 0),e([i()],M.prototype,"_analysisController",void 0),e([i({readOnly:!0})],M.prototype,"type",void 0),e([i({constructOnly:!0,nonNullable:!0})],M.prototype,"analysis",void 0),e([i()],M.prototype,"updating",null),e([i()],M.prototype,"result",null),e([i()],M.prototype,"measurementData",void 0),e([i()],M.prototype,"viewData",null),e([i()],M.prototype,"areaLabel",null),e([i()],M.prototype,"perimeterLengthLabel",null),e([i()],M.prototype,"validMeasurement",null),e([i()],M.prototype,"path",void 0),e([i()],M.prototype,"lastDraggedVertex",void 0),e([i()],M.prototype,"stagedPoint",void 0),e([i()],M.prototype,"mode",void 0),e([i()],M.prototype,"unit",null),e([i()],M.prototype,"tool",void 0),e([i()],M.prototype,"userOperation",void 0),M=e([a("esri.views.3d.analysis.AreaMeasurementAnalysisView3D")],M);const w=M;export{w as default};
