import{J as pt,K as gt}from"./index.144928e4.js";import{a as yt,l as W}from"./elementPlus.8e650391.js";import"./vue.86c1cb21.js";var ot=globalThis&&globalThis.__extends||function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var e in n)n.hasOwnProperty(e)&&(o[e]=n[e])},i(r,t)};return function(r,t){i(r,t);function o(){this.constructor=r}r.prototype=t===null?Object.create(t):(o.prototype=t.prototype,new o)}}(),m;(function(i){i.InvalidFile="InvalidFile",i.InvalidToken="InvalidToken",i.InvalidMetadata="InvalidMetadata",i.InvalidChunkSize="InvalidChunkSize",i.InvalidCustomVars="InvalidCustomVars",i.NotAvailableUploadHost="NotAvailableUploadHost",i.ReadCacheFailed="ReadCacheFailed",i.InvalidCacheData="InvalidCacheData",i.WriteCacheFailed="WriteCacheFailed",i.RemoveCacheFailed="RemoveCacheFailed",i.GetCanvasContextFailed="GetCanvasContextFailed",i.UnsupportedFileType="UnsupportedFileType",i.FileReaderReadFailed="FileReaderReadFailed",i.NotAvailableXMLHttpRequest="NotAvailableXMLHttpRequest",i.InvalidProgressEventTarget="InvalidProgressEventTarget",i.RequestError="RequestError"})(m||(m={}));var w=function(){function i(r,t){this.name=r,this.message=t,this.stack=new Error().stack}return i}(),H=function(i){ot(r,i);function r(t,o,n,e){var l=i.call(this,m.RequestError,n)||this;return l.code=t,l.reqId=o,l.isRequestError=!0,l.data=e,l}return r}(w),vt=function(i){ot(r,i);function r(t,o){return o===void 0&&(o=""),i.call(this,0,o,t)||this}return r}(H),bt=function(){function i(r,t){this.runTask=r,this.limit=t,this.aborted=!1,this.queue=[],this.processing=[]}return i.prototype.enqueue=function(r){var t=this;return new Promise(function(o,n){t.queue.push({task:r,resolve:o,reject:n}),t.check()})},i.prototype.run=function(r){var t=this;this.queue=this.queue.filter(function(o){return o!==r}),this.processing.push(r),this.runTask(r.task).then(function(){t.processing=t.processing.filter(function(o){return o!==r}),r.resolve(),t.check()},function(o){return r.reject(o)})},i.prototype.check=function(){var r=this;if(!this.aborted){var t=this.processing.length,o=this.limit-t;this.queue.slice(0,o).forEach(function(n){r.run(n)})}},i.prototype.abort=function(){this.queue=[],this.aborted=!0},i}(),mt=globalThis&&globalThis.__extends||function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var e in n)n.hasOwnProperty(e)&&(o[e]=n[e])},i(r,t)};return function(r,t){i(r,t);function o(){this.constructor=r}r.prototype=t===null?Object.create(t):(o.prototype=t.prototype,new o)}}(),E=globalThis&&globalThis.__assign||function(){return E=Object.assign||function(i){for(var r,t=1,o=arguments.length;t"u")return"";var r=i+"",t="",o,n,e=0;o=n=0,e=r.length;for(var l=0;l127&&d<2048)y=String.fromCharCode(d>>6|192,d&63|128);else if((d&63488^55296)>0)y=String.fromCharCode(d>>12|224,d>>6&63|128,d&63|128);else{if((d&64512^55296)>0)throw new RangeError("Unmatched trail surrogate at "+l);var a=r.charCodeAt(++l);if((a&64512^56320)>0)throw new RangeError("Unmatched lead surrogate at "+(l-1));d=((d&1023)<<10)+(a&1023)+65536,y=String.fromCharCode(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}y!==null&&(n>o&&(t+=r.slice(o,n)),t+=y,o=n=l+1)}return n>o&&(t+=r.slice(o,e)),t}function Ct(i){var r=[],t=0,o=0,n=0;for(i+="";t>10&1023)),r.push(String.fromCharCode(56320|o&1023))):r.push(String.fromCharCode(o)),t+=n}return r.join("")}function St(i){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t,o,n,e,l,d,y,a,h=0,v=0,_="",T=[];if(!i)return i;i=Tt(i+"");do t=i.charCodeAt(h++),o=i.charCodeAt(h++),n=i.charCodeAt(h++),a=t<<16|o<<8|n,e=a>>18&63,l=a>>12&63,d=a>>6&63,y=a&63,T[v++]=r.charAt(e)+r.charAt(l)+r.charAt(d)+r.charAt(y);while(h>16&255,o=a>>8&255,n=a&255,d===64?T[v++]=String.fromCharCode(t):y===64?T[v++]=String.fromCharCode(t,o):T[v++]=String.fromCharCode(t,o,n);while(h>>25)+s|0,c+=(u&s|~u&f)+p[1]-389564586|0,c=(c<<12|c>>>20)+u|0,f+=(c&u|~c&s)+p[2]+606105819|0,f=(f<<17|f>>>15)+c|0,s+=(f&c|~f&u)+p[3]-1044525330|0,s=(s<<22|s>>>10)+f|0,u+=(s&f|~s&c)+p[4]-176418897|0,u=(u<<7|u>>>25)+s|0,c+=(u&s|~u&f)+p[5]+1200080426|0,c=(c<<12|c>>>20)+u|0,f+=(c&u|~c&s)+p[6]-1473231341|0,f=(f<<17|f>>>15)+c|0,s+=(f&c|~f&u)+p[7]-45705983|0,s=(s<<22|s>>>10)+f|0,u+=(s&f|~s&c)+p[8]+1770035416|0,u=(u<<7|u>>>25)+s|0,c+=(u&s|~u&f)+p[9]-1958414417|0,c=(c<<12|c>>>20)+u|0,f+=(c&u|~c&s)+p[10]-42063|0,f=(f<<17|f>>>15)+c|0,s+=(f&c|~f&u)+p[11]-1990404162|0,s=(s<<22|s>>>10)+f|0,u+=(s&f|~s&c)+p[12]+1804603682|0,u=(u<<7|u>>>25)+s|0,c+=(u&s|~u&f)+p[13]-40341101|0,c=(c<<12|c>>>20)+u|0,f+=(c&u|~c&s)+p[14]-1502002290|0,f=(f<<17|f>>>15)+c|0,s+=(f&c|~f&u)+p[15]+1236535329|0,s=(s<<22|s>>>10)+f|0,u+=(s&c|f&~c)+p[1]-165796510|0,u=(u<<5|u>>>27)+s|0,c+=(u&f|s&~f)+p[6]-1069501632|0,c=(c<<9|c>>>23)+u|0,f+=(c&s|u&~s)+p[11]+643717713|0,f=(f<<14|f>>>18)+c|0,s+=(f&u|c&~u)+p[0]-373897302|0,s=(s<<20|s>>>12)+f|0,u+=(s&c|f&~c)+p[5]-701558691|0,u=(u<<5|u>>>27)+s|0,c+=(u&f|s&~f)+p[10]+38016083|0,c=(c<<9|c>>>23)+u|0,f+=(c&s|u&~s)+p[15]-660478335|0,f=(f<<14|f>>>18)+c|0,s+=(f&u|c&~u)+p[4]-405537848|0,s=(s<<20|s>>>12)+f|0,u+=(s&c|f&~c)+p[9]+568446438|0,u=(u<<5|u>>>27)+s|0,c+=(u&f|s&~f)+p[14]-1019803690|0,c=(c<<9|c>>>23)+u|0,f+=(c&s|u&~s)+p[3]-187363961|0,f=(f<<14|f>>>18)+c|0,s+=(f&u|c&~u)+p[8]+1163531501|0,s=(s<<20|s>>>12)+f|0,u+=(s&c|f&~c)+p[13]-1444681467|0,u=(u<<5|u>>>27)+s|0,c+=(u&f|s&~f)+p[2]-51403784|0,c=(c<<9|c>>>23)+u|0,f+=(c&s|u&~s)+p[7]+1735328473|0,f=(f<<14|f>>>18)+c|0,s+=(f&u|c&~u)+p[12]-1926607734|0,s=(s<<20|s>>>12)+f|0,u+=(s^f^c)+p[5]-378558|0,u=(u<<4|u>>>28)+s|0,c+=(u^s^f)+p[8]-2022574463|0,c=(c<<11|c>>>21)+u|0,f+=(c^u^s)+p[11]+1839030562|0,f=(f<<16|f>>>16)+c|0,s+=(f^c^u)+p[14]-35309556|0,s=(s<<23|s>>>9)+f|0,u+=(s^f^c)+p[1]-1530992060|0,u=(u<<4|u>>>28)+s|0,c+=(u^s^f)+p[4]+1272893353|0,c=(c<<11|c>>>21)+u|0,f+=(c^u^s)+p[7]-155497632|0,f=(f<<16|f>>>16)+c|0,s+=(f^c^u)+p[10]-1094730640|0,s=(s<<23|s>>>9)+f|0,u+=(s^f^c)+p[13]+681279174|0,u=(u<<4|u>>>28)+s|0,c+=(u^s^f)+p[0]-358537222|0,c=(c<<11|c>>>21)+u|0,f+=(c^u^s)+p[3]-722521979|0,f=(f<<16|f>>>16)+c|0,s+=(f^c^u)+p[6]+76029189|0,s=(s<<23|s>>>9)+f|0,u+=(s^f^c)+p[9]-640364487|0,u=(u<<4|u>>>28)+s|0,c+=(u^s^f)+p[12]-421815835|0,c=(c<<11|c>>>21)+u|0,f+=(c^u^s)+p[15]+530742520|0,f=(f<<16|f>>>16)+c|0,s+=(f^c^u)+p[2]-995338651|0,s=(s<<23|s>>>9)+f|0,u+=(f^(s|~c))+p[0]-198630844|0,u=(u<<6|u>>>26)+s|0,c+=(s^(u|~f))+p[7]+1126891415|0,c=(c<<10|c>>>22)+u|0,f+=(u^(c|~s))+p[14]-1416354905|0,f=(f<<15|f>>>17)+c|0,s+=(c^(f|~u))+p[5]-57434055|0,s=(s<<21|s>>>11)+f|0,u+=(f^(s|~c))+p[12]+1700485571|0,u=(u<<6|u>>>26)+s|0,c+=(s^(u|~f))+p[3]-1894986606|0,c=(c<<10|c>>>22)+u|0,f+=(u^(c|~s))+p[10]-1051523|0,f=(f<<15|f>>>17)+c|0,s+=(c^(f|~u))+p[1]-2054922799|0,s=(s<<21|s>>>11)+f|0,u+=(f^(s|~c))+p[8]+1873313359|0,u=(u<<6|u>>>26)+s|0,c+=(s^(u|~f))+p[15]-30611744|0,c=(c<<10|c>>>22)+u|0,f+=(u^(c|~s))+p[6]-1560198380|0,f=(f<<15|f>>>17)+c|0,s+=(c^(f|~u))+p[13]+1309151649|0,s=(s<<21|s>>>11)+f|0,u+=(f^(s|~c))+p[4]-145523070|0,u=(u<<6|u>>>26)+s|0,c+=(s^(u|~f))+p[11]-1120210379|0,c=(c<<10|c>>>22)+u|0,f+=(u^(c|~s))+p[2]+718787259|0,f=(f<<15|f>>>17)+c|0,s+=(c^(f|~u))+p[9]-343485551|0,s=(s<<21|s>>>11)+f|0,g[0]=u+g[0]|0,g[1]=s+g[1]|0,g[2]=f+g[2]|0,g[3]=c+g[3]|0}function e(g){var p=[],u;for(u=0;u<64;u+=4)p[u>>2]=g.charCodeAt(u)+(g.charCodeAt(u+1)<<8)+(g.charCodeAt(u+2)<<16)+(g.charCodeAt(u+3)<<24);return p}function l(g){var p=[],u;for(u=0;u<64;u+=4)p[u>>2]=g[u]+(g[u+1]<<8)+(g[u+2]<<16)+(g[u+3]<<24);return p}function d(g){var p=g.length,u=[1732584193,-271733879,-1732584194,271733878],s,f,c,x,C,S;for(s=64;s<=p;s+=64)n(u,e(g.substring(s-64,s)));for(g=g.substring(s-64),f=g.length,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s=0;s>2]|=g.charCodeAt(s)<<(s%4<<3);if(c[s>>2]|=128<<(s%4<<3),s>55)for(n(u,c),s=0;s<16;s+=1)c[s]=0;return x=p*8,x=x.toString(16).match(/(.*?)(.{0,8})$/),C=parseInt(x[2],16),S=parseInt(x[1],16)||0,c[14]=C,c[15]=S,n(u,c),u}function y(g){var p=g.length,u=[1732584193,-271733879,-1732584194,271733878],s,f,c,x,C,S;for(s=64;s<=p;s+=64)n(u,l(g.subarray(s-64,s)));for(g=s-64>2]|=g[s]<<(s%4<<3);if(c[s>>2]|=128<<(s%4<<3),s>55)for(n(u,c),s=0;s<16;s+=1)c[s]=0;return x=p*8,x=x.toString(16).match(/(.*?)(.{0,8})$/),C=parseInt(x[2],16),S=parseInt(x[1],16)||0,c[14]=C,c[15]=S,n(u,c),u}function a(g){var p="",u;for(u=0;u<4;u+=1)p+=o[g>>u*8+4&15]+o[g>>u*8&15];return p}function h(g){var p;for(p=0;pc?new ArrayBuffer(0):(x=c-f,C=new ArrayBuffer(x),S=new Uint8Array(C),J=new Uint8Array(this,f,x),S.set(J),C)}}();function v(g){return/[\u0080-\uFFFF]/.test(g)&&(g=unescape(encodeURIComponent(g))),g}function _(g,p){var u=g.length,s=new ArrayBuffer(u),f=new Uint8Array(s),c;for(c=0;c>2]|=p.charCodeAt(s)<<(s%4<<3);return this._finish(f,u),c=h(this._hash),g&&(c=D(c)),this.reset(),c},b.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},b.prototype.setState=function(g){return this._buff=g.buff,this._length=g.length,this._hash=g.hash,this},b.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},b.prototype._finish=function(g,p){var u=p,s,f,c;if(g[u>>2]|=128<<(u%4<<3),u>55)for(n(this._hash,g),u=0;u<16;u+=1)g[u]=0;s=this._length*8,s=s.toString(16).match(/(.*?)(.{0,8})$/),f=parseInt(s[2],16),c=parseInt(s[1],16)||0,g[14]=f,g[15]=c,n(this._hash,g)},b.hash=function(g,p){return b.hashBinary(v(g),p)},b.hashBinary=function(g,p){var u=d(g),s=h(u);return p?D(s):s},b.ArrayBuffer=function(){this.reset()},b.ArrayBuffer.prototype.append=function(g){var p=O(this._buff.buffer,g,!0),u=p.length,s;for(this._length+=g.byteLength,s=64;s<=u;s+=64)n(this._hash,l(p.subarray(s-64,s)));return this._buff=s-64>2]|=p[f]<<(f%4<<3);return this._finish(s,u),c=h(this._hash),g&&(c=D(c)),this.reset(),c},b.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.ArrayBuffer.prototype.getState=function(){var g=b.prototype.getState.call(this);return g.buff=T(g.buff),g},b.ArrayBuffer.prototype.setState=function(g){return g.buff=_(g.buff,!0),b.prototype.setState.call(this,g)},b.ArrayBuffer.prototype.destroy=b.prototype.destroy,b.ArrayBuffer.prototype._finish=b.prototype._finish,b.ArrayBuffer.hash=function(g,p){var u=y(new Uint8Array(g)),s=h(u);return p?D(s):s},b})})(st);var It=st.exports;const Ut=yt(It);var M=globalThis&&globalThis.__assign||function(){return M=Object.assign||function(i){for(var r,t=1,o=arguments.length;t0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]i.size)t=i.size;else for(;i.size>t*1e4;)t*=2;for(var o=[],n=Math.ceil(i.size/t),e=0;e3?r[1]:r[0];if(!t)throw new w(m.InvalidToken,"missing assess key field.");var o=null;try{o=JSON.parse(At(r[r.length-1]))}catch{throw new w(m.InvalidToken,"token parse failed.")}if(o==null)throw new w(m.InvalidToken,"putPolicy is null.");if(o.scope==null)throw new w(m.InvalidToken,"scope field is null.");var n=o.scope.split(":")[0];if(!n)throw new w(m.InvalidToken,"resolve bucketName failed.");return{assessKey:t,bucketName:n,scope:o.scope}}var k,I={z0:"z0",z1:"z1",z2:"z2",na0:"na0",as0:"as0",cnEast2:"cn-east-2"},Gt=(k={},k[I.z0]={srcUphost:["up.qiniup.com"],cdnUphost:["upload.qiniup.com"]},k[I.z1]={srcUphost:["up-z1.qiniup.com"],cdnUphost:["upload-z1.qiniup.com"]},k[I.z2]={srcUphost:["up-z2.qiniup.com"],cdnUphost:["upload-z2.qiniup.com"]},k[I.na0]={srcUphost:["up-na0.qiniup.com"],cdnUphost:["upload-na0.qiniup.com"]},k[I.as0]={srcUphost:["up-as0.qiniup.com"],cdnUphost:["upload-as0.qiniup.com"]},k[I.cnEast2]={srcUphost:["up-cn-east-2.qiniup.com"],cdnUphost:["upload-cn-east-2.qiniup.com"]},k),z=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}},Nt=function(i,r,t,o){return r=r||"&",t=t||"=",i===null&&(i=void 0),typeof i=="object"?Object.keys(i).map(function(n){var e=encodeURIComponent(z(n))+t;return Array.isArray(i[n])?i[n].map(function(l){return e+encodeURIComponent(z(l))}).join(r):e+encodeURIComponent(z(i[n]))}).filter(Boolean).join(r):o?encodeURIComponent(z(o))+t+encodeURIComponent(z(i)):""},lt;lt=Nt;var A=globalThis&&globalThis.__assign||function(){return A=Object.assign||function(i){for(var r,t=1,o=arguments.length;t0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]0)&&!(n=o.next()).done;)e.push(n.value)}catch(d){l={error:d}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(l)throw l.error}}return e},ee=globalThis&&globalThis.__spread||function(){for(var i=[],r=0;r1e4*ie)return this.handleError(new w(m.InvalidFile,"file size exceed maximum value 10000G")),[2];if(this.putExtra.customVars&&!Rt(this.putExtra.customVars))return this.handleError(new w(m.InvalidCustomVars,"customVars key should start width x:")),[2];if(this.putExtra.metadata&&!Pt(this.putExtra.metadata))return this.handleError(new w(m.InvalidMetadata,"metadata key should start with x-qn-meta-")),[2];e.label=1;case 1:return e.trys.push([1,4,,5]),this.uploadAt=new Date().getTime(),[4,this.checkAndUpdateUploadHost()];case 2:return e.sent(),[4,this.run()];case 3:return r=e.sent(),this.onComplete(r.data),this.checkAndUnfreezeHost(),this.sendLog(r.reqId,200),[2];case 4:return t=e.sent(),this.aborted?(this.logger.warn("upload is aborted."),this.sendLog("",-2),[2]):(this.clear(),this.logger.error(t),t instanceof H&&(this.sendLog(t.reqId,t.code),this.checkAndFreezeHost(t),o=++this.retryCount<=this.config.retryCount,n=ne.includes(t.code),n&&o)?(this.logger.warn("error auto retry: "+this.retryCount+"/"+this.config.retryCount+"."),this.putFile(),[2]):(this.onError(t),[3,5]));case 5:return[2]}})})},i.prototype.clear=function(){this.xhrList.forEach(function(r){r.onreadystatechange=null,r.abort()}),this.xhrList=[],this.logger.info("cleanup uploading xhr.")},i.prototype.stop=function(){this.logger.info("aborted."),this.clear(),this.aborted=!0},i.prototype.addXhr=function(r){this.xhrList.push(r)},i.prototype.sendLog=function(r,t){var o,n;this.logger.report({code:t,reqId:r,remoteIp:"",upType:"jssdk-h5",size:this.file.size,time:Math.floor(this.uploadAt/1e3),port:$t((o=this.uploadHost)===null||o===void 0?void 0:o.getUrl()),host:Vt((n=this.uploadHost)===null||n===void 0?void 0:n.getUrl()),bytesSent:this.progress?this.progress.total.loaded:0,duration:Math.floor((new Date().getTime()-this.uploadAt)/1e3)})},i.prototype.getProgressInfoItem=function(r,t,o){return j({size:t,loaded:r,percent:r/t*100},o==null?{}:{fromCache:o})},i}(),oe=globalThis&&globalThis.__extends||function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var e in n)n.hasOwnProperty(e)&&(o[e]=n[e])},i(r,t)};return function(r,t){i(r,t);function o(){this.constructor=r}r.prototype=t===null?Object.create(t):(o.prototype=t.prototype,new o)}}(),L=globalThis&&globalThis.__assign||function(){return L=Object.assign||function(i){for(var r,t=1,o=arguments.length;t0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]1024)throw new w(m.InvalidChunkSize,"chunkSize maximum value is 1024");return[4,this.initBeforeUploadChunks()];case 1:y.sent(),t=new bt(function(a){return P(d,void 0,void 0,function(){return R(this,function(h){switch(h.label){case 0:if(this.aborted)throw t.abort(),new Error("pool is aborted");return[4,this.uploadChunk(a)];case 1:return h.sent(),[2]}})})},this.config.concurrentRequestLimit),o=null,n=this.getLocalKey(),e=this.chunks.map(function(a,h){return t.enqueue({chunk:a,index:h})}),y.label=2;case 2:return y.trys.push([2,5,,6]),[4,Promise.all(e)];case 3:return y.sent(),[4,this.mkFileReq()];case 4:return o=y.sent(),[3,6];case 5:throw l=y.sent(),l instanceof H&&(l.code===612||l.code===400)&&N(n,this.logger),l;case 6:return N(n,this.logger),[2,o]}})})},r.prototype.uploadChunk=function(t){return P(this,void 0,void 0,function(){var o,n,e,l,d,y,a,h,v,_=this;return R(this,function(T){switch(T.label){case 0:return o=t.index,n=t.chunk,e=this.cachedUploadedList[o],this.logger.info("upload part "+o+", cache:",e),l=this.config.checkByMD5,d=function(){_.usedCacheList[o]=!0,_.updateChunkProgress(n.size,o),_.uploadedList[o]=e,_.updateLocalCache()},e&&!l?(d(),[2]):[4,Mt(n)];case 1:return y=T.sent(),this.logger.info("computed part md5.",y),e&&y===e.md5?(d(),[2]):(this.usedCacheList[o]=!1,a=function(O){_.updateChunkProgress(O.loaded,o)},h={body:n,md5:this.config.checkByServer?y:void 0,onProgress:a,onCreate:function(O){return _.addXhr(O)}},this.logger.info("part "+o+" start uploading."),[4,Zt(this.token,this.key,t.index+1,this.getUploadInfo(),h)]);case 2:return v=T.sent(),this.logger.info("part "+o+" upload completed."),a({loaded:n.size,total:n.size}),this.uploadedList[o]={etag:v.data.etag,md5:v.data.md5,size:n.size},this.updateLocalCache(),[2]}})})},r.prototype.mkFileReq=function(){return P(this,void 0,void 0,function(){var t,o,n=this;return R(this,function(e){switch(e.label){case 0:return t=L(L(L({parts:this.uploadedList.map(function(l,d){return{etag:l.etag,partNumber:d+1}}),fname:this.putExtra.fname},this.putExtra.mimeType&&{mimeType:this.putExtra.mimeType}),this.putExtra.customVars&&{customVars:this.putExtra.customVars}),this.putExtra.metadata&&{metadata:this.putExtra.metadata}),this.logger.info("parts upload completed, make file.",t),[4,Yt(this.token,this.key,this.getUploadInfo(),{onCreate:function(l){return n.addXhr(l)},body:JSON.stringify(t)})];case 1:return o=e.sent(),this.logger.info("finish Resume Progress."),this.updateMkFileProgress(1),[2,o]}})})},r.prototype.initBeforeUploadChunks=function(){return P(this,void 0,void 0,function(){var t,o,n;return R(this,function(e){switch(e.label){case 0:return this.uploadedList=[],this.usedCacheList=[],t=qt(this.getLocalKey(),this.logger),t?[3,2]:(this.logger.info("init upload parts from api."),[4,Kt(this.token,this.bucketName,this.key,this.uploadHost.getUrl())]);case 1:return o=e.sent(),this.logger.info("initd upload parts of id: "+o.data.uploadId+"."),this.uploadId=o.data.uploadId,this.cachedUploadedList=[],[3,3];case 2:n=["resume upload parts from local cache,","total "+t.data.length+" part,","id is "+t.id+"."],this.logger.info(n.join(" ")),this.cachedUploadedList=t.data,this.uploadId=t.id,e.label=3;case 3:return this.chunks=zt(this.file,this.config.chunkSize),this.loaded={mkFileProgress:0,chunks:this.chunks.map(function(l){return 0})},this.notifyResumeProgress(),[2]}})})},r.prototype.getUploadInfo=function(){return{id:this.uploadId,url:this.uploadHost.getUrl()}},r.prototype.getLocalKey=function(){return Ht(this.file.name,this.key,this.file.size)},r.prototype.updateLocalCache=function(){Lt(this.getLocalKey(),{id:this.uploadId,data:this.uploadedList},this.logger)},r.prototype.updateChunkProgress=function(t,o){this.loaded.chunks[o]=t,this.notifyResumeProgress()},r.prototype.updateMkFileProgress=function(t){this.loaded.mkFileProgress=t,this.notifyResumeProgress()},r.prototype.notifyResumeProgress=function(){var t=this;this.progress={total:this.getProgressInfoItem(Et(this.loaded.chunks)+this.loaded.mkFileProgress,this.file.size+1),chunks:this.chunks.map(function(o,n){var e=t.usedCacheList[n];return t.getProgressInfoItem(t.loaded.chunks[n],o.size,e)}),uploadInfo:{id:this.uploadId,url:this.uploadHost.getUrl()}},this.onData(this.progress)},r}(ht),Y=globalThis&&globalThis.__awaiter||function(i,r,t,o){function n(e){return e instanceof t?e:new t(function(l){l(e)})}return new(t||(t=Promise))(function(e,l){function d(h){try{a(o.next(h))}catch(v){l(v)}}function y(h){try{a(o.throw(h))}catch(v){l(v)}}function a(h){h.done?e(h.value):n(h.value).then(d,y)}a((o=o.apply(i,r||[])).next())})},Q=globalThis&&globalThis.__generator||function(i,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,n,e,l;return l={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function d(a){return function(h){return y([a,h])}}function y(a){if(o)throw new TypeError("Generator is already executing.");for(;t;)try{if(o=1,n&&(e=a[0]&2?n.return:a[0]?n.throw||((e=n.return)&&e.call(n),0):n.next)&&!(e=e.call(n,a[1])).done)return e;switch(n=0,e&&(a=[a[0]&2,e.value]),a[0]){case 0:case 1:e=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,n=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]>>1^3988292384:o>>>=1;r[t]=o}return r},i.prototype.append=function(r){for(var t=this.crc,o=0;o>>8^this.table[(t^r[o])&255];this.crc=t},i.prototype.compute=function(){return(this.crc^-1)>>>0},i.prototype.readAsUint8Array=function(r){return Y(this,void 0,void 0,function(){var t;return Q(this,function(o){switch(o.label){case 0:return typeof r.arrayBuffer!="function"?[3,2]:(t=Uint8Array.bind,[4,r.arrayBuffer()]);case 1:return[2,new(t.apply(Uint8Array,[void 0,o.sent()]))];case 2:return[2,new Promise(function(n,e){var l=new FileReader;l.onload=function(){if(l.result==null){e();return}if(typeof l.result=="string"){e();return}n(new Uint8Array(l.result))},l.readAsArrayBuffer(r)})]}})})},i.prototype.file=function(r){return Y(this,void 0,void 0,function(){var t,o,n,e,l,d;return Q(this,function(y){switch(y.label){case 0:return r.size<=U?(t=this.append,[4,this.readAsUint8Array(r)]):[3,2];case 1:return t.apply(this,[y.sent()]),[2,this.compute()];case 2:o=Math.ceil(r.size/U),n=0,y.label=3;case 3:return n0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]0&&dt(i,r,t-1)};var n=[r.code||"",r.reqId||"",r.host||"",r.remoteIp||"",r.port||"",r.duration||"",r.time||"",r.bytesSent||"",r.upType||"",r.size||""].join(",");o.send(n)}var he=globalThis&&globalThis.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var o=t.call(i),n,e=[],l;try{for(;(r===void 0||r-- >0)&&!(n=o.next()).done;)e.push(n.value)}catch(d){l={error:d}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(l)throw l.error}}return e},V=globalThis&&globalThis.__spread||function(){for(var i=[],r=0;r0&&e[e.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!e||a[1]>e[0]&&a[1]0)&&!(n=o.next()).done;)e.push(n.value)}catch(d){l={error:d}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(l)throw l.error}}return e},ge=globalThis&&globalThis.__spread||function(){for(var i=[],r=0;r=r},i.prototype.freeze=function(r){r===void 0&&(r=20);var t=new Date().getTime()+r*1e3;B.set(this.host,t)},i.prototype.unfreeze=function(){B.delete(this.host)},i.prototype.getUrl=function(){return this.protocol+"://"+this.host},i.prototype.getUnfreezeTime=function(){return B.get(this.host)},i}(),ve=function(){function i(r){r===void 0&&(r=[]),this.initHosts=r,this.cachedHostsMap=new Map}return i.prototype.register=function(r,t,o,n){this.cachedHostsMap.set(r+"@"+t,o.map(function(e){return new ye(e,n)}))},i.prototype.refresh=function(r,t,o){var n,e,l,d;return et(this,void 0,void 0,function(){var y,a,h;return rt(this,function(v){switch(v.label){case 0:return y=this.cachedHostsMap.get(r+"@"+t)||[],y.length>0?[2]:this.initHosts.length>0?(this.register(r,t,this.initHosts,o),[2]):[4,Wt(r,t,o)];case 1:return a=v.sent(),(a==null?void 0:a.data)!=null&&(h=ge(((e=(n=a.data.up)===null||n===void 0?void 0:n.acc)===null||e===void 0?void 0:e.main)||[],((d=(l=a.data.up)===null||l===void 0?void 0:l.acc)===null||d===void 0?void 0:d.backup)||[]),this.register(r,t,h,o)),[2]}})})},i.prototype.getUp=function(r,t,o){return et(this,void 0,void 0,function(){var n,e,l;return rt(this,function(d){switch(d.label){case 0:return[4,this.refresh(r,t,o)];case 1:return d.sent(),n=this.cachedHostsMap.get(r+"@"+t)||[],n.length===0?[2,null]:(e=n.filter(function(y){return!y.isFrozen()}),e.length>0?[2,e[0]]:(l=n.slice().sort(function(y,a){return(y.getUnfreezeTime()||0)-(a.getUnfreezeTime()||0)}),[2,l[0]]))}})})},i}();function be(i,r,t,o){return i.config&&i.config.forceDirect?(o.info("ues forceDirect mode."),new tt(i,r,t,o)):i.file.size>4*U?(o.info("file size over 4M, use Resume."),new se(i,r,t,o)):(o.info("file size less or equal than 4M, use Direct."),new tt(i,r,t,o))}function me(i,r,t,o,n){var e=new de(t,n==null?void 0:n.disableStatisticsReport,n==null?void 0:n.debugLogLevel,i.name),l={file:i,key:r,token:t,putExtra:o,config:xe(n,e)},d=new ve(l.config.uphost);return new xt(function(y){var a=be(l,{onData:function(h){return y.next(h)},onError:function(h){return y.error(h)},onComplete:function(h){return y.complete(h)}},d,e);return a.putFile(),a.stop.bind(a)})}var F=globalThis&&globalThis.__assign||function(){return F=Object.assign||function(i){for(var r,t=1,o=arguments.length;t0)&&!(n=o.next()).done;)e.push(n.value)}catch(d){l={error:d}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(l)throw l.error}}return e},G=globalThis&&globalThis.__spread||function(){for(var i=[],r=0;r{me(i,n,e,o.putExtra,o.putConfig).subscribe({next(y){y&&t(y.total)},error(y){d(y)},async complete(y){let a={url:o.domain+"/"+n,key:n};if(o.successHandle){a=await o.successHandle(a),l(a);return}l(a)}})})}async function Ie(i){const{getConfig:r}=gt(),t=r("qiniu"),o=i.options,n=W.merge(W.cloneDeep(t),o);return i.options=n,await Ce(i)}export{Te as getToken,Ie as upload};