@sl-material/sl-import 1.0.0-beta15 → 1.0.0-beta17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sl-import.es.js CHANGED
@@ -3168,7 +3168,7 @@ class ImportDialogUploader {
3168
3168
  * 获取并发限制数
3169
3169
  */
3170
3170
  get concurrentLimit() {
3171
- return this.config.concurrentLimit ?? 3;
3171
+ return this.config.concurrentLimit != null ? this.config.concurrentLimit : 3;
3172
3172
  }
3173
3173
  /**
3174
3174
  * 判断是否应该使用分片上传
@@ -1562,7 +1562,7 @@
1562
1562
  <div class="import-dialog-vanilla-loading-spinner"></div>
1563
1563
  </div>
1564
1564
  `:""}
1565
- `}}var nt={exports:{}};(function(i){(function(){var t=function(e){if(!(this instanceof t))return new t(e);if(this.version=1,this.support=typeof File<"u"&&typeof Blob<"u"&&typeof FileList<"u"&&(!!Blob.prototype.webkitSlice||!!Blob.prototype.mozSlice||!!Blob.prototype.slice||!1),!this.support)return!1;var a=this;a.files=[],a.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,fileParameterName:"file",chunkNumberParameterName:"resumableChunkNumber",chunkSizeParameterName:"resumableChunkSize",currentChunkSizeParameterName:"resumableCurrentChunkSize",totalSizeParameterName:"resumableTotalSize",typeParameterName:"resumableType",identifierParameterName:"resumableIdentifier",fileNameParameterName:"resumableFilename",relativePathParameterName:"resumableRelativePath",totalChunksParameterName:"resumableTotalChunks",throttleProgressCallbacks:.5,query:{},headers:{},preprocess:null,method:"multipart",uploadMethod:"POST",testMethod:"GET",prioritizeFirstAndLastChunk:!1,target:"/",testTarget:null,parameterNamespace:"",testChunks:!0,generateUniqueIdentifier:null,getTarget:null,maxChunkRetries:100,chunkRetryInterval:void 0,permanentErrors:[400,404,415,500,501],maxFiles:void 0,withCredentials:!1,xhrTimeout:0,clearInput:!0,chunkFormat:"blob",setChunkTypeFromFile:!1,maxFilesErrorCallback:function(s,p){var g=a.getOpt("maxFiles");alert("Please upload no more than "+g+" file"+(g===1?"":"s")+" at a time.")},minFileSize:1,minFileSizeErrorCallback:function(s,p){alert(s.fileName||s.name+" is too small, please upload files larger than "+l.formatSize(a.getOpt("minFileSize"))+".")},maxFileSize:void 0,maxFileSizeErrorCallback:function(s,p){alert(s.fileName||s.name+" is too large, please upload files less than "+l.formatSize(a.getOpt("maxFileSize"))+".")},fileType:[],fileTypeErrorCallback:function(s,p){alert(s.fileName||s.name+" has type not allowed, please upload files of type "+a.getOpt("fileType")+".")}},a.opts=e||{},a.getOpt=function(s){var p=this;if(s instanceof Array){var g={};return l.each(s,function(u){g[u]=p.getOpt(u)}),g}if(p instanceof I){if(typeof p.opts[s]<"u")return p.opts[s];p=p.fileObj}if(p instanceof E){if(typeof p.opts[s]<"u")return p.opts[s];p=p.resumableObj}if(p instanceof t)return typeof p.opts[s]<"u"?p.opts[s]:p.defaults[s]},a.events=[],a.on=function(s,p){a.events.push(s.toLowerCase(),p)},a.fire=function(){for(var s=[],p=0;p<arguments.length;p++)s.push(arguments[p]);for(var g=s[0].toLowerCase(),p=0;p<=a.events.length;p+=2)a.events[p]==g&&a.events[p+1].apply(a,s.slice(1)),a.events[p]=="catchall"&&a.events[p+1].apply(null,s);g=="fileerror"&&a.fire("error",s[2],s[1]),g=="fileprogress"&&a.fire("progress")};var l={stopEvent:function(s){s.stopPropagation(),s.preventDefault()},each:function(s,p){if(typeof s.length<"u"){for(var g=0;g<s.length;g++)if(p(s[g])===!1)return}else for(g in s)if(p(g,s[g])===!1)return},generateUniqueIdentifier:function(s,p){var g=a.getOpt("generateUniqueIdentifier");if(typeof g=="function")return g(s,p);var u=s.webkitRelativePath||s.fileName||s.name,o=s.size;return o+"-"+u.replace(/[^0-9a-zA-Z_-]/img,"")},contains:function(s,p){var g=!1;return l.each(s,function(u){return u==p?(g=!0,!1):!0}),g},formatSize:function(s){return s<1024?s+" bytes":s<1024*1024?(s/1024).toFixed(0)+" KB":s<1024*1024*1024?(s/1024/1024).toFixed(1)+" MB":(s/1024/1024/1024).toFixed(1)+" GB"},getTarget:function(s,p){var g=a.getOpt("target");if(s==="test"&&a.getOpt("testTarget")&&(g=a.getOpt("testTarget")==="/"?a.getOpt("target"):a.getOpt("testTarget")),typeof g=="function")return g(p);var u=g.indexOf("?")<0?"?":"&",o=p.join("&");return g+u+o}},c=function(s){l.stopEvent(s),s.dataTransfer&&s.dataTransfer.items?b(s.dataTransfer.items,s):s.dataTransfer&&s.dataTransfer.files&&b(s.dataTransfer.files,s)},h=function(s){s.preventDefault()};function m(s,p,g,u){var o;if(s.isFile)return s.file(function(R){R.relativePath=p+R.name,g.push(R),u()});if(s.isDirectory?o=s:s instanceof File&&g.push(s),typeof s.webkitGetAsEntry=="function"&&(o=s.webkitGetAsEntry()),o&&o.isDirectory)return D(o,p+o.name+"/",g,u);typeof s.getAsFile=="function"&&(s=s.getAsFile(),s instanceof File&&(s.relativePath=p+s.name,g.push(s))),u()}function y(s,p){if(!s||s.length===0)return p();s[0](function(){y(s.slice(1),p)})}function D(s,p,g,u){var o=s.createReader();o.readEntries(function(R){if(!R.length)return u();y(R.map(function(C){return m.bind(null,C,p,g)}),u)})}function b(s,p){if(s.length){a.fire("beforeAdd");var g=[];y(Array.prototype.map.call(s,function(u){return m.bind(null,u,"",g)}),function(){g.length&&T(g,p)})}}var T=function(s,p){var g=0,u=a.getOpt(["maxFiles","minFileSize","maxFileSize","maxFilesErrorCallback","minFileSizeErrorCallback","maxFileSizeErrorCallback","fileType","fileTypeErrorCallback"]);if(typeof u.maxFiles<"u"&&u.maxFiles<s.length+a.files.length)if(u.maxFiles===1&&a.files.length===1&&s.length===1)a.removeFile(a.files[0]);else return u.maxFilesErrorCallback(s,g++),!1;var o=[],R=[],C=s.length,F=function(){if(!--C){if(!o.length&&!R.length)return;window.setTimeout(function(){a.fire("filesAdded",o,R)},0)}};l.each(s,function(O){var Y=O.name;if(u.fileType.length>0){var Z=!1;for(var W in u.fileType){var H="."+u.fileType[W];if(Y.toLowerCase().indexOf(H.toLowerCase(),Y.length-H.length)!==-1){Z=!0;break}}if(!Z)return u.fileTypeErrorCallback(O,g++),!1}if(typeof u.minFileSize<"u"&&O.size<u.minFileSize)return u.minFileSizeErrorCallback(O,g++),!1;if(typeof u.maxFileSize<"u"&&O.size>u.maxFileSize)return u.maxFileSizeErrorCallback(O,g++),!1;function se(X){a.getFromUniqueIdentifier(X)?R.push(O):function(){O.uniqueIdentifier=X;var de=new E(a,O,X);a.files.push(de),o.push(de),de.container=typeof p<"u"?p.srcElement:null,window.setTimeout(function(){a.fire("fileAdded",de,p)},0)}(),F()}var $=l.generateUniqueIdentifier(O,p);$&&typeof $.then=="function"?$.then(function(X){se(X)},function(){F()}):se($)})};function E(s,p,g){var u=this;u.opts={},u.getOpt=s.getOpt,u._prevProgress=0,u.resumableObj=s,u.file=p,u.fileName=p.fileName||p.name,u.size=p.size,u.relativePath=p.relativePath||p.webkitRelativePath||u.fileName,u.uniqueIdentifier=g,u._pause=!1,u.container="";var o=g!==void 0,R=function(C,F){switch(C){case"progress":u.resumableObj.fire("fileProgress",u,F);break;case"error":u.abort(),o=!0,u.chunks=[],u.resumableObj.fire("fileError",u,F);break;case"success":if(o)return;u.resumableObj.fire("fileProgress",u),u.isComplete()&&u.resumableObj.fire("fileSuccess",u,F);break;case"retry":u.resumableObj.fire("fileRetry",u);break}};return u.chunks=[],u.abort=function(){var C=0;l.each(u.chunks,function(F){F.status()=="uploading"&&(F.abort(),C++)}),C>0&&u.resumableObj.fire("fileProgress",u)},u.cancel=function(){var C=u.chunks;u.chunks=[],l.each(C,function(F){F.status()=="uploading"&&(F.abort(),u.resumableObj.uploadNextChunk())}),u.resumableObj.removeFile(u),u.resumableObj.fire("fileProgress",u)},u.retry=function(){u.bootstrap();var C=!1;u.resumableObj.on("chunkingComplete",function(){C||u.resumableObj.upload(),C=!0})},u.bootstrap=function(){u.abort(),o=!1,u.chunks=[],u._prevProgress=0;for(var C=u.getOpt("forceChunkSize")?Math.ceil:Math.floor,F=Math.max(C(u.file.size/u.getOpt("chunkSize")),1),O=0;O<F;O++)(function(Y){window.setTimeout(function(){u.chunks.push(new I(u.resumableObj,u,Y,R)),u.resumableObj.fire("chunkingProgress",u,Y/F)},0)})(O);window.setTimeout(function(){u.resumableObj.fire("chunkingComplete",u)},0)},u.progress=function(){if(o)return 1;var C=0,F=!1;return l.each(u.chunks,function(O){O.status()=="error"&&(F=!0),C+=O.progress(!0)}),C=F||C>.99999?1:C,C=Math.max(u._prevProgress,C),u._prevProgress=C,C},u.isUploading=function(){var C=!1;return l.each(u.chunks,function(F){if(F.status()=="uploading")return C=!0,!1}),C},u.isComplete=function(){var C=!1;return l.each(u.chunks,function(F){var O=F.status();if(O=="pending"||O=="uploading"||F.preprocessState===1)return C=!0,!1}),!C},u.pause=function(C){typeof C>"u"?u._pause=!u._pause:u._pause=C},u.isPaused=function(){return u._pause},u.resumableObj.fire("chunkingStart",u),u.bootstrap(),this}function I(s,p,g,u){var o=this;o.opts={},o.getOpt=s.getOpt,o.resumableObj=s,o.fileObj=p,o.fileObjSize=p.size,o.fileObjType=p.file.type,o.offset=g,o.callback=u,o.lastProgressCallback=new Date,o.tested=!1,o.retries=0,o.pendingRetry=!1,o.preprocessState=0;var R=o.getOpt("chunkSize");return o.loaded=0,o.startByte=o.offset*R,o.endByte=Math.min(o.fileObjSize,(o.offset+1)*R),o.fileObjSize-o.endByte<R&&!o.getOpt("forceChunkSize")&&(o.endByte=o.fileObjSize),o.xhr=null,o.test=function(){o.xhr=new XMLHttpRequest;var C=function(W){o.tested=!0;var H=o.status();H=="success"?(o.callback(H,o.message()),o.resumableObj.uploadNextChunk()):o.send()};o.xhr.addEventListener("load",C,!1),o.xhr.addEventListener("error",C,!1),o.xhr.addEventListener("timeout",C,!1);var F=[],O=o.getOpt("parameterNamespace"),Y=o.getOpt("query");typeof Y=="function"&&(Y=Y(o.fileObj,o)),l.each(Y,function(W,H){F.push([encodeURIComponent(O+W),encodeURIComponent(H)].join("="))}),F=F.concat([["chunkNumberParameterName",o.offset+1],["chunkSizeParameterName",o.getOpt("chunkSize")],["currentChunkSizeParameterName",o.endByte-o.startByte],["totalSizeParameterName",o.fileObjSize],["typeParameterName",o.fileObjType],["identifierParameterName",o.fileObj.uniqueIdentifier],["fileNameParameterName",o.fileObj.fileName],["relativePathParameterName",o.fileObj.relativePath],["totalChunksParameterName",o.fileObj.chunks.length]].filter(function(W){return o.getOpt(W[0])}).map(function(W){return[O+o.getOpt(W[0]),encodeURIComponent(W[1])].join("=")})),o.xhr.open(o.getOpt("testMethod"),l.getTarget("test",F)),o.xhr.timeout=o.getOpt("xhrTimeout"),o.xhr.withCredentials=o.getOpt("withCredentials");var Z=o.getOpt("headers");typeof Z=="function"&&(Z=Z(o.fileObj,o)),l.each(Z,function(W,H){o.xhr.setRequestHeader(W,H)}),o.xhr.send(null)},o.preprocessFinished=function(){o.preprocessState=2,o.send()},o.send=function(){var C=o.getOpt("preprocess");if(typeof C=="function")switch(o.preprocessState){case 0:o.preprocessState=1,C(o);return;case 1:return}if(o.getOpt("testChunks")&&!o.tested){o.test();return}o.xhr=new XMLHttpRequest,o.xhr.upload.addEventListener("progress",function(K){new Date-o.lastProgressCallback>o.getOpt("throttleProgressCallbacks")*1e3&&(o.callback("progress"),o.lastProgressCallback=new Date),o.loaded=K.loaded||0},!1),o.loaded=0,o.pendingRetry=!1,o.callback("progress");var F=function(K){var G=o.status();if(G=="success"||G=="error")o.callback(G,o.message()),o.resumableObj.uploadNextChunk();else{o.callback("retry",o.message()),o.abort(),o.retries++;var be=o.getOpt("chunkRetryInterval");be!==void 0?(o.pendingRetry=!0,setTimeout(o.send,be)):o.send()}};o.xhr.addEventListener("load",F,!1),o.xhr.addEventListener("error",F,!1),o.xhr.addEventListener("timeout",F,!1);var O=[["chunkNumberParameterName",o.offset+1],["chunkSizeParameterName",o.getOpt("chunkSize")],["currentChunkSizeParameterName",o.endByte-o.startByte],["totalSizeParameterName",o.fileObjSize],["typeParameterName",o.fileObjType],["identifierParameterName",o.fileObj.uniqueIdentifier],["fileNameParameterName",o.fileObj.fileName],["relativePathParameterName",o.fileObj.relativePath],["totalChunksParameterName",o.fileObj.chunks.length]].filter(function(K){return o.getOpt(K[0])}).reduce(function(K,G){return K[o.getOpt(G[0])]=G[1],K},{}),Y=o.getOpt("query");typeof Y=="function"&&(Y=Y(o.fileObj,o)),l.each(Y,function(K,G){O[K]=G});var Z=o.fileObj.file.slice?"slice":o.fileObj.file.mozSlice?"mozSlice":o.fileObj.file.webkitSlice?"webkitSlice":"slice",W=o.fileObj.file[Z](o.startByte,o.endByte,o.getOpt("setChunkTypeFromFile")?o.fileObj.file.type:""),H=null,se=[],$=o.getOpt("parameterNamespace");if(o.getOpt("method")==="octet")H=W,l.each(O,function(K,G){se.push([encodeURIComponent($+K),encodeURIComponent(G)].join("="))});else if(H=new FormData,l.each(O,function(K,G){H.append($+K,G),se.push([encodeURIComponent($+K),encodeURIComponent(G)].join("="))}),o.getOpt("chunkFormat")=="blob")H.append($+o.getOpt("fileParameterName"),W,o.fileObj.fileName);else if(o.getOpt("chunkFormat")=="base64"){var X=new FileReader;X.onload=function(K){H.append($+o.getOpt("fileParameterName"),X.result),o.xhr.send(H)},X.readAsDataURL(W)}var de=l.getTarget("upload",se),Te=o.getOpt("uploadMethod");o.xhr.open(Te,de),o.getOpt("method")==="octet"&&o.xhr.setRequestHeader("Content-Type","application/octet-stream"),o.xhr.timeout=o.getOpt("xhrTimeout"),o.xhr.withCredentials=o.getOpt("withCredentials");var me=o.getOpt("headers");typeof me=="function"&&(me=me(o.fileObj,o)),l.each(me,function(K,G){o.xhr.setRequestHeader(K,G)}),o.getOpt("chunkFormat")=="blob"&&o.xhr.send(H)},o.abort=function(){o.xhr&&o.xhr.abort(),o.xhr=null},o.status=function(){return o.pendingRetry?"uploading":o.xhr?o.xhr.readyState<4?"uploading":o.xhr.status==200||o.xhr.status==201?"success":l.contains(o.getOpt("permanentErrors"),o.xhr.status)||o.retries>=o.getOpt("maxChunkRetries")?"error":(o.abort(),"pending"):"pending"},o.message=function(){return o.xhr?o.xhr.responseText:""},o.progress=function(C){typeof C>"u"&&(C=!1);var F=C?(o.endByte-o.startByte)/o.fileObjSize:1;if(o.pendingRetry)return 0;(!o.xhr||!o.xhr.status)&&(F*=.95);var O=o.status();switch(O){case"success":case"error":return 1*F;case"pending":return 0*F;default:return o.loaded/(o.endByte-o.startByte)*F}},this}return a.uploadNextChunk=function(){var s=!1;if(a.getOpt("prioritizeFirstAndLastChunk")&&(l.each(a.files,function(g){if(g.chunks.length&&g.chunks[0].status()=="pending"&&g.chunks[0].preprocessState===0)return g.chunks[0].send(),s=!0,!1;if(g.chunks.length>1&&g.chunks[g.chunks.length-1].status()=="pending"&&g.chunks[g.chunks.length-1].preprocessState===0)return g.chunks[g.chunks.length-1].send(),s=!0,!1}),s)||(l.each(a.files,function(g){if(g.isPaused()===!1&&l.each(g.chunks,function(u){if(u.status()=="pending"&&u.preprocessState===0)return u.send(),s=!0,!1}),s)return!1}),s))return!0;var p=!1;return l.each(a.files,function(g){if(!g.isComplete())return p=!0,!1}),p||a.fire("complete"),!1},a.assignBrowse=function(s,p){typeof s.length>"u"&&(s=[s]),l.each(s,function(g){var u;g.tagName==="INPUT"&&g.type==="file"?u=g:(u=document.createElement("input"),u.setAttribute("type","file"),u.style.display="none",g.addEventListener("click",function(){u.style.opacity=0,u.style.display="block",u.focus(),u.click(),u.style.display="none"},!1),g.appendChild(u));var o=a.getOpt("maxFiles");typeof o>"u"||o!=1?u.setAttribute("multiple","multiple"):u.removeAttribute("multiple"),p?u.setAttribute("webkitdirectory","webkitdirectory"):u.removeAttribute("webkitdirectory");var R=a.getOpt("fileType");typeof R<"u"&&R.length>=1?u.setAttribute("accept",R.map(function(C){return"."+C}).join(",")):u.removeAttribute("accept"),u.addEventListener("change",function(C){T(C.target.files,C);var F=a.getOpt("clearInput");F&&(C.target.value="")},!1)})},a.assignDrop=function(s){typeof s.length>"u"&&(s=[s]),l.each(s,function(p){p.addEventListener("dragover",h,!1),p.addEventListener("dragenter",h,!1),p.addEventListener("drop",c,!1)})},a.unAssignDrop=function(s){typeof s.length>"u"&&(s=[s]),l.each(s,function(p){p.removeEventListener("dragover",h),p.removeEventListener("dragenter",h),p.removeEventListener("drop",c)})},a.isUploading=function(){var s=!1;return l.each(a.files,function(p){if(p.isUploading())return s=!0,!1}),s},a.upload=function(){if(!a.isUploading()){a.fire("uploadStart");for(var s=1;s<=a.getOpt("simultaneousUploads");s++)a.uploadNextChunk()}},a.pause=function(){l.each(a.files,function(s){s.abort()}),a.fire("pause")},a.cancel=function(){a.fire("beforeCancel");for(var s=a.files.length-1;s>=0;s--)a.files[s].cancel();a.fire("cancel")},a.progress=function(){var s=0,p=0;return l.each(a.files,function(g){s+=g.progress()*g.size,p+=g.size}),p>0?s/p:0},a.addFile=function(s,p){T([s],p)},a.addFiles=function(s,p){T(s,p)},a.removeFile=function(s){for(var p=a.files.length-1;p>=0;p--)a.files[p]===s&&a.files.splice(p,1)},a.getFromUniqueIdentifier=function(s){var p=!1;return l.each(a.files,function(g){g.uniqueIdentifier==s&&(p=g)}),p},a.getSize=function(){var s=0;return l.each(a.files,function(p){s+=p.size}),s},a.handleDropEvent=function(s){c(s)},a.handleChangeEvent=function(s){T(s.target.files,s),s.target.value=""},a.updateQuery=function(s){a.opts.query=s},this};i.exports=t})()})(nt);var Ht=nt.exports;const zt=Et(Ht);class Yt{constructor(t,e={}){M(this,"resumable");M(this,"currentFileItem",null);M(this,"chunkedConfig");M(this,"callbacks");M(this,"uploadCompleteResolve");M(this,"uploadCompleteReject");this.chunkedConfig=t,this.callbacks=e}async upload(t){try{const e=await this.chunkedConfig.initUpload(t.file.name,t.file.size);return t.uploadSessionId=e.uploadSessionId,this.currentFileItem=t,this.initResumable(e),this.resumable.addFile(t.file),await this.waitForUploadComplete()}catch(e){throw e instanceof Error?e:new Error(String(e))}}waitForUploadComplete(){return new Promise((t,e)=>{this.uploadCompleteResolve=t,this.uploadCompleteReject=e})}initResumable(t){this.resumable&&this.resumable.cancel();const e=this.chunkedConfig.getResumableConfig(t),l={...{chunkSize:t.partSize,simultaneousUploads:3,testChunks:!1,method:"multipart",chunkNumberParameterName:"partNumber",totalChunksParameterName:"totalParts",fileParameterName:"file",withCredentials:!0,maxChunkRetries:3,chunkRetryInterval:1e3,forceChunkSize:!0},...e};this.resumable=new zt(l),this.bindResumableEvents()}bindResumableEvents(){this.resumable.on("progress",()=>{var e,a,l,c;const t=Math.floor(this.resumable.progress()*100);this.currentFileItem&&(this.currentFileItem.progress=Math.min(t,90),(a=(e=this.callbacks).onProgress)==null||a.call(e,this.currentFileItem,this.currentFileItem.progress)),(c=(l=this.callbacks).onUpdate)==null||c.call(l)}),this.resumable.on("fileSuccess",()=>{this.handleResumableComplete()}),this.resumable.on("error",t=>{console.error("[ChunkedUploader] 上传错误:",t),this.handleResumableError(t)}),this.resumable.on("fileAdded",()=>{this.resumable.upload()})}async handleResumableComplete(){if(!(!this.currentFileItem||!this.uploadCompleteResolve||!this.uploadCompleteReject))try{const t=await this.chunkedConfig.mergeChunks(this.currentFileItem.uploadSessionId);this.currentFileItem&&(this.currentFileItem.progress=100),this.uploadCompleteResolve(t),this.cleanup()}catch(t){const e=t instanceof Error?t:new Error(String(t));this.handleResumableError(e.message)}}handleResumableError(t){var e,a;this.currentFileItem&&(this.currentFileItem.status="error",this.currentFileItem.errorMessage=t),this.uploadCompleteReject&&(this.uploadCompleteReject(new Error(t)),this.cleanup()),(a=(e=this.callbacks).onUpdate)==null||a.call(e)}cleanup(){this.uploadCompleteResolve=void 0,this.uploadCompleteReject=void 0}pause(){this.resumable&&this.resumable.pause()}resume(){this.resumable&&this.resumable.upload()}cancel(){this.resumable&&(this.resumable.cancel(),this.resumable=null),this.currentFileItem=null,this.cleanup()}}const Bt=()=>`file_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;class qt{constructor(t,e={}){M(this,"config");M(this,"callbacks");M(this,"chunkedUploader",null);M(this,"uploadQueue",[]);M(this,"activeUploads",0);M(this,"uploadFileList",[]);M(this,"fileList",[]);M(this,"uploadProgress",0);M(this,"isUploading",!1);M(this,"uploadMessage","");M(this,"uploadMessageType","info");this.config=t,this.callbacks=e,this.initUploaders()}initUploaders(){const t=this.config.uploadConfig;t!=null&&t.chunkedUpload&&!this.config.multiple&&(this.chunkedUploader=new Yt(t.chunkedUpload,{onProgress:(e,a)=>{var l,c,h,m;(c=(l=this.callbacks).onUploadProgress)==null||c.call(l,e,a),(m=(h=this.callbacks).onUpdate)==null||m.call(h)},onUpdate:()=>{var e,a;return(a=(e=this.callbacks).onUpdate)==null?void 0:a.call(e)}}))}get concurrentLimit(){return this.config.concurrentLimit??3}shouldUseChunkedUpload(){const t=this.config.uploadConfig;return!!(t!=null&&t.chunkedUpload&&!this.config.multiple)}updateConfig(t){this.config={...this.config,...t},this.initUploaders()}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}reset(){this.cancelUpload(),this.uploadFileList=[],this.fileList=[],this.uploadProgress=0,this.isUploading=!1,this.uploadMessage="",this.uploadMessageType="info",this.uploadQueue=[],this.activeUploads=0}beforeUpload(t){var a,l,c,h,m,y,D,b,T,E;const e=Array.isArray(t)?t:[t];if(!e.length)return(l=(a=this.callbacks).onMessage)==null||l.call(a,"请选择文件","warning"),!1;if(this.config.multiple&&this.uploadFileList.length+e.length>this.config.maxFiles)return(h=(c=this.callbacks).onMessage)==null||h.call(c,`最多只能上传 ${this.config.maxFiles} 个文件`,"warning"),!1;for(const I of e)if(I.size>this.config.maxFileSize)return(y=(m=this.callbacks).onMessage)==null||y.call(m,`文件 ${I.name} 超过最大限制 ${Math.round(this.config.maxFileSize/1024/1024)}MB`,"warning"),!1;for(const I of e){const s={id:Bt(),file:I,name:I.name,size:I.size,progress:0,status:"pending"};this.config.multiple?(this.uploadFileList.unshift(s),this.fileList.unshift(I)):(this.uploadFileList=[s],this.fileList=[I])}return(b=(D=this.callbacks).onUpdate)==null||b.call(D),(E=(T=this.callbacks).onFileChange)==null||E.call(T,this.uploadFileList),this.processFilesWithCustomUpload(),!0}async processFilesWithCustomUpload(){const t=this.uploadFileList.filter(e=>e.status==="pending");for(const e of t)await this.processFileWithCustomUpload(e)}async processFileWithCustomUpload(t){var a,l,c,h,m,y,D,b,T,E,I;const e=(a=this.config.uploadConfig)==null?void 0:a.customUpload;if(!e){t.status="success",t.progress=100,t.response=t.file,(c=(l=this.callbacks).onUpdate)==null||c.call(l);return}t.status="uploading",t.progress=0,this.isUploading=!0,(m=(h=this.callbacks).onUpdate)==null||m.call(h);try{const s={fileList:[...this.uploadFileList],removeFile:p=>{this.removeFile(p)}};t.response=await e(t.file,s,p=>{var g,u,o,R;t.progress=p,(u=(g=this.callbacks).onUploadProgress)==null||u.call(g,t,p),(R=(o=this.callbacks).onUpdate)==null||R.call(o)}),t.status="success",t.progress=100,(D=(y=this.callbacks).onUploadSuccess)==null||D.call(y,t,t.response)}catch(s){t.status="error",t.errorMessage=s instanceof Error?s.message:"处理失败",(T=(b=this.callbacks).onUploadError)==null||T.call(b,t,s)}this.isUploading=this.uploadFileList.some(s=>s.status==="uploading"),(I=(E=this.callbacks).onUpdate)==null||I.call(E),this.updateOverallProgress()}removeFile(t){var e,a,l,c,h,m;if(t!==void 0&&t>=0&&t<this.uploadFileList.length){if(this.uploadFileList[t].status==="uploading")return(a=(e=this.callbacks).onMessage)==null||a.call(e,"正在上传中,无法删除","warning"),!1;this.uploadFileList.splice(t,1),this.fileList.splice(t,1)}else this.uploadFileList=[],this.fileList=[];return this.uploadProgress=0,this.uploadMessage="",this.uploadMessageType="info",this.isUploading=!1,(c=(l=this.callbacks).onFileChange)==null||c.call(l,this.uploadFileList),(m=(h=this.callbacks).onUpdate)==null||m.call(h),!0}enqueueUpload(t){const e=t.filter(a=>!this.uploadQueue.some(l=>l.id===a.id));this.uploadQueue.push(...e),this.processUploadQueue()}processUploadQueue(){for(;this.uploadQueue.length>0&&this.activeUploads<this.concurrentLimit;){const t=this.uploadQueue.shift();t.status==="pending"&&(this.activeUploads++,this.uploadSingleFile(t).finally(()=>{this.activeUploads--,this.processUploadQueue()}))}}async uploadSingleFile(t){var e,a,l,c,h,m,y,D;t.status="uploading",t.progress=0,this.isUploading=!0,(a=(e=this.callbacks).onUpdate)==null||a.call(e);try{t.response=await this.uploadFileChunked(t),t.status="success",t.progress=100,(c=(l=this.callbacks).onUploadSuccess)==null||c.call(l,t,t.response)}catch(b){t.status="error",t.errorMessage=b instanceof Error?b.message:"上传失败",(m=(h=this.callbacks).onUploadError)==null||m.call(h,t,b)}this.isUploading=this.uploadFileList.some(b=>b.status==="uploading"),(D=(y=this.callbacks).onUpdate)==null||D.call(y),this.updateOverallProgress()}async uploadFileChunked(t){if(!this.chunkedUploader)throw new Error("分片上传需要配置 chunkedUpload");return await this.chunkedUploader.upload(t)}async startUpload(){this.shouldUseChunkedUpload()&&await this.startChunkedUploadFiles()}async startChunkedUploadFiles(){const t=this.uploadFileList.filter(e=>e.status==="pending");this.enqueueUpload(t)}pauseUpload(){var t;(t=this.chunkedUploader)==null||t.pause()}resumeUpload(){var t;(t=this.chunkedUploader)==null||t.resume()}cancelUpload(){var t,e,a;(t=this.chunkedUploader)==null||t.cancel(),this.uploadQueue=[],this.activeUploads=0,this.isUploading=!1,this.uploadMessage="上传已取消",this.uploadMessageType="info",(a=(e=this.callbacks).onUpdate)==null||a.call(e)}updateOverallProgress(){if(this.uploadFileList.length===0){this.uploadProgress=0;return}const t=this.uploadFileList.reduce((e,a)=>e+a.progress,0);this.uploadProgress=Math.round(t/this.uploadFileList.length)}hasUploadingFiles(){return this.uploadFileList.some(t=>t.status==="uploading")}hasPendingFiles(){return this.uploadFileList.some(t=>t.status==="pending")}hasAllFilesUploaded(){return this.uploadFileList.length>0&&this.uploadFileList.every(t=>t.status==="success")}getFailedFiles(){return this.uploadFileList.filter(t=>t.status==="error")}}const it={success:"icon-success",error:"icon-cuowu",warning:"icon-warning",info:"icon-info"},De=new Set;function Wt(i){const{message:t,type:e,duration:a=3e3,closable:l=!0}=i,c=document.createElement("div");c.className=`import-dialog-vanilla-toast ${e}`;const h=it[e]||it.info;c.innerHTML=`
1565
+ `}}var nt={exports:{}};(function(i){(function(){var t=function(e){if(!(this instanceof t))return new t(e);if(this.version=1,this.support=typeof File<"u"&&typeof Blob<"u"&&typeof FileList<"u"&&(!!Blob.prototype.webkitSlice||!!Blob.prototype.mozSlice||!!Blob.prototype.slice||!1),!this.support)return!1;var a=this;a.files=[],a.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,fileParameterName:"file",chunkNumberParameterName:"resumableChunkNumber",chunkSizeParameterName:"resumableChunkSize",currentChunkSizeParameterName:"resumableCurrentChunkSize",totalSizeParameterName:"resumableTotalSize",typeParameterName:"resumableType",identifierParameterName:"resumableIdentifier",fileNameParameterName:"resumableFilename",relativePathParameterName:"resumableRelativePath",totalChunksParameterName:"resumableTotalChunks",throttleProgressCallbacks:.5,query:{},headers:{},preprocess:null,method:"multipart",uploadMethod:"POST",testMethod:"GET",prioritizeFirstAndLastChunk:!1,target:"/",testTarget:null,parameterNamespace:"",testChunks:!0,generateUniqueIdentifier:null,getTarget:null,maxChunkRetries:100,chunkRetryInterval:void 0,permanentErrors:[400,404,415,500,501],maxFiles:void 0,withCredentials:!1,xhrTimeout:0,clearInput:!0,chunkFormat:"blob",setChunkTypeFromFile:!1,maxFilesErrorCallback:function(s,p){var g=a.getOpt("maxFiles");alert("Please upload no more than "+g+" file"+(g===1?"":"s")+" at a time.")},minFileSize:1,minFileSizeErrorCallback:function(s,p){alert(s.fileName||s.name+" is too small, please upload files larger than "+l.formatSize(a.getOpt("minFileSize"))+".")},maxFileSize:void 0,maxFileSizeErrorCallback:function(s,p){alert(s.fileName||s.name+" is too large, please upload files less than "+l.formatSize(a.getOpt("maxFileSize"))+".")},fileType:[],fileTypeErrorCallback:function(s,p){alert(s.fileName||s.name+" has type not allowed, please upload files of type "+a.getOpt("fileType")+".")}},a.opts=e||{},a.getOpt=function(s){var p=this;if(s instanceof Array){var g={};return l.each(s,function(u){g[u]=p.getOpt(u)}),g}if(p instanceof I){if(typeof p.opts[s]<"u")return p.opts[s];p=p.fileObj}if(p instanceof E){if(typeof p.opts[s]<"u")return p.opts[s];p=p.resumableObj}if(p instanceof t)return typeof p.opts[s]<"u"?p.opts[s]:p.defaults[s]},a.events=[],a.on=function(s,p){a.events.push(s.toLowerCase(),p)},a.fire=function(){for(var s=[],p=0;p<arguments.length;p++)s.push(arguments[p]);for(var g=s[0].toLowerCase(),p=0;p<=a.events.length;p+=2)a.events[p]==g&&a.events[p+1].apply(a,s.slice(1)),a.events[p]=="catchall"&&a.events[p+1].apply(null,s);g=="fileerror"&&a.fire("error",s[2],s[1]),g=="fileprogress"&&a.fire("progress")};var l={stopEvent:function(s){s.stopPropagation(),s.preventDefault()},each:function(s,p){if(typeof s.length<"u"){for(var g=0;g<s.length;g++)if(p(s[g])===!1)return}else for(g in s)if(p(g,s[g])===!1)return},generateUniqueIdentifier:function(s,p){var g=a.getOpt("generateUniqueIdentifier");if(typeof g=="function")return g(s,p);var u=s.webkitRelativePath||s.fileName||s.name,o=s.size;return o+"-"+u.replace(/[^0-9a-zA-Z_-]/img,"")},contains:function(s,p){var g=!1;return l.each(s,function(u){return u==p?(g=!0,!1):!0}),g},formatSize:function(s){return s<1024?s+" bytes":s<1024*1024?(s/1024).toFixed(0)+" KB":s<1024*1024*1024?(s/1024/1024).toFixed(1)+" MB":(s/1024/1024/1024).toFixed(1)+" GB"},getTarget:function(s,p){var g=a.getOpt("target");if(s==="test"&&a.getOpt("testTarget")&&(g=a.getOpt("testTarget")==="/"?a.getOpt("target"):a.getOpt("testTarget")),typeof g=="function")return g(p);var u=g.indexOf("?")<0?"?":"&",o=p.join("&");return g+u+o}},c=function(s){l.stopEvent(s),s.dataTransfer&&s.dataTransfer.items?b(s.dataTransfer.items,s):s.dataTransfer&&s.dataTransfer.files&&b(s.dataTransfer.files,s)},h=function(s){s.preventDefault()};function m(s,p,g,u){var o;if(s.isFile)return s.file(function(R){R.relativePath=p+R.name,g.push(R),u()});if(s.isDirectory?o=s:s instanceof File&&g.push(s),typeof s.webkitGetAsEntry=="function"&&(o=s.webkitGetAsEntry()),o&&o.isDirectory)return D(o,p+o.name+"/",g,u);typeof s.getAsFile=="function"&&(s=s.getAsFile(),s instanceof File&&(s.relativePath=p+s.name,g.push(s))),u()}function y(s,p){if(!s||s.length===0)return p();s[0](function(){y(s.slice(1),p)})}function D(s,p,g,u){var o=s.createReader();o.readEntries(function(R){if(!R.length)return u();y(R.map(function(C){return m.bind(null,C,p,g)}),u)})}function b(s,p){if(s.length){a.fire("beforeAdd");var g=[];y(Array.prototype.map.call(s,function(u){return m.bind(null,u,"",g)}),function(){g.length&&T(g,p)})}}var T=function(s,p){var g=0,u=a.getOpt(["maxFiles","minFileSize","maxFileSize","maxFilesErrorCallback","minFileSizeErrorCallback","maxFileSizeErrorCallback","fileType","fileTypeErrorCallback"]);if(typeof u.maxFiles<"u"&&u.maxFiles<s.length+a.files.length)if(u.maxFiles===1&&a.files.length===1&&s.length===1)a.removeFile(a.files[0]);else return u.maxFilesErrorCallback(s,g++),!1;var o=[],R=[],C=s.length,F=function(){if(!--C){if(!o.length&&!R.length)return;window.setTimeout(function(){a.fire("filesAdded",o,R)},0)}};l.each(s,function(O){var Y=O.name;if(u.fileType.length>0){var Z=!1;for(var W in u.fileType){var H="."+u.fileType[W];if(Y.toLowerCase().indexOf(H.toLowerCase(),Y.length-H.length)!==-1){Z=!0;break}}if(!Z)return u.fileTypeErrorCallback(O,g++),!1}if(typeof u.minFileSize<"u"&&O.size<u.minFileSize)return u.minFileSizeErrorCallback(O,g++),!1;if(typeof u.maxFileSize<"u"&&O.size>u.maxFileSize)return u.maxFileSizeErrorCallback(O,g++),!1;function se(X){a.getFromUniqueIdentifier(X)?R.push(O):function(){O.uniqueIdentifier=X;var de=new E(a,O,X);a.files.push(de),o.push(de),de.container=typeof p<"u"?p.srcElement:null,window.setTimeout(function(){a.fire("fileAdded",de,p)},0)}(),F()}var $=l.generateUniqueIdentifier(O,p);$&&typeof $.then=="function"?$.then(function(X){se(X)},function(){F()}):se($)})};function E(s,p,g){var u=this;u.opts={},u.getOpt=s.getOpt,u._prevProgress=0,u.resumableObj=s,u.file=p,u.fileName=p.fileName||p.name,u.size=p.size,u.relativePath=p.relativePath||p.webkitRelativePath||u.fileName,u.uniqueIdentifier=g,u._pause=!1,u.container="";var o=g!==void 0,R=function(C,F){switch(C){case"progress":u.resumableObj.fire("fileProgress",u,F);break;case"error":u.abort(),o=!0,u.chunks=[],u.resumableObj.fire("fileError",u,F);break;case"success":if(o)return;u.resumableObj.fire("fileProgress",u),u.isComplete()&&u.resumableObj.fire("fileSuccess",u,F);break;case"retry":u.resumableObj.fire("fileRetry",u);break}};return u.chunks=[],u.abort=function(){var C=0;l.each(u.chunks,function(F){F.status()=="uploading"&&(F.abort(),C++)}),C>0&&u.resumableObj.fire("fileProgress",u)},u.cancel=function(){var C=u.chunks;u.chunks=[],l.each(C,function(F){F.status()=="uploading"&&(F.abort(),u.resumableObj.uploadNextChunk())}),u.resumableObj.removeFile(u),u.resumableObj.fire("fileProgress",u)},u.retry=function(){u.bootstrap();var C=!1;u.resumableObj.on("chunkingComplete",function(){C||u.resumableObj.upload(),C=!0})},u.bootstrap=function(){u.abort(),o=!1,u.chunks=[],u._prevProgress=0;for(var C=u.getOpt("forceChunkSize")?Math.ceil:Math.floor,F=Math.max(C(u.file.size/u.getOpt("chunkSize")),1),O=0;O<F;O++)(function(Y){window.setTimeout(function(){u.chunks.push(new I(u.resumableObj,u,Y,R)),u.resumableObj.fire("chunkingProgress",u,Y/F)},0)})(O);window.setTimeout(function(){u.resumableObj.fire("chunkingComplete",u)},0)},u.progress=function(){if(o)return 1;var C=0,F=!1;return l.each(u.chunks,function(O){O.status()=="error"&&(F=!0),C+=O.progress(!0)}),C=F||C>.99999?1:C,C=Math.max(u._prevProgress,C),u._prevProgress=C,C},u.isUploading=function(){var C=!1;return l.each(u.chunks,function(F){if(F.status()=="uploading")return C=!0,!1}),C},u.isComplete=function(){var C=!1;return l.each(u.chunks,function(F){var O=F.status();if(O=="pending"||O=="uploading"||F.preprocessState===1)return C=!0,!1}),!C},u.pause=function(C){typeof C>"u"?u._pause=!u._pause:u._pause=C},u.isPaused=function(){return u._pause},u.resumableObj.fire("chunkingStart",u),u.bootstrap(),this}function I(s,p,g,u){var o=this;o.opts={},o.getOpt=s.getOpt,o.resumableObj=s,o.fileObj=p,o.fileObjSize=p.size,o.fileObjType=p.file.type,o.offset=g,o.callback=u,o.lastProgressCallback=new Date,o.tested=!1,o.retries=0,o.pendingRetry=!1,o.preprocessState=0;var R=o.getOpt("chunkSize");return o.loaded=0,o.startByte=o.offset*R,o.endByte=Math.min(o.fileObjSize,(o.offset+1)*R),o.fileObjSize-o.endByte<R&&!o.getOpt("forceChunkSize")&&(o.endByte=o.fileObjSize),o.xhr=null,o.test=function(){o.xhr=new XMLHttpRequest;var C=function(W){o.tested=!0;var H=o.status();H=="success"?(o.callback(H,o.message()),o.resumableObj.uploadNextChunk()):o.send()};o.xhr.addEventListener("load",C,!1),o.xhr.addEventListener("error",C,!1),o.xhr.addEventListener("timeout",C,!1);var F=[],O=o.getOpt("parameterNamespace"),Y=o.getOpt("query");typeof Y=="function"&&(Y=Y(o.fileObj,o)),l.each(Y,function(W,H){F.push([encodeURIComponent(O+W),encodeURIComponent(H)].join("="))}),F=F.concat([["chunkNumberParameterName",o.offset+1],["chunkSizeParameterName",o.getOpt("chunkSize")],["currentChunkSizeParameterName",o.endByte-o.startByte],["totalSizeParameterName",o.fileObjSize],["typeParameterName",o.fileObjType],["identifierParameterName",o.fileObj.uniqueIdentifier],["fileNameParameterName",o.fileObj.fileName],["relativePathParameterName",o.fileObj.relativePath],["totalChunksParameterName",o.fileObj.chunks.length]].filter(function(W){return o.getOpt(W[0])}).map(function(W){return[O+o.getOpt(W[0]),encodeURIComponent(W[1])].join("=")})),o.xhr.open(o.getOpt("testMethod"),l.getTarget("test",F)),o.xhr.timeout=o.getOpt("xhrTimeout"),o.xhr.withCredentials=o.getOpt("withCredentials");var Z=o.getOpt("headers");typeof Z=="function"&&(Z=Z(o.fileObj,o)),l.each(Z,function(W,H){o.xhr.setRequestHeader(W,H)}),o.xhr.send(null)},o.preprocessFinished=function(){o.preprocessState=2,o.send()},o.send=function(){var C=o.getOpt("preprocess");if(typeof C=="function")switch(o.preprocessState){case 0:o.preprocessState=1,C(o);return;case 1:return}if(o.getOpt("testChunks")&&!o.tested){o.test();return}o.xhr=new XMLHttpRequest,o.xhr.upload.addEventListener("progress",function(K){new Date-o.lastProgressCallback>o.getOpt("throttleProgressCallbacks")*1e3&&(o.callback("progress"),o.lastProgressCallback=new Date),o.loaded=K.loaded||0},!1),o.loaded=0,o.pendingRetry=!1,o.callback("progress");var F=function(K){var G=o.status();if(G=="success"||G=="error")o.callback(G,o.message()),o.resumableObj.uploadNextChunk();else{o.callback("retry",o.message()),o.abort(),o.retries++;var be=o.getOpt("chunkRetryInterval");be!==void 0?(o.pendingRetry=!0,setTimeout(o.send,be)):o.send()}};o.xhr.addEventListener("load",F,!1),o.xhr.addEventListener("error",F,!1),o.xhr.addEventListener("timeout",F,!1);var O=[["chunkNumberParameterName",o.offset+1],["chunkSizeParameterName",o.getOpt("chunkSize")],["currentChunkSizeParameterName",o.endByte-o.startByte],["totalSizeParameterName",o.fileObjSize],["typeParameterName",o.fileObjType],["identifierParameterName",o.fileObj.uniqueIdentifier],["fileNameParameterName",o.fileObj.fileName],["relativePathParameterName",o.fileObj.relativePath],["totalChunksParameterName",o.fileObj.chunks.length]].filter(function(K){return o.getOpt(K[0])}).reduce(function(K,G){return K[o.getOpt(G[0])]=G[1],K},{}),Y=o.getOpt("query");typeof Y=="function"&&(Y=Y(o.fileObj,o)),l.each(Y,function(K,G){O[K]=G});var Z=o.fileObj.file.slice?"slice":o.fileObj.file.mozSlice?"mozSlice":o.fileObj.file.webkitSlice?"webkitSlice":"slice",W=o.fileObj.file[Z](o.startByte,o.endByte,o.getOpt("setChunkTypeFromFile")?o.fileObj.file.type:""),H=null,se=[],$=o.getOpt("parameterNamespace");if(o.getOpt("method")==="octet")H=W,l.each(O,function(K,G){se.push([encodeURIComponent($+K),encodeURIComponent(G)].join("="))});else if(H=new FormData,l.each(O,function(K,G){H.append($+K,G),se.push([encodeURIComponent($+K),encodeURIComponent(G)].join("="))}),o.getOpt("chunkFormat")=="blob")H.append($+o.getOpt("fileParameterName"),W,o.fileObj.fileName);else if(o.getOpt("chunkFormat")=="base64"){var X=new FileReader;X.onload=function(K){H.append($+o.getOpt("fileParameterName"),X.result),o.xhr.send(H)},X.readAsDataURL(W)}var de=l.getTarget("upload",se),Te=o.getOpt("uploadMethod");o.xhr.open(Te,de),o.getOpt("method")==="octet"&&o.xhr.setRequestHeader("Content-Type","application/octet-stream"),o.xhr.timeout=o.getOpt("xhrTimeout"),o.xhr.withCredentials=o.getOpt("withCredentials");var me=o.getOpt("headers");typeof me=="function"&&(me=me(o.fileObj,o)),l.each(me,function(K,G){o.xhr.setRequestHeader(K,G)}),o.getOpt("chunkFormat")=="blob"&&o.xhr.send(H)},o.abort=function(){o.xhr&&o.xhr.abort(),o.xhr=null},o.status=function(){return o.pendingRetry?"uploading":o.xhr?o.xhr.readyState<4?"uploading":o.xhr.status==200||o.xhr.status==201?"success":l.contains(o.getOpt("permanentErrors"),o.xhr.status)||o.retries>=o.getOpt("maxChunkRetries")?"error":(o.abort(),"pending"):"pending"},o.message=function(){return o.xhr?o.xhr.responseText:""},o.progress=function(C){typeof C>"u"&&(C=!1);var F=C?(o.endByte-o.startByte)/o.fileObjSize:1;if(o.pendingRetry)return 0;(!o.xhr||!o.xhr.status)&&(F*=.95);var O=o.status();switch(O){case"success":case"error":return 1*F;case"pending":return 0*F;default:return o.loaded/(o.endByte-o.startByte)*F}},this}return a.uploadNextChunk=function(){var s=!1;if(a.getOpt("prioritizeFirstAndLastChunk")&&(l.each(a.files,function(g){if(g.chunks.length&&g.chunks[0].status()=="pending"&&g.chunks[0].preprocessState===0)return g.chunks[0].send(),s=!0,!1;if(g.chunks.length>1&&g.chunks[g.chunks.length-1].status()=="pending"&&g.chunks[g.chunks.length-1].preprocessState===0)return g.chunks[g.chunks.length-1].send(),s=!0,!1}),s)||(l.each(a.files,function(g){if(g.isPaused()===!1&&l.each(g.chunks,function(u){if(u.status()=="pending"&&u.preprocessState===0)return u.send(),s=!0,!1}),s)return!1}),s))return!0;var p=!1;return l.each(a.files,function(g){if(!g.isComplete())return p=!0,!1}),p||a.fire("complete"),!1},a.assignBrowse=function(s,p){typeof s.length>"u"&&(s=[s]),l.each(s,function(g){var u;g.tagName==="INPUT"&&g.type==="file"?u=g:(u=document.createElement("input"),u.setAttribute("type","file"),u.style.display="none",g.addEventListener("click",function(){u.style.opacity=0,u.style.display="block",u.focus(),u.click(),u.style.display="none"},!1),g.appendChild(u));var o=a.getOpt("maxFiles");typeof o>"u"||o!=1?u.setAttribute("multiple","multiple"):u.removeAttribute("multiple"),p?u.setAttribute("webkitdirectory","webkitdirectory"):u.removeAttribute("webkitdirectory");var R=a.getOpt("fileType");typeof R<"u"&&R.length>=1?u.setAttribute("accept",R.map(function(C){return"."+C}).join(",")):u.removeAttribute("accept"),u.addEventListener("change",function(C){T(C.target.files,C);var F=a.getOpt("clearInput");F&&(C.target.value="")},!1)})},a.assignDrop=function(s){typeof s.length>"u"&&(s=[s]),l.each(s,function(p){p.addEventListener("dragover",h,!1),p.addEventListener("dragenter",h,!1),p.addEventListener("drop",c,!1)})},a.unAssignDrop=function(s){typeof s.length>"u"&&(s=[s]),l.each(s,function(p){p.removeEventListener("dragover",h),p.removeEventListener("dragenter",h),p.removeEventListener("drop",c)})},a.isUploading=function(){var s=!1;return l.each(a.files,function(p){if(p.isUploading())return s=!0,!1}),s},a.upload=function(){if(!a.isUploading()){a.fire("uploadStart");for(var s=1;s<=a.getOpt("simultaneousUploads");s++)a.uploadNextChunk()}},a.pause=function(){l.each(a.files,function(s){s.abort()}),a.fire("pause")},a.cancel=function(){a.fire("beforeCancel");for(var s=a.files.length-1;s>=0;s--)a.files[s].cancel();a.fire("cancel")},a.progress=function(){var s=0,p=0;return l.each(a.files,function(g){s+=g.progress()*g.size,p+=g.size}),p>0?s/p:0},a.addFile=function(s,p){T([s],p)},a.addFiles=function(s,p){T(s,p)},a.removeFile=function(s){for(var p=a.files.length-1;p>=0;p--)a.files[p]===s&&a.files.splice(p,1)},a.getFromUniqueIdentifier=function(s){var p=!1;return l.each(a.files,function(g){g.uniqueIdentifier==s&&(p=g)}),p},a.getSize=function(){var s=0;return l.each(a.files,function(p){s+=p.size}),s},a.handleDropEvent=function(s){c(s)},a.handleChangeEvent=function(s){T(s.target.files,s),s.target.value=""},a.updateQuery=function(s){a.opts.query=s},this};i.exports=t})()})(nt);var Ht=nt.exports;const zt=Et(Ht);class Yt{constructor(t,e={}){M(this,"resumable");M(this,"currentFileItem",null);M(this,"chunkedConfig");M(this,"callbacks");M(this,"uploadCompleteResolve");M(this,"uploadCompleteReject");this.chunkedConfig=t,this.callbacks=e}async upload(t){try{const e=await this.chunkedConfig.initUpload(t.file.name,t.file.size);return t.uploadSessionId=e.uploadSessionId,this.currentFileItem=t,this.initResumable(e),this.resumable.addFile(t.file),await this.waitForUploadComplete()}catch(e){throw e instanceof Error?e:new Error(String(e))}}waitForUploadComplete(){return new Promise((t,e)=>{this.uploadCompleteResolve=t,this.uploadCompleteReject=e})}initResumable(t){this.resumable&&this.resumable.cancel();const e=this.chunkedConfig.getResumableConfig(t),l={...{chunkSize:t.partSize,simultaneousUploads:3,testChunks:!1,method:"multipart",chunkNumberParameterName:"partNumber",totalChunksParameterName:"totalParts",fileParameterName:"file",withCredentials:!0,maxChunkRetries:3,chunkRetryInterval:1e3,forceChunkSize:!0},...e};this.resumable=new zt(l),this.bindResumableEvents()}bindResumableEvents(){this.resumable.on("progress",()=>{var e,a,l,c;const t=Math.floor(this.resumable.progress()*100);this.currentFileItem&&(this.currentFileItem.progress=Math.min(t,90),(a=(e=this.callbacks).onProgress)==null||a.call(e,this.currentFileItem,this.currentFileItem.progress)),(c=(l=this.callbacks).onUpdate)==null||c.call(l)}),this.resumable.on("fileSuccess",()=>{this.handleResumableComplete()}),this.resumable.on("error",t=>{console.error("[ChunkedUploader] 上传错误:",t),this.handleResumableError(t)}),this.resumable.on("fileAdded",()=>{this.resumable.upload()})}async handleResumableComplete(){if(!(!this.currentFileItem||!this.uploadCompleteResolve||!this.uploadCompleteReject))try{const t=await this.chunkedConfig.mergeChunks(this.currentFileItem.uploadSessionId);this.currentFileItem&&(this.currentFileItem.progress=100),this.uploadCompleteResolve(t),this.cleanup()}catch(t){const e=t instanceof Error?t:new Error(String(t));this.handleResumableError(e.message)}}handleResumableError(t){var e,a;this.currentFileItem&&(this.currentFileItem.status="error",this.currentFileItem.errorMessage=t),this.uploadCompleteReject&&(this.uploadCompleteReject(new Error(t)),this.cleanup()),(a=(e=this.callbacks).onUpdate)==null||a.call(e)}cleanup(){this.uploadCompleteResolve=void 0,this.uploadCompleteReject=void 0}pause(){this.resumable&&this.resumable.pause()}resume(){this.resumable&&this.resumable.upload()}cancel(){this.resumable&&(this.resumable.cancel(),this.resumable=null),this.currentFileItem=null,this.cleanup()}}const Bt=()=>`file_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;class qt{constructor(t,e={}){M(this,"config");M(this,"callbacks");M(this,"chunkedUploader",null);M(this,"uploadQueue",[]);M(this,"activeUploads",0);M(this,"uploadFileList",[]);M(this,"fileList",[]);M(this,"uploadProgress",0);M(this,"isUploading",!1);M(this,"uploadMessage","");M(this,"uploadMessageType","info");this.config=t,this.callbacks=e,this.initUploaders()}initUploaders(){const t=this.config.uploadConfig;t!=null&&t.chunkedUpload&&!this.config.multiple&&(this.chunkedUploader=new Yt(t.chunkedUpload,{onProgress:(e,a)=>{var l,c,h,m;(c=(l=this.callbacks).onUploadProgress)==null||c.call(l,e,a),(m=(h=this.callbacks).onUpdate)==null||m.call(h)},onUpdate:()=>{var e,a;return(a=(e=this.callbacks).onUpdate)==null?void 0:a.call(e)}}))}get concurrentLimit(){return this.config.concurrentLimit!=null?this.config.concurrentLimit:3}shouldUseChunkedUpload(){const t=this.config.uploadConfig;return!!(t!=null&&t.chunkedUpload&&!this.config.multiple)}updateConfig(t){this.config={...this.config,...t},this.initUploaders()}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}reset(){this.cancelUpload(),this.uploadFileList=[],this.fileList=[],this.uploadProgress=0,this.isUploading=!1,this.uploadMessage="",this.uploadMessageType="info",this.uploadQueue=[],this.activeUploads=0}beforeUpload(t){var a,l,c,h,m,y,D,b,T,E;const e=Array.isArray(t)?t:[t];if(!e.length)return(l=(a=this.callbacks).onMessage)==null||l.call(a,"请选择文件","warning"),!1;if(this.config.multiple&&this.uploadFileList.length+e.length>this.config.maxFiles)return(h=(c=this.callbacks).onMessage)==null||h.call(c,`最多只能上传 ${this.config.maxFiles} 个文件`,"warning"),!1;for(const I of e)if(I.size>this.config.maxFileSize)return(y=(m=this.callbacks).onMessage)==null||y.call(m,`文件 ${I.name} 超过最大限制 ${Math.round(this.config.maxFileSize/1024/1024)}MB`,"warning"),!1;for(const I of e){const s={id:Bt(),file:I,name:I.name,size:I.size,progress:0,status:"pending"};this.config.multiple?(this.uploadFileList.unshift(s),this.fileList.unshift(I)):(this.uploadFileList=[s],this.fileList=[I])}return(b=(D=this.callbacks).onUpdate)==null||b.call(D),(E=(T=this.callbacks).onFileChange)==null||E.call(T,this.uploadFileList),this.processFilesWithCustomUpload(),!0}async processFilesWithCustomUpload(){const t=this.uploadFileList.filter(e=>e.status==="pending");for(const e of t)await this.processFileWithCustomUpload(e)}async processFileWithCustomUpload(t){var a,l,c,h,m,y,D,b,T,E,I;const e=(a=this.config.uploadConfig)==null?void 0:a.customUpload;if(!e){t.status="success",t.progress=100,t.response=t.file,(c=(l=this.callbacks).onUpdate)==null||c.call(l);return}t.status="uploading",t.progress=0,this.isUploading=!0,(m=(h=this.callbacks).onUpdate)==null||m.call(h);try{const s={fileList:[...this.uploadFileList],removeFile:p=>{this.removeFile(p)}};t.response=await e(t.file,s,p=>{var g,u,o,R;t.progress=p,(u=(g=this.callbacks).onUploadProgress)==null||u.call(g,t,p),(R=(o=this.callbacks).onUpdate)==null||R.call(o)}),t.status="success",t.progress=100,(D=(y=this.callbacks).onUploadSuccess)==null||D.call(y,t,t.response)}catch(s){t.status="error",t.errorMessage=s instanceof Error?s.message:"处理失败",(T=(b=this.callbacks).onUploadError)==null||T.call(b,t,s)}this.isUploading=this.uploadFileList.some(s=>s.status==="uploading"),(I=(E=this.callbacks).onUpdate)==null||I.call(E),this.updateOverallProgress()}removeFile(t){var e,a,l,c,h,m;if(t!==void 0&&t>=0&&t<this.uploadFileList.length){if(this.uploadFileList[t].status==="uploading")return(a=(e=this.callbacks).onMessage)==null||a.call(e,"正在上传中,无法删除","warning"),!1;this.uploadFileList.splice(t,1),this.fileList.splice(t,1)}else this.uploadFileList=[],this.fileList=[];return this.uploadProgress=0,this.uploadMessage="",this.uploadMessageType="info",this.isUploading=!1,(c=(l=this.callbacks).onFileChange)==null||c.call(l,this.uploadFileList),(m=(h=this.callbacks).onUpdate)==null||m.call(h),!0}enqueueUpload(t){const e=t.filter(a=>!this.uploadQueue.some(l=>l.id===a.id));this.uploadQueue.push(...e),this.processUploadQueue()}processUploadQueue(){for(;this.uploadQueue.length>0&&this.activeUploads<this.concurrentLimit;){const t=this.uploadQueue.shift();t.status==="pending"&&(this.activeUploads++,this.uploadSingleFile(t).finally(()=>{this.activeUploads--,this.processUploadQueue()}))}}async uploadSingleFile(t){var e,a,l,c,h,m,y,D;t.status="uploading",t.progress=0,this.isUploading=!0,(a=(e=this.callbacks).onUpdate)==null||a.call(e);try{t.response=await this.uploadFileChunked(t),t.status="success",t.progress=100,(c=(l=this.callbacks).onUploadSuccess)==null||c.call(l,t,t.response)}catch(b){t.status="error",t.errorMessage=b instanceof Error?b.message:"上传失败",(m=(h=this.callbacks).onUploadError)==null||m.call(h,t,b)}this.isUploading=this.uploadFileList.some(b=>b.status==="uploading"),(D=(y=this.callbacks).onUpdate)==null||D.call(y),this.updateOverallProgress()}async uploadFileChunked(t){if(!this.chunkedUploader)throw new Error("分片上传需要配置 chunkedUpload");return await this.chunkedUploader.upload(t)}async startUpload(){this.shouldUseChunkedUpload()&&await this.startChunkedUploadFiles()}async startChunkedUploadFiles(){const t=this.uploadFileList.filter(e=>e.status==="pending");this.enqueueUpload(t)}pauseUpload(){var t;(t=this.chunkedUploader)==null||t.pause()}resumeUpload(){var t;(t=this.chunkedUploader)==null||t.resume()}cancelUpload(){var t,e,a;(t=this.chunkedUploader)==null||t.cancel(),this.uploadQueue=[],this.activeUploads=0,this.isUploading=!1,this.uploadMessage="上传已取消",this.uploadMessageType="info",(a=(e=this.callbacks).onUpdate)==null||a.call(e)}updateOverallProgress(){if(this.uploadFileList.length===0){this.uploadProgress=0;return}const t=this.uploadFileList.reduce((e,a)=>e+a.progress,0);this.uploadProgress=Math.round(t/this.uploadFileList.length)}hasUploadingFiles(){return this.uploadFileList.some(t=>t.status==="uploading")}hasPendingFiles(){return this.uploadFileList.some(t=>t.status==="pending")}hasAllFilesUploaded(){return this.uploadFileList.length>0&&this.uploadFileList.every(t=>t.status==="success")}getFailedFiles(){return this.uploadFileList.filter(t=>t.status==="error")}}const it={success:"icon-success",error:"icon-cuowu",warning:"icon-warning",info:"icon-info"},De=new Set;function Wt(i){const{message:t,type:e,duration:a=3e3,closable:l=!0}=i,c=document.createElement("div");c.className=`import-dialog-vanilla-toast ${e}`;const h=it[e]||it.info;c.innerHTML=`
1566
1566
  <div class="import-dialog-vanilla-toast-content">
1567
1567
  <i class="iconfont ${h} import-dialog-vanilla-toast-icon"></i>
1568
1568
  <span class="import-dialog-vanilla-toast-message">${t}</span>