Files
dafuweng/public/exadmin/assets/qiniu-js.8b174ca3.js
2026-03-02 13:44:38 +08:00

2 lines
40 KiB
JavaScript

import{S as Y}from"./spark-md5.2cc5764b.js";import{s as Q}from"./querystring.62f12500.js";var G=globalThis&&globalThis.__extends||function(){var o=function(r,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var e in i)i.hasOwnProperty(e)&&(n[e]=i[e])},o(r,t)};return function(r,t){o(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),f;(function(o){o.InvalidFile="InvalidFile",o.InvalidToken="InvalidToken",o.InvalidMetadata="InvalidMetadata",o.InvalidChunkSize="InvalidChunkSize",o.InvalidCustomVars="InvalidCustomVars",o.NotAvailableUploadHost="NotAvailableUploadHost",o.ReadCacheFailed="ReadCacheFailed",o.InvalidCacheData="InvalidCacheData",o.WriteCacheFailed="WriteCacheFailed",o.RemoveCacheFailed="RemoveCacheFailed",o.GetCanvasContextFailed="GetCanvasContextFailed",o.UnsupportedFileType="UnsupportedFileType",o.FileReaderReadFailed="FileReaderReadFailed",o.NotAvailableXMLHttpRequest="NotAvailableXMLHttpRequest",o.InvalidProgressEventTarget="InvalidProgressEventTarget",o.RequestError="RequestError"})(f||(f={}));var d=function(){function o(r,t){this.name=r,this.message=t,this.stack=new Error().stack}return o}(),x=function(o){G(r,o);function r(t,n,i,e){var s=o.call(this,f.RequestError,i)||this;return s.code=t,s.reqId=n,s.isRequestError=!0,s.data=e,s}return r}(d),tt=function(o){G(r,o);function r(t,n){return n===void 0&&(n=""),o.call(this,0,n,t)||this}return r}(x),et=function(){function o(r,t){this.runTask=r,this.limit=t,this.queue=[],this.processing=[]}return o.prototype.enqueue=function(r){var t=this;return new Promise(function(n,i){t.queue.push({task:r,resolve:n,reject:i}),t.check()})},o.prototype.run=function(r){var t=this;this.queue=this.queue.filter(function(n){return n!==r}),this.processing.push(r),this.runTask(r.task).then(function(){t.processing=t.processing.filter(function(n){return n!==r}),r.resolve(),t.check()},function(n){return r.reject(n)})},o.prototype.check=function(){var r=this,t=this.processing.length,n=this.limit-t;this.queue.slice(0,n).forEach(function(i){r.run(i)})},o}(),rt=globalThis&&globalThis.__extends||function(){var o=function(r,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var e in i)i.hasOwnProperty(e)&&(n[e]=i[e])},o(r,t)};return function(r,t){o(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),_=globalThis&&globalThis.__assign||function(){return _=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},_.apply(this,arguments)},nt=function(){function o(){this.closed=!1}return o.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this._unsubscribe&&this._unsubscribe())},o.prototype.add=function(r){this._unsubscribe=r},o}(),it=function(o){rt(r,o);function r(t,n,i){var e=o.call(this)||this;return e.isStopped=!1,t&&typeof t=="object"?e.destination=t:e.destination=_(_(_({},t&&{next:t}),n&&{error:n}),i&&{complete:i}),e}return r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,o.prototype.unsubscribe.call(this))},r.prototype.next=function(t){!this.isStopped&&this.destination.next&&this.destination.next(t)},r.prototype.error=function(t){!this.isStopped&&this.destination.error&&(this.isStopped=!0,this.destination.error(t))},r.prototype.complete=function(t){!this.isStopped&&this.destination.complete&&(this.isStopped=!0,this.destination.complete(t))},r}(nt),ot=function(){function o(r){this._subscribe=r}return o.prototype.subscribe=function(r,t,n){var i=new it(r,t,n);return i.add(this._subscribe(i)),i},o}();function at(o){if(o===null||typeof o=="undefined")return"";var r=o+"",t="",n,i,e=0;n=i=0,e=r.length;for(var s=0;s<e;s++){var u=r.charCodeAt(s),c=null;if(u<128)i++;else if(u>127&&u<2048)c=String.fromCharCode(u>>6|192,u&63|128);else if((u&63488^55296)>0)c=String.fromCharCode(u>>12|224,u>>6&63|128,u&63|128);else{if((u&64512^55296)>0)throw new RangeError("Unmatched trail surrogate at "+s);var a=r.charCodeAt(++s);if((a&64512^56320)>0)throw new RangeError("Unmatched lead surrogate at "+(s-1));u=((u&1023)<<10)+(a&1023)+65536,c=String.fromCharCode(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}c!==null&&(i>n&&(t+=r.slice(n,i)),t+=c,n=i=s+1)}return i>n&&(t+=r.slice(n,e)),t}function st(o){var r=[],t=0,n=0,i=0;for(o+="";t<o.length;){n=o.charCodeAt(t)&255,i=0,n<=191?(n=n&127,i=1):n<=223?(n=n&31,i=2):n<=239?(n=n&15,i=3):(n=n&7,i=4);for(var e=1;e<i;++e)n=n<<6|o.charCodeAt(e+t)&63;i===4?(n-=65536,r.push(String.fromCharCode(55296|n>>10&1023)),r.push(String.fromCharCode(56320|n&1023))):r.push(String.fromCharCode(n)),t+=i}return r.join("")}function ut(o){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t,n,i,e,s,u,c,a,l=0,h=0,p="",g=[];if(!o)return o;o=at(o+"");do t=o.charCodeAt(l++),n=o.charCodeAt(l++),i=o.charCodeAt(l++),a=t<<16|n<<8|i,e=a>>18&63,s=a>>12&63,u=a>>6&63,c=a&63,g[h++]=r.charAt(e)+r.charAt(s)+r.charAt(u)+r.charAt(c);while(l<o.length);switch(p=g.join(""),o.length%3){case 1:p=p.slice(0,-2)+"==";break;case 2:p=p.slice(0,-1)+"=";break}return p}function lt(o){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t,n,i,e,s,u,c,a,l=0,h=0,p="",g=[];if(!o)return o;o+="";do e=r.indexOf(o.charAt(l++)),s=r.indexOf(o.charAt(l++)),u=r.indexOf(o.charAt(l++)),c=r.indexOf(o.charAt(l++)),a=e<<18|s<<12|u<<6|c,t=a>>16&255,n=a>>8&255,i=a&255,u===64?g[h++]=String.fromCharCode(t):c===64?g[h++]=String.fromCharCode(t,n):g[h++]=String.fromCharCode(t,n,i);while(l<o.length);return p=g.join(""),st(p)}function N(o){return o=ut(o),o.replace(/\//g,"_").replace(/\+/g,"-")}function ct(o){return o=o.replace(/_/g,"/").replace(/-/g,"+"),lt(o)}var z=globalThis&&globalThis.__assign||function(){return z=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},z.apply(this,arguments)},ht=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},ft=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},m=Math.pow(1024,2);function dt(o,r){var t=r*m;if(t>o.size)t=o.size;else for(;o.size>t*1e4;)t*=2;for(var n=[],i=Math.ceil(o.size/t),e=0;e<i;e++){var s=o.slice(t*e,e===i-1?o.size:t*(e+1));n.push(s)}return n}function pt(o){return Object.keys(o).every(function(r){return r.indexOf("x-qn-meta-")===0})}function gt(o){return Object.keys(o).every(function(r){return r.indexOf("x:")===0})}function vt(o){return o.reduce(function(r,t){return r+t},0)}function yt(o,r,t){try{localStorage.setItem(o,JSON.stringify(r))}catch{t.warn(new d(f.WriteCacheFailed,"setLocalFileInfo failed: "+o))}}function bt(o,r,t){var n=r==null?"_":"_key_"+r+"_";return"qiniu_js_sdk_upload_file_name_"+o+n+"size_"+t}function A(o,r){try{localStorage.removeItem(o)}catch{r.warn(new d(f.RemoveCacheFailed,"removeLocalFileInfo failed. key: "+o))}}function mt(o,r){var t=null;try{t=localStorage.getItem(o)}catch{r.warn(new d(f.ReadCacheFailed,"getLocalFileInfo failed. key: "+o))}if(t==null)return null;var n=null;try{n=JSON.parse(t)}catch{A(o,r),r.warn(new d(f.InvalidCacheData,"getLocalFileInfo failed to parse. key: "+o))}return n}function F(o){var r="UpToken "+o;return{Authorization:r}}function wt(o){var r=F(o);return z({"content-type":"application/octet-stream"},r)}function _t(o){var r=F(o);return z({"content-type":"application/json"},r)}function X(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject)return new window.ActiveXObject("Microsoft.XMLHTTP");throw new d(f.NotAvailableXMLHttpRequest,"the current environment does not support.")}function kt(o){return ht(this,void 0,void 0,function(){var r,t;return ft(this,function(n){switch(n.label){case 0:return[4,xt(o)];case 1:return r=n.sent(),t=new Y.ArrayBuffer,t.append(r),[2,t.end()]}})})}function xt(o){return new Promise(function(r,t){var n=new FileReader;n.onload=function(i){if(i.target){var e=i.target.result;r(e)}else t(new d(f.InvalidProgressEventTarget,"progress event target is undefined"))},n.onerror=function(){t(new d(f.FileReaderReadFailed,"fileReader read failed"))},n.readAsArrayBuffer(o)})}function T(o,r){return new Promise(function(t,n){var i=X();if(i.open(r.method,o),r.onCreate&&r.onCreate(i),r.headers){var e=r.headers;Object.keys(e).forEach(function(s){i.setRequestHeader(s,e[s])})}i.upload.addEventListener("progress",function(s){s.lengthComputable&&r.onProgress&&r.onProgress({loaded:s.loaded,total:s.total})}),i.onreadystatechange=function(){var s=i.responseText;if(i.readyState===4){var u=i.getResponseHeader("x-reqId")||"";if(i.status===0){n(new tt("network error.",u));return}if(i.status!==200){var c="xhr request failed, code: "+i.status;s&&(c+=" response: "+s);var a=void 0;try{a=JSON.parse(s)}catch{}n(new x(i.status,u,c,a));return}try{t({data:JSON.parse(s),reqId:u})}catch(l){n(l)}}},i.send(r.body)})}function Tt(o){if(o&&o.match){var r=o.match(/(^https?)/);if(!r)return"";var t=r[1];return r=o.match(/^https?:\/\/([^:^/]*):(\d*)/),r?r[2]:t==="http"?"80":"443"}return""}function Ct(o){if(o&&o.match){var r=o.match(/^https?:\/\/([^:^/]*)/);return r?r[1]:""}return""}function L(o){if(!o)throw new d(f.InvalidToken,"invalid token.");var r=o.split(":");if(r.length===1)throw new d(f.InvalidToken,"invalid token segments.");var t=r.length>3?r[1]:r[0];if(!t)throw new d(f.InvalidToken,"missing assess key field.");var n=null;try{n=JSON.parse(ct(r[r.length-1]))}catch{throw new d(f.InvalidToken,"token parse failed.")}if(n==null)throw new d(f.InvalidToken,"putPolicy is null.");if(n.scope==null)throw new d(f.InvalidToken,"scope field is null.");var i=n.scope.split(":")[0];if(!i)throw new d(f.InvalidToken,"resolve bucketName failed.");return{assessKey:t,bucketName:i,scope:n.scope}}var v,b={z0:"z0",z1:"z1",z2:"z2",na0:"na0",as0:"as0",cnEast2:"cn-east-2"},St=(v={},v[b.z0]={srcUphost:["up.qiniup.com"],cdnUphost:["upload.qiniup.com"]},v[b.z1]={srcUphost:["up-z1.qiniup.com"],cdnUphost:["upload-z1.qiniup.com"]},v[b.z2]={srcUphost:["up-z2.qiniup.com"],cdnUphost:["upload-z2.qiniup.com"]},v[b.na0]={srcUphost:["up-na0.qiniup.com"],cdnUphost:["upload-na0.qiniup.com"]},v[b.as0]={srcUphost:["up-as0.qiniup.com"],cdnUphost:["upload-as0.qiniup.com"]},v[b.cnEast2]={srcUphost:["up-cn-east-2.qiniup.com"],cdnUphost:["upload-cn-east-2.qiniup.com"]},v),y=globalThis&&globalThis.__assign||function(){return y=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},y.apply(this,arguments)},It=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},zt=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}};function Ot(o,r,t){return It(this,void 0,void 0,function(){var n,i;return zt(this,function(e){return n=Q({ak:o,bucket:r}),i=t+"://api.qiniu.com/v2/query?"+n,[2,T(i,{method:"GET"})]})})}function J(o,r,t){var n=t.url,i=t.id;return n+"/buckets/"+o+"/objects/"+(r!=null?N(r):"~")+"/uploads/"+i}function Ft(o,r,t,n){var i=n+"/buckets/"+r+"/objects/"+(t!=null?N(t):"~")+"/uploads";return T(i,{method:"POST",headers:F(o)})}function Pt(o,r,t,n,i){var e=L(o).bucketName,s=J(e,r,n)+("/"+t),u=wt(o);return i.md5&&(u["Content-MD5"]=i.md5),T(s,y(y({},i),{method:"PUT",headers:u}))}function Et(o,r,t,n){var i=L(o).bucketName,e=J(i,r,t);return T(e,y(y({},n),{method:"POST",headers:_t(o)}))}function Ut(o,r,t){return T(o,y({method:"POST",body:r},t))}var O=globalThis&&globalThis.__assign||function(){return O=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},O.apply(this,arguments)},H=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},q=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},At=globalThis&&globalThis.__read||function(o,r){var t=typeof Symbol=="function"&&o[Symbol.iterator];if(!t)return o;var n=t.call(o),i,e=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)e.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return e},Rt=globalThis&&globalThis.__spread||function(){for(var o=[],r=0;r<arguments.length;r++)o=o.concat(At(arguments[r]));return o},Lt=4,W=[0,502,503,504,599],Ht=Rt(W,[612]),qt=Math.pow(1024,3),K=function(){function o(r,t,n,i){this.hostPool=n,this.logger=i,this.aborted=!1,this.retryCount=0,this.xhrList=[],this.config=r.config,i.info("config inited.",this.config),this.putExtra=O({fname:""},r.putExtra),i.info("putExtra inited.",this.putExtra),this.key=r.key,this.file=r.file,this.token=r.token,this.onData=t.onData,this.onError=t.onError,this.onComplete=t.onComplete;try{var e=L(this.token);this.bucketName=e.bucketName,this.assessKey=e.assessKey}catch(s){i.error("get putPolicy from token failed.",s),this.onError(s)}}return o.prototype.checkAndUpdateUploadHost=function(){return H(this,void 0,void 0,function(){var r;return q(this,function(t){switch(t.label){case 0:return this.logger.info("get available upload host."),[4,this.hostPool.getUp(this.assessKey,this.bucketName,this.config.upprotocol)];case 1:if(r=t.sent(),r==null)throw new d(f.NotAvailableUploadHost,"no available upload host.");return this.uploadHost!=null&&this.uploadHost.host!==r.host?this.logger.warn("host switches from "+this.uploadHost.host+" to "+r.host+"."):this.logger.info("use host "+r.host+"."),this.uploadHost=r,[2]}})})},o.prototype.checkAndUnfreezeHost=function(){this.logger.info("check unfreeze host."),this.uploadHost!=null&&this.uploadHost.isFrozen()&&(this.logger.warn(this.uploadHost.host+" will be unfrozen."),this.uploadHost.unfreeze())},o.prototype.checkAndFreezeHost=function(r){this.logger.info("check freeze host."),r instanceof x&&this.uploadHost!=null&&W.includes(r.code)&&(this.logger.warn(this.uploadHost.host+" will be temporarily frozen."),this.uploadHost.freeze())},o.prototype.handleError=function(r){this.logger.error(r.message),this.onError(r)},o.prototype.putFile=function(){return H(this,void 0,void 0,function(){var r,t,n,i,e,s;return q(this,function(u){switch(u.label){case 0:if(this.aborted=!1,this.putExtra.fname||(this.logger.info("use file.name as fname."),this.putExtra.fname=this.file.name),this.file.size>1e4*qt)return this.handleError(new d(f.InvalidFile,"file size exceed maximum value 10000G")),[2];if(this.putExtra.customVars&&!gt(this.putExtra.customVars))return this.handleError(new d(f.InvalidCustomVars,"customVars key should start width x:")),[2];if(this.putExtra.metadata&&!pt(this.putExtra.metadata))return this.handleError(new d(f.InvalidMetadata,"metadata key should start with x-qn-meta-")),[2];u.label=1;case 1:return u.trys.push([1,4,,5]),this.uploadAt=new Date().getTime(),[4,this.checkAndUpdateUploadHost()];case 2:return u.sent(),[4,this.run()];case 3:return r=u.sent(),this.onComplete(r.data),this.checkAndUnfreezeHost(),this.sendLog(r.reqId,200),[2];case 4:return t=u.sent(),this.logger.error(t),this.clear(),t instanceof x&&(n=this.aborted?"":t.reqId,i=this.aborted?-2:t.code,this.sendLog(n,i),this.checkAndFreezeHost(t),e=++this.retryCount<=this.config.retryCount,s=!this.aborted&&Ht.includes(t.code),s&&e)?(this.logger.warn("error auto retry: "+this.retryCount+"/"+this.config.retryCount+"."),this.putFile(),[2]):(this.onError(t),[3,5]);case 5:return[2]}})})},o.prototype.clear=function(){this.logger.info("start cleaning all xhr."),this.xhrList.forEach(function(r){r.onreadystatechange=null,r.abort()}),this.logger.info("cleanup completed."),this.xhrList=[]},o.prototype.stop=function(){this.logger.info("stop."),this.clear(),this.aborted=!0},o.prototype.addXhr=function(r){this.xhrList.push(r)},o.prototype.sendLog=function(r,t){var n,i;this.logger.report({code:t,reqId:r,remoteIp:"",upType:"jssdk-h5",size:this.file.size,time:Math.floor(this.uploadAt/1e3),port:Tt((n=this.uploadHost)===null||n===void 0?void 0:n.getUrl()),host:Ct((i=this.uploadHost)===null||i===void 0?void 0:i.getUrl()),bytesSent:this.progress?this.progress.total.loaded:0,duration:Math.floor((new Date().getTime()-this.uploadAt)/1e3)})},o.prototype.getProgressInfoItem=function(r,t,n){return O({size:t,loaded:r,percent:r/t*100},n==null?{}:{fromCache:n})},o}(),Dt=globalThis&&globalThis.__extends||function(){var o=function(r,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var e in i)i.hasOwnProperty(e)&&(n[e]=i[e])},o(r,t)};return function(r,t){o(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),k=globalThis&&globalThis.__assign||function(){return k=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},k.apply(this,arguments)},C=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},S=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}};function jt(o){var r=/^[1-9]\d*$/;return r.test(String(o))}var Mt=function(o){Dt(r,o);function r(){return o!==null&&o.apply(this,arguments)||this}return r.prototype.run=function(){return C(this,void 0,void 0,function(){var t,n,i,e,s,u=this;return S(this,function(c){switch(c.label){case 0:if(this.logger.info("start run Resume."),!this.config.chunkSize||!jt(this.config.chunkSize))throw new d(f.InvalidChunkSize,"chunkSize must be a positive integer");if(this.config.chunkSize>1024)throw new d(f.InvalidChunkSize,"chunkSize maximum value is 1024");return[4,this.initBeforeUploadChunks()];case 1:c.sent(),t=new et(function(a){return u.uploadChunk(a)},this.config.concurrentRequestLimit),n=null,i=this.getLocalKey(),e=this.chunks.map(function(a,l){return t.enqueue({chunk:a,index:l})}),c.label=2;case 2:return c.trys.push([2,5,,6]),[4,Promise.all(e)];case 3:return c.sent(),[4,this.mkFileReq()];case 4:return n=c.sent(),[3,6];case 5:throw s=c.sent(),s instanceof x&&(s.code===612||s.code===400)&&A(i,this.logger),s;case 6:return A(i,this.logger),[2,n]}})})},r.prototype.uploadChunk=function(t){return C(this,void 0,void 0,function(){var n,i,e,s,u,c,a,l,h,p=this;return S(this,function(g){switch(g.label){case 0:return n=t.index,i=t.chunk,e=this.cachedUploadedList[n],this.logger.info("upload part "+n+", cache:",e),s=this.config.checkByMD5,u=function(){p.usedCacheList[n]=!0,p.updateChunkProgress(i.size,n),p.uploadedList[n]=e,p.updateLocalCache()},e&&!s?(u(),[2]):[4,kt(i)];case 1:return c=g.sent(),this.logger.info("computed part md5.",c),e&&c===e.md5?(u(),[2]):(this.usedCacheList[n]=!1,a=function(P){p.updateChunkProgress(P.loaded,n)},l={body:i,md5:this.config.checkByServer?c:void 0,onProgress:a,onCreate:function(P){return p.addXhr(P)}},this.logger.info("part "+n+" start uploading."),[4,Pt(this.token,this.key,t.index+1,this.getUploadInfo(),l)]);case 2:return h=g.sent(),this.logger.info("part "+n+" upload completed."),a({loaded:i.size,total:i.size}),this.uploadedList[n]={etag:h.data.etag,md5:h.data.md5,size:i.size},this.updateLocalCache(),[2]}})})},r.prototype.mkFileReq=function(){return C(this,void 0,void 0,function(){var t,n,i=this;return S(this,function(e){switch(e.label){case 0:return t=k(k(k({parts:this.uploadedList.map(function(s,u){return{etag:s.etag,partNumber:u+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,Et(this.token,this.key,this.getUploadInfo(),{onCreate:function(s){return i.addXhr(s)},body:JSON.stringify(t)})];case 1:return n=e.sent(),this.logger.info("finish Resume Progress."),this.updateMkFileProgress(1),[2,n]}})})},r.prototype.initBeforeUploadChunks=function(){return C(this,void 0,void 0,function(){var t,n,i;return S(this,function(e){switch(e.label){case 0:return this.uploadedList=[],this.usedCacheList=[],t=mt(this.getLocalKey(),this.logger),t?[3,2]:(this.logger.info("init upload parts from api."),[4,Ft(this.token,this.bucketName,this.key,this.uploadHost.getUrl())]);case 1:return n=e.sent(),this.logger.info("initd upload parts of id: "+n.data.uploadId+"."),this.uploadId=n.data.uploadId,this.cachedUploadedList=[],[3,3];case 2:i=["resume upload parts from local cache,","total "+t.data.length+" part,","id is "+t.id+"."],this.logger.info(i.join(" ")),this.cachedUploadedList=t.data,this.uploadId=t.id,e.label=3;case 3:return this.chunks=dt(this.file,this.config.chunkSize),this.loaded={mkFileProgress:0,chunks:this.chunks.map(function(s){return 0})},this.notifyResumeProgress(),[2]}})})},r.prototype.getUploadInfo=function(){return{id:this.uploadId,url:this.uploadHost.getUrl()}},r.prototype.getLocalKey=function(){return bt(this.file.name,this.key,this.file.size)},r.prototype.updateLocalCache=function(){yt(this.getLocalKey(),{id:this.uploadId,data:this.uploadedList},this.logger)},r.prototype.updateChunkProgress=function(t,n){this.loaded.chunks[n]=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(vt(this.loaded.chunks)+this.loaded.mkFileProgress,this.file.size+1),chunks:this.chunks.map(function(n,i){var e=t.usedCacheList[i];return t.getProgressInfoItem(t.loaded.chunks[i],n.size,e)}),uploadInfo:{id:this.uploadId,url:this.uploadHost.getUrl()}},this.onData(this.progress)},r}(K),D=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},j=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},$t=function(){function o(){this.crc=-1,this.table=this.makeTable()}return o.prototype.makeTable=function(){for(var r=new Array,t=0;t<256;t++){for(var n=t,i=0;i<8;i++)n&1?n=n>>>1^3988292384:n>>>=1;r[t]=n}return r},o.prototype.append=function(r){for(var t=this.crc,n=0;n<r.byteLength;n++)t=t>>>8^this.table[(t^r[n])&255];this.crc=t},o.prototype.compute=function(){return(this.crc^-1)>>>0},o.prototype.readAsUint8Array=function(r){return D(this,void 0,void 0,function(){var t;return j(this,function(n){switch(n.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,n.sent()]))];case 2:return[2,new Promise(function(i,e){var s=new FileReader;s.onload=function(){if(s.result==null){e();return}if(typeof s.result=="string"){e();return}i(new Uint8Array(s.result))},s.readAsArrayBuffer(r)})]}})})},o.prototype.file=function(r){return D(this,void 0,void 0,function(){var t,n,i,e,s,u;return j(this,function(c){switch(c.label){case 0:return r.size<=m?(t=this.append,[4,this.readAsUint8Array(r)]):[3,2];case 1:return t.apply(this,[c.sent()]),[2,this.compute()];case 2:n=Math.ceil(r.size/m),i=0,c.label=3;case 3:return i<n?(e=i*m,s=i===n-1?r.size:e+m,[4,this.readAsUint8Array(r.slice(e,s))]):[3,6];case 4:u=c.sent(),this.append(new Uint8Array(u)),c.label=5;case 5:return i++,[3,3];case 6:return[2,this.compute()]}})})},o.file=function(r){var t=new o;return t.file(r)},o}(),Bt=globalThis&&globalThis.__extends||function(){var o=function(r,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var e in i)i.hasOwnProperty(e)&&(n[e]=i[e])},o(r,t)};return function(r,t){o(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Vt=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},Gt=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},M=function(o){Bt(r,o);function r(){return o!==null&&o.apply(this,arguments)||this}return r.prototype.run=function(){return Vt(this,void 0,void 0,function(){var t,n,i,e,s=this;return Gt(this,function(u){switch(u.label){case 0:return this.logger.info("start run Direct."),t=new FormData,t.append("file",this.file),t.append("token",this.token),this.key!=null&&t.append("key",this.key),t.append("fname",this.putExtra.fname),this.config.checkByServer?[4,$t.file(this.file)]:[3,2];case 1:n=u.sent(),t.append("crc32",n.toString()),u.label=2;case 2:return this.putExtra.customVars&&(this.logger.info("init customVars."),i=this.putExtra.customVars,Object.keys(i).forEach(function(c){return t.append(c,i[c].toString())}),this.logger.info("customVars inited.")),this.logger.info("formData inited."),[4,Ut(this.uploadHost.getUrl(),t,{onProgress:function(c){s.updateDirectProgress(c.loaded,c.total)},onCreate:function(c){return s.addXhr(c)}})];case 3:return e=u.sent(),this.logger.info("Direct progress finish."),this.finishDirectProgress(),[2,e]}})})},r.prototype.updateDirectProgress=function(t,n){this.progress={total:this.getProgressInfoItem(t,n+1)},this.onData(this.progress)},r.prototype.finishDirectProgress=function(){if(!this.progress){this.logger.warn("progress is null."),this.progress={total:this.getProgressInfoItem(this.file.size,this.file.size)},this.onData(this.progress);return}var t=this.progress.total;this.progress={total:this.getProgressInfoItem(t.loaded+1,t.size)},this.onData(this.progress)},r}(K);function Z(o,r,t){t===void 0&&(t=3);var n=X();n.open("POST","https://uplog.qbox.me/log/3"),n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.setRequestHeader("Authorization",F(o).Authorization),n.onreadystatechange=function(){n.readyState===4&&n.status!==200&&t>0&&Z(o,r,t-1)};var i=[r.code||"",r.reqId||"",r.host||"",r.remoteIp||"",r.port||"",r.duration||"",r.time||"",r.bytesSent||"",r.upType||"",r.size||""].join(",");n.send(i)}var Nt=globalThis&&globalThis.__read||function(o,r){var t=typeof Symbol=="function"&&o[Symbol.iterator];if(!t)return o;var n=t.call(o),i,e=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)e.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return e},E=globalThis&&globalThis.__spread||function(){for(var o=[],r=0;r<arguments.length;r++)o=o.concat(Nt(arguments[r]));return o},Xt=function(){function o(r,t,n,i){t===void 0&&(t=!0),n===void 0&&(n="OFF"),i===void 0&&(i="UPLOAD"),this.token=r,this.disableReport=t,this.level=n,this.prefix=i,this.id=++o.id}return o.prototype.getPrintPrefix=function(r){return"Qiniu-JS-SDK ["+r+"]["+this.prefix+"#"+this.id+"]:"},o.prototype.report=function(r,t){if(!this.disableReport)try{Z(this.token,r,t)}catch(n){this.warn(n)}},o.prototype.info=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=["INFO"];n.includes(this.level)&&console.log.apply(console,E([this.getPrintPrefix("INFO")],r))},o.prototype.warn=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=["INFO","WARN"];n.includes(this.level)&&console.warn.apply(console,E([this.getPrintPrefix("WARN")],r))},o.prototype.error=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=["INFO","WARN","ERROR"];n.includes(this.level)&&console.error.apply(console,E([this.getPrintPrefix("ERROR")],r))},o.id=0,o}(),$=globalThis&&globalThis.__awaiter||function(o,r,t,n){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function u(l){try{a(n.next(l))}catch(h){s(h)}}function c(l){try{a(n.throw(l))}catch(h){s(h)}}function a(l){l.done?e(l.value):i(l.value).then(u,c)}a((n=n.apply(o,r||[])).next())})},B=globalThis&&globalThis.__generator||function(o,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},n,i,e,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(e=a[0]&2?i.return:a[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,a[1])).done)return e;switch(i=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++,i=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]<e[3])){t.label=a[1];break}if(a[0]===6&&t.label<e[1]){t.label=e[1],e=a;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(a);break}e[2]&&t.ops.pop(),t.trys.pop();continue}a=r.call(o,t)}catch(l){a=[6,l],i=0}finally{n=e=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Jt=globalThis&&globalThis.__read||function(o,r){var t=typeof Symbol=="function"&&o[Symbol.iterator];if(!t)return o;var n=t.call(o),i,e=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)e.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return e},Wt=globalThis&&globalThis.__spread||function(){for(var o=[],r=0;r<arguments.length;r++)o=o.concat(Jt(arguments[r]));return o},I=new Map,Kt=function(){function o(r,t){this.host=r,this.protocol=t}return o.prototype.isFrozen=function(){var r=new Date().getTime(),t=I.get(this.host);return t!=null&&t>=r},o.prototype.freeze=function(r){r===void 0&&(r=20);var t=new Date().getTime()+r*1e3;I.set(this.host,t)},o.prototype.unfreeze=function(){I.delete(this.host)},o.prototype.getUrl=function(){return this.protocol+"://"+this.host},o.prototype.getUnfreezeTime=function(){return I.get(this.host)},o}(),Zt=function(){function o(r){r===void 0&&(r=[]),this.initHosts=r,this.cachedHostsMap=new Map}return o.prototype.register=function(r,t,n,i){this.cachedHostsMap.set(r+"@"+t,n.map(function(e){return new Kt(e,i)}))},o.prototype.refresh=function(r,t,n){var i,e,s,u;return $(this,void 0,void 0,function(){var c,a,l;return B(this,function(h){switch(h.label){case 0:return c=this.cachedHostsMap.get(r+"@"+t)||[],c.length>0?[2]:this.initHosts.length>0?(this.register(r,t,this.initHosts,n),[2]):[4,Ot(r,t,n)];case 1:return a=h.sent(),(a==null?void 0:a.data)!=null&&(l=Wt(((e=(i=a.data.up)===null||i===void 0?void 0:i.acc)===null||e===void 0?void 0:e.main)||[],((u=(s=a.data.up)===null||s===void 0?void 0:s.acc)===null||u===void 0?void 0:u.backup)||[]),this.register(r,t,l,n)),[2]}})})},o.prototype.getUp=function(r,t,n){return $(this,void 0,void 0,function(){var i,e,s;return B(this,function(u){switch(u.label){case 0:return[4,this.refresh(r,t,n)];case 1:return u.sent(),i=this.cachedHostsMap.get(r+"@"+t)||[],i.length===0?[2,null]:(e=i.filter(function(c){return!c.isFrozen()}),e.length>0?[2,e[0]]:(s=i.slice().sort(function(c,a){return(c.getUnfreezeTime()||0)-(a.getUnfreezeTime()||0)}),[2,s[0]]))}})})},o}();function Yt(o,r,t,n){return o.config&&o.config.forceDirect?(n.info("ues forceDirect mode."),new M(o,r,t,n)):o.file.size>4*m?(n.info("file size over 4M, use Resume."),new Mt(o,r,t,n)):(n.info("file size less or equal than 4M, use Direct."),new M(o,r,t,n))}function ie(o,r,t,n,i){var e=new Xt(t,i==null?void 0:i.disableStatisticsReport,i==null?void 0:i.debugLogLevel,o.name),s={file:o,key:r,token:t,putExtra:n,config:ee(i,e)},u=new Zt(s.config.uphost);return new ot(function(c){var a=Yt(s,{onData:function(l){return c.next(l)},onError:function(l){return c.error(l)},onComplete:function(l){return c.complete(l)}},u,e);return a.putFile(),a.stop.bind(a)})}var w=globalThis&&globalThis.__assign||function(){return w=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},w.apply(this,arguments)},Qt=globalThis&&globalThis.__rest||function(o,r){var t={};for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&r.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(o);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(o,n[i])&&(t[n[i]]=o[n[i]]);return t},te=globalThis&&globalThis.__read||function(o,r){var t=typeof Symbol=="function"&&o[Symbol.iterator];if(!t)return o;var n=t.call(o),i,e=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)e.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return e},U=globalThis&&globalThis.__spread||function(){for(var o=[],r=0;r<arguments.length;r++)o=o.concat(te(arguments[r]));return o};function ee(o,r){var t=w({},o),n=t.upprotocol,i=t.uphost,e=Qt(t,["upprotocol","uphost"]),s=w({uphost:[],retryCount:3,checkByMD5:!1,forceDirect:!1,useCdnDomain:!0,checkByServer:!1,concurrentRequestLimit:3,chunkSize:Lt,upprotocol:"https",debugLogLevel:"OFF",disableStatisticsReport:!1},e);n&&(s.upprotocol=n.replace(/:$/,""));var u=[];if(r&&(o==null?void 0:o.uphost)!=null&&(o==null?void 0:o.region)!=null&&r.warn("do not use both the uphost and region config."),i)Array.isArray(i)?u.push.apply(u,U(i)):u.push(i);else if(s==null?void 0:s.region){var c=St[s==null?void 0:s.region];s.useCdnDomain?u.push.apply(u,U(c.cdnUphost)):u.push.apply(u,U(c.srcUphost))}return w(w({},s),{uphost:u.filter(Boolean)})}var V=globalThis&&globalThis.__assign||function(){return V=Object.assign||function(o){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(o[i]=r[i])}return o},V.apply(this,arguments)};globalThis&&globalThis.__awaiter;globalThis&&globalThis.__generator;var R={PNG:"image/png",JPEG:"image/jpeg",WEBP:"image/webp",BMP:"image/bmp"};Object.keys(R).map(function(o){return R[o]});R.JPEG;export{ie as u};