fluxforge
Version:
企业级文件分块和并发处理库,具备 Web Workers、自动重试、实时进度跟踪和 MD5 完整性验证功能,专为现代浏览器设计。非常适合大文件上传、流式处理和数据处理管道场景。
3 lines (2 loc) • 21.2 kB
JavaScript
(function(l,p){typeof exports=="object"&&typeof module!="undefined"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(l=typeof globalThis!="undefined"?globalThis:l||self,p(l.FluxForge={}))})(this,function(l){"use strict";var K=Object.defineProperty;var N=(l,p,_)=>p in l?K(l,p,{enumerable:!0,configurable:!0,writable:!0,value:_}):l[p]=_;var I=(l,p,_)=>N(l,typeof p!="symbol"?p+"":p,_);var C=(l,p,_)=>new Promise((F,R)=>{var P=w=>{try{L(_.next(w))}catch(M){R(M)}},T=w=>{try{L(_.throw(w))}catch(M){R(M)}},L=w=>w.done?F(w.value):Promise.resolve(w.value).then(P,T);L((_=_.apply(l,p)).next())});function p(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var _={exports:{}},F;function R(){return F||(F=1,function(a,s){(function(o){a.exports=o()})(function(o){var b=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function u(f,i){var e=f[0],t=f[1],n=f[2],r=f[3];e+=(t&n|~t&r)+i[0]-680876936|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&n)+i[1]-389564586|0,r=(r<<12|r>>>20)+e|0,n+=(r&e|~r&t)+i[2]+606105819|0,n=(n<<17|n>>>15)+r|0,t+=(n&r|~n&e)+i[3]-1044525330|0,t=(t<<22|t>>>10)+n|0,e+=(t&n|~t&r)+i[4]-176418897|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&n)+i[5]+1200080426|0,r=(r<<12|r>>>20)+e|0,n+=(r&e|~r&t)+i[6]-1473231341|0,n=(n<<17|n>>>15)+r|0,t+=(n&r|~n&e)+i[7]-45705983|0,t=(t<<22|t>>>10)+n|0,e+=(t&n|~t&r)+i[8]+1770035416|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&n)+i[9]-1958414417|0,r=(r<<12|r>>>20)+e|0,n+=(r&e|~r&t)+i[10]-42063|0,n=(n<<17|n>>>15)+r|0,t+=(n&r|~n&e)+i[11]-1990404162|0,t=(t<<22|t>>>10)+n|0,e+=(t&n|~t&r)+i[12]+1804603682|0,e=(e<<7|e>>>25)+t|0,r+=(e&t|~e&n)+i[13]-40341101|0,r=(r<<12|r>>>20)+e|0,n+=(r&e|~r&t)+i[14]-1502002290|0,n=(n<<17|n>>>15)+r|0,t+=(n&r|~n&e)+i[15]+1236535329|0,t=(t<<22|t>>>10)+n|0,e+=(t&r|n&~r)+i[1]-165796510|0,e=(e<<5|e>>>27)+t|0,r+=(e&n|t&~n)+i[6]-1069501632|0,r=(r<<9|r>>>23)+e|0,n+=(r&t|e&~t)+i[11]+643717713|0,n=(n<<14|n>>>18)+r|0,t+=(n&e|r&~e)+i[0]-373897302|0,t=(t<<20|t>>>12)+n|0,e+=(t&r|n&~r)+i[5]-701558691|0,e=(e<<5|e>>>27)+t|0,r+=(e&n|t&~n)+i[10]+38016083|0,r=(r<<9|r>>>23)+e|0,n+=(r&t|e&~t)+i[15]-660478335|0,n=(n<<14|n>>>18)+r|0,t+=(n&e|r&~e)+i[4]-405537848|0,t=(t<<20|t>>>12)+n|0,e+=(t&r|n&~r)+i[9]+568446438|0,e=(e<<5|e>>>27)+t|0,r+=(e&n|t&~n)+i[14]-1019803690|0,r=(r<<9|r>>>23)+e|0,n+=(r&t|e&~t)+i[3]-187363961|0,n=(n<<14|n>>>18)+r|0,t+=(n&e|r&~e)+i[8]+1163531501|0,t=(t<<20|t>>>12)+n|0,e+=(t&r|n&~r)+i[13]-1444681467|0,e=(e<<5|e>>>27)+t|0,r+=(e&n|t&~n)+i[2]-51403784|0,r=(r<<9|r>>>23)+e|0,n+=(r&t|e&~t)+i[7]+1735328473|0,n=(n<<14|n>>>18)+r|0,t+=(n&e|r&~e)+i[12]-1926607734|0,t=(t<<20|t>>>12)+n|0,e+=(t^n^r)+i[5]-378558|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^n)+i[8]-2022574463|0,r=(r<<11|r>>>21)+e|0,n+=(r^e^t)+i[11]+1839030562|0,n=(n<<16|n>>>16)+r|0,t+=(n^r^e)+i[14]-35309556|0,t=(t<<23|t>>>9)+n|0,e+=(t^n^r)+i[1]-1530992060|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^n)+i[4]+1272893353|0,r=(r<<11|r>>>21)+e|0,n+=(r^e^t)+i[7]-155497632|0,n=(n<<16|n>>>16)+r|0,t+=(n^r^e)+i[10]-1094730640|0,t=(t<<23|t>>>9)+n|0,e+=(t^n^r)+i[13]+681279174|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^n)+i[0]-358537222|0,r=(r<<11|r>>>21)+e|0,n+=(r^e^t)+i[3]-722521979|0,n=(n<<16|n>>>16)+r|0,t+=(n^r^e)+i[6]+76029189|0,t=(t<<23|t>>>9)+n|0,e+=(t^n^r)+i[9]-640364487|0,e=(e<<4|e>>>28)+t|0,r+=(e^t^n)+i[12]-421815835|0,r=(r<<11|r>>>21)+e|0,n+=(r^e^t)+i[15]+530742520|0,n=(n<<16|n>>>16)+r|0,t+=(n^r^e)+i[2]-995338651|0,t=(t<<23|t>>>9)+n|0,e+=(n^(t|~r))+i[0]-198630844|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~n))+i[7]+1126891415|0,r=(r<<10|r>>>22)+e|0,n+=(e^(r|~t))+i[14]-1416354905|0,n=(n<<15|n>>>17)+r|0,t+=(r^(n|~e))+i[5]-57434055|0,t=(t<<21|t>>>11)+n|0,e+=(n^(t|~r))+i[12]+1700485571|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~n))+i[3]-1894986606|0,r=(r<<10|r>>>22)+e|0,n+=(e^(r|~t))+i[10]-1051523|0,n=(n<<15|n>>>17)+r|0,t+=(r^(n|~e))+i[1]-2054922799|0,t=(t<<21|t>>>11)+n|0,e+=(n^(t|~r))+i[8]+1873313359|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~n))+i[15]-30611744|0,r=(r<<10|r>>>22)+e|0,n+=(e^(r|~t))+i[6]-1560198380|0,n=(n<<15|n>>>17)+r|0,t+=(r^(n|~e))+i[13]+1309151649|0,t=(t<<21|t>>>11)+n|0,e+=(n^(t|~r))+i[4]-145523070|0,e=(e<<6|e>>>26)+t|0,r+=(t^(e|~n))+i[11]-1120210379|0,r=(r<<10|r>>>22)+e|0,n+=(e^(r|~t))+i[2]+718787259|0,n=(n<<15|n>>>17)+r|0,t+=(r^(n|~e))+i[9]-343485551|0,t=(t<<21|t>>>11)+n|0,f[0]=e+f[0]|0,f[1]=t+f[1]|0,f[2]=n+f[2]|0,f[3]=r+f[3]|0}function c(f){var i=[],e;for(e=0;e<64;e+=4)i[e>>2]=f.charCodeAt(e)+(f.charCodeAt(e+1)<<8)+(f.charCodeAt(e+2)<<16)+(f.charCodeAt(e+3)<<24);return i}function g(f){var i=[],e;for(e=0;e<64;e+=4)i[e>>2]=f[e]+(f[e+1]<<8)+(f[e+2]<<16)+(f[e+3]<<24);return i}function m(f){var i=f.length,e=[1732584193,-271733879,-1732584194,271733878],t,n,r,d,B,U;for(t=64;t<=i;t+=64)u(e,c(f.substring(t-64,t)));for(f=f.substring(t-64),n=f.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<n;t+=1)r[t>>2]|=f.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(u(e,r),t=0;t<16;t+=1)r[t]=0;return d=i*8,d=d.toString(16).match(/(.*?)(.{0,8})$/),B=parseInt(d[2],16),U=parseInt(d[1],16)||0,r[14]=B,r[15]=U,u(e,r),e}function S(f){var i=f.length,e=[1732584193,-271733879,-1732584194,271733878],t,n,r,d,B,U;for(t=64;t<=i;t+=64)u(e,g(f.subarray(t-64,t)));for(f=t-64<i?f.subarray(t-64):new Uint8Array(0),n=f.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<n;t+=1)r[t>>2]|=f[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(u(e,r),t=0;t<16;t+=1)r[t]=0;return d=i*8,d=d.toString(16).match(/(.*?)(.{0,8})$/),B=parseInt(d[2],16),U=parseInt(d[1],16)||0,r[14]=B,r[15]=U,u(e,r),e}function A(f){var i="",e;for(e=0;e<4;e+=1)i+=b[f>>e*8+4&15]+b[f>>e*8&15];return i}function y(f){var i;for(i=0;i<f.length;i+=1)f[i]=A(f[i]);return f.join("")}y(m("hello")),typeof ArrayBuffer!="undefined"&&!ArrayBuffer.prototype.slice&&function(){function f(i,e){return i=i|0||0,i<0?Math.max(i+e,0):Math.min(i,e)}ArrayBuffer.prototype.slice=function(i,e){var t=this.byteLength,n=f(i,t),r=t,d,B,U,z;return e!==o&&(r=f(e,t)),n>r?new ArrayBuffer(0):(d=r-n,B=new ArrayBuffer(d),U=new Uint8Array(B),z=new Uint8Array(this,n,d),U.set(z),B)}}();function v(f){return/[\u0080-\uFFFF]/.test(f)&&(f=unescape(encodeURIComponent(f))),f}function x(f,i){var e=f.length,t=new ArrayBuffer(e),n=new Uint8Array(t),r;for(r=0;r<e;r+=1)n[r]=f.charCodeAt(r);return i?n:t}function G(f){return String.fromCharCode.apply(null,new Uint8Array(f))}function J(f,i,e){var t=new Uint8Array(f.byteLength+i.byteLength);return t.set(new Uint8Array(f)),t.set(new Uint8Array(i),f.byteLength),t}function j(f){var i=[],e=f.length,t;for(t=0;t<e-1;t+=2)i.push(parseInt(f.substr(t,2),16));return String.fromCharCode.apply(String,i)}function h(){this.reset()}return h.prototype.append=function(f){return this.appendBinary(v(f)),this},h.prototype.appendBinary=function(f){this._buff+=f,this._length+=f.length;var i=this._buff.length,e;for(e=64;e<=i;e+=64)u(this._hash,c(this._buff.substring(e-64,e)));return this._buff=this._buff.substring(e-64),this},h.prototype.end=function(f){var i=this._buff,e=i.length,t,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r;for(t=0;t<e;t+=1)n[t>>2]|=i.charCodeAt(t)<<(t%4<<3);return this._finish(n,e),r=y(this._hash),f&&(r=j(r)),this.reset(),r},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(f){return this._buff=f.buff,this._length=f.length,this._hash=f.hash,this},h.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},h.prototype._finish=function(f,i){var e=i,t,n,r;if(f[e>>2]|=128<<(e%4<<3),e>55)for(u(this._hash,f),e=0;e<16;e+=1)f[e]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),n=parseInt(t[2],16),r=parseInt(t[1],16)||0,f[14]=n,f[15]=r,u(this._hash,f)},h.hash=function(f,i){return h.hashBinary(v(f),i)},h.hashBinary=function(f,i){var e=m(f),t=y(e);return i?j(t):t},h.ArrayBuffer=function(){this.reset()},h.ArrayBuffer.prototype.append=function(f){var i=J(this._buff.buffer,f),e=i.length,t;for(this._length+=f.byteLength,t=64;t<=e;t+=64)u(this._hash,g(i.subarray(t-64,t)));return this._buff=t-64<e?new Uint8Array(i.buffer.slice(t-64)):new Uint8Array(0),this},h.ArrayBuffer.prototype.end=function(f){var i=this._buff,e=i.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n,r;for(n=0;n<e;n+=1)t[n>>2]|=i[n]<<(n%4<<3);return this._finish(t,e),r=y(this._hash),f&&(r=j(r)),this.reset(),r},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 f=h.prototype.getState.call(this);return f.buff=G(f.buff),f},h.ArrayBuffer.prototype.setState=function(f){return f.buff=x(f.buff,!0),h.prototype.setState.call(this,f)},h.ArrayBuffer.prototype.destroy=h.prototype.destroy,h.ArrayBuffer.prototype._finish=h.prototype._finish,h.ArrayBuffer.hash=function(f,i){var e=S(new Uint8Array(f)),t=y(e);return i?j(t):t},h})}(_)),_.exports}var P=R();const T=p(P);class L{constructor(){I(this,"paused",!1);I(this,"cancelled",!1);I(this,"pauseResolvers",[]);I(this,"timers",[]);I(this,"abortController",new AbortController)}get signal(){return this.abortController.signal}checkCancelled(){if(this.cancelled)throw new Error("Task cancelled")}waitIfPaused(){return C(this,null,function*(){this.paused&&(yield new Promise(s=>{this.pauseResolvers.push(s)}))})}delay(s){return C(this,null,function*(){yield new Promise(o=>{const b=setTimeout(o,s);this.timers.push({timer:b,resolve:o})})})}clearTimers(){this.timers.splice(0).forEach(({timer:s,resolve:o})=>{clearTimeout(s),o()})}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 C(this,null,function*(){let o=0;for(;;){s.checkCancelled(),yield s.waitIfPaused(),s.checkCancelled();try{return yield a()}catch(b){const u=Math.min(1e3*o++,5e3);yield s.delay(u)}}})}const M=`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})}})})();
`,E=typeof self!="undefined"&&self.Blob&&new Blob([M],{type:"text/javascript;charset=utf-8"});function O(a){let s;try{if(s=E&&(self.URL||self.webkitURL).createObjectURL(E),!s)throw"";const o=new Worker(s,{name:a==null?void 0:a.name});return o.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(s)}),o}catch(o){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(M),{name:a==null?void 0:a.name})}finally{s&&(self.URL||self.webkitURL).revokeObjectURL(s)}}function $(a,s,o,b,u){const c=new O;return c.onmessage=({data:g})=>{const{chunk:m,chunkIndex:S}=g,A=o+S;u.get(A).resolve(m),u.delete(A)},c.postMessage({file:a,chunkSize:s,start:o,end:b}),c}function W(a,s={}){if(!(a!=null&&a.size))throw new Error("Invalid or empty file");const{chunkSize:o=Math.min(1024*1024,a.size)}=s,b=Math.min(navigator.hardwareConcurrency||4,Math.ceil(a.size/o)),u=Math.ceil(a.size/o),c=new Map,g=Array.from({length:u},(A,y)=>new Promise((v,x)=>c.set(y,{resolve:v,reject:x}))),m=Math.ceil(u/b),S=Array.from({length:Math.min(b,u)},(A,y)=>$(a,o,y*m,Math.min((y+1)*m,u),c));return Promise.allSettled(g).finally(()=>S.forEach(A=>A.terminate())),g}function D(a,s,o={}){const{concurrency:b=6,onProgress:u}=o,c=new L,g=new Set;let m=0;const S=y=>C(null,null,function*(){const v=yield y;yield w(()=>C(null,null,function*(){yield s(v,c.signal),m++,u==null||u(m,a.length)}),c)}),A=C(null,null,function*(){try{for(const y of a){c.checkCancelled();const v=S(y).finally(()=>g.delete(v));g.add(v),g.size>=b&&(yield Promise.race(g),c.checkCancelled())}yield Promise.all(g)}finally{c.cleanup(),g.clear()}});return{pause:()=>c.pause(),resume:()=>c.resume(),cancel:()=>c.cancel(),promise:A}}function q(a){return C(this,null,function*(){const s=yield Promise.all(a),o=new T;return s.forEach(b=>o.append(b.hash)),o.end()})}function H(a){return C(this,null,function*(){return Promise.all(a)})}l.calculateFileHash=q,l.chunkFile=W,l.collectChunks=H,l.processChunks=D,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});