"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"),l=require("./Processor.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(u);exports.FilesProcessor=function(u){var o=u.multiple,c=u.accept,f=u.className,d=u.processFile,m=u.value,p=void 0===m?[]:m,v=u.onDone,_=u.onDelete,g=u.maxFiles,j=u.maxSize,x=u.formatProgress,F=u.onProcessingFailure,q=u.onStartProcessing,h=i.useStyles(),D=n.useState([]),P=D[0],b=D[1];n.useEffect((function(){P.length>0&&P.every((function(e){return"success"in e}))&&P.some((function(e){return e.success}))&&(b((function(e){return e.filter((function(e){return!e.success}))})),v(P.filter((function(e){return e.success})).map((function(e){return e.data}))))}),[P]);var y=n.useCallback((function(e){b((function(r){return r.filter((function(r){return r.file!==e}))}))}),[]),z=n.useCallback((function(r){r.success||null==F||F(r.file,r.cancelled,r.error),b((function(n){return n.map((function(n){return n.file===r.file?e.__assign(e.__assign({},n),{data:r.data,success:r.success}):n}))}))}),[]),S=n.useCallback((function(r){null==q||q(r);var n=r.map((function(e){return{file:e}}));b((function(r){return e.__spreadArray(e.__spreadArray([],r,!0),n,!0)}))}),[]);return r.jsxs("div",e.__assign({className:a.default(h.root,f)},{children:[(o||0===P.length&&0===(null==p?void 0:p.length))&&r.jsx(s.FilesDropzone,{multiple:o,onDrop:S,accept:c,maxFiles:g,maxSize:j}),(P.length>0||(null==p?void 0:p.length)>0)&&r.jsxs("div",e.__assign({className:h.files},{children:[P.map((function(e){return r.jsx(l.Processor,{processFile:d,onStatusChange:z,file:e.file,onDelete:y,formatProgress:x},"".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})}))]}))]}))};
