/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{throwIfAborted as t}from"../../core/promiseUtils.js";import{isLoaded as e,canProjectWithoutEngine as r,project as o,load as i}from"../../geometry/projectionUtils.js";let n,s=null;async function c(e){s||(s=import("../../portal/support/geometryServiceUtils.js").then(t=>n=t)),await s,t(e)}async function p(t,s,a,l){if(!t)return null;const m=t.spatialReference;return e()||r(m,s)?o(t,s):n?n.projectGeometry(t,s,a,l):(await Promise.race([c(l),i(l)]),p(t,s,a,l))}export{p as projectWithEngineOrService};
