"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),o=u(r),l=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=e.isCacheEnabled,b=void 0!==p&&p,v=n.useState(c),h=o.default(v,2),g=h[0],y=h[1],m=n.useState(f),q=o.default(m,2),x=q[0],k=q[1],D=n.useState(null),S=o.default(D,2),w=S[0],F=S[1],L=n.useRef({}),A=n.useCallback(a.debounce(i.default(l.default.mark((function e(){var t,n,i,o,s,c,d=arguments;return l.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(y(!0),e.prev=1,t=d.length,n=new Array(t),i=0;i<t;i++)n[i]=d[i];if(o=JSON.stringify(n),!L.current[o]||!b){e.next=7;break}return k(a.clone(L.current[o])),e.abrupt("return");case 7:return e.next=9,r.apply(void 0,n);case 9:s=e.sent,c=u(s),k(c),b&&(L.current[o]=c),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(1),F(e.t0),console.error(e.t0);case 19:return e.prev=19,y(!1),e.finish(19);case 22:case"end":return e.stop()}}),e,null,[[1,15,19,22]])}))),500),[u,r,b]);return{isLoading:g,data:x,error:w,loadData:A,setData:k,setIsLoading:y}};
//# sourceMappingURL=useLoadedData.js.map
