"use strict";var e=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/regenerator"),a=require("lodash"),n=require("react");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=u(e),l=u(r),o=u(t);module.exports=function(e){var r=e.loadFn,t=e.getDataFromResponseFn,u=void 0===t?a.identity((function(e){return e})):t,s=e.initialLoading,c=void 0===s||s,d=e.initialData,f=void 0===d?null:d,p=n.useState(c),v=l.default(p,2),b=v[0],h=v[1],g=n.useState(f),m=l.default(g,2),q=m[0],y=m[1],x=n.useState(null),D=l.default(x,2),k=D[0],w=D[1],F=n.useRef(null),L=n.useCallback(a.debounce(i.default(o.default.mark((function e(){var t,n,i,l,s=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(h(!0),e.prev=1,t=s.length,n=new Array(t),i=0;i<t;i++)n[i]=s[i];return F.current=n,e.next=6,r.apply(void 0,n);case 6:l=e.sent,a.isEqual(F.current,n)&&y(u(l)),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),w(e.t0),console.error(e.t0);case 14:return e.prev=14,h(!1),e.finish(14);case 17:case"end":return e.stop()}}),e,null,[[1,10,14,17]])}))),500),[u,r]);return{isLoading:b,data:q,error:k,loadData:L,setData:y,setIsLoading:h}};
