/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{getMetersPerUnitForSR as e}from"../../../core/units.js";import{distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{absoluteHeightElevationInfo as r}from"../../../support/elevationInfoUtils.js";import{fromAnyMapPoint as s,asVec2 as i}from"../sketch/normalizedPoint.js";import{defaults as o}from"./Settings.js";import{squaredScreenDistance as h}from"./snappingUtils.js";import{vectorToScreenPoint as n}from"../support/viewUtils.js";class l{constructor(e,t){this.view=e,this.options=t,this.squaredShortLineThreshold=o.shortLineThreshold*o.shortLineThreshold}snap(e,t){return null!=t.vertexHandle?"vertex"!==t.vertexHandle.type?[]:this.snapExistingVertex(e,t):this.snapNewVertex(e,t)}edgeExceedsShortLineThreshold(e,t){return this.exceedsShortLineThreshold(s(e.leftVertex.pos,this.view,t),s(e.rightVertex.pos,this.view,t),t)}exceedsShortLineThreshold(e,t,{spatialReference:s}){return 0===this.squaredShortLineThreshold||h(n(t,s,r,this.view),n(e,s,r,this.view))>this.squaredShortLineThreshold}isVertical(r,s,{spatialReference:h}){const n=e(h);return t(i(r),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:t}=this.options,r=e*t;return r*r}}export{l as SnappingAlgorithm};
