/*
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","../request","../core/queryUtils","../geometry/support/normalizeUtils","./networkService","./utils","./support/ClosestFacilitySolveResult"],(function(e,r,t,i,s,a,o,n){"use strict";const l=i.createQueryParamsHelper({accumulateAttributes:{name:"accumulateAttributeNames"},attributeParameterValues:!0,directionsTimeAttribute:{name:"directionsTimeAttributeName"},impedanceAttribute:{name:"impedanceAttributeName"},facilities:!0,incidents:!0,outSpatialReference:{name:"outSR",getter:e=>e.outSpatialReference.wkid},pointBarriers:{name:"barriers"},polylineBarriers:!0,polygonBarriers:!0,restrictionAttributes:{name:"restrictionAttributeNames"},returnPointBarriers:{name:"returnBarriers"},returnRoutes:{name:"returnCFRoutes"},travelMode:!0});function u(e,r,t){return c.apply(this,arguments)}function c(){return(c=r._asyncToGenerator((function*(e,r,i){const u=[],c=[],p={},f={},m=o.parseUrl(e),{path:y}=m;r.incidents&&r.incidents.features&&a.collectGeometries(r.incidents.features,c,"incidents.features",p),r.facilities&&r.facilities.features&&a.collectGeometries(r.facilities.features,c,"facilities.features",p),r.pointBarriers&&r.pointBarriers.features&&a.collectGeometries(r.pointBarriers.features,c,"pointBarriers.features",p),r.polylineBarriers&&r.polylineBarriers.features&&a.collectGeometries(r.polylineBarriers.features,c,"polylineBarriers.features",p),r.polygonBarriers&&r.polygonBarriers.features&&a.collectGeometries(r.polygonBarriers.features,c,"polygonBarriers.features",p);const d=yield s.normalizeCentralMeridian(c);for(const t in p){const e=p[t];u.push(t),f[t]=d.slice(e[0],e[1])}if(a.isInputGeometryZAware(f,u)){let e=null;try{e=yield a.fetchServiceDescription(y,r.apiKey,i)}catch{}e&&!e.hasZ&&a.dropZValuesOffInputGeometry(f,u)}for(const t in f)f[t].forEach(((e,i)=>{r.get(t)[i].geometry=e}));const B={...i,query:{...m.query,...l.toQueryParams(r),f:"json"}},{data:b}=yield t(`${y}/solveClosestFacility`,B);return n.fromJSON(b)}))).apply(this,arguments)}e.solve=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
