/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import r from"../../request.js";import{parseUrl as t,encode as e,asValidOptions as s}from"../utils.js";import{isValidExtent as o,isValidLocation as n}from"./utils.js";import a from"../support/AddressCandidate.js";import i from"../support/AddressToLocationsParameters.js";async function d(o,n,a){const d=i.from(n),p=t(o),{address:m,...u}=d.toJSON(),c={...m,...u,f:"json"},j=e({...p.query,...c}),l=s(j,a),A=`${p.path}/findAddressCandidates`;return r(A,l).then(f)}function f({data:r}){if(!r)return[];const{candidates:t,spatialReference:e}=r;return t?t.map(r=>{if(!r)return;const{extent:t,location:s}=r,i=!t||o(t);return n(s)&&i?(t&&(t.spatialReference=e),s&&(s.spatialReference=e),a.fromJSON(r)):void 0}):[]}export{d as addressToLocations};
