/*
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","../../operations/urlUtils"],(function(e,t,o,r){"use strict";function n(e,t){const o=e.toJSON();return o.objectIds&&(o.objectIds=o.objectIds.join(",")),o.orderByFields&&(o.orderByFields=o.orderByFields.join(",")),!o.outFields||null!=t&&t.returnCountOnly?delete o.outFields:o.outFields.includes("*")?o.outFields="*":o.outFields=o.outFields.join(","),o.outSpatialReference&&(o.outSR=o.outSR.wkid||JSON.stringify(o.outSR.toJSON()),delete o.outSpatialReference),o.dynamicDataSource&&(o.layer=JSON.stringify({source:o.dynamicDataSource}),delete o.dynamicDataSource),o}function u(e,t,o){return a.apply(this,arguments)}function a(){return(a=t._asyncToGenerator((function*(e,t,o){const r=yield l(e,t,o),n=r.data,u=n.geometryType,a=n.spatialReference,i={};for(const s of n.relatedRecordGroups){const e={fields:void 0,objectIdFieldName:void 0,geometryType:u,spatialReference:a,hasZ:!!n.hasZ,hasM:!!n.hasM,features:s.relatedRecords};if(null!=s.objectId)i[s.objectId]=e;else for(const t in s)s.hasOwnProperty(t)&&"relatedRecords"!==t&&(i[s[t]]=e)}return{...r,data:i}}))).apply(this,arguments)}function i(e,t,o){return s.apply(this,arguments)}function s(){return(s=t._asyncToGenerator((function*(e,t,o){const r=yield l(e,t,o,{returnCountOnly:!0}),n=r.data,u={};for(const a of n.relatedRecordGroups)null!=a.objectId&&(u[a.objectId]=a.count);return{...r,data:u}}))).apply(this,arguments)}function l(e,t){return c.apply(this,arguments)}function c(){return(c=t._asyncToGenerator((function*(e,t,u={},a){const i=r.mapParameters({...e.query,f:"json",...a,...n(t,a)});return o(e.path+"/queryRelatedRecords",{...u,query:{...u.query,...i}})}))).apply(this,arguments)}e.executeRelationshipQuery=u,e.executeRelationshipQueryForCount=i,e.toQueryStringParameters=n,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
