// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("../../chunks/tslib.es6 ../../Graphic ../../core/Accessor ../../core/arrayUtils ../../core/ByteSizeUnit ../../core/Collection ../../core/collectionUtils ../../core/deprecate ../../core/Logger ../../core/LRUCache ../../core/maybe ../../core/memoize ../../core/reactiveUtils ../../core/unitUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/accessorSupport/decorators/subclass ../../layers/support/ElevationQueryTileCache ../../properties/defaultUnit ./ElevationProfileController ./ElevationProfileLineGround ./elevationProfileLineTypes ./ElevationProfileTool ./support/constants ./support/geometryUtils ./support/ProfileGenerationError ./support/profileUtils ./support/statisticsUtils".split(" "),
function(c,y,b,n,z,p,A,B,q,C,k,D,r,m,d,N,E,F,G,H,I,J,K,h,t,l,L,u){b=class extends b{constructor(a){super(a);this.input=this.view=null;this._getEffectiveUnitsMemoized=D.memoize((e,g)=>({distance:e,elevation:g}));this.hoveredChartPosition=null;this.uniformChartScaling=!1;this.error=this._currentTileCache=this.queue=this.defaultUnit=null;this._defaultProfileLineGround=new I;this._userUnit=this._userUnitOptions=null;a?.profiles||(this.profiles=new p([this._defaultProfileLineGround]))}initialize(){this.addHandles(r.watch(()=>
this.view,a=>{null==a?q.getLogger(this).warnOnce("no view. Widget will be disabled until a view is provided."):(this.removeHandles(v),a="3d"===a.type?a.resourceController:void 0,this.queue?.destroy(),this.queue=L.createProfileQueue(a?.scheduler),(a=a?.addUpdatingObject(this))&&this.addHandles(a,v))},r.syncAndInitial));this.tool=new K.ElevationProfileTool({viewModel:this});this._controller=new H.ElevationProfileController({viewModel:this})}destroy(){this._defaultProfileLineGround=k.destroyMaybe(this._defaultProfileLineGround);
this._controller=k.destroyMaybe(this._controller);this._currentTileCache=k.destroyMaybe(this._currentTileCache);this.tool=k.destroyMaybe(this.tool);this.queue=k.destroyMaybe(this.queue)}get profiles(){return this._get("profiles")}set profiles(a){const e=this._get("profiles");a=a??new p;this._set("profiles",A.referenceSetter(a,e))}get state(){const a=this.view;return null!=a&&a.ready?this.tool.state:h.ElevationProfileState.Disabled}get progress(){let a=0,e=0;for(const g of this.visibleProfiles)a++,
e+=g.progress;return 0
g.result));const e=m.adaptiveLengthUnit(a.maxDistance,"meters",this.unit);a=m.adaptiveVerticalLengthUnit(a.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,a)}get geodesicDistanceThreshold(){return this._get("geodesicDistanceThreshold")}set geodesicDistanceThreshold(a){B.deprecatedProperty(q.getLogger(this),"geodesicDistanceThreshold",{version:"4.29",warnOnce:!0});this._set("geodesicDistanceThreshold",a)}get highlightEnabled(){return this.tool.highlightEnabled}set highlightEnabled(a){this.tool.highlightEnabled=
a}get hasVertices(){const a=this.input?.geometry;return t.isPolyline(a)&&0e+g.length,0)}get hoveredPoints(){return null!=this.input&&this.visible&&this.tool.editable?this.visibleProfiles.map(a=>{const e=a.hoveredPoint;return null!=e?{hoveredPoint:e,color:a.color}:null}).filter(n.isSome):[]}get statistics(){return u.mergeStatistics(this.visibleProfiles.map(a=>a.statistics))}get chartData(){if(null==this.input)return null;const {effectiveUnits:a,progress:e,statistics:g,visibleProfiles:w,
uniformChartScaling:M}=this,x=w.filter(f=>f.hasZ).map(f=>({id:f.id,type:f.type,title:f.title,color:f.color,samples:f.samples,progress:f.progress,chartFillEnabled:f.chartFillEnabled,chartStrokeWidth:f.chartStrokeWidth,chartStrokeOffsetY:f.chartStrokeOffsetY,viewVisualizationEnabled:f.viewVisualizationEnabled}));return 0===x.length?null:{lines:x,effectiveUnits:a,statistics:g,refined:1===e,dynamicElevationRange:w.some(f=>"view"===f.type),uniformScaling:M}}get visibleProfiles(){return this.profiles.toArray().filter(a=>
a.available&&a.visible)}get minDemResolutions(){const a=[];for(const {minDemResolution:e}of this.visibleProfiles)null!=e&&a.push(e);return a}get minDemResolution(){return n.min(this.minDemResolutions)}get errorState(){if(!t.isValidInputPath(this.input?.geometry))return h.ElevationProfileErrorState.NoValidInput;if(null!=this.error){if(l.isProfileGenerationError(this.error))switch(this.error.cause){case l.ProfileGenerationErrorCause.TooComplex:return h.ElevationProfileErrorState.TooComplex;case l.ProfileGenerationErrorCause.InvalidGeometry:return h.ElevationProfileErrorState.InvalidGeometry;
case l.ProfileGenerationErrorCause.InvalidElevationInfo:return h.ElevationProfileErrorState.InvalidElevationInfo;case l.ProfileGenerationErrorCause.ElevationQueryError:return h.ElevationProfileErrorState.NoValidInput}return h.ElevationProfileErrorState.UnknownError}return 0===this.visibleProfiles.length?h.ElevationProfileErrorState.NoVisibleProfiles:null==this.chartData&&1===this.progress?h.ElevationProfileErrorState.RefinedButNoChartData:h.ElevationProfileErrorState.None}get tileCache(){this._currentTileCache=
k.destroyMaybe(this._currentTileCache);var a=this.view;if(null!=a&&"3d"===a?.type&&(a=a.basemapTerrain?.elevationQueryCache,null!=a))return a;null==this._currentTileCache&&(this._currentTileCache=new F.ElevationQueryTileCache(new C.LRUCache(20*z.ByteSizeUnit.MEGABYTES)));return this._currentTileCache}get visible(){return this.tool.visible}set visible(a){this.tool.visible=a}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const a=this.view;return null!=
a&&"3d"===a.type?a.elevationProvider:null}get updating(){const {progress:a}=this,e=!!this.queue?.updating;return 0a||e}start(a){this.tool.interaction.start(a)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(a,e){const g=this.unitOptions;return null!=a&&g.includes(a)?a:e?this._findSelectableUnit(e):g[0]}_filteredOrAllUnits(a){a=(null!=a?a:[]).filter(e=>m.measurementLengthUnits.includes(e));return 0===a.length?
m.measurementLengthUnits.slice():a}};c.__decorate([d.property()],b.prototype,"view",void 0);c.__decorate([d.property({type:y})],b.prototype,"input",void 0);c.__decorate([d.property({type:J.ElevationProfileLineCollection,nonNullable:!0})],b.prototype,"profiles",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"state",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"progress",null);c.__decorate([d.property()],b.prototype,"unitOptions",null);c.__decorate([d.property()],b.prototype,
"unit",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"effectiveUnits",null);c.__decorate([d.property()],b.prototype,"geodesicDistanceThreshold",null);c.__decorate([d.property()],b.prototype,"hoveredChartPosition",void 0);c.__decorate([d.property()],b.prototype,"uniformChartScaling",void 0);c.__decorate([d.property()],b.prototype,"highlightEnabled",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"hoveredPoints",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"statistics",
null);c.__decorate([d.property()],b.prototype,"chartData",null);c.__decorate([d.property()],b.prototype,"visibleProfiles",null);c.__decorate([d.property()],b.prototype,"minDemResolutions",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"minDemResolution",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"errorState",null);c.__decorate([d.property(G.defaultUnitPropertyMetadata)],b.prototype,"defaultUnit",void 0);c.__decorate([d.property()],b.prototype,"queue",void 0);c.__decorate([d.property()],
b.prototype,"tileCache",null);c.__decorate([d.property()],b.prototype,"tool",void 0);c.__decorate([d.property()],b.prototype,"visible",null);c.__decorate([d.property()],b.prototype,"error",void 0);c.__decorate([d.property()],b.prototype,"inputIsSketched",null);c.__decorate([d.property()],b.prototype,"elevationProvider",null);c.__decorate([d.property()],b.prototype,"updating",null);c.__decorate([d.property()],b.prototype,"_defaultProfileLineGround",void 0);c.__decorate([d.property()],b.prototype,"_userUnitOptions",
void 0);c.__decorate([d.property()],b.prototype,"_controller",void 0);c.__decorate([d.property()],b.prototype,"_userUnit",void 0);b=c.__decorate([E.subclass("esri.widgets.ElevationProfile.ElevationProfileViewModel")],b);const v=Symbol("updating-object");return b});