/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{convertUnit as t}from"../../core/units.js";import{getNearestCoordinate as e,getNearestVertex as r,getNearestVertices as s,load as i,supportsCurves as o,isLoaded as n}from"./gx/operatorProximityGeodesic.js";let a,m,c,u,p,d;function f(){return!!a&&n()}async function l(){if(!f()){const[t,e]=await Promise.all([import("./support/apiConverter.js"),import("./support/proximityResult.js"),i()]);a=t.fromGeometry,m=t.fromPoint,c=t.fromSpatialReference,u=t.getSpatialReference,p=e.toProximityResult,d=o()}}function g(r,s,i={}){let{calculateLeftRightSide:o=!1,maxDeviation:n=NaN,testPolygonInterior:d=!0,unit:f}=i;f&&n&&(n=t(n,f,"meters"));const l=u(r),g=e(a(r),m(s).getXY(),c(l),n,d,o);return f&&g.m_distance&&(g.m_distance=t(g.m_distance,"meters",f)),p(g,r,o)}function _(e,s,i={}){const{unit:o}=i,n=u(e),d=r(a(e),m(s).getXY(),c(n));return o&&d.m_distance&&(d.m_distance=t(d.m_distance,"meters",o)),p(d,e)}function x(e,r,i,o,n={}){const{unit:d}=n;d&&i&&(i=t(i,d,"meters"));const f=u(e);return s(a(e),m(r).getXY(),c(f),i,o).map(r=>(d&&r.m_distance&&(r.m_distance=t(r.m_distance,"meters",d)),p(r,e)))}export{g as getNearestCoordinate,_ as getNearestVertex,x as getNearestVertices,f as isLoaded,l as load,d as supportsCurves};
