fileuploadsdk 0.0.1

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.
Files changed (40) hide show
  1. package/README.md +17 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/index.cjs.js.map +1 -0
  4. package/dist/cjs/index.d.ts +3 -0
  5. package/dist/cjs/index.d.ts.map +1 -0
  6. package/dist/esm/index.d.ts +3 -0
  7. package/dist/esm/index.d.ts.map +1 -0
  8. package/dist/esm/index.esm.js +2 -0
  9. package/dist/esm/index.esm.js.map +1 -0
  10. package/dist/index.cjs.js +11 -0
  11. package/dist/index.cjs.js.map +1 -0
  12. package/dist/index.d.ts +378 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.esm.js +11 -0
  15. package/dist/index.esm.js.map +1 -0
  16. package/dist/index.umd.js +11 -0
  17. package/dist/index.umd.js.map +1 -0
  18. package/dist/types/constants/errmsg.d.ts +6 -0
  19. package/dist/types/core/parallel-uploader.d.ts +16 -0
  20. package/dist/types/core/slice-uploader.d.ts +38 -0
  21. package/dist/types/core/upload.d.ts +21 -0
  22. package/dist/types/core/web-worker-helper.d.ts +16 -0
  23. package/dist/types/index.d.ts +20 -0
  24. package/dist/types/react/components/Progress.d.ts +9 -0
  25. package/dist/types/react/components/Upload.d.ts +13 -0
  26. package/dist/types/react/components/UploadList.d.ts +11 -0
  27. package/dist/types/react/hooks/useUpload.d.ts +14 -0
  28. package/dist/types/react/index.d.ts +6 -0
  29. package/dist/types/types/index.d.ts +224 -0
  30. package/dist/types/utils/file.d.ts +52 -0
  31. package/dist/types/vue/components/Progress.vue.d.ts +17 -0
  32. package/dist/types/vue/components/Upload.vue.d.ts +232 -0
  33. package/dist/types/vue/components/UploadList.vue.d.ts +26 -0
  34. package/dist/types/vue/composables/useUpload.d.ts +90 -0
  35. package/dist/types/vue/index.d.ts +6 -0
  36. package/dist/umd/index.d.ts +3 -0
  37. package/dist/umd/index.d.ts.map +1 -0
  38. package/dist/umd/index.umd.js +2 -0
  39. package/dist/umd/index.umd.js.map +1 -0
  40. package/package.json +74 -0
