"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),r=require("react/jsx-runtime"),n=require("react"),s=require("../FilesDropzone/FilesDropzone.js");require("../../utils/index.js");var t=require("../FilesLoaderV2/FilesLoaderV2.js"),i=require("./styles.js"),u=require("classnames"),o=require("./Processor.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=a(u);exports.FilesProcessor=function(u){var a=u.multiple,c=u.accept,f=u.className,d=u.processFile,m=u.value,p=void 0===m?[]:m,v=u.onDone,_=u.onDelete,j=u.maxFiles,x=u.maxSize,g=u.formatProgress,F=i.useStyles(),q=n.useState([]),h=q[0],D=q[1];n.useEffect((function(){h.length>0&&h.every((function(e){return"success"in e}))&&h.some((function(e){return e.success}))&&(D((function(e){return e.filter((function(e){return!e.success}))})),v(h.filter((function(e){return e.success})).map((function(e){return e.data}))))}),[h]);var b=n.useCallback((function(e){D((function(r){return r.filter((function(r){return r.file!==e}))}))}),[]),y=n.useCallback((function(r){D((function(n){return n.map((function(n){return n.file===r.file?e.__assign(e.__assign({},n),{data:r.data,success:r.success}):n}))}))}),[]),z=n.useCallback((function(r){var n=r.map((function(e){return{file:e}}));D((function(r){return e.__spreadArray(e.__spreadArray([],r,!0),n,!0)}))}),[]);return r.jsxs("div",e.__assign({className:l.default(F.root,f)},{children:[(a||0===h.length&&0===(null==p?void 0:p.length))&&r.jsx(s.FilesDropzone,{multiple:a,onDrop:z,accept:c,maxFiles:j,maxSize:x}),(h.length>0||(null==p?void 0:p.length)>0)&&r.jsxs("div",e.__assign({className:F.files},{children:[h.map((function(e){return r.jsx(o.Processor,{processFile:d,onStatusChange:y,file:e.file,onDelete:b,formatProgress:g},"".concat(e.file.size,"|").concat(e.file.name))})),null==p?void 0:p.map((function(e){return r.jsx(t.FilesLoaderV2,{name:e.name,onDelete:_?function(){return _(e)}:void 0,total:0,current:0})}))]}))]}))};
