/*
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/has","../../geometry/support/normalizeUtils","../../layers/support/Field","../../layers/support/MapImage","../utils","../support/DataFile","../support/FeatureSet","../support/LinearUnit","../support/ParameterValue","../support/RasterData"],(function(e,a,t,r,u,l,o,n,s,c,i,p,P){"use strict";function G(e,a,t,r,u){return f.apply(this,arguments)}function f(){return(f=a._asyncToGenerator((function*(e,a,r,l,o){const s={},c={},i=[];return v(l,i,s),u.normalizeCentralMeridian(i).then((u=>{const{outSpatialReference:i,processExtent:p,processSpatialReference:P,returnFeatureCollection:G,returnM:f,returnZ:v}=r,{path:m}=n.parseUrl(e);for(const e in s){const a=s[e];c[e]=u.slice(a[0],a[1])}const d=i?i.wkid||i:null,y=P?P.wkid||P:null,M="execute"===a?{returnFeatureCollection:G||void 0,returnM:f||void 0,returnZ:v||void 0}:null,b=S({...p?{context:{extent:p,outSR:d,processSR:y}}:{"env:outSR":d,"env:processSR":y},...l,...M,f:"json"},null,c),g={...o,query:b};return t(`${m}/${a}`,g)}))}))).apply(this,arguments)}function v(e,a,t){for(const r in e){const u=e[r];if(u&&"object"==typeof u&&u instanceof c){const{features:e}=u;t[r]=[a.length,a.length+e.length],e.forEach((e=>{a.push(e.geometry)}))}}}function m(e){const a=e.dataType,t=p.fromJSON(e);switch(a){case"GPBoolean":case"GPDouble":case"GPLong":case"GPString":case"GPMultiValue:GPBoolean":case"GPMultiValue:GPDouble":case"GPMultiValue:GPLong":case"GPMultiValue:GPString":return t;case"GPDate":t.value=new Date(t.value);break;case"GPDataFile":t.value=s.fromJSON(t.value);break;case"GPLinearUnit":t.value=i.fromJSON(t.value);break;case"GPFeatureRecordSetLayer":case"GPRecordSet":{const a=e.value.url;t.value=a?s.fromJSON(t.value):c.fromJSON(t.value);break}case"GPRasterData":case"GPRasterDataLayer":{const a=e.value.mapImage;t.value=a?o.fromJSON(a):P.fromJSON(t.value);break}case"GPField":t.value=l.fromJSON(t.value);break;case"GPMultiValue:GPDate":{const e=t.value;t.value=e.map((e=>new Date(e)));break}case"GPMultiValue:GPDataFile":t.value=t.value.map((e=>s.fromJSON(e)));break;case"GPMultiValue:GPLinearUnit":t.value=t.value.map((e=>i.fromJSON(e)));break;case"GPMultiValue:GPFeatureRecordSetLayer":case"GPMultiValue:GPRecordSet":t.value=t.value.map((e=>c.fromJSON(e)));break;case"GPMultiValue:GPRasterData":case"GPMultiValue:GPRasterDataLayer":t.value=t.value.map((e=>e?o.fromJSON(e):P.fromJSON(t.value)));break;case"GPMultiValue:GPField":t.value=t.value.map((e=>l.fromJSON(e)))}return t}function S(e,a,t){for(const r in e){const a=e[r];Array.isArray(a)?e[r]=JSON.stringify(a.map((e=>S({item:e},!0).item))):a instanceof Date&&(e[r]=a.getTime())}return n.encode(e,a,t)}e.collectGeometries=v,e.constructRequest=G,e.decode=m,e.gpEncode=S,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
