"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),r=require("react/jsx-runtime"),t=require("react"),n=require("../FilesLoaderV2/FilesLoaderV2.js");exports.Processor=function(o){var s=o.onStatusChange,a=o.file,u=o.processFile,c=o.onDelete,l=o.formatProgress,i=t.useState({total:0,current:0}),f=i[0],d=i[1],v=t.useState(),b=v[0],m=v[1],g=t.useState(!1),p=g[0],C=g[1],_=t.useState(),S=_[0],h=_[1],j=t.useCallback((function(e,r){d({total:e,current:r})}),[]),x=t.useMemo((function(){if(S)return function(){S(),C(!0),s({success:!1,cancelled:!0,file:a})}}),[S]),k=t.useCallback((function(){var r=!1;return function(t){return e.__awaiter(void 0,void 0,void 0,(function(){var n,o,a,c;return e.__generator(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),n=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r||j.apply(void 0,e)},[4,u(t,n,(function(e){h((function(){return function(){r=!0,e()}}))}))];case 1:return o=e.sent(),r?[2]:(d((function(e){var r=e.total;return{total:r,current:r}})),s({success:!0,cancelled:!1,data:o,file:t}),[3,3]);case 2:return a=e.sent(),r?[2]:(c=a instanceof Error?a:new Error(String(a)),m(c),s({success:!1,cancelled:!1,error:c,file:t}),[3,3]);case 3:return[2]}}))}))}}),[u,s]),q=t.useCallback((function(){m(void 0),C(!1),s({file:a,success:!1,data:void 0,error:void 0,cancelled:!1}),k()(a)}),[a,k,s]),F=t.useCallback((function(){c(a)}),[c,a]);t.useEffect((function(){k()(a)}),[a,k]);var P=b?null==b?void 0:b.message:p?"Cancelled":null;return r.jsx(n.FilesLoaderV2,{name:a.name,total:f.total,current:f.current,errorText:P,onCancel:x,onReload:q,onDelete:F,formatProgress:l})};
