/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import o from"../../request.js";import r from"../../core/Error.js";import{parseUrl as e}from"../utils.js";import t from"../support/AddressCandidate.js";import a from"../support/LocationToAddressParameters.js";async function n(n,s,d){const u=e(n),{path:c,query:p}=u,l=a.from(s);if(!l.location)throw new r("location-to-address:location-required","The location parameter is required");const f={...d,query:{...p,...i(l),f:"json"}},m=`${c}/reverseGeocode`,{data:j}=await o(m,f),{address:y,location:S}=j;return t.fromJSON({address:y?.Match_addr??"",attributes:y,location:S,score:100})}function i(o){const r=o.toJSON(),{featureTypes:e,forStorage:t,langCode:a,location:n,locationType:i,outFields:s,outSR:d,preferredLabelValues:u,returnInputLocation:c,token:p}=r;return{featureTypes:e?.join(","),forStorage:t,langCode:a,location:JSON.stringify(n),locationType:i,outFields:s?.join(","),outSR:d?.wkid??void 0,preferredLabelValues:u,returnInputLocation:c,token:p}}export{n as locationToAddress};