@@ -0,0 +1,378 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from 'axios';
2
+ import React from 'react';
3
+
4
+ interface UploadConfig {
5
+ /**
6
+ * 上传接口地址
7
+ */
8
+ url: string;
9
+ /**
10
+ * 上传方法
11
+ */
12
+ method?: 'POST' | 'PUT' | 'PATCH';
13
+ /**
14
+ * 请求头
15
+ */
16
+ headers?: Record<string, string>;
17
+ /**
18
+ * 超时时间
19
+ */
20
+ timeout?: number;
21
+ /**
22
+ * 是否跨域
23
+ */
24
+ withCredentials?: boolean;
25
+ /**
26
+ * 最大重试次数
27
+ */
28
+ maxRetries?: number;
29
+ /**
30
+ * 重试延迟时间
31
+ */
32
+ retryDelay?: number;
33
+ /**
34
+ * 分片大小
35
+ */
36
+ chunkSize?: number;
37
+ /**
38
+ * 分片重试次数
39
+ */
40
+ chunkRetry?: number;
41
+ /**
42
+ * 并发数
43
+ */
44
+ concurrency?: number;
45
+ /**
46
+ * 是否自动上传
47
+ */
48
+ autoUpload?: boolean;
49
+ /**
50
+ * 是否多选
51
+ */
52
+ multiple?: boolean;
53
+ /**
54
+ * 接受的文件类型
55
+ */
56
+ accept?: string;
57
+ /**
58
+ * 最大文件大小
59
+ */
60
+ maxSize?: number;
61
+ /**
62
+ * 最小文件大小
63
+ */
64
+ minSize?: number;
65
+ /**
66
+ * 上传进度回调
67
+ */
68
+ onProgress?: (progress: ProgressEvent) => void;
69
+ /**
70
+ * 上传成功回调
71
+ */
72
+ onSuccess?: (response: any, file: UploadFile) => void;
73
+ /**
74
+ * 上传失败回调
75
+ */
76
+ onError?: (error: Error, file: UploadFile) => void;
77
+ /**
78
+ * 上传取消回调
79
+ */
80
+ onCancel?: (file: UploadFile) => void;
81
+ beforeUpload?: (file: File) => boolean | Promise<boolean>;
82
+ /**
83
+ * 文件列表改变回调
84
+ */
85
+ onFileListChange?: (fileList: UploadFile[]) => void;
86
+ }
87
+ /**
88
+ * 上传文件对象
89
+ */
90
+ interface UploadFile {
91
+ /**
92
+ * 文件唯一标识
93
+ */
94
+ uid: string;
95
+ /**
96
+ * 文件对象
97
+ */
98
+ file: File;
99
+ /**
100
+ * 文件名
101
+ */
102
+ name: string;
103
+ /**
104
+ * 文件大小
105
+ */
106
+ size: number;
107
+ /**
108
+ * 文件类型
109
+ */
110
+ type: string;
111
+ /**
112
+ * 上传状态
113
+ */
114
+ status: 'pending' | 'uploading' | 'success' | 'error' | 'canceled';
115
+ /**
116
+ * 上传进度
117
+ */
118
+ percent: number;
119
+ /**
120
+ * 上传响应
121
+ */
122
+ response?: any;
123
+ /**
124
+ * 上传错误
125
+ */
126
+ error?: Error;
127
+ /**
128
+ * 文件分片列表
129
+ */
130
+ chunkList?: FileChunk[];
131
+ /**
132
+ * 文件哈希值
133
+ */
134
+ hash?: string;
135
+ /**
136
+ * 已上传大小
137
+ */
138
+ uploadedSize: number;
139
+ }
140
+ /**
141
+ * 文件分片对象
142
+ */
143
+ interface FileChunk {
144
+ /**
145
+ * 分片索引
146
+ */
147
+ index: number;
148
+ /**
149
+ * 分片对象
150
+ */
151
+ chunk: Blob;
152
+ /**
153
+ * 分片哈希值
154
+ */
155
+ hash: string;
156
+ /**
157
+ * 分片大小
158
+ */
159
+ size: number;
160
+ /**
161
+ * 分片上传进度
162
+ */
163
+ progress: number;
164
+ /**
165
+ * 分片上传状态
166
+ */
167
+ status: 'pending' | 'uploading' | 'success' | 'error';
168
+ }
169
+ /**
170
+ * 秒传检查结果对象
171
+ */
172
+ interface CheckResult {
173
+ /**
174
+ * 是否需要上传
175
+ */
176
+ shouldUpload: boolean;
177
+ /**
178
+ * 已上传分片索引列表
179
+ */
180
+ uploadedList?: string[];
181
+ /**
182
+ * 是否文件已存在
183
+ */
184
+ fileExists?: boolean;
185
+ }
186
+ /**
187
+ * 上传参数对象
188
+ */
189
+ interface UploadParams {
190
+ /**
191
+ * 文件对象
192
+ */
193
+ file: File;
194
+ /**
195
+ * 分片索引
196
+ */
197
+ chunkIndex?: number;
198
+ /**
199
+ * 总分片数
200
+ */
201
+ totalChunks?: number;
202
+ /**
203
+ * 分片哈希值
204
+ */
205
+ chunkHash?: string;
206
+ /**
207
+ * 文件哈希值
208
+ */
209
+ fileHash?: string;
210
+ /**
211
+ * 文件名
212
+ */
213
+ fileName?: string;
214
+ }
215
+
216
+ declare abstract class BaseUploader {
217
+ protected config: UploadConfig;
218
+ protected axiosInstance: AxiosInstance;
219
+ protected fileList: UploadFile[];
220
+ protected abortControllers: Map<string, AbortController>;
221
+ constructor(config: UploadConfig);
222
+ addFile(file: File): UploadFile;
223
+ addFiles(files: File[]): UploadFile[];
224
+ removeFile(uid: string): void;
225
+ clearFiles(): void;
226
+ getFileList(): UploadFile[];
227
+ abstract upload(file: UploadFile): Promise<void>;
228
+ uploadAll(): Promise<void>;
229
+ abortUpload(uid: string): void;
230
+ retryUpload(uid: string): Promise<void>;
231
+ protected checkFastUpload(file: UploadFile): Promise<CheckResult>;
232
+ protected updateProgress(file: UploadFile, loaded: number, total: number): void;
233
+ protected request<T>(config: AxiosRequestConfig, maxRetries?: number | undefined): Promise<T>;
234
+ }
235
+
236
+ declare class SliceUploader extends BaseUploader {
237
+ private chunkSize;
238
+ constructor(config: any);
239
+ /**
240
+ * 分片上传
241
+ */
242
+ upload(file: UploadFile): Promise<void>;
243
+ /**
244
+ * 验证文件
245
+ */
246
+ private validateFile;
247
+ /**
248
+ * 处理秒传
249
+ */
250
+ private handleFastUpload;
251
+ /**
252
+ * 上传分片
253
+ */
254
+ private uploadChunks;
255
+ /**
256
+ * 上传单个分片
257
+ */
258
+ private uploadChunk;
259
+ /**
260
+ * 合并分片
261
+ */
262
+ private mergeChunks;
263
+ /**
264
+ * 处理上传错误
265
+ */
266
+ private handleUploadError;
267
+ /**
268
+ * 恢复上传(断点续传)
269
+ */
270
+ resumeUpload(uid: string): Promise<void>;
271
+ }
272
+
273
+ declare class ParallelUploader extends BaseUploader {
274
+ private concurrent;
275
+ constructor(config: any);
276
+ /**
277
+ * 并行上传多个文件
278
+ */
279
+ upload(file: UploadFile): Promise<void>;
280
+ /**
281
+ * 并行上传所有文件
282
+ */
283
+ uploadAll(): Promise<void>;
284
+ private validateFile;
285
+ private handleUploadError;
286
+ }
287
+
288
+ interface UploadProps extends UploadConfig {
289
+ children?: React.ReactNode;
290
+ className?: string;
291
+ style?: React.CSSProperties;
292
+ drag?: boolean;
293
+ showFileList?: boolean;
294
+ listType?: 'text' | 'picture' | 'picture-card';
295
+ }
296
+ declare const Upload: React.FC<UploadProps>;
297
+
298
+ declare const useUpload: (config: UploadConfig) => {
299
+ fileList: UploadFile[];
300
+ uploading: boolean;
301
+ handleFileSelect: (files: FileList | File[]) => void;
302
+ uploadAll: () => Promise<void>;
303
+ cancelUpload: (uid: string) => void;
304
+ retryUpload: (uid: string) => Promise<void>;
305
+ removeFile: (uid: string) => void;
306
+ clearFiles: () => void;
307
+ uploader: SliceUploader | ParallelUploader | null;
308
+ };
309
+
310
+ /**
311
+ * 生成文件哈希值
312
+ * @param file 文件对象
313
+ * @returns 文件哈希值
314
+ */
315
+ declare const generateFileId: (file: File) => string;
316
+ /**
317
+ * 获取文件扩展名
318
+ * @param filename 文件名
319
+ * @returns 文件扩展名
320
+ */
321
+ declare const getFileExtension: (filename: string) => string;
322
+ /**
323
+ * 验证文件类型是否符合要求
324
+ * @param file 文件对象
325
+ * @param accept 接受的文件类型
326
+ * @returns 是否符合要求
327
+ */
328
+ declare const validateFileType: (file: File, accept?: string) => boolean;
329
+ /**
330
+ * 验证文件大小是否符合要求
331
+ * @param file 文件对象
332
+ * @param maxSize 最大文件大小
333
+ * @param minSize 最小文件大小
334
+ * @returns 是否符合要求
335
+ */
336
+ declare const validateFileSize: (file: File, maxSize?: number, minSize?: number) => boolean;
337
+ /**
338
+ * 创建文件分片
339
+ * @param file 文件对象
340
+ * @param chunkSize 分片大小
341
+ * @returns 文件分片列表
342
+ */
343
+ declare const createFileChunks: (file: File, chunkSize: number) => Blob[];
344
+ /**
345
+ * 计算文件哈希值
346
+ * @param file 文件对象
347
+ * @returns 文件哈希值
348
+ */
349
+ declare const calculateFileHash: (file: File) => Promise<string>;
350
+ /**
351
+ * 计算文件分片大小
352
+ * @param fileSize 文件大小
353
+ * @returns 分片大小
354
+ */
355
+ declare const calculateChunkSize: (fileSize: number) => number;
356
+ /**
357
+ * 格式化文件大小
358
+ * @param bytes 文件大小
359
+ * @returns 格式化后的文件大小
360
+ */
361
+ declare const formatFileSize: (bytes: number) => string;
362
+
363
+ declare const defaultConfig: {
364
+ url: string;
365
+ method: "POST";
366
+ timeout: number;
367
+ maxRetries: number;
368
+ retryDelay: number;
369
+ chunkSize: number;
370
+ chunkRetry: number;
371
+ concurrent: number;
372
+ autoUpload: boolean;
373
+ multiple: boolean;
374
+ withCredentials: boolean;
375
+ };
376
+
377
+ export { BaseUploader, ParallelUploader, Upload as ReactUpload, SliceUploader, calculateChunkSize, calculateFileHash, createFileChunks, defaultConfig, formatFileSize, generateFileId, getFileExtension, useUpload as useReactUpload, validateFileSize, validateFileType };
378
+ export type { CheckResult, FileChunk, UploadConfig, UploadFile, UploadParams };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAS,aAAa,SAErB;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import e from"axios";import t,{useState as n,useRef as r,useCallback as i}from"react";function s(e,t,n,r){return new(n||(n=Promise))(function(i,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((r=r.apply(e,t||[])).next())})}function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var a,l={exports:{}};var c=(a||(a=1,l.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],s=e[3];r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|s>>>20)+n|0)&n|~s&r)+t[2]+606105819|0)<<17|i>>>15)+s|0)&s|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|s>>>20)+n|0)&n|~s&r)+t[6]-1473231341|0)<<17|i>>>15)+s|0)&s|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|s>>>20)+n|0)&n|~s&r)+t[10]-42063|0)<<17|i>>>15)+s|0)&s|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|s>>>20)+n|0)&n|~s&r)+t[14]-1502002290|0)<<17|i>>>15)+s|0)&s|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|s>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+s|0)&n|s&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|s>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+s|0)&n|s&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|s>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+s|0)&n|s&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|s>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+s|0)&n|s&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|s>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+s|0)^s^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|s>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+s|0)^s^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|s>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+s|0)^s^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|s>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+s|0)^s^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[14]-1416354905|0)<<15|i>>>17)+s|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[10]-1051523|0)<<15|i>>>17)+s|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[6]-1560198380|0)<<15|i>>>17)+s|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[2]+718787259|0)<<15|i>>>17)+s|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=s+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function s(e){var t,i,s,o,a,l,c=e.length,u=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(u,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(u,s),t=0;t<16;t+=1)s[t]=0;return o=(o=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(o[2],16),l=parseInt(o[1],16)||0,s[14]=a,s[15]=l,n(u,s),u}function o(e){var t,r,s,o,a,l,c=e.length,u=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(u,i(e.subarray(t-64,t)));for(r=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)s[t>>2]|=e[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(u,s),t=0;t<16;t+=1)s[t]=0;return o=(o=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(o[2],16),l=parseInt(o[1],16)||0,s[14]=a,s[15]=l,n(u,s),u}function a(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function l(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function u(e,t){var n,r=e.length,i=new ArrayBuffer(r),s=new Uint8Array(i);for(n=0;n<r;n+=1)s[n]=e.charCodeAt(n);return t?s:i}function d(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function p(e,t,n){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),r}function h(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function f(){this.reset()}return l(s("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,s,o,a,l=this.byteLength,c=t(n,l),u=l;return r!==e&&(u=t(r,l)),c>u?new ArrayBuffer(0):(i=u-c,s=new ArrayBuffer(i),o=new Uint8Array(s),a=new Uint8Array(this,c,i),o.set(a),s)}}(),f.prototype.append=function(e){return this.appendBinary(c(e)),this},f.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},f.prototype.end=function(e){var t,n,r=this._buff,i=r.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)s[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(s,i),n=l(this._hash),e&&(n=h(n)),this.reset(),n},f.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},f.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},f.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},f.prototype._finish=function(e,t){var r,i,s,o=t;if(e[o>>2]|=128<<(o%4<<3),o>55)for(n(this._hash,e),o=0;o<16;o+=1)e[o]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),s=parseInt(r[1],16)||0,e[14]=i,e[15]=s,n(this._hash,e)},f.hash=function(e,t){return f.hashBinary(c(e),t)},f.hashBinary=function(e,t){var n=l(s(e));return t?h(n):n},f.ArrayBuffer=function(){this.reset()},f.ArrayBuffer.prototype.append=function(e){var t,r=p(this._buff.buffer,e),s=r.length;for(this._length+=e.byteLength,t=64;t<=s;t+=64)n(this._hash,i(r.subarray(t-64,t)));return this._buff=t-64<s?new Uint8Array(r.buffer.slice(t-64)):new Uint8Array(0),this},f.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)s[t>>2]|=r[t]<<(t%4<<3);return this._finish(s,i),n=l(this._hash),e&&(n=h(n)),this.reset(),n},f.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.ArrayBuffer.prototype.getState=function(){var e=f.prototype.getState.call(this);return e.buff=d(e.buff),e},f.ArrayBuffer.prototype.setState=function(e){return e.buff=u(e.buff,!0),f.prototype.setState.call(this,e)},f.ArrayBuffer.prototype.destroy=f.prototype.destroy,f.ArrayBuffer.prototype._finish=f.prototype._finish,f.ArrayBuffer.hash=function(e,t){var n=l(o(new Uint8Array(e)));return t?h(n):n},f}()),l.exports),u=o(c);const d=e=>`${e.name}-${e.size}-${e.type}-${e.lastModified}`,p=e=>e.slice(e.lastIndexOf(".")+1),h=(e,t)=>{if(!t)return!0;const n=t.split(",").map(e=>e.trim()),r=e.type,i=p(e.name);return n.some(e=>{if(e.startsWith("."))return i===e.slice(1);if(e.includes("/")){const t=e.split("/")[0];return r.startsWith(t)}return r===e})},f=(e,t,n)=>!(t&&e.size>t)&&!(n&&e.size<n),m=(e,t)=>{const n=[];let r=0;for(;r<e.size;){const i=Math.min(r+t,e.size),s=e.slice(r,i);n.push(s),r=i}return n},g=e=>new Promise(t=>{const n=new u.ArrayBuffer,r=new FileReader,i=2097152,s=m(e,i);let o=0;r.onload=e=>{var r;n.append(null===(r=e.target)||void 0===r?void 0:r.result),o++,o<s.length?a():t(n.end())},r.onerror=()=>{t("")};const a=()=>{const t=o*i,n=t+i>=e.size?e.size:t+i;r.readAsArrayBuffer(e.slice(t,n))};a()}),y=e=>e<=10485760?e:e<=104857600?5242880:e<=1073741824?10485760:20971520,v=e=>{if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB","TB"][t]};class x{constructor(t){this.fileList=[],this.abortControllers=new Map,this.config=Object.assign({method:"POST",headers:{},timeout:3e4,maxRetries:3,retryDelay:1e3,chunkSize:5242880,chunkRetry:3,concurrency:3,autoUpload:!0,multiple:!1,withCredentials:!1},t),this.axiosInstance=e.create({timeout:this.config.timeout,headers:this.config.headers,withCredentials:this.config.withCredentials})}addFile(e){var t,n;const r={uid:d(e),file:e,name:e.name,size:e.size,type:e.type,status:"pending",percent:0,uploadedSize:0};return this.fileList.push(r),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),this.config.autoUpload&&this.upload(r),r}addFiles(e){return e.map(e=>this.addFile(e))}removeFile(e){var t,n;const r=this.fileList.findIndex(t=>t.uid===e);-1!==r&&(this.abortUpload(e),this.fileList.splice(r,1),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList))}clearFiles(){var e,t;this.fileList.forEach(e=>{this.abortUpload(e.uid)}),this.fileList=[],null===(t=(e=this.config).onFileListChange)||void 0===t||t.call(e,this.fileList)}getFileList(){return[...this.fileList]}uploadAll(){return s(this,void 0,void 0,function*(){const e=this.fileList.filter(e=>"pending"===e.status);yield Promise.all(e.map(e=>this.upload(e)))})}abortUpload(e){var t,n,r,i;const s=this.abortControllers.get(e);if(s){s.abort(),this.abortControllers.delete(e);const o=this.fileList.find(t=>t.uid===e);o&&(o.status="canceled",o.percent=0,null===(n=(t=this.config).onCancel)||void 0===n||n.call(t,o),null===(i=(r=this.config).onFileListChange)||void 0===i||i.call(r,this.fileList))}}retryUpload(e){return s(this,void 0,void 0,function*(){var t,n;const r=this.fileList.find(t=>t.uid===e);!r||"error"!==r.status&&"canceled"!==r.status||(r.status="pending",r.percent=0,r.error=void 0,null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),yield this.upload(r))})}checkFastUpload(e){return s(this,void 0,void 0,function*(){if(!this.config.url)return{shouldUpload:!0};try{return(yield this.axiosInstance.post(`${this.config.url}/check`,{fileName:e.name,fileSize:e.size,lastModified:e.file.lastModified})).data}catch(e){return console.warn("秒传检查失败,继续正常上传:",e),{shouldUpload:!0}}})}updateProgress(e,t,n){var r,i;if(e.uploadedSize=t,e.percent=n>0?Math.round(t/n*100):0,this.config.onProgress){const e=new ProgressEvent("progress",{loaded:t,total:n,lengthComputable:!0});this.config.onProgress(e)}null===(i=(r=this.config).onFileListChange)||void 0===i||i.call(r,this.fileList)}request(e){return s(this,arguments,void 0,function*(e,t=this.config.maxRetries){var n,r;let i;for(let s=0;s<t;s++)try{const t=new AbortController;(null===(n=e.data)||void 0===n?void 0:n.uid)&&this.abortControllers.set(e.data.uid,t);const i=yield this.axiosInstance(Object.assign(Object.assign({},e),{signal:t.signal}));return(null===(r=e.data)||void 0===r?void 0:r.uid)&&this.abortControllers.delete(e.data.uid),i.data}catch(e){if(i=e,"ERR_CANCELED"===e.code)throw e;s<t-1&&(yield new Promise(e=>setTimeout(e,this.config.retryDelay*Math.pow(2,s))))}throw i})}}class b{value;next;constructor(e){this.value=e}}class j{#e;#t;#n;constructor(){this.clear()}enqueue(e){const t=new b(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#n++}dequeue(){const e=this.#e;if(e)return this.#e=this.#e.next,this.#n--,this.#e||(this.#t=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}}function w(e){k(e);const t=new j;let n=0;const r=()=>{n<e&&t.size>0&&(n++,t.dequeue()())},i=async(e,t,i)=>{const s=(async()=>e(...i))();t(s);try{await s}catch{}n--,r()},s=(s,...o)=>new Promise(a=>{((s,o,a)=>{new Promise(e=>{t.enqueue(e)}).then(i.bind(void 0,s,o,a)),n<e&&r()})(s,a,o)});return Object.defineProperties(s,{activeCount:{get:()=>n},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}},concurrency:{get:()=>e,set(i){k(i),e=i,queueMicrotask(()=>{for(;n<e&&t.size>0;)r()})}},map:{async value(e,t){const n=Array.from(e,(e,n)=>this(t,e,n));return Promise.all(n)}}}),s}function k(e){if(!Number.isInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}class N extends x{constructor(e){super(e),this.chunkSize=e.chunkSize||5242880}upload(e){return s(this,void 0,void 0,function*(){try{if(!(yield this.validateFile(e)))return;const t=yield this.checkFastUpload(e);if(!0===(null==t?void 0:t.fileExists))return void(yield this.handleFastUpload(e,t));e.hash=yield g(e.file);const n=m(e.file,this.chunkSize);e.chunkList=n.map((t,n)=>({index:n,chunk:t,hash:`${e.hash}-${n}`,size:t.size,progress:0,status:"pending"})),yield this.uploadChunks(e,t.uploadedList||[]),yield this.mergeChunks(e)}catch(t){this.handleUploadError(e,t)}})}validateFile(e){return s(this,void 0,void 0,function*(){var t,n;if(this.config.beforeUpload){if(!(yield Promise.resolve(this.config.beforeUpload(e.file))))return this.removeFile(e.uid),!1}return e.status="uploading",null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),!0})}handleFastUpload(e,t){return s(this,void 0,void 0,function*(){var t,n;e.status="success",e.percent=100,e.response={message:"秒传成功"},this.config.onSuccess&&this.config.onSuccess(e.response,e),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList)})}uploadChunks(e,t){return s(this,void 0,void 0,function*(){const{chunkList:n}=e;if(!n)return;const r=w(this.config.concurrency||3),i=[];n.filter(e=>!t.includes(e.hash)).forEach(t=>{const n=r(()=>this.uploadChunk(e,t));i.push(n)}),yield Promise.all(i)})}uploadChunk(e,t){return s(this,void 0,void 0,function*(){t.status="uploading";const n=new FormData;n.append("file",t.chunk),n.append("chunkIndex",t.index.toString()),n.append("chunkHash",t.hash),n.append("fileHash",e.hash),n.append("fileName",e.name),n.append("totalChunks",e.chunkList.length.toString()),n.append("uid",e.uid);try{yield this.request({method:this.config.method,url:this.config.url,data:n,onUploadProgress:n=>{const r=n.loaded,i=n.total||t.size;t.progress=Math.round(r/i*100);const s=e.chunkList.reduce((e,n)=>e+(n.index===t.index?r:n.size*(n.progress/100)),0),o=e.size;this.updateProgress(e,s,o)}},this.config.chunkRetry),t.status="success",t.progress=100}catch(e){throw t.status="error",e}})}mergeChunks(e){return s(this,void 0,void 0,function*(){var t,n;const r=yield this.request({method:"POST",url:`${this.config.url}/merge`,data:{fileName:e.name,fileHash:e.hash,totalChunks:e.chunkList.length,uid:e.uid}});e.status="success",e.percent=100,e.response=r,this.config.onSuccess&&this.config.onSuccess(r,e),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList)})}handleUploadError(e,t){var n,r;e.status="error",e.error=t,this.config.onError&&this.config.onError(t,e),null===(r=(n=this.config).onFileListChange)||void 0===r||r.call(n,this.fileList)}resumeUpload(e){return s(this,void 0,void 0,function*(){const t=this.fileList.find(t=>t.uid===e);if(t&&"error"===t.status)try{const e=(yield this.request({method:"GET",url:`${this.config.url}/uploaded`,params:{fileHash:t.hash,fileName:t.name}})).uploadedList||[];yield this.uploadChunks(t,e),yield this.mergeChunks(t)}catch(e){this.handleUploadError(t,e)}})}}class C extends x{constructor(e){super(e),this.concurrent=e.concurrent||3}upload(e){return s(this,void 0,void 0,function*(){var t,n,r,i;try{if(!(yield this.validateFile(e)))return;e.status="uploading",null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList);const r=new FormData;r.append("file",e.file),r.append("fileName",e.name),r.append("uid",e.uid);const i=yield this.request({method:this.config.method,url:this.config.url,data:r,onUploadProgress:t=>{this.updateProgress(e,t.loaded,t.total||e.size)}});e.status="success",e.percent=100,e.response=i,this.config.onSuccess&&this.config.onSuccess(i,e)}catch(t){this.handleUploadError(e,t)}null===(i=(r=this.config).onFileListChange)||void 0===i||i.call(r,this.fileList)})}uploadAll(){return s(this,void 0,void 0,function*(){const e=this.fileList.filter(e=>"pending"===e.status),t=w(this.concurrent),n=e.map(e=>t(()=>this.upload(e)));yield Promise.all(n)})}validateFile(e){return s(this,void 0,void 0,function*(){if(this.config.beforeUpload){if(!(yield Promise.resolve(this.config.beforeUpload(e.file))))return this.removeFile(e.uid),!1}return!0})}handleUploadError(e,t){e.status="error",e.error=t,this.config.onError&&this.config.onError(t,e)}}var L,_={exports:{}},S={};var F,U,z={};
2
+ /**
3
+ * @license React
4
+ * react-jsx-runtime.development.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */function A(){return F||(F=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===C?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case f:return"Fragment";case g:return"Profiler";case m:return"StrictMode";case b:return"Suspense";case j:return"SuspenseList";case N:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case h:return"Portal";case v:return t.displayName||"Context";case y:return(t._context.displayName||"Context")+".Consumer";case x:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case w:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case k:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function n(e){return""+e}function r(e){try{n(e);var t=!1}catch(e){t=!0}if(t){var r=(t=console).error,i="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",i),n(e)}}function i(t){if(t===f)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===k)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function s(){return Error("react-stack-top-frame")}function o(){var t=e(this.type);return U[t]||(U[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function a(t,n,i,s,a,c){var d,h=n.children;if(void 0!==h)if(s)if(S(h)){for(s=0;s<h.length;s++)l(h[s]);Object.freeze&&Object.freeze(h)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(h);if(_.call(n,"key")){h=e(t);var f=Object.keys(n).filter(function(e){return"key"!==e});s=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",R[h+s]||(f=0<f.length?"{"+f.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',s,h,f,h),R[h+s]=!0)}if(h=null,void 0!==i&&(r(i),h=""+i),function(e){if(_.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(n)&&(r(n.key),h=""+n.key),"key"in n)for(var m in i={},n)"key"!==m&&(i[m]=n[m]);else i=n;return h&&function(e,t){function n(){u||(u=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(i,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,n,r,i,s){var a=n.ref;return e={$$typeof:p,type:e,key:t,props:n,_owner:r},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:o}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:s}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,h,i,null===(d=L.A)?null:d.getOwner(),a,c)}function l(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===k&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function c(e){return"object"==typeof e&&null!==e&&e.$$typeof===p}var u,d=t,p=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),v=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),L=d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=Object.prototype.hasOwnProperty,S=Array.isArray,F=console.createTask?console.createTask:function(){return null},U={},A=(d={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(d,s)(),O=F(i(s)),R={};z.Fragment=f,z.jsx=function(e,t,n){var r=1e4>L.recentlyCreatedOwnerStacks++;return a(e,t,n,!1,r?Error("react-stack-top-frame"):A,r?F(i(e)):O)},z.jsxs=function(e,t,n){var r=1e4>L.recentlyCreatedOwnerStacks++;return a(e,t,n,!0,r?Error("react-stack-top-frame"):A,r?F(i(e)):O)}}()),z}var O=(U||(U=1,"production"===process.env.NODE_ENV?_.exports=function(){if(L)return S;L=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,r){var i=null;if(void 0!==r&&(i=""+r),void 0!==n.key&&(i=""+n.key),"key"in n)for(var s in r={},n)"key"!==s&&(r[s]=n[s]);else r=n;return n=r.ref,{$$typeof:e,type:t,key:i,ref:void 0!==n?n:null,props:r}}return S.Fragment=t,S.jsx=n,S.jsxs=n,S}():_.exports=A()),_.exports);const R=e=>{const[t,o]=n([]),[a,l]=n(!1),c=r(null),u=i(()=>{e.chunkSize&&e.chunkSize>0?c.current=new N(Object.assign(Object.assign({},e),{onFileListChange:t=>{var n;o(t),null===(n=e.onFileListChange)||void 0===n||n.call(e,t)}})):c.current=new C(Object.assign(Object.assign({},e),{onFileListChange:t=>{var n;o(t),null===(n=e.onFileListChange)||void 0===n||n.call(e,t)}}))},[e]);return{fileList:t,uploading:a,handleFileSelect:i(t=>{c.current||u();const n=Array.from(t).filter(t=>!(e.accept&&!h(t,e.accept))&&!!f(t,e.maxSize,e.minSize));n.length>0&&c.current.addFiles(n)},[e,u]),uploadAll:i(()=>s(void 0,void 0,void 0,function*(){if(c.current){l(!0);try{yield c.current.uploadAll()}finally{l(!1)}}}),[]),cancelUpload:i(e=>{var t;null===(t=c.current)||void 0===t||t.abortUpload(e)},[]),retryUpload:i(e=>s(void 0,void 0,void 0,function*(){var t;yield null===(t=c.current)||void 0===t?void 0:t.retryUpload(e)}),[]),removeFile:i(e=>{var t;null===(t=c.current)||void 0===t||t.removeFile(e)},[]),clearFiles:i(()=>{var e;null===(e=c.current)||void 0===e||e.clearFiles()},[]),uploader:c.current}},P=({fileList:e,listType:t,onCancel:n,onRetry:r,onRemove:i})=>0===e.length?null:(()=>{switch(t){case"picture":return O.jsx("div",{className:"upload-list upload-list-picture",children:e.map(e=>O.jsxs("div",{className:"upload-list-item upload-list-item-picture",children:[O.jsx("div",{className:"upload-list-item-thumbnail",children:e.type.startsWith("image/")?O.jsx("img",{src:URL.createObjectURL(e.file),alt:e.name,onLoad:()=>URL.revokeObjectURL(URL.createObjectURL(e.file))}):O.jsx("div",{className:"upload-list-item-icon",children:e.type.split("/")[0]})}),O.jsxs("div",{className:"upload-list-item-info",children:[O.jsx("div",{className:"upload-list-item-name",children:e.name}),O.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&O.jsxs(O.Fragment,{children:[O.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&O.jsx("span",{className:"upload-list-item-success",children:"✓ 成功"}),"error"===e.status&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"upload-list-item-error",children:"✗ 失败"}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),"canceled"===e.status&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),O.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>i(e.uid),children:"删除"})]})]})]},e.uid))});case"picture-card":return O.jsx("div",{className:"upload-list upload-list-picture-card",children:e.map(e=>O.jsxs("div",{className:"upload-list-item upload-list-item-picture-card",children:[O.jsxs("div",{className:"upload-list-item-thumbnail",children:[e.type.startsWith("image/")?O.jsx("img",{src:URL.createObjectURL(e.file),alt:e.name,onLoad:()=>URL.revokeObjectURL(URL.createObjectURL(e.file))}):O.jsx("div",{className:"upload-list-item-icon",children:e.type.split("/")[0]}),O.jsx("div",{className:"upload-list-item-overlay",children:O.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&O.jsxs(O.Fragment,{children:[O.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&O.jsx("span",{className:"upload-list-item-success",children:"✓"}),"error"===e.status&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"upload-list-item-error",children:"✗"}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),"canceled"===e.status&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),O.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>i(e.uid),children:"删除"})]})})]}),O.jsx("div",{className:"upload-list-item-name",children:e.name})]},e.uid))});default:return O.jsx("div",{className:"upload-list upload-list-text",children:e.map(e=>{return O.jsxs("div",{className:"upload-list-item",children:[O.jsxs("div",{className:"upload-list-item-name",children:[O.jsx("span",{children:e.name}),O.jsxs("span",{className:"upload-list-item-size",children:["(",(t=e.size,t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`),")"]})]}),O.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&O.jsxs(O.Fragment,{children:[O.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&O.jsx("span",{className:"upload-list-item-success",children:"✓ 成功"}),"error"===e.status&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"upload-list-item-error",children:"✗ 失败"}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),"canceled"===e.status&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),O.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),O.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>i(e.uid),children:"删除"})]})]},e.uid);var t})})}})(),E=({fileList:e,onUploadAll:t,onClear:n})=>{const r=(()=>{if(0===e.length)return 0;const t=e.reduce((e,t)=>e+t.size,0),n=e.reduce((e,t)=>e+(t.uploadedSize||0),0);return Math.round(n/t*100)})(),i=e.filter(e=>"uploading"===e.status).length,s=e.filter(e=>"success"===e.status).length,o=e.filter(e=>"error"===e.status).length;return 0===e.length?null:O.jsxs("div",{className:"upload-progress",children:[O.jsxs("div",{className:"upload-progress-header",children:[O.jsxs("div",{className:"upload-progress-status",children:[i>0&&O.jsxs("span",{className:"upload-progress-uploading",children:["正在上传 ",i," 个文件..."]}),0===i&&s>0&&O.jsxs("span",{className:"upload-progress-success",children:["已成功上传 ",s," 个文件"]}),o>0&&O.jsxs("span",{className:"upload-progress-error",children:["有 ",o," 个文件上传失败"]})]}),O.jsxs("div",{className:"upload-progress-actions",children:[O.jsx("button",{className:"upload-progress-action upload-progress-start",onClick:t,disabled:i>0,children:"开始上传"}),O.jsx("button",{className:"upload-progress-action upload-progress-clear",onClick:n,children:"清空"})]})]}),O.jsxs("div",{className:"upload-progress-bar-container",children:[O.jsx("div",{className:"upload-progress-bar",style:{width:`${r}%`}}),O.jsxs("div",{className:"upload-progress-text",children:[r,"%"]})]}),O.jsx("div",{className:"upload-progress-footer",children:O.jsxs("div",{className:"upload-progress-stats",children:[O.jsxs("span",{children:["总数: ",e.length]}),O.jsxs("span",{children:["成功: ",s]}),O.jsxs("span",{children:["失败: ",o]}),O.jsxs("span",{children:["等待: ",e.length-s-o-i]})]})})]})};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}("/* 上传组件共享样式 */\n\n/* 基础样式 */\n.upload-container {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.upload-drag {\n border: 2px dashed #d9d9d9;\n border-radius: 6px;\n padding: 40px 20px;\n text-align: center;\n cursor: pointer;\n transition: border-color 0.3s;\n}\n\n.upload-drag:hover,\n.upload-dragover {\n border-color: #1890ff;\n}\n\n.upload-trigger {\n display: inline-block;\n cursor: pointer;\n}\n\n.upload-default {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: #666;\n}\n\n.upload-icon {\n font-size: 32px;\n color: #999;\n margin-bottom: 8px;\n}\n\n.upload-text {\n font-size: 14px;\n}\n\n/* UploadList 样式 */\n.upload-list {\n margin-top: 12px;\n}\n\n.upload-list-item {\n display: flex;\n align-items: center;\n padding: 8px 0;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.upload-list-item-name {\n flex: 1;\n font-size: 14px;\n color: #333;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.upload-list-item-size {\n font-size: 12px;\n color: #999;\n margin-left: 8px;\n}\n\n.upload-list-item-status {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.upload-list-item-progress {\n font-size: 12px;\n color: #1890ff;\n}\n\n.upload-list-item-success {\n font-size: 12px;\n color: #52c41a;\n}\n\n.upload-list-item-error {\n font-size: 12px;\n color: #ff4d4f;\n}\n\n.upload-list-item-canceled {\n font-size: 12px;\n color: #999;\n}\n\n.upload-list-item-action {\n font-size: 12px;\n color: #1890ff;\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n}\n\n.upload-list-item-action:hover {\n text-decoration: underline;\n}\n\n.upload-list-item-remove {\n color: #999;\n}\n\n/* 图片类型样式 */\n.upload-list-item-picture {\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n}\n\n.upload-list-item-thumbnail {\n position: relative;\n width: 100px;\n height: 100px;\n border-radius: 4px;\n overflow: hidden;\n border: 1px solid #f0f0f0;\n}\n\n.upload-list-item-thumbnail img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.upload-list-item-icon {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #f5f5f5;\n font-size: 12px;\n color: #999;\n}\n\n.upload-list-item-info {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n/* 图片卡片类型样式 */\n.upload-list-picture-card {\n display: flex;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.upload-list-item-picture-card {\n width: 120px;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n border: none;\n padding: 0;\n}\n\n.upload-list-item-picture-card .upload-list-item-thumbnail {\n width: 120px;\n height: 120px;\n}\n\n.upload-list-item-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.upload-list-item-picture-card .upload-list-item-status {\n color: white;\n flex-direction: column;\n gap: 8px;\n}\n\n.upload-list-item-picture-card .upload-list-item-action {\n color: white;\n border: 1px solid white;\n padding: 2px 8px;\n border-radius: 4px;\n}\n\n.upload-list-item-picture-card .upload-list-item-action:hover {\n background-color: white;\n color: #1890ff;\n text-decoration: none;\n}\n\n.upload-list-item-picture-card .upload-list-item-name {\n font-size: 12px;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n}\n\n/* Progress 组件样式 */\n.upload-progress {\n margin-top: 12px;\n padding: 12px;\n background-color: #fafafa;\n border-radius: 6px;\n}\n\n.upload-progress-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 12px;\n}\n\n.upload-progress-status {\n font-size: 14px;\n color: #333;\n}\n\n.upload-progress-uploading {\n color: #1890ff;\n}\n\n.upload-progress-success {\n color: #52c41a;\n}\n\n.upload-progress-error {\n color: #ff4d4f;\n}\n\n.upload-progress-actions {\n display: flex;\n gap: 8px;\n}\n\n.upload-progress-action {\n font-size: 12px;\n padding: 4px 12px;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n background-color: white;\n cursor: pointer;\n transition: all 0.3s;\n}\n\n.upload-progress-action:hover {\n border-color: #1890ff;\n color: #1890ff;\n}\n\n.upload-progress-action:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.upload-progress-action:disabled:hover {\n border-color: #d9d9d9;\n color: #999;\n}\n\n.upload-progress-start {\n color: #1890ff;\n border-color: #1890ff;\n}\n\n.upload-progress-start:hover {\n background-color: #e6f7ff;\n}\n\n.upload-progress-clear {\n color: #666;\n}\n\n.upload-progress-bar-container {\n position: relative;\n height: 8px;\n background-color: #f0f0f0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n}\n\n.upload-progress-bar {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n background-color: #1890ff;\n transition: width 0.3s ease;\n}\n\n.upload-progress-text {\n position: absolute;\n top: 0;\n right: 8px;\n height: 100%;\n display: flex;\n align-items: center;\n font-size: 12px;\n color: #666;\n}\n\n.upload-progress-footer {\n margin-top: 8px;\n}\n\n.upload-progress-stats {\n display: flex;\n gap: 16px;\n font-size: 12px;\n color: #999;\n}");const B=e=>{var{children:t,className:n="",style:s,drag:o=!1,showFileList:a=!0,listType:l="text"}=e,c=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(e,["children","className","style","drag","showFileList","listType"]);const u=r(null),d=r(null),{fileList:p,uploading:h,handleFileSelect:f,uploadAll:m,cancelUpload:g,retryUpload:y,removeFile:v,clearFiles:x}=R(c),b=i(()=>{var e;null===(e=u.current)||void 0===e||e.click()},[]),j=i(e=>{e.target.files&&(f(e.target.files),e.target.value="")},[f]),w=i(e=>{var t,n;e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?null===(t=d.current)||void 0===t||t.classList.add("upload-dragover"):"dragleave"===e.type&&(null===(n=d.current)||void 0===n||n.classList.remove("upload-dragover"))},[]),k=i(e=>{var t;e.preventDefault(),e.stopPropagation(),null===(t=d.current)||void 0===t||t.classList.remove("upload-dragover"),e.dataTransfer.files&&f(e.dataTransfer.files)},[f]),N=()=>t||O.jsxs("div",{className:"upload-default",children:[O.jsx("div",{className:"upload-icon",children:"+"}),O.jsx("div",{className:"upload-text",children:"点击或拖拽文件到此区域上传"})]});return O.jsxs("div",{className:`upload-container ${n}`,style:s,children:[O.jsx("input",{ref:u,type:"file",style:{display:"none"},multiple:c.multiple,accept:c.accept,onChange:j}),o?O.jsx("div",{ref:d,className:"upload-drag",onClick:b,onDragEnter:w,onDragOver:w,onDragLeave:w,onDrop:k,children:N()}):O.jsx("div",{className:"upload-trigger",onClick:b,children:N()}),a&&O.jsx(P,{fileList:p,listType:l,onCancel:g,onRetry:y,onRemove:v}),h&&O.jsx(E,{fileList:p,onUploadAll:m,onClear:x})]})},T={url:"",method:"POST",timeout:3e4,maxRetries:3,retryDelay:1e3,chunkSize:5242880,chunkRetry:3,concurrent:3,autoUpload:!0,multiple:!1,withCredentials:!1};export{x as BaseUploader,C as ParallelUploader,B as ReactUpload,N as SliceUploader,y as calculateChunkSize,g as calculateFileHash,m as createFileChunks,T as defaultConfig,v as formatFileSize,d as generateFileId,p as getFileExtension,R as useReactUpload,f as validateFileSize,h as validateFileType};
11
+ //# sourceMappingURL=index.esm.js.map