/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import i from"../../../../core/Accessor.js";import{getContrast as o}from"../../../../core/colorUtils.js";import{watch as s,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{throttle as a}from"../../../../core/throttle.js";import{property as l,subclass as n}from"../../../../core/accessorSupport/decorators.js";import p from"../../../../symbols/CIMSymbol.js";import{getConfig as c}from"../../../analysis/ElevationProfile/constants.js";import{ElevationProfileHoveredPointVisualization as h}from"../../../analysis/ElevationProfile/ElevationProfileHoveredPointVisualization.js";import{createLineGeometry as y}from"../../../analysis/ElevationProfile/elevationProfileVisualizationUtils.js";let d=class extends i{constructor(e){super(e),this._graphic=new t,this._updateGeometryThrottled=a(e=>{e&&(this._graphic.geometry=y(e.samples,e.spatialReference))},c().profileLinesUpdateThrottleMillis)}initialize(){this.addGraphic(this._graphic),this._indicatorVisualization=new h({analysisViewData:this.analysisViewData,line:this.line,view:this.view}),this.addHandles([s(()=>this._effectiveLineVisible,e=>{this._graphic.visible=e},r),s(()=>this._effectiveIndicatorVisible,e=>{this._indicatorVisualization.visible=e},r),s(()=>this._colorUpdateParameters,e=>this._updateColor(e),r),s(()=>this.analysisViewData.analysis.geometry,()=>{this._graphic.geometry=null},r),s(()=>this._geometryUpdateParameters,e=>this._updateGeometryThrottled(e),r),this._updateGeometryThrottled])}destroy(){this._graphic.destroy()}get updating(){return this._updateGeometryThrottled.hasPendingUpdates()}get _result(){return this.analysisViewData.results.find(e=>e.computation.profile===this.line)}get _effectiveLineVisible(){return this.getEffectiveVisible("lineVisible")}get _effectiveIndicatorVisible(){const e=this.getEffectiveVisible("hoveredPointVisible");return this._effectiveLineVisible?e&&!!this._graphic.geometry:e}getEffectiveVisible(e){const{analysisViewData:t,_result:i}=this;return t.visible&&!!i?.available&&i.computation.profile.viewOptions[e]}get _geometryUpdateParameters(){const e={samples:this._result?.samples,spatialReference:this.view.spatialReference};return e.samples&&this._effectiveLineVisible&&1!==this.analysisViewData.progress?null:e}get _colorUpdateParameters(){const e=this._result?.computation.profile.color;return e?{color:e.toArray(),contrastColor:o(e).toArray()}:null}_updateColor(e){e&&(this._graphic.symbol=new p({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",capStyle:"Butt",color:e.color,effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],joinStyle:"Round",width:1.5},{type:"CIMSolidStroke",capStyle:"Butt",color:e.contrastColor,joinStyle:"Round",width:1.5}]}}}))}};e([l({constructOnly:!0})],d.prototype,"addGraphic",void 0),e([l({constructOnly:!0})],d.prototype,"analysisViewData",void 0),e([l({constructOnly:!0})],d.prototype,"line",void 0),e([l({constructOnly:!0})],d.prototype,"view",void 0),e([l()],d.prototype,"updating",null),e([l()],d.prototype,"_result",null),e([l()],d.prototype,"_effectiveLineVisible",null),e([l()],d.prototype,"_effectiveIndicatorVisible",null),e([l()],d.prototype,"_geometryUpdateParameters",null),e([l()],d.prototype,"_colorUpdateParameters",null),d=e([n("esri.views.2d.analysis.ElevationProfile.ElevationProfileLineVisualization2D")],d);export{d as ElevationProfileLineVisualization2D};
