/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
class t{filter(t,n){return n}notifyElevationSourceChange(){}}class n{filter(t,n){const{point:r,distance:o}=t,{z:c}=r;if(!(null!=c))return n;if(0===n.length)return n;const i=s(o),u=this._updateCandidatesTo3D(n,r,i).filter(e);return u.sort(a),u}_updateCandidatesTo3D(t,n,e){for(const r of t)switch(r.type){case"edge":o(r,n,e);continue;case"vertex":i(r,n,e);continue}return t}}function e(t){return t.distance<=1}function r(e=!1){return e?new n:new t}function o(t,n,{x:e,y:r,z:o}){const{start:i,end:s,target:a}=t;if(t.curve)throw new Error("Curves are not yet supported.");t.draped||c(a,n,i,s);const u=(n.x-a.x)/e,d=(n.y-a.y)/r,f=(n.z-a.z)/o;t.distance=Math.sqrt(u*u+d*d+f*f)}function c(t,n,e,r){const o=r.x-e.x,c=r.y-e.y,i=r.z-e.z,s=o*o+c*c+i*i,a=(n.x-e.x)*o+(n.y-e.y)*c+i*(n.z-e.z),u=Math.min(1,Math.max(0,a/s)),d=e.x+o*u,f=e.y+c*u,y=e.z+i*u;t.x=d,t.y=f,t.z=y}function i(t,n,{x:e,y:r,z:o}){const{target:c}=t,i=(n.x-c.x)/e,s=(n.y-c.y)/r,a=(n.z-c.z)/o,u=Math.sqrt(i*i+s*s+a*a);t.distance=u}function s(t){return"number"==typeof t?{x:t,y:t,z:t}:t}function a(t,n){return t.distance-n.distance}export{r as getSnappingCandidateElevationFilter};
