/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{destroyHandle as o}from"../../../../core/handleUtils.js";import i from"../../../../core/Logger.js";import{mapCollection as s}from"../../../../core/mapCollectionUtils.js";import{watch as r,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{convertUnit as a}from"../../../../core/units.js";import{property as l,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{getDefaultUnitForView as c}from"../../../../support/getDefaultUnitForView.js";import{isGeodesicDimension as p,computeGeometryFromDimension as u,computeLength as d,computationToGeometryDependencies as y}from"./lengthDimensionUtils.js";import{geodesicDistanceThreshold as h}from"../../../support/geodesicMeasurementUtils.js";let f=class extends e{constructor(t){super(t)}initialize(){const t=s(()=>this.analysisViewData.computations,({computation:t})=>this._watchComputation(t));this.addHandles(o(t))}get analysis(){return this.analysisViewData.analysis}get _defaultUnit(){return c(this.view)}_watchComputation(t){return r(()=>y(t),e=>{const{measureType:o}=e;if(p(e)&&"direct"!==o){const e=Math.round(a(h,"meters","kilometers"));return i.getLogger(this).warnOnce(`A ${o} dimension in the analysis (id: '${this.analysis.id}') will not display, because only direct dimensions can measure lengths greater than ${e} km. Update the measureType of the affected dimension to "direct" to display it.`),void(t.geometry=null)}const s=u(e,this.view.renderCoordsHelper,t.geometry);t.geometry=s,t.result.length=d(s,o,this._defaultUnit,this.automaticLengthMeasurementUtils)},n)}};t([l({constructOnly:!0})],f.prototype,"analysisViewData",void 0),t([l({constructOnly:!0})],f.prototype,"view",void 0),t([l({constructOnly:!0})],f.prototype,"automaticLengthMeasurementUtils",void 0),t([l()],f.prototype,"analysis",null),t([l()],f.prototype,"_defaultUnit",null),f=t([m("esri.views.3d.analysis.Dimension.DimensionController")],f);export{f as DimensionController};
