/*
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","../../Color","../../core/arrayUtils","../../core/Evented","../../core/handleUtils","../../core/maybe","../../core/memoize","../../core/reactiveUtils","../../core/uuid","../../core/accessorSupport/decorators/property","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../geometry/Point","./support/constants","./support/unitUtils"],(function(e,t,o,r,i,n,s,l,p,a,c,u,d,y,_,h,v){"use strict";let f=function(t){function i(e){var r;return(r=t.call(this,e)||this).type=null,r.id=a.generateUUID(),r.title=null,r.color=new o("#000000"),r.visible=!0,r._getSamplesMemoized=l.memoize(((e,t)=>v.convertSamples(e,t))),r._getStatisticsMemoized=l.memoize(((e,t)=>v.convertStatistics(e,t))),r.viewVisualizationEnabled=!0,r.result=null,r.effectiveUnits=null,r.numSamplesForPreview=30,r.numSamplesPerChunk=200,r.chartFillEnabled=!0,r.chartStrokeWidth=1.5,r.chartStrokeOffsetY=0,r}e._inheritsLoose(i,t);var c=i.prototype;return c.queryElevation=function(){throw new Error("not implemented")},c.attach=function(e){return this._viewModel=e,n.handlesGroup([p.watch((()=>e.effectiveUnits),(e=>{this.effectiveUnits=e}),p.syncAndInitial),p.watch((()=>[e.input]),(()=>this._onChange()),p.sync)])},c.toggleVisibility=function(e){this.visible=void 0===e?!this.visible:e},c._onChange=function(){this.emit("change")},c._getPoint=function(e){const{samples:t,result:o}=this;if(s.isNone(t)||s.isNone(o))return null;const i=t.length;if(0===i)return null;const n=e*t[i-1].distance,{x:l,y:p,z:a}=r.binaryFindClosest(t,n,(e=>e.distance));return s.isNone(a)?null:new _({x:l,y:p,z:a,spatialReference:o.spatialReference})},e._createClass(i,[{key:"progress",get:function(){return s.isSome(this.result)&&this.visible?this.result.progress:0}},{key:"samples",get:function(){return this._getSamplesMemoized(this.result,this.effectiveUnits)}},{key:"statistics",get:function(){return this._getStatisticsMemoized(this.result,this.effectiveUnits)}},{key:"hoveredPoint",get:function(){return s.applySome(this._viewModel.hoveredChartPosition,(e=>this._getPoint(e)))}},{key:"available",get:function(){return!0}},{key:"hasZ",get:function(){const e=this.result;return s.isSome(e)&&e.hasZ}},{key:"minDemResolution",get:function(){return h.DEFAULT_DEM_RESOLUTION}}]),i}(i.EventedAccessor);t.__decorate([c.property({nonNullable:!0})],f.prototype,"id",void 0),t.__decorate([c.property({nonNullable:!0})],f.prototype,"title",void 0),t.__decorate([c.property({type:o,nonNullable:!0})],f.prototype,"color",void 0),t.__decorate([c.property({nonNullable:!0})],f.prototype,"visible",void 0),t.__decorate([c.property({readOnly:!0})],f.prototype,"progress",null),t.__decorate([c.property({readOnly:!0})],f.prototype,"samples",null),t.__decorate([c.property({readOnly:!0})],f.prototype,"statistics",null),t.__decorate([c.property()],f.prototype,"hoveredPoint",null),t.__decorate([c.property()],f.prototype,"viewVisualizationEnabled",void 0),t.__decorate([c.property()],f.prototype,"available",null),t.__decorate([c.property()],f.prototype,"result",void 0),t.__decorate([c.property()],f.prototype,"effectiveUnits",void 0),t.__decorate([c.property()],f.prototype,"numSamplesForPreview",void 0),t.__decorate([c.property()],f.prototype,"numSamplesPerChunk",void 0),t.__decorate([c.property()],f.prototype,"chartFillEnabled",void 0),t.__decorate([c.property()],f.prototype,"chartStrokeWidth",void 0),t.__decorate([c.property()],f.prototype,"chartStrokeOffsetY",void 0),t.__decorate([c.property({readOnly:!0})],f.prototype,"hasZ",null),t.__decorate([c.property({readOnly:!0})],f.prototype,"minDemResolution",null),t.__decorate([c.property()],f.prototype,"_viewModel",void 0),f=t.__decorate([y.subclass("esri.widgets.ElevationProfile.ElevationProfileLine")],f);return f}));
