/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{handlesGroup as e}from"../../../core/handleUtils.js";import{watch as t,initial as o}from"../../../core/reactiveUtils.js";import n from"../../../geometry/Extent.js";import{projectOrLoad as r}from"../../../geometry/projectionUtils.js";import{projectBoundingRect as i}from"../../../geometry/projection/projectBoundingRect.js";import{intersects as l,fromExtent as s,empty as c}from"../../../geometry/support/aaBoundingRect.js";function m(c){let m=!1;const u=(e,t,o)=>{if(m)return;if(a(e,o)||null==t)return;const g=r(t,c.view.spatialReference);if(null!=g.pending)return m=!0,void g.pending.finally(()=>{m=!1,u(e,t,o)});const v=g.geometry;if(null==v)return;const d="point"===v.type?n.fromPoint(v):v.extent;if(null==d)return;i(e.extent,e.spatialReference,f,c.view.spatialReference)&&l(f,s(d,p))&&c.onElevationChanges()};let g;const v=t(()=>({elevationMode:c.elevationInfo?.mode,geometry:c.geometry}),({elevationMode:e,geometry:t})=>{g?.remove(),"absolute-height"!==e&&(g=c.view.elevationProvider.on("elevation-change",o=>u(o,t,e)))},o);return e([v,g])}function a({context:e},t){return null!=t&&("absolute-height"===t||"scene"===e&&"relative-to-scene"!==t)}const f=c(),p=c();export{m as createElevationUpdateHandle};
