/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as a,subclass as r}from"../../../core/accessorSupport/decorators.js";import{eyeWithinExtent as s}from"../camera/intersectionUtils.js";import{applySurfaceCollisionConstraint as i}from"../camera/constraintUtils/surfaceCollision.js";let o=class extends t{constructor(e){super(e),this._sourceCamera=null}initialize(){this.addHandles(this.view.elevationProvider.on("elevation-change",e=>this._handleElevationChangeEvent(e)))}setSourceCamera(e){this._sourceCamera=e.clone()}_handleElevationChangeEvent(e){!this.view.state.cameraController&&"ground"===e.context&&this.view.state.constraints.collision.enabled&&null!=e.spatialReference&&s(this.view,this._sourceCamera||this.view.state.camera,e.extent,e.spatialReference)&&this._applyToCurrentCamera()}_applyToCurrentCamera(){this.view.state.updateCamera(e=>{i(this.view,this._sourceCamera||this.view.state.camera,e,1)})}};e([a({constructOnly:!0})],o.prototype,"view",void 0),o=e([r("esri.views.3d.state.SurfaceCollisionConstraint")],o);export{o as SurfaceCollisionConstraint};
