/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import e from"../../../core/Handles.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as i,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{HoveredPoints as n}from"./HoveredPoints.js";import{InputRepresentation3D as o}from"./InputRepresentation3D.js";import{ProfileLines3D as r}from"./ProfileLines3D.js";class h{constructor(t,h){this._handles=new e,this._inputRepresentation=new o({view:t}),this._hoveredPoints=new n({view:t}),this._profileLines=new r({view:t}),this._handles.add([i(()=>h.viewModel.hoveredPoints,e=>this._hoveredPoints.update(e),s),i(()=>h.viewModel.input?.geometry,()=>{this._profileLines.remove()},s),i(()=>{const{state:e,editable:t,highlightEnabled:i,viewModel:s}=h,n=s.input;return n&&(n.commitProperty("geometry"),n.commitProperty("layer")),{input:n,state:e,editable:t,highlightEnabled:i}},e=>this._updateInputRepresentation(e),s),i(()=>h.viewModel.chartData,e=>this._profileLines.update(e),s)])}get updating(){return this._inputRepresentation.updating||this._profileLines.updating}destroy(){this._handles=t(this._handles),this._inputRepresentation=t(this._inputRepresentation),this._hoveredPoints=t(this._hoveredPoints),this._profileLines=t(this._profileLines)}_updateInputRepresentation({input:e,state:t,editable:i,highlightEnabled:s}){const n=this._inputRepresentation;if(!s)return n.remove();"selected"===t?n.showHighlight(e):"created"!==t||i?n.remove():n.showReshaping(e)}}export{h as ElevationProfileView3D};
