import e from"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import{dataFormatter as t}from"../shared/dataFormatter.js";import{corvaAPI as a}from"../../../../clients/index.js";var i=["intervention_unit.name","intervention_unit.wells","intervention_unit.active_well"],u=function(){var e=n(r.mark((function e(n,u){var s,o;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.get("/v2/intervention_units",{per_page:300,page:n,sort:"name",fields:i},{signal:u});case 2:return o=e.sent,e.abrupt("return",null!==(s=t.deserialize(o))&&void 0!==s?s:[]);case 4:case"end":return e.stop()}}),e)})));return function(n,r){return e.apply(this,arguments)}}(),s=function(e){var n,r,t=null!==(n=null===(r=e.active_well)||void 0===r?void 0:r.asset_id)&&void 0!==n?n:null,a=function(e){if(null==e||!e.length)return[];var n=[];return e.forEach((function(e){null!=e.asset_id&&n.push(e.asset_id)})),n}(e.wells);return null==t||a.includes(t)||a.push(t),{id:Number(e.id),name:e.name,activeWellAssetId:t,assetIds:a}},o=function(){var t=n(r.mark((function n(t){var a,i,o,l;return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:a=[],i=1,o=!0;case 3:if(!o){n.next=13;break}return null==t||t.throwIfAborted(),n.next=7,u(i,t);case 7:l=n.sent,a.push.apply(a,e(l)),o=300===l.length,i+=1,n.next=3;break;case 13:return n.abrupt("return",a.map(s));case 14:case"end":return n.stop()}}),n)})));return function(e){return t.apply(this,arguments)}}();export{o as fetchInterventionUnits};
//# sourceMappingURL=fetchInterventionUnits.js.map
