UNPKG

fluxforge

Version:

企业级文件分块和并发处理库,具备 Web Workers、自动重试、实时进度跟踪和 MD5 完整性验证功能,专为现代浏览器设计。非常适合大文件上传、流式处理和数据处理管道场景。

329 lines (328 loc) 26.6 kB
var P = Object.defineProperty; var x = (a, s, h) => s in a ? P(a, s, { enumerable: !0, configurable: !0, writable: !0, value: h }) : a[s] = h; var B = (a, s, h) => x(a, typeof s != "symbol" ? s + "" : s, h); var w = (a, s, h) => new Promise((l, o) => { var c = (y) => { try { g(h.next(y)); } catch (_) { o(_); } }, p = (y) => { try { g(h.throw(y)); } catch (_) { o(_); } }, g = (y) => y.done ? l(y.value) : Promise.resolve(y.value).then(c, p); g((h = h.apply(a, s)).next()); }); function T(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var S = { exports: {} }, I; function E() { return I || (I = 1, function(a, s) { (function(h) { a.exports = h(); })(function(h) { var l = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; function o(f, i) { var r = f[0], t = f[1], n = f[2], e = f[3]; r += (t & n | ~t & e) + i[0] - 680876936 | 0, r = (r << 7 | r >>> 25) + t | 0, e += (r & t | ~r & n) + i[1] - 389564586 | 0, e = (e << 12 | e >>> 20) + r | 0, n += (e & r | ~e & t) + i[2] + 606105819 | 0, n = (n << 17 | n >>> 15) + e | 0, t += (n & e | ~n & r) + i[3] - 1044525330 | 0, t = (t << 22 | t >>> 10) + n | 0, r += (t & n | ~t & e) + i[4] - 176418897 | 0, r = (r << 7 | r >>> 25) + t | 0, e += (r & t | ~r & n) + i[5] + 1200080426 | 0, e = (e << 12 | e >>> 20) + r | 0, n += (e & r | ~e & t) + i[6] - 1473231341 | 0, n = (n << 17 | n >>> 15) + e | 0, t += (n & e | ~n & r) + i[7] - 45705983 | 0, t = (t << 22 | t >>> 10) + n | 0, r += (t & n | ~t & e) + i[8] + 1770035416 | 0, r = (r << 7 | r >>> 25) + t | 0, e += (r & t | ~r & n) + i[9] - 1958414417 | 0, e = (e << 12 | e >>> 20) + r | 0, n += (e & r | ~e & t) + i[10] - 42063 | 0, n = (n << 17 | n >>> 15) + e | 0, t += (n & e | ~n & r) + i[11] - 1990404162 | 0, t = (t << 22 | t >>> 10) + n | 0, r += (t & n | ~t & e) + i[12] + 1804603682 | 0, r = (r << 7 | r >>> 25) + t | 0, e += (r & t | ~r & n) + i[13] - 40341101 | 0, e = (e << 12 | e >>> 20) + r | 0, n += (e & r | ~e & t) + i[14] - 1502002290 | 0, n = (n << 17 | n >>> 15) + e | 0, t += (n & e | ~n & r) + i[15] + 1236535329 | 0, t = (t << 22 | t >>> 10) + n | 0, r += (t & e | n & ~e) + i[1] - 165796510 | 0, r = (r << 5 | r >>> 27) + t | 0, e += (r & n | t & ~n) + i[6] - 1069501632 | 0, e = (e << 9 | e >>> 23) + r | 0, n += (e & t | r & ~t) + i[11] + 643717713 | 0, n = (n << 14 | n >>> 18) + e | 0, t += (n & r | e & ~r) + i[0] - 373897302 | 0, t = (t << 20 | t >>> 12) + n | 0, r += (t & e | n & ~e) + i[5] - 701558691 | 0, r = (r << 5 | r >>> 27) + t | 0, e += (r & n | t & ~n) + i[10] + 38016083 | 0, e = (e << 9 | e >>> 23) + r | 0, n += (e & t | r & ~t) + i[15] - 660478335 | 0, n = (n << 14 | n >>> 18) + e | 0, t += (n & r | e & ~r) + i[4] - 405537848 | 0, t = (t << 20 | t >>> 12) + n | 0, r += (t & e | n & ~e) + i[9] + 568446438 | 0, r = (r << 5 | r >>> 27) + t | 0, e += (r & n | t & ~n) + i[14] - 1019803690 | 0, e = (e << 9 | e >>> 23) + r | 0, n += (e & t | r & ~t) + i[3] - 187363961 | 0, n = (n << 14 | n >>> 18) + e | 0, t += (n & r | e & ~r) + i[8] + 1163531501 | 0, t = (t << 20 | t >>> 12) + n | 0, r += (t & e | n & ~e) + i[13] - 1444681467 | 0, r = (r << 5 | r >>> 27) + t | 0, e += (r & n | t & ~n) + i[2] - 51403784 | 0, e = (e << 9 | e >>> 23) + r | 0, n += (e & t | r & ~t) + i[7] + 1735328473 | 0, n = (n << 14 | n >>> 18) + e | 0, t += (n & r | e & ~r) + i[12] - 1926607734 | 0, t = (t << 20 | t >>> 12) + n | 0, r += (t ^ n ^ e) + i[5] - 378558 | 0, r = (r << 4 | r >>> 28) + t | 0, e += (r ^ t ^ n) + i[8] - 2022574463 | 0, e = (e << 11 | e >>> 21) + r | 0, n += (e ^ r ^ t) + i[11] + 1839030562 | 0, n = (n << 16 | n >>> 16) + e | 0, t += (n ^ e ^ r) + i[14] - 35309556 | 0, t = (t << 23 | t >>> 9) + n | 0, r += (t ^ n ^ e) + i[1] - 1530992060 | 0, r = (r << 4 | r >>> 28) + t | 0, e += (r ^ t ^ n) + i[4] + 1272893353 | 0, e = (e << 11 | e >>> 21) + r | 0, n += (e ^ r ^ t) + i[7] - 155497632 | 0, n = (n << 16 | n >>> 16) + e | 0, t += (n ^ e ^ r) + i[10] - 1094730640 | 0, t = (t << 23 | t >>> 9) + n | 0, r += (t ^ n ^ e) + i[13] + 681279174 | 0, r = (r << 4 | r >>> 28) + t | 0, e += (r ^ t ^ n) + i[0] - 358537222 | 0, e = (e << 11 | e >>> 21) + r | 0, n += (e ^ r ^ t) + i[3] - 722521979 | 0, n = (n << 16 | n >>> 16) + e | 0, t += (n ^ e ^ r) + i[6] + 76029189 | 0, t = (t << 23 | t >>> 9) + n | 0, r += (t ^ n ^ e) + i[9] - 640364487 | 0, r = (r << 4 | r >>> 28) + t | 0, e += (r ^ t ^ n) + i[12] - 421815835 | 0, e = (e << 11 | e >>> 21) + r | 0, n += (e ^ r ^ t) + i[15] + 530742520 | 0, n = (n << 16 | n >>> 16) + e | 0, t += (n ^ e ^ r) + i[2] - 995338651 | 0, t = (t << 23 | t >>> 9) + n | 0, r += (n ^ (t | ~e)) + i[0] - 198630844 | 0, r = (r << 6 | r >>> 26) + t | 0, e += (t ^ (r | ~n)) + i[7] + 1126891415 | 0, e = (e << 10 | e >>> 22) + r | 0, n += (r ^ (e | ~t)) + i[14] - 1416354905 | 0, n = (n << 15 | n >>> 17) + e | 0, t += (e ^ (n | ~r)) + i[5] - 57434055 | 0, t = (t << 21 | t >>> 11) + n | 0, r += (n ^ (t | ~e)) + i[12] + 1700485571 | 0, r = (r << 6 | r >>> 26) + t | 0, e += (t ^ (r | ~n)) + i[3] - 1894986606 | 0, e = (e << 10 | e >>> 22) + r | 0, n += (r ^ (e | ~t)) + i[10] - 1051523 | 0, n = (n << 15 | n >>> 17) + e | 0, t += (e ^ (n | ~r)) + i[1] - 2054922799 | 0, t = (t << 21 | t >>> 11) + n | 0, r += (n ^ (t | ~e)) + i[8] + 1873313359 | 0, r = (r << 6 | r >>> 26) + t | 0, e += (t ^ (r | ~n)) + i[15] - 30611744 | 0, e = (e << 10 | e >>> 22) + r | 0, n += (r ^ (e | ~t)) + i[6] - 1560198380 | 0, n = (n << 15 | n >>> 17) + e | 0, t += (e ^ (n | ~r)) + i[13] + 1309151649 | 0, t = (t << 21 | t >>> 11) + n | 0, r += (n ^ (t | ~e)) + i[4] - 145523070 | 0, r = (r << 6 | r >>> 26) + t | 0, e += (t ^ (r | ~n)) + i[11] - 1120210379 | 0, e = (e << 10 | e >>> 22) + r | 0, n += (r ^ (e | ~t)) + i[2] + 718787259 | 0, n = (n << 15 | n >>> 17) + e | 0, t += (e ^ (n | ~r)) + i[9] - 343485551 | 0, t = (t << 21 | t >>> 11) + n | 0, f[0] = r + f[0] | 0, f[1] = t + f[1] | 0, f[2] = n + f[2] | 0, f[3] = e + f[3] | 0; } function c(f) { var i = [], r; for (r = 0; r < 64; r += 4) i[r >> 2] = f.charCodeAt(r) + (f.charCodeAt(r + 1) << 8) + (f.charCodeAt(r + 2) << 16) + (f.charCodeAt(r + 3) << 24); return i; } function p(f) { var i = [], r; for (r = 0; r < 64; r += 4) i[r >> 2] = f[r] + (f[r + 1] << 8) + (f[r + 2] << 16) + (f[r + 3] << 24); return i; } function g(f) { var i = f.length, r = [1732584193, -271733879, -1732584194, 271733878], t, n, e, b, m, v; for (t = 64; t <= i; t += 64) o(r, c(f.substring(t - 64, t))); for (f = f.substring(t - 64), n = f.length, e = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], t = 0; t < n; t += 1) e[t >> 2] |= f.charCodeAt(t) << (t % 4 << 3); if (e[t >> 2] |= 128 << (t % 4 << 3), t > 55) for (o(r, e), t = 0; t < 16; t += 1) e[t] = 0; return b = i * 8, b = b.toString(16).match(/(.*?)(.{0,8})$/), m = parseInt(b[2], 16), v = parseInt(b[1], 16) || 0, e[14] = m, e[15] = v, o(r, e), r; } function y(f) { var i = f.length, r = [1732584193, -271733879, -1732584194, 271733878], t, n, e, b, m, v; for (t = 64; t <= i; t += 64) o(r, p(f.subarray(t - 64, t))); for (f = t - 64 < i ? f.subarray(t - 64) : new Uint8Array(0), n = f.length, e = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], t = 0; t < n; t += 1) e[t >> 2] |= f[t] << (t % 4 << 3); if (e[t >> 2] |= 128 << (t % 4 << 3), t > 55) for (o(r, e), t = 0; t < 16; t += 1) e[t] = 0; return b = i * 8, b = b.toString(16).match(/(.*?)(.{0,8})$/), m = parseInt(b[2], 16), v = parseInt(b[1], 16) || 0, e[14] = m, e[15] = v, o(r, e), r; } function _(f) { var i = "", r; for (r = 0; r < 4; r += 1) i += l[f >> r * 8 + 4 & 15] + l[f >> r * 8 & 15]; return i; } function d(f) { var i; for (i = 0; i < f.length; i += 1) f[i] = _(f[i]); return f.join(""); } d(g("hello")), typeof ArrayBuffer != "undefined" && !ArrayBuffer.prototype.slice && function() { function f(i, r) { return i = i | 0 || 0, i < 0 ? Math.max(i + r, 0) : Math.min(i, r); } ArrayBuffer.prototype.slice = function(i, r) { var t = this.byteLength, n = f(i, t), e = t, b, m, v, M; return r !== h && (e = f(r, t)), n > e ? new ArrayBuffer(0) : (b = e - n, m = new ArrayBuffer(b), v = new Uint8Array(m), M = new Uint8Array(this, n, b), v.set(M), m); }; }(); function A(f) { return /[\u0080-\uFFFF]/.test(f) && (f = unescape(encodeURIComponent(f))), f; } function U(f, i) { var r = f.length, t = new ArrayBuffer(r), n = new Uint8Array(t), e; for (e = 0; e < r; e += 1) n[e] = f.charCodeAt(e); return i ? n : t; } function F(f) { return String.fromCharCode.apply(null, new Uint8Array(f)); } function j(f, i, r) { var t = new Uint8Array(f.byteLength + i.byteLength); return t.set(new Uint8Array(f)), t.set(new Uint8Array(i), f.byteLength), t; } function C(f) { var i = [], r = f.length, t; for (t = 0; t < r - 1; t += 2) i.push(parseInt(f.substr(t, 2), 16)); return String.fromCharCode.apply(String, i); } function u() { this.reset(); } return u.prototype.append = function(f) { return this.appendBinary(A(f)), this; }, u.prototype.appendBinary = function(f) { this._buff += f, this._length += f.length; var i = this._buff.length, r; for (r = 64; r <= i; r += 64) o(this._hash, c(this._buff.substring(r - 64, r))); return this._buff = this._buff.substring(r - 64), this; }, u.prototype.end = function(f) { var i = this._buff, r = i.length, t, n = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], e; for (t = 0; t < r; t += 1) n[t >> 2] |= i.charCodeAt(t) << (t % 4 << 3); return this._finish(n, r), e = d(this._hash), f && (e = C(e)), this.reset(), e; }, u.prototype.reset = function() { return this._buff = "", this._length = 0, this._hash = [1732584193, -271733879, -1732584194, 271733878], this; }, u.prototype.getState = function() { return { buff: this._buff, length: this._length, hash: this._hash.slice() }; }, u.prototype.setState = function(f) { return this._buff = f.buff, this._length = f.length, this._hash = f.hash, this; }, u.prototype.destroy = function() { delete this._hash, delete this._buff, delete this._length; }, u.prototype._finish = function(f, i) { var r = i, t, n, e; if (f[r >> 2] |= 128 << (r % 4 << 3), r > 55) for (o(this._hash, f), r = 0; r < 16; r += 1) f[r] = 0; t = this._length * 8, t = t.toString(16).match(/(.*?)(.{0,8})$/), n = parseInt(t[2], 16), e = parseInt(t[1], 16) || 0, f[14] = n, f[15] = e, o(this._hash, f); }, u.hash = function(f, i) { return u.hashBinary(A(f), i); }, u.hashBinary = function(f, i) { var r = g(f), t = d(r); return i ? C(t) : t; }, u.ArrayBuffer = function() { this.reset(); }, u.ArrayBuffer.prototype.append = function(f) { var i = j(this._buff.buffer, f), r = i.length, t; for (this._length += f.byteLength, t = 64; t <= r; t += 64) o(this._hash, p(i.subarray(t - 64, t))); return this._buff = t - 64 < r ? new Uint8Array(i.buffer.slice(t - 64)) : new Uint8Array(0), this; }, u.ArrayBuffer.prototype.end = function(f) { var i = this._buff, r = i.length, t = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], n, e; for (n = 0; n < r; n += 1) t[n >> 2] |= i[n] << (n % 4 << 3); return this._finish(t, r), e = d(this._hash), f && (e = C(e)), this.reset(), e; }, u.ArrayBuffer.prototype.reset = function() { return this._buff = new Uint8Array(0), this._length = 0, this._hash = [1732584193, -271733879, -1732584194, 271733878], this; }, u.ArrayBuffer.prototype.getState = function() { var f = u.prototype.getState.call(this); return f.buff = F(f.buff), f; }, u.ArrayBuffer.prototype.setState = function(f) { return f.buff = U(f.buff, !0), u.prototype.setState.call(this, f); }, u.ArrayBuffer.prototype.destroy = u.prototype.destroy, u.ArrayBuffer.prototype._finish = u.prototype._finish, u.ArrayBuffer.hash = function(f, i) { var r = y(new Uint8Array(f)), t = d(r); return i ? C(t) : t; }, u; }); }(S)), S.exports; } var z = E(); const $ = /* @__PURE__ */ T(z); class O { constructor() { B(this, "paused", !1); B(this, "cancelled", !1); B(this, "pauseResolvers", []); B(this, "timers", []); B(this, "abortController", new AbortController()); } // 获取当前的 AbortSignal,用于传递给异步任务 get signal() { return this.abortController.signal; } // 检查任务是否已取消,若已取消则抛出错误 checkCancelled() { if (this.cancelled) throw new Error("Task cancelled"); } // 如果任务被暂停,则等待恢复 waitIfPaused() { return w(this, null, function* () { this.paused && (yield new Promise((s) => { this.pauseResolvers.push(s); })); }); } // 延迟指定时间,支持取消 delay(s) { return w(this, null, function* () { yield new Promise((h) => { const l = setTimeout(h, s); this.timers.push({ timer: l, resolve: h }); }); }); } // 取消所有重试延迟,并立即执行其回调 clearTimers() { this.timers.splice(0).forEach(({ timer: s, resolve: h }) => { clearTimeout(s), h(); }); } // 暂停任务 pause() { this.paused = !0, this.abortController.abort(), this.clearTimers(); } // 恢复任务 resume() { this.paused && (this.paused = !1, this.abortController = new AbortController(), this.clearTimers(), this.pauseResolvers.splice(0).forEach((s) => s())); } // 取消任务 cancel() { this.cancelled = !0, this.abortController.abort(), this.clearTimers(), this.paused && (this.paused = !1, this.pauseResolvers.splice(0).forEach((s) => s())); } // 清理状态,防止内存泄漏 cleanup() { this.paused = !1, this.pauseResolvers.length = 0, this.clearTimers(); } } function W(a, s) { return w(this, null, function* () { let h = 0; for (; ; ) { s.checkCancelled(), yield s.waitIfPaused(), s.checkCancelled(); try { return yield a(); } catch (l) { const o = Math.min(1e3 * h++, 5e3); yield s.delay(o); } } }); } const R = `var M=(w,A,b)=>new Promise((S,m)=>{var U=p=>{try{a(b.next(p))}catch(s){m(s)}},C=p=>{try{a(b.throw(p))}catch(s){m(s)}},a=p=>p.done?S(p.value):Promise.resolve(p.value).then(U,C);a((b=b.apply(w,A)).next())});(function(){"use strict";function w(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var A={exports:{}},b;function S(){return b||(b=1,function(a,p){(function(s){a.exports=s()})(function(s){var c=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function u(i,f){var r=i[0],t=i[1],n=i[2],e=i[3];r+=(t&n|~t&e)+f[0]-680876936|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[1]-389564586|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[2]+606105819|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[3]-1044525330|0,t=(t<<22|t>>>10)+n|0,r+=(t&n|~t&e)+f[4]-176418897|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[5]+1200080426|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[6]-1473231341|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[7]-45705983|0,t=(t<<22|t>>>10)+n|0,r+=(t&n|~t&e)+f[8]+1770035416|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[9]-1958414417|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[10]-42063|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[11]-1990404162|0,t=(t<<22|t>>>10)+n|0,r+=(t&n|~t&e)+f[12]+1804603682|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[13]-40341101|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[14]-1502002290|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[15]+1236535329|0,t=(t<<22|t>>>10)+n|0,r+=(t&e|n&~e)+f[1]-165796510|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[6]-1069501632|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[11]+643717713|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[0]-373897302|0,t=(t<<20|t>>>12)+n|0,r+=(t&e|n&~e)+f[5]-701558691|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[10]+38016083|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[15]-660478335|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[4]-405537848|0,t=(t<<20|t>>>12)+n|0,r+=(t&e|n&~e)+f[9]+568446438|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[14]-1019803690|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[3]-187363961|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[8]+1163531501|0,t=(t<<20|t>>>12)+n|0,r+=(t&e|n&~e)+f[13]-1444681467|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[2]-51403784|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[7]+1735328473|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[12]-1926607734|0,t=(t<<20|t>>>12)+n|0,r+=(t^n^e)+f[5]-378558|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[8]-2022574463|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[11]+1839030562|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[14]-35309556|0,t=(t<<23|t>>>9)+n|0,r+=(t^n^e)+f[1]-1530992060|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[4]+1272893353|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[7]-155497632|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[10]-1094730640|0,t=(t<<23|t>>>9)+n|0,r+=(t^n^e)+f[13]+681279174|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[0]-358537222|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[3]-722521979|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[6]+76029189|0,t=(t<<23|t>>>9)+n|0,r+=(t^n^e)+f[9]-640364487|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[12]-421815835|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[15]+530742520|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[2]-995338651|0,t=(t<<23|t>>>9)+n|0,r+=(n^(t|~e))+f[0]-198630844|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[7]+1126891415|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[14]-1416354905|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[5]-57434055|0,t=(t<<21|t>>>11)+n|0,r+=(n^(t|~e))+f[12]+1700485571|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[3]-1894986606|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[10]-1051523|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[1]-2054922799|0,t=(t<<21|t>>>11)+n|0,r+=(n^(t|~e))+f[8]+1873313359|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[15]-30611744|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[6]-1560198380|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[13]+1309151649|0,t=(t<<21|t>>>11)+n|0,r+=(n^(t|~e))+f[4]-145523070|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[11]-1120210379|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[2]+718787259|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[9]-343485551|0,t=(t<<21|t>>>11)+n|0,i[0]=r+i[0]|0,i[1]=t+i[1]|0,i[2]=n+i[2]|0,i[3]=e+i[3]|0}function d(i){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=i.charCodeAt(r)+(i.charCodeAt(r+1)<<8)+(i.charCodeAt(r+2)<<16)+(i.charCodeAt(r+3)<<24);return f}function y(i){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=i[r]+(i[r+1]<<8)+(i[r+2]<<16)+(i[r+3]<<24);return f}function _(i){var f=i.length,r=[1732584193,-271733879,-1732584194,271733878],t,n,e,o,l,g;for(t=64;t<=f;t+=64)u(r,d(i.substring(t-64,t)));for(i=i.substring(t-64),n=i.length,e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<n;t+=1)e[t>>2]|=i.charCodeAt(t)<<(t%4<<3);if(e[t>>2]|=128<<(t%4<<3),t>55)for(u(r,e),t=0;t<16;t+=1)e[t]=0;return o=f*8,o=o.toString(16).match(/(.*?)(.{0,8})$/),l=parseInt(o[2],16),g=parseInt(o[1],16)||0,e[14]=l,e[15]=g,u(r,e),r}function L(i){var f=i.length,r=[1732584193,-271733879,-1732584194,271733878],t,n,e,o,l,g;for(t=64;t<=f;t+=64)u(r,y(i.subarray(t-64,t)));for(i=t-64<f?i.subarray(t-64):new Uint8Array(0),n=i.length,e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<n;t+=1)e[t>>2]|=i[t]<<(t%4<<3);if(e[t>>2]|=128<<(t%4<<3),t>55)for(u(r,e),t=0;t<16;t+=1)e[t]=0;return o=f*8,o=o.toString(16).match(/(.*?)(.{0,8})$/),l=parseInt(o[2],16),g=parseInt(o[1],16)||0,e[14]=l,e[15]=g,u(r,e),r}function j(i){var f="",r;for(r=0;r<4;r+=1)f+=c[i>>r*8+4&15]+c[i>>r*8&15];return f}function B(i){var f;for(f=0;f<i.length;f+=1)i[f]=j(i[f]);return i.join("")}B(_("hello")),typeof ArrayBuffer!="undefined"&&!ArrayBuffer.prototype.slice&&function(){function i(f,r){return f=f|0||0,f<0?Math.max(f+r,0):Math.min(f,r)}ArrayBuffer.prototype.slice=function(f,r){var t=this.byteLength,n=i(f,t),e=t,o,l,g,F;return r!==s&&(e=i(r,t)),n>e?new ArrayBuffer(0):(o=e-n,l=new ArrayBuffer(o),g=new Uint8Array(l),F=new Uint8Array(this,n,o),g.set(F),l)}}();function I(i){return/[\\u0080-\\uFFFF]/.test(i)&&(i=unescape(encodeURIComponent(i))),i}function D(i,f){var r=i.length,t=new ArrayBuffer(r),n=new Uint8Array(t),e;for(e=0;e<r;e+=1)n[e]=i.charCodeAt(e);return f?n:t}function $(i){return String.fromCharCode.apply(null,new Uint8Array(i))}function q(i,f,r){var t=new Uint8Array(i.byteLength+f.byteLength);return t.set(new Uint8Array(i)),t.set(new Uint8Array(f),i.byteLength),t}function v(i){var f=[],r=i.length,t;for(t=0;t<r-1;t+=2)f.push(parseInt(i.substr(t,2),16));return String.fromCharCode.apply(String,f)}function h(){this.reset()}return h.prototype.append=function(i){return this.appendBinary(I(i)),this},h.prototype.appendBinary=function(i){this._buff+=i,this._length+=i.length;var f=this._buff.length,r;for(r=64;r<=f;r+=64)u(this._hash,d(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},h.prototype.end=function(i){var f=this._buff,r=f.length,t,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e;for(t=0;t<r;t+=1)n[t>>2]|=f.charCodeAt(t)<<(t%4<<3);return this._finish(n,r),e=B(this._hash),i&&(e=v(e)),this.reset(),e},h.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},h.prototype.setState=function(i){return this._buff=i.buff,this._length=i.length,this._hash=i.hash,this},h.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},h.prototype._finish=function(i,f){var r=f,t,n,e;if(i[r>>2]|=128<<(r%4<<3),r>55)for(u(this._hash,i),r=0;r<16;r+=1)i[r]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),n=parseInt(t[2],16),e=parseInt(t[1],16)||0,i[14]=n,i[15]=e,u(this._hash,i)},h.hash=function(i,f){return h.hashBinary(I(i),f)},h.hashBinary=function(i,f){var r=_(i),t=B(r);return f?v(t):t},h.ArrayBuffer=function(){this.reset()},h.ArrayBuffer.prototype.append=function(i){var f=q(this._buff.buffer,i),r=f.length,t;for(this._length+=i.byteLength,t=64;t<=r;t+=64)u(this._hash,y(f.subarray(t-64,t)));return this._buff=t-64<r?new Uint8Array(f.buffer.slice(t-64)):new Uint8Array(0),this},h.ArrayBuffer.prototype.end=function(i){var f=this._buff,r=f.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n,e;for(n=0;n<r;n+=1)t[n>>2]|=f[n]<<(n%4<<3);return this._finish(t,r),e=B(this._hash),i&&(e=v(e)),this.reset(),e},h.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.ArrayBuffer.prototype.getState=function(){var i=h.prototype.getState.call(this);return i.buff=$(i.buff),i},h.ArrayBuffer.prototype.setState=function(i){return i.buff=D(i.buff,!0),h.prototype.setState.call(this,i)},h.ArrayBuffer.prototype.destroy=h.prototype.destroy,h.ArrayBuffer.prototype._finish=h.prototype._finish,h.ArrayBuffer.hash=function(i,f){var r=L(new Uint8Array(i)),t=B(r);return f?v(t):t},h})}(A)),A.exports}var m=S(),U=w(m);function C(a,p,s){return M(this,null,function*(){for(;;)try{const c=p*s,u=Math.min(c+s,a.size),d=a.slice(c,u),y=yield d.arrayBuffer(),_=new U.ArrayBuffer;return _.append(y),{index:p,start:c,end:u,hash:_.end(),blob:d}}catch(c){}})}onmessage=p=>M(null,[p],function*({data:a}){const{file:s,chunkSize:c,start:u,end:d}=a;for(let y=u;y<d;y++){const _=yield C(s,y,c);postMessage({type:"chunk",chunk:_,chunkIndex:y-u})}})})(); `, L = typeof self != "undefined" && self.Blob && new Blob([R], { type: "text/javascript;charset=utf-8" }); function D(a) { let s; try { if (s = L && (self.URL || self.webkitURL).createObjectURL(L), !s) throw ""; const h = new Worker(s, { name: a == null ? void 0 : a.name }); return h.addEventListener("error", () => { (self.URL || self.webkitURL).revokeObjectURL(s); }), h; } catch (h) { return new Worker( "data:text/javascript;charset=utf-8," + encodeURIComponent(R), { name: a == null ? void 0 : a.name } ); } finally { s && (self.URL || self.webkitURL).revokeObjectURL(s); } } function q(a, s, h, l, o) { const c = new D(); return c.onmessage = ({ data: p }) => { const { chunk: g, chunkIndex: y } = p, _ = h + y; o.get(_).resolve(g), o.delete(_); }, c.postMessage({ file: a, chunkSize: s, start: h, end: l }), c; } function G(a, s = {}) { if (!(a != null && a.size)) throw new Error("Invalid or empty file"); const { chunkSize: h = Math.min(1024 * 1024, a.size) } = s, l = Math.min(navigator.hardwareConcurrency || 4, Math.ceil(a.size / h)), o = Math.ceil(a.size / h), c = /* @__PURE__ */ new Map(), p = Array.from({ length: o }, (_, d) => new Promise((A, U) => c.set(d, { resolve: A, reject: U }))), g = Math.ceil(o / l), y = Array.from({ length: Math.min(l, o) }, (_, d) => q(a, h, d * g, Math.min((d + 1) * g, o), c)); return Promise.allSettled(p).finally(() => y.forEach((_) => _.terminate())), p; } function J(a, s, h = {}) { const { concurrency: l = 6, onProgress: o } = h, c = new O(), p = /* @__PURE__ */ new Set(); let g = 0; const y = (d) => w(null, null, function* () { const A = yield d; yield W(() => w(null, null, function* () { yield s(A, c.signal), g++, o == null || o(g, a.length); }), c); }), _ = w(null, null, function* () { try { for (const d of a) { c.checkCancelled(); const A = y(d).finally(() => p.delete(A)); p.add(A), p.size >= l && (yield Promise.race(p), c.checkCancelled()); } yield Promise.all(p); } finally { c.cleanup(), p.clear(); } }); return { pause: () => c.pause(), resume: () => c.resume(), cancel: () => c.cancel(), promise: _ }; } function K(a) { return w(this, null, function* () { const s = yield Promise.all(a), h = new $(); return s.forEach((l) => h.append(l.hash)), h.end(); }); } function N(a) { return w(this, null, function* () { return Promise.all(a); }); } export { K as calculateFileHash, G as chunkFile, N as collectChunks, J as processChunks };