/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{isSome as e}from"../../../core/arrayUtils.js";import{convertUnit as t}from"../../../core/units.js";import{load as r,execute as o,isLoaded as i,executeMany as s}from"../gx/operatorGeodesicBuffer.js";import{geodeticCurveType as n}from"../support/geodeticCurveType.js";let a,m,c;function u(){return!!a&&i()}async function p(){if(!u()){const[e]=await Promise.all([import("../support/jsonConverter.js"),r()]);a=e.fromGeometries,m=e.fromGeometry,c=e.toGeometry}}function f(e,r,i={}){let{curveType:s="geodesic",maxDeviation:a=NaN,unit:u}=i;u&&(r=t(r,u,"meters"),a&&(a=t(a,u,"meters")));const p=m(e),f=p.getSpatialReference();return c(o(p.getGeometry(),f,n[s],r,a),f)}function l(r,o,i={}){let{curveType:m="geodesic",maxDeviation:u=NaN,union:p=!1,unit:f}=i;f&&(o=o.map(e=>t(e,f,"meters")),u&&(u=t(u,f,"meters")));const[l,y]=a(r);return s(l,y,n[m],o,u,p).map(e=>c(e,y)).filter(e)}export{f as execute,l as executeMany,u as isLoaded,p as load};
