/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../analysis/DirectLineMeasurementAnalysis.js";import i from"../../core/Accessor.js";import{deprecateUnnecessaryViewModel as s}from"../../core/deprecate.js";import r from"../../core/Logger.js";import{watch as n,syncAndInitial as o}from"../../core/reactiveUtils.js";import{measurementLengthUnits as l}from"../../core/units.js";import{property as a,subclass as u}from"../../core/accessorSupport/decorators.js";import{defaultUnitPropertyMetadata as p}from"../../properties/defaultUnit.js";import{AnalysisViewModelMixin as c}from"../support/AnalysisViewModelMixin.js";let d=class extends(c(i)){constructor(t){super(t),this.analysis=null,this._userUnitOptions=null,this._userUnit=null,this.supportedViewType="3d",this.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",t?.suppressDeprecationWarning||s(r.getLogger(this),"Direct Line Measurement 3D","arcgis-direct-line-measurement-3d",{version:"4.33"})}initialize(){this.addHandles(n(()=>({analysis:this.analysis,unit:this.unit}),({analysis:t,unit:e})=>{null!=t&&(t.unit=e)},o))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){const{tool:t}=this;if(null==t)return null;const e=()=>({text:null,state:"unavailable"}),i=t=>({text:t,state:"available"}),{analysisViewData:s}=t,r=null!=s.result;return{mode:s.result?.mode??"euclidean",directDistance:r&&"euclidean"===s.actualVisualizedMeasurement?i(s.directLabelText):e(),horizontalDistance:r?i(s.horizontalLabelText):e(),verticalDistance:r?i(s.verticalLabelText):e()}}get unitOptions(){const t=this._userUnitOptions?.filter(t=>l.includes(t));return t&&t.length>0?t:l.slice()}set unitOptions(t){this._userUnitOptions=t}get unit(){const t=this._userUnit,e=this.unitOptions;if(t&&e.includes(t))return t;const i=this.defaultUnit;return i&&e.includes(i)?i:e[0]}set unit(t){this._userUnit=t}constructAnalysis(){return new e}};t([a({type:e})],d.prototype,"analysis",void 0),t([a({readOnly:!0})],d.prototype,"state",null),t([a({readOnly:!0})],d.prototype,"measurement",null),t([a()],d.prototype,"unitOptions",null),t([a()],d.prototype,"_userUnitOptions",void 0),t([a()],d.prototype,"unit",null),t([a()],d.prototype,"_userUnit",void 0),t([a(p)],d.prototype,"defaultUnit",void 0),d=t([u("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],d);const m=d;export{m as default};
