import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/regenerator";import{jsx as n}from"react/jsx-runtime";import{useState as o,useCallback as a,useMemo as c,useEffect as i}from"react";import{FilesLoader as u}from"../FilesLoader/FilesLoader.js";var l=function(l){var s=l.onStatusChange,f=l.file,m=l.processFile,p=l.onDelete,d=l.formatProgress,v=o({total:0,current:0,indeterminate:!0,complete:!1}),b=r(v,2),x=b[0],g=b[1],h=o(),k=r(h,2),y=k[0],w=k[1],C=o(!1),F=r(C,2),j=F[0],D=F[1],E=o(),L=r(E,2),P=L[0],S=L[1],T=a((function(e,r){g({total:e,current:r,indeterminate:!1,complete:!1})}),[]),A=c((function(){if(P)return function(){P(),D(!0),s({success:!1,cancelled:!0,file:f})}}),[P,f,s]),G=a((function(){var r=!1;return function(){var n=e(t.mark((function e(n){var o,a,c,i;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,o=function(){r||T.apply(void 0,arguments)},a=function(e){S((function(){return function(){r=!0,e()}}))},e.next=5,m(n,o,a);case 5:if(c=e.sent,!r){e.next=8;break}return e.abrupt("return");case 8:g((function(e){var r=e.total;return{total:r,current:r,indeterminate:e.indeterminate,complete:!0}})),s({success:!0,cancelled:!1,data:c,file:n}),e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(0),!r){e.next=16;break}return e.abrupt("return");case 16:i=e.t0 instanceof Error?e.t0:new Error(String(e.t0)),w(i),s({success:!1,cancelled:!1,error:i,file:n});case 19:case"end":return e.stop()}}),e,null,[[0,12]])})));return function(e){return n.apply(this,arguments)}}()}),[m,s,T]),R=a((function(){w(void 0),D(!1),s({file:f,success:!1,data:void 0,error:void 0,cancelled:!1}),G()(f)}),[f,G,s]),q=a((function(){p(f)}),[p,f]);i((function(){G()(f)}),[f,G]);var z=j?"Cancelled":null,B=y?null==y?void 0:y.message:z;return n(u,{name:f.name,total:x.total,current:x.current,error:B,onCancel:A,onReload:R,onDelete:q,formatProgress:d,complete:x.complete,indeterminate:x.indeterminate})};export{l as Processor};
//# sourceMappingURL=Processor.js.map
