"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/regenerator"),a=require("../../../../../clients/index.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e),u=i(r),c=i(t),l=i(n);function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){u.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var f=function(){var e=c.default(l.default.mark((function e(r){var t,n,i,u,c,s,f,b,h,y,d,g,v,O,j,m,P,w,k,q;return l.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.path,n=r.queryParams,i=r.chunkSize,u=void 0===i?1e3:i,c=r.fetchLimit,s=void 0===c?1/0:c,f=r.signal,b=r.paginationStyle,h=void 0===b?"offset":b,y=r.fetcher,d=void 0===y?a.corvaDataAPI.get:y,g=r.rawQueryString,v=[],O=[],m=1;case 4:return null==f||f.throwIfAborted(),k=s-v.length,j=Math.min(u,k),q="offset"===h?{limit:j,skip:v.length}:{per_page:j,page:m},e.next=10,d(t,p(p({},n),q),{signal:f,rawQueryString:g});case 10:O=e.sent,v.push.apply(v,o.default(null!==(w=O)&&void 0!==w?w:[])),m+=1;case 13:if(v.length<s&&(null===(P=O)||void 0===P?void 0:P.length)>0&&O.length===j){e.next=4;break}case 14:return e.abrupt("return",v);case 15:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}();exports.fetchDataByChunks=f;
//# sourceMappingURL=fetchDataByChunks.js.map
