/*
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/handleUtils","../../core/maybe","../../core/memoize","../../core/reactiveUtils","../../core/unitUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./ElevationProfileLine","./support/elevationQuerySourceUtils"],(function(e,r,o,t,n,i,a,s,l,u,c,p,d,y,v){"use strict";let _=function(r){function l(e){var t;return(t=r.call(this,e)||this).type="ground",t.color=new o("#ff7f00"),t.viewVisualizationEnabled=!0,t.numSamplesForPreview=50,t.numSamplesPerChunk=1e3,t._getQueryElevationDependencies=i.memoize(((e,r)=>({ground:e,groundLayers:r}))),t}e._inheritsLoose(l,r);var u=l.prototype;return u.queryElevation=function(){var r=e._asyncToGenerator((function*(e,r){const o=this.queryElevationDependencies;if(n.isNone(o))throw new Error("ElevationProfileLineGround: no dependencies");const{ground:t}=o;if(n.isNone(t))throw new Error("No ground configured in the view");const i=yield t.queryElevation(e,r),a=s.getMetersPerVerticalUnitForSR(e.spatialReference),l=s.getMetersPerVerticalUnitForSR(t.layers.getItemAt(0).spatialReference);if(a!==l){const e=i.geometry;e.points=e.points.map((([e,o,t])=>[e,o,t===r.noDataValue?t:t*l/a]))}return i}));function o(e,o){return r.apply(this,arguments)}return o}(),u.attach=function(e){return t.handlesGroup([r.prototype.attach.call(this,e),a.watch((()=>this.queryElevationDependencies),(()=>this._onChange()))])},e._createClass(l,[{key:"available",get:function(){const e=this._ground;return n.isSome(e)&&e.layers.some((e=>e.visible))}},{key:"minDemResolution",get:function(){return v.getGroundMinDemResolution(this._ground)}},{key:"queryElevationDependencies",get:function(){return this._getQueryElevationDependencies(this._ground,this._groundLayers)}},{key:"_ground",get:function(){var e;return n.applySome(null==(e=this._viewModel)?void 0:e.view,(e=>{var r;return null==(r=e.map)?void 0:r.ground}))}},{key:"_groundLayers",get:function(){const e=this._ground,r=n.applySome(e,(e=>{var r;return null==(r=e.layers)?void 0:r.toArray()}));return n.unwrapOr(r,[])}}]),l}(y);r.__decorate([l.property({type:o,nonNullable:!0})],_.prototype,"color",void 0),r.__decorate([l.property()],_.prototype,"viewVisualizationEnabled",void 0),r.__decorate([l.property()],_.prototype,"available",null),r.__decorate([l.property({readOnly:!0})],_.prototype,"minDemResolution",null),r.__decorate([l.property()],_.prototype,"queryElevationDependencies",null),r.__decorate([l.property()],_.prototype,"_ground",null),r.__decorate([l.property()],_.prototype,"_groundLayers",null),_=r.__decorate([d.subclass("esri.widgets.ElevationProfile.ElevationProfileLineGround")],_);return _}));
