/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t}from"tslib";import e 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{ElevationProfileIndicatorPointVisualization as h}from"../../../analysis/ElevationProfile/ElevationProfileIndicatorPointVisualization.js";import{createLineGeometry as y}from"../../../analysis/ElevationProfile/elevationProfileVisualizationUtils.js";let d=class extends i{constructor(t){super(t),this._graphic=new e,this._updateGeometryThrottled=a(t=>{t&&(this._graphic.geometry=y(t.samples,t.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,t=>{this._graphic.visible=t},r),s(()=>this._effectiveIndicatorVisible,t=>{this._indicatorVisualization.visible=t},r),s(()=>this._colorUpdateParameters,t=>this._updateColor(t),r),s(()=>this.analysisViewData.analysis.geometry,()=>{this._graphic.geometry=null},r),s(()=>this._geometryUpdateParameters,t=>this._updateGeometryThrottled(t),r),this._updateGeometryThrottled])}destroy(){this._graphic.destroy()}get updating(){return this._updateGeometryThrottled.hasPendingUpdates()}get _result(){return this.analysisViewData.results.find(t=>t.computation.profile===this.line)}get _effectiveLineVisible(){return this.getEffectiveVisible("lineVisible")}get _effectiveIndicatorVisible(){const t=this.getEffectiveVisible("indicatorPointVisible");return this._effectiveLineVisible?t&&!!this._graphic.geometry:t}getEffectiveVisible(t){const{analysisViewData:e,_result:i}=this;return e.visible&&!!i?.available&&i.computation.profile.viewOptions[t]}get _geometryUpdateParameters(){const t={samples:this._result?.samples,spatialReference:this.view.spatialReference};return t.samples&&this._effectiveLineVisible&&1!==this.analysisViewData.progress?null:t}get _colorUpdateParameters(){const t=this._result?.computation.profile.color;return t?{color:t.toArray(),contrastColor:o(t).toArray()}:null}_updateColor(t){t&&(this._graphic.symbol=new p({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",capStyle:"Butt",color:t.color,effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],joinStyle:"Round",width:1.5},{type:"CIMSolidStroke",capStyle:"Butt",color:t.contrastColor,joinStyle:"Round",width:1.5}]}}}))}};t([l({constructOnly:!0})],d.prototype,"addGraphic",void 0),t([l({constructOnly:!0})],d.prototype,"analysisViewData",void 0),t([l({constructOnly:!0})],d.prototype,"line",void 0),t([l({constructOnly:!0})],d.prototype,"view",void 0),t([l()],d.prototype,"updating",null),t([l()],d.prototype,"_result",null),t([l()],d.prototype,"_effectiveLineVisible",null),t([l()],d.prototype,"_effectiveIndicatorVisible",null),t([l()],d.prototype,"_geometryUpdateParameters",null),t([l()],d.prototype,"_colorUpdateParameters",null),d=t([n("esri.views.2d.analysis.ElevationProfile.ElevationProfileLineVisualization2D")],d);export{d as ElevationProfileLineVisualization2D};
