/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../analysis/DirectLineMeasurementAnalysis","../../core/maybe","../../core/unitUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../properties/defaultUnit","../../views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool","../support/InteractiveAnalysisViewModel"],(function(e,t,i,n,s,r,a,l,o,u,c,p,d){"use strict";let h=function(t){function r(e){var i;return(i=t.call(this,e)||this).analysis=null,i.supportedViewType="3d",i.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",i._userUnit=null,i._userUnitOptions=null,i}e._inheritsLoose(r,t);var a=r.prototype;return a.constructAnalysis=function(){return new i},a.constructTool=function(){return new p({view:n.unwrap(this.view),analysis:this.analysis,analysisViewData:n.unwrap(this.analysisView),visible:this.visible})},a._findSelectableUnit=function(e,t){const i=this.unitOptions;return i.includes(e)?e:t?this._findSelectableUnit(t):i[0]},a._filteredOrAllUnits=function(e){if(!e)return s.measurementLengthUnits.slice();const t=e.filter((e=>s.measurementLengthUnits.includes(e)));return 0===t.length?s.measurementLengthUnits.slice():t},e._createClass(r,[{key:"state",get:function(){return this.disabled||!this.ready?"disabled":n.isNone(this.tool)?"ready":this.tool.state}},{key:"measurement",get:function(){if(n.isNone(this.tool))return null;const e={mode:"euclidean",directDistance:{text:null,state:"unavailable"},horizontalDistance:{text:null,state:"unavailable"},verticalDistance:{text:null,state:"unavailable"}},{analysisViewData:t}=this.tool;if(n.isNone(t))return e;const i=t.actualVisualizedMeasurement,s=n.isSome(t.result)?"available":"unavailable";switch(i){case"euclidean":return{mode:"euclidean",directDistance:{text:t.directLabelText,state:s},horizontalDistance:{text:t.horizontalLabelText,state:s},verticalDistance:{text:t.verticalLabelText,state:s}};case"geodesic":return{mode:"geodesic",directDistance:{text:null,state:"unavailable"},horizontalDistance:{text:t.horizontalLabelText,state:s},verticalDistance:{text:t.verticalLabelText,state:s}};default:return e}}},{key:"unitOptions",get:function(){return this._filteredOrAllUnits(this._userUnitOptions)},set:function(e){this._userUnitOptions=e,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}},{key:"unit",get:function(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)},set:function(e){this._userUnit=e?this._findSelectableUnit(e,this._userUnit):null,this.analysis.unit=e}}]),r}(d.InteractiveAnalysisViewModel);t.__decorate([r.property({type:i})],h.prototype,"analysis",void 0),t.__decorate([r.property({readOnly:!0})],h.prototype,"state",null),t.__decorate([r.property({readOnly:!0})],h.prototype,"measurement",null),t.__decorate([r.property()],h.prototype,"unitOptions",null),t.__decorate([r.property()],h.prototype,"unit",null),t.__decorate([r.property(c.defaultUnitPropertyMetadata)],h.prototype,"defaultUnit",void 0),t.__decorate([r.property()],h.prototype,"_userUnit",void 0),t.__decorate([r.property()],h.prototype,"_userUnitOptions",void 0),h=t.__decorate([u.subclass("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],h);return h}));
