/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../core/maybe","../../../chunks/vec2f64","./SnappingAlgorithm","./snappingUtils","./candidates/LineSnappingCandidate","../support/viewUtils","../../support/geometry2dUtils"],(function(e,t,n,o,i,r,s,a,p){"use strict";let d=function(e){function i(){return e.apply(this,arguments)||this}t._inheritsLoose(i,e);var d=i.prototype;return d.snapNewVertex=function(e,t){const n=t.editGeometryOperations.data.components[0],o=n.edges.length,i=[];if(o<1)return i;const r=t.coordinateHelper,s=a.anyMapPointToScreenPoint(e,r,t.elevationInfo,this.view),p=n.edges[o-1];let d=p;do{this.edgeExceedsShortLineThreshold(d,t)&&this._processCandidateProposal(d.leftVertex.pos,d.rightVertex.pos,e,s,t,i),d=d.leftVertex.leftEdge}while(d&&d!==p);return i},d.snapExistingVertex=function(e,t){const o=[],i=n.unwrap(t.vertexHandle),r=i.component;if(r.edges.length<2)return o;const s=t.coordinateHelper,p=a.anyMapPointToScreenPoint(e,s,t.elevationInfo,this.view),d=i.leftEdge,l=i.rightEdge;d&&l&&this.edgeExceedsShortLineThreshold(d,t)&&this.edgeExceedsShortLineThreshold(l,t)&&this._processCandidateProposal(d.leftVertex.pos,l.rightVertex.pos,e,p,t,o);const h=r.edges[0];let c=h;do{c!==i.leftEdge&&c!==i.rightEdge&&this.edgeExceedsShortLineThreshold(c,t)&&this._processCandidateProposal(c.leftVertex.pos,c.rightVertex.pos,e,p,t,o),c=c.rightVertex.rightEdge}while(c&&c!==h);return o},d._processCandidateProposal=function(e,t,n,i,d,l){const h=p.projectPointToLine(o.create(),n,e,t),{coordinateHelper:c,elevationInfo:g,pointer:u}=d,f=c.fromXYZ(h,c.getZ(n,0));r.squareDistance(i,a.anyMapPointToScreenPoint(f,c,g,this.view))<this.squaredProximityTreshold(u)&&l.push(new s.LineSnappingCandidate({coordinateHelper:c,lineStart:e,lineEnd:t,targetPoint:f,elevationInfo:g}))},i}(i.SnappingAlgorithm);e.LineSnapper=d,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
