/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import r from"../request.js";import{normalizeCentralMeridian as e}from"../geometry/support/normalizeUtils.js";import{parseUrl as t,encode as o,asValidOptions as s}from"./utils.js";import{identifyToIdentifyRESTParameters as n}from"./operations/identify.js";import u from"./support/IdentifyParameters.js";import i from"./support/IdentifyResult.js";async function f(u,i,f){const c=(i=a(i)).geometry?[i.geometry]:[],l=t(u);return l.path+="/identify",e(c).then(e=>{const t=n(i,{geometry:e?.[0]}),u=o({...l.query,f:"json",...t}),a=s(u,f);return r(l.path,a).then(m).then(r=>p(r,i.sublayers))})}function m(r){const e=r.data;return e.results=e.results||[],e.exceededTransferLimit=Boolean(e.exceededTransferLimit),e.results=e.results.map(r=>i.fromJSON(r)),e}function a(r){return r=u.from(r)}function p(r,e){if(!e?.length)return r;const t=new Map;function o(r){t.set(r.id,r),r.sublayers&&r.sublayers.forEach(o)}e.forEach(o);for(const s of r.results)s.feature.sourceLayer=t.get(s.layerId);return r}export{f as identify};
