/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../Color","../../../core/Accessor","../../../core/Handles","../../../core/maybe","../../../core/reactiveUtils","../../../core/throttle","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../chunks/vec4f64","../../../geometry/Polyline","../../../views/3d/interactive/visualElements/OutlineVisualElement","./constants"],(function(e,t,o,s,r,i,n,l,a,c,u,h,d,f,p,_,y,v){"use strict";const m=100;e.ProfileLines3D=function(e){function o(t){var o;return(o=e.call(this,t)||this)._chartData=null,o._visualElements=[],o._handles=new i,o}t._inheritsLoose(o,e);var r=o.prototype;return r.initialize=function(){const e=a.throttle((e=>{this._update(e)}),m);this._handles.add([l.watch((()=>({spatialReference:this.view.spatialReference,chartData:this._chartData})),e,l.syncAndInitial),e])},r.destroy=function(){this._handles.destroy(),this._destroyVisualElements()},r.remove=function(){this._destroyVisualElements()},r.update=function(e){this._chartData=e},r._update=function(e){const{chartData:t}=e;if(n.isNone(t))return this.remove();if(!t.refined)return;const o=this._visualElements,r=t.lines.filter((e=>e.viewVisualizationEnabled)),i=r.length;for(;o.length>i;)o.pop().destroy();const l=v.PROFILE_LINES_STYLE_3D;for(;o.length<i;){const e=new y.OutlineVisualElement({view:this.view,elevationInfo:{mode:"absolute-height",offset:0},innerWidth:l.width-l.outlineSize,width:l.width,falloff:l.falloff,color:l.outlineColor,renderOccluded:l.renderOccluded});o.push(e)}const a=e.spatialReference;for(let n=0;n<i;++n){const e=o[n],t=r[i-1-n];e.geometry=this._createLineGeometry(t,a),e.innerColor=p.fromArray(s.toUnitRGBA(t.color))}},r._createLineGeometry=function(e,t){const o=n.unwrapOr(e.samples,[]),s=o.length-1,r=[];let i=[];for(let l=0;l<=s;l++){const{x:e,y:t,z:a}=o[l];n.isSome(a)&&i.push([e,t,a]),(l===s||n.isNone(a))&&i.length&&(r.push(i),i=[])}return new _({paths:r,hasZ:!0,spatialReference:t})},r._destroyVisualElements=function(){this._visualElements.forEach((e=>e.destroy())),this._visualElements.length=0},o}(r),o.__decorate([c.property()],e.ProfileLines3D.prototype,"view",void 0),o.__decorate([c.property()],e.ProfileLines3D.prototype,"_chartData",void 0),e.ProfileLines3D=o.__decorate([f.subclass("esri.widgets.ElevationProfile.support.ProfileLines3D")],e.ProfileLines3D),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
