/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import{getMetersPerUnitForSR as e}from"../../../core/units.js";import{distance as r}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{absoluteHeightElevationInfo as t}from"../../../support/elevationInfoUtils.js";import{fromAnyMapPoint as s,asVec2 as i}from"../sketch/normalizedPoint.js";import{defaults as o}from"./Settings.js";import"../../../core/RandomLCG.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/watch.js";import"../../../core/has.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../core/sql/UnknownTimeZone.js";import"../../../time/constants.js";import"luxon";import"../../../intl/date.js";import"../../../rest/support/Query.js";import"../../input/InputManager.js";import"../keybindings.js";import{squaredScreenDistance as h}from"../../../core/screenUtils.js";import{vectorToScreenPoint as n}from"../support/viewUtils.js";class p{constructor(e,r){this.view=e,this.options=r,this.squaredShortLineThreshold=o.shortLineThreshold*o.shortLineThreshold}async snap(e,r){return null!=r.vertexHandle?"vertex"!==r.vertexHandle.type?[]:this.snapExistingVertex(e,r):this.snapNewVertex(e,r)}edgeExceedsShortLineThreshold(e,r){return this.exceedsShortLineThreshold(s(e.leftVertex.pos,this.view,r),s(e.rightVertex.pos,this.view,r),r)}exceedsShortLineThreshold(e,r,{spatialReference:s}){return 0===this.squaredShortLineThreshold||h(n(r,s,t,this.view),n(e,s,t,this.view))>this.squaredShortLineThreshold}isVertical(t,s,{spatialReference:h}){const n=e(h);return r(i(t),i(s))*n<o.verticalLineThresholdMeters}squaredProximityThreshold(e){return"touch"===e?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:e,touchSensitivityMultiplier:r}=this.options,t=e*r;return t*t}}export{p as SnappingAlgorithm};
