import e from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import{jsxs as n,jsx as o}from"react/jsx-runtime";import{useState as i,useEffect as c,useCallback as s}from"react";import{FilesDropzone as l}from"../FilesDropzone/FilesDropzone.js";import{FilesLoaderV2 as u}from"../FilesLoaderV2/FilesLoaderV2.js";import{useStyles as a}from"./styles.js";import f from"classnames";import{Processor as m}from"./Processor.js";function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var d=function(r){var p=r.multiple,d=r.accept,g=r.className,v=r.processFile,O=r.value,j=void 0===O?[]:O,y=r.onDone,h=r.onDelete,P=r.maxFiles,D=r.maxSize,F=r.formatProgress,w=r.onProcessingFailure,x=r.onStartProcessing,S=a(),z=i([]),N=t(z,2),A=N[0],C=N[1];c((function(){A.length>0&&A.every((function(e){return"success"in e}))&&A.some((function(e){return e.success}))&&(C((function(e){return e.filter((function(e){return!e.success}))})),y(A.filter((function(e){return e.success})).map((function(e){return e.data}))))}),[A]);var E=s((function(e){C((function(r){return r.filter((function(r){return r.file!==e}))}))}),[]),L=s((function(e){e.success||null==w||w(e.file,e.cancelled,e.error),C((function(r){return r.map((function(r){return r.file===e.file?b(b({},r),{},{data:e.data,success:e.success}):r}))}))}),[]),V=s((function(r){null==x||x(r);var t=r.map((function(e){return{file:e}}));C((function(r){return[].concat(e(r),e(t))}))}),[]);return n("div",{className:f(S.root,g),children:[(p||0===A.length&&0===(null==j?void 0:j.length))&&o(l,{multiple:p,onDrop:V,accept:d,maxFiles:P,maxSize:D}),(A.length>0||(null==j?void 0:j.length)>0)&&n("div",{className:S.files,children:[A.map((function(e){return o(m,{processFile:v,onStatusChange:L,file:e.file,onDelete:E,formatProgress:F},"".concat(e.file.size,"|").concat(e.file.name))})),null==j?void 0:j.map((function(e){return o(u,{name:e.name,onDelete:h?function(){return h(e)}:void 0,total:0,current:0})}))]})]})};export{d as FilesProcessor};
//# sourceMappingURL=FilesProcessor.js.map
