/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{watch as i,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{throttle as o}from"../../../core/throttle.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromArray as a}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{OutlineVisualElement as n}from"../../../views/3d/interactive/visualElements/OutlineVisualElement.js";import{getConfig as d}from"./constants.js";import{createLineGeometry as h}from"./visualizationUtils.js";let c=class extends e{constructor(t){super(t),this._chartData=null,this._visualElements=[],this._throttledUpdate=null,this._update=t=>{const{chartData:e}=t;if(null==e)return this.remove();if(!e.refined)return;const i=this._visualElements,s=e.lines.filter(t=>t.viewVisualizationEnabled),o=s.length;for(;i.length>o;)i.pop().destroy();const r=d().profileLinesStyle3D;for(;i.length<o;){const t=new n({view:this.view,elevationInfo:{mode:"absolute-height",offset:0},innerWidth:r.innerWidth,innerColor:r.innerColor,width:r.width,falloff:r.falloff,renderOccluded:r.renderOccluded,isDecoration:!0});i.push(t)}const l=t.spatialReference;for(let n=0;n<o;++n){const t=i[n],e=s[o-1-n];t.geometry=h(e,l),t.color=a(e.color.toUnitRGBA())}}}initialize(){const t=d().profileLinesUpdateThrottleMillis;let e=this._update;if(t>0){const i=o(this._update,t);this.addHandles(i),this._throttledUpdate=i,e=i}this.addHandles([i(()=>({spatialReference:this.view.spatialReference,chartData:this._chartData}),e,s)])}destroy(){this._destroyVisualElements()}get updating(){return!0===this._throttledUpdate?.hasPendingUpdates()}remove(){this._destroyVisualElements()}update(t){this._chartData=t}_destroyVisualElements(){this._visualElements.forEach(t=>t.destroy()),this._visualElements.length=0}};t([r()],c.prototype,"view",void 0),t([r()],c.prototype,"_chartData",void 0),t([r()],c.prototype,"updating",null),c=t([l("esri.widgets.ElevationProfile.support.ProfileLines3D")],c);export{c as ProfileLines3D};
