VideoUploader-d6060469.js 46 KB

1
  1. /* empty css *//* empty css *//* empty css */import{d as t,q as e,ar as r,z as n,o,l as i,b4 as a,w as s,e as u,t as l,b as c,c as h,A as f,a as p,f as d,cD as g,a7 as y,cE as b,aw as v,K as m,cF as w,_}from"./index-d6660742.js";import{h as k}from"./http-3a170d74.js";/* empty css */var T,x,C,A=globalThis&&globalThis.__extends||(T=function(t,e){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}T(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});(C=x||(x={})).InvalidFile="InvalidFile",C.InvalidToken="InvalidToken",C.InvalidMetadata="InvalidMetadata",C.InvalidChunkSize="InvalidChunkSize",C.InvalidCustomVars="InvalidCustomVars",C.NotAvailableUploadHost="NotAvailableUploadHost",C.ReadCacheFailed="ReadCacheFailed",C.InvalidCacheData="InvalidCacheData",C.WriteCacheFailed="WriteCacheFailed",C.RemoveCacheFailed="RemoveCacheFailed",C.GetCanvasContextFailed="GetCanvasContextFailed",C.UnsupportedFileType="UnsupportedFileType",C.FileReaderReadFailed="FileReaderReadFailed",C.NotAvailableXMLHttpRequest="NotAvailableXMLHttpRequest",C.InvalidProgressEventTarget="InvalidProgressEventTarget",C.RequestError="RequestError";var S=function(t,e){this.name=t,this.message=e,this.stack=(new Error).stack},I=function(t){function e(e,r,n,o){var i=t.call(this,x.RequestError,n)||this;return i.code=e,i.reqId=r,i.isRequestError=!0,i.data=o,i}return A(e,t),e}(S),O=function(t){function e(e,r){return void 0===r&&(r=""),t.call(this,0,r,e)||this}return A(e,t),e}(I),P=function(){function t(t,e){this.runTask=t,this.limit=e,this.aborted=!1,this.queue=[],this.processing=[]}return t.prototype.enqueue=function(t){var e=this;return new Promise((function(r,n){e.queue.push({task:t,resolve:r,reject:n}),e.check()}))},t.prototype.run=function(t){var e=this;this.queue=this.queue.filter((function(e){return e!==t})),this.processing.push(t),this.runTask(t.task).then((function(){e.processing=e.processing.filter((function(e){return e!==t})),t.resolve(),e.check()}),(function(e){return t.reject(e)}))},t.prototype.check=function(){var t=this;if(!this.aborted){var e=this.processing.length,r=this.limit-e;this.queue.slice(0,r).forEach((function(e){t.run(e)}))}},t.prototype.abort=function(){this.queue=[],this.aborted=!0},t}(),U=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),z=globalThis&&globalThis.__assign||function(){return z=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},z.apply(this,arguments)};function j(t){var e,r,n,o,i,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s=0,u=0,l="",c=[];if(!t)return t;t=function(t){if(null==t)return"";var e,r,n,o=t+"",i="";e=r=0,n=o.length;for(var a=0;a<n;a++){var s=o.charCodeAt(a),u=null;if(s<128)r++;else if(s>127&&s<2048)u=String.fromCharCode(s>>6|192,63&s|128);else if((63488&s^55296)>0)u=String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128);else{if((64512&s^55296)>0)throw new RangeError("Unmatched trail surrogate at "+a);var l=o.charCodeAt(++a);if((64512&l^56320)>0)throw new RangeError("Unmatched lead surrogate at "+(a-1));s=((1023&s)<<10)+(1023&l)+65536,u=String.fromCharCode(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}null!==u&&(r>e&&(i+=o.slice(e,r)),i+=u,e=r=a+1)}return r>e&&(i+=o.slice(e,n)),i}(t+"");do{e=(i=t.charCodeAt(s++)<<16|t.charCodeAt(s++)<<8|t.charCodeAt(s++))>>18&63,r=i>>12&63,n=i>>6&63,o=63&i,c[u++]=a.charAt(e)+a.charAt(r)+a.charAt(n)+a.charAt(o)}while(s<t.length);switch(l=c.join(""),t.length%3){case 1:l=l.slice(0,-2)+"==";break;case 2:l=l.slice(0,-1)+"="}return l}function L(t){var e,r,n,o,i,a,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,l=0,c=[];if(!t)return t;t+="";do{e=(a=s.indexOf(t.charAt(u++))<<18|s.indexOf(t.charAt(u++))<<12|(o=s.indexOf(t.charAt(u++)))<<6|(i=s.indexOf(t.charAt(u++))))>>16&255,r=a>>8&255,n=255&a,c[l++]=64===o?String.fromCharCode(e):64===i?String.fromCharCode(e,r):String.fromCharCode(e,r,n)}while(u<t.length);return function(t){var e=[],r=0,n=0,o=0;for(t+="";r<t.length;){o=0,(n=255&t.charCodeAt(r))<=191?(n&=127,o=1):n<=223?(n&=31,o=2):n<=239?(n&=15,o=3):(n&=7,o=4);for(var i=1;i<o;++i)n=n<<6|63&t.charCodeAt(i+r);4===o?(n-=65536,e.push(String.fromCharCode(55296|n>>10&1023)),e.push(String.fromCharCode(56320|1023&n))):e.push(String.fromCharCode(n)),r+=o}return e.join("")}(c.join(""))}function E(t){return(t=j(t)).replace(/\//g,"_").replace(/\+/g,"-")}!function(t){function e(e,r,n){var o=t.call(this)||this;return o.isStopped=!1,o.destination=e&&"object"==typeof e?e:z(z(z({},e&&{next:e}),r&&{error:r}),n&&{complete:n}),o}U(e,t),e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype.next=function(t){!this.isStopped&&this.destination.next&&this.destination.next(t)},e.prototype.error=function(t){!this.isStopped&&this.destination.error&&(this.isStopped=!0,this.destination.error(t))},e.prototype.complete=function(t){!this.isStopped&&this.destination.complete&&(this.isStopped=!0,this.destination.complete(t))}}(function(){function t(){this.closed=!1}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this._unsubscribe&&this._unsubscribe())},t.prototype.add=function(t){this._unsubscribe=t},t}());var F={};({get exports(){return F},set exports(t){F=t}}).exports=function(t){var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function r(t,e){var r=t[0],n=t[1],o=t[2],i=t[3];n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[0]-680876936|0)<<7|r>>>25)+n|0)&n|~r&o)+e[1]-389564586|0)<<12|i>>>20)+r|0)&r|~i&n)+e[2]+606105819|0)<<17|o>>>15)+i|0)&i|~o&r)+e[3]-1044525330|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[4]-176418897|0)<<7|r>>>25)+n|0)&n|~r&o)+e[5]+1200080426|0)<<12|i>>>20)+r|0)&r|~i&n)+e[6]-1473231341|0)<<17|o>>>15)+i|0)&i|~o&r)+e[7]-45705983|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[8]+1770035416|0)<<7|r>>>25)+n|0)&n|~r&o)+e[9]-1958414417|0)<<12|i>>>20)+r|0)&r|~i&n)+e[10]-42063|0)<<17|o>>>15)+i|0)&i|~o&r)+e[11]-1990404162|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[12]+1804603682|0)<<7|r>>>25)+n|0)&n|~r&o)+e[13]-40341101|0)<<12|i>>>20)+r|0)&r|~i&n)+e[14]-1502002290|0)<<17|o>>>15)+i|0)&i|~o&r)+e[15]+1236535329|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[1]-165796510|0)<<5|r>>>27)+n|0)&o|n&~o)+e[6]-1069501632|0)<<9|i>>>23)+r|0)&n|r&~n)+e[11]+643717713|0)<<14|o>>>18)+i|0)&r|i&~r)+e[0]-373897302|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[5]-701558691|0)<<5|r>>>27)+n|0)&o|n&~o)+e[10]+38016083|0)<<9|i>>>23)+r|0)&n|r&~n)+e[15]-660478335|0)<<14|o>>>18)+i|0)&r|i&~r)+e[4]-405537848|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[9]+568446438|0)<<5|r>>>27)+n|0)&o|n&~o)+e[14]-1019803690|0)<<9|i>>>23)+r|0)&n|r&~n)+e[3]-187363961|0)<<14|o>>>18)+i|0)&r|i&~r)+e[8]+1163531501|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[13]-1444681467|0)<<5|r>>>27)+n|0)&o|n&~o)+e[2]-51403784|0)<<9|i>>>23)+r|0)&n|r&~n)+e[7]+1735328473|0)<<14|o>>>18)+i|0)&r|i&~r)+e[12]-1926607734|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[5]-378558|0)<<4|r>>>28)+n|0)^n^o)+e[8]-2022574463|0)<<11|i>>>21)+r|0)^r^n)+e[11]+1839030562|0)<<16|o>>>16)+i|0)^i^r)+e[14]-35309556|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[1]-1530992060|0)<<4|r>>>28)+n|0)^n^o)+e[4]+1272893353|0)<<11|i>>>21)+r|0)^r^n)+e[7]-155497632|0)<<16|o>>>16)+i|0)^i^r)+e[10]-1094730640|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[13]+681279174|0)<<4|r>>>28)+n|0)^n^o)+e[0]-358537222|0)<<11|i>>>21)+r|0)^r^n)+e[3]-722521979|0)<<16|o>>>16)+i|0)^i^r)+e[6]+76029189|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[9]-640364487|0)<<4|r>>>28)+n|0)^n^o)+e[12]-421815835|0)<<11|i>>>21)+r|0)^r^n)+e[15]+530742520|0)<<16|o>>>16)+i|0)^i^r)+e[2]-995338651|0)<<23|n>>>9)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[0]-198630844|0)<<6|r>>>26)+n|0)|~o))+e[7]+1126891415|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[14]-1416354905|0)<<15|o>>>17)+i|0)|~r))+e[5]-57434055|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[12]+1700485571|0)<<6|r>>>26)+n|0)|~o))+e[3]-1894986606|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[10]-1051523|0)<<15|o>>>17)+i|0)|~r))+e[1]-2054922799|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[8]+1873313359|0)<<6|r>>>26)+n|0)|~o))+e[15]-30611744|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[6]-1560198380|0)<<15|o>>>17)+i|0)|~r))+e[13]+1309151649|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[4]-145523070|0)<<6|r>>>26)+n|0)|~o))+e[11]-1120210379|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[2]+718787259|0)<<15|o>>>17)+i|0)|~r))+e[9]-343485551|0)<<21|n>>>11)+o|0,t[0]=r+t[0]|0,t[1]=n+t[1]|0,t[2]=o+t[2]|0,t[3]=i+t[3]|0}function n(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function o(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function i(t){var e,o,i,a,s,u,l=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=l;e+=64)r(c,n(t.substring(e-64,e)));for(o=(t=t.substring(e-64)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<o;e+=1)i[e>>2]|=t.charCodeAt(e)<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(r(c,i),e=0;e<16;e+=1)i[e]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),u=parseInt(a[1],16)||0,i[14]=s,i[15]=u,r(c,i),c}function a(t){var e,n,i,a,s,u,l=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=l;e+=64)r(c,o(t.subarray(e-64,e)));for(n=(t=e-64<l?t.subarray(e-64):new Uint8Array(0)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<n;e+=1)i[e>>2]|=t[e]<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(r(c,i),e=0;e<16;e+=1)i[e]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),u=parseInt(a[1],16)||0,i[14]=s,i[15]=u,r(c,i),c}function s(t){var r,n="";for(r=0;r<4;r+=1)n+=e[t>>8*r+4&15]+e[t>>8*r&15];return n}function u(t){var e;for(e=0;e<t.length;e+=1)t[e]=s(t[e]);return t.join("")}function l(t){return/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t))),t}function c(t,e){var r,n=t.length,o=new ArrayBuffer(n),i=new Uint8Array(o);for(r=0;r<n;r+=1)i[r]=t.charCodeAt(r);return e?i:o}function h(t){return String.fromCharCode.apply(null,new Uint8Array(t))}function f(t,e,r){var n=new Uint8Array(t.byteLength+e.byteLength);return n.set(new Uint8Array(t)),n.set(new Uint8Array(e),t.byteLength),r?n:n.buffer}function p(t){var e,r=[],n=t.length;for(e=0;e<n-1;e+=2)r.push(parseInt(t.substr(e,2),16));return String.fromCharCode.apply(String,r)}function d(){this.reset()}return u(i("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(t,e){return(t=0|t||0)<0?Math.max(t+e,0):Math.min(t,e)}ArrayBuffer.prototype.slice=function(r,n){var o,i,a,s,u=this.byteLength,l=e(r,u),c=u;return n!==t&&(c=e(n,u)),l>c?new ArrayBuffer(0):(o=c-l,i=new ArrayBuffer(o),a=new Uint8Array(i),s=new Uint8Array(this,l,o),a.set(s),i)}}(),d.prototype.append=function(t){return this.appendBinary(l(t)),this},d.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var e,o=this._buff.length;for(e=64;e<=o;e+=64)r(this._hash,n(this._buff.substring(e-64,e)));return this._buff=this._buff.substring(e-64),this},d.prototype.end=function(t){var e,r,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<o;e+=1)i[e>>2]|=n.charCodeAt(e)<<(e%4<<3);return this._finish(i,o),r=u(this._hash),t&&(r=p(r)),this.reset(),r},d.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},d.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},d.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},d.prototype._finish=function(t,e){var n,o,i,a=e;if(t[a>>2]|=128<<(a%4<<3),a>55)for(r(this._hash,t),a=0;a<16;a+=1)t[a]=0;n=(n=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(n[2],16),i=parseInt(n[1],16)||0,t[14]=o,t[15]=i,r(this._hash,t)},d.hash=function(t,e){return d.hashBinary(l(t),e)},d.hashBinary=function(t,e){var r=u(i(t));return e?p(r):r},d.ArrayBuffer=function(){this.reset()},d.ArrayBuffer.prototype.append=function(t){var e,n=f(this._buff.buffer,t,!0),i=n.length;for(this._length+=t.byteLength,e=64;e<=i;e+=64)r(this._hash,o(n.subarray(e-64,e)));return this._buff=e-64<i?new Uint8Array(n.buffer.slice(e-64)):new Uint8Array(0),this},d.ArrayBuffer.prototype.end=function(t){var e,r,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<o;e+=1)i[e>>2]|=n[e]<<(e%4<<3);return this._finish(i,o),r=u(this._hash),t&&(r=p(r)),this.reset(),r},d.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.ArrayBuffer.prototype.getState=function(){var t=d.prototype.getState.call(this);return t.buff=h(t.buff),t},d.ArrayBuffer.prototype.setState=function(t){return t.buff=c(t.buff,!0),d.prototype.setState.call(this,t)},d.ArrayBuffer.prototype.destroy=d.prototype.destroy,d.ArrayBuffer.prototype._finish=d.prototype._finish,d.ArrayBuffer.hash=function(t,e){var r=u(a(new Uint8Array(t)));return e?p(r):r},d}();const q=F;var R,B=globalThis&&globalThis.__assign||function(){return B=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},B.apply(this,arguments)},D=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function s(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))},H=globalThis&&globalThis.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},M=Math.pow(1024,2);function N(t,e){try{localStorage.removeItem(t)}catch(r){e.warn(new S(x.RemoveCacheFailed,"removeLocalFileInfo failed. key: "+t))}}function V(t){return{Authorization:"UpToken "+t}}function X(t){var e=V(t);return B({"content-type":"application/json"},e)}function G(t){return D(this,void 0,void 0,(function(){var e,r;return H(this,(function(n){switch(n.label){case 0:return[4,$(t)];case 1:return e=n.sent(),(r=new q.ArrayBuffer).append(e),[2,r.end()]}}))}))}function $(t){return new Promise((function(e,r){var n=new FileReader;n.onload=function(t){if(t.target){var n=t.target.result;e(n)}else r(new S(x.InvalidProgressEventTarget,"progress event target is undefined"))},n.onerror=function(){r(new S(x.FileReaderReadFailed,"fileReader read failed"))},n.readAsArrayBuffer(t)}))}function K(t,e){return new Promise((function(r,n){var o=function(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject)return new window.ActiveXObject("Microsoft.XMLHTTP");throw new S(x.NotAvailableXMLHttpRequest,"the current environment does not support.")}();if(o.open(e.method,t),e.onCreate&&e.onCreate(o),e.headers){var i=e.headers;Object.keys(i).forEach((function(t){o.setRequestHeader(t,i[t])}))}o.upload.addEventListener("progress",(function(t){t.lengthComputable&&e.onProgress&&e.onProgress({loaded:t.loaded,total:t.total})})),o.onreadystatechange=function(){var t=o.responseText;if(4===o.readyState){var e=o.getResponseHeader("x-reqId")||"";if(0!==o.status)if(200===o.status)try{r({data:JSON.parse(t),reqId:e})}catch(s){n(s)}else{var i="xhr request failed, code: "+o.status;t&&(i+=" response: "+t);var a=void 0;try{a=JSON.parse(t)}catch(u){}n(new I(o.status,e,i,a))}else n(new O("network error.",e))}},o.send(e.body)}))}function J(t){if(t&&t.match){var e=t.match(/(^https?)/);if(!e)return"";var r=e[1];return(e=t.match(/^https?:\/\/([^:^/]*):(\d*)/))?e[2]:"http"===r?"80":"443"}return""}function W(t){if(t&&t.match){var e=t.match(/^https?:\/\/([^:^/]*)/);return e?e[1]:""}return""}function Q(t){if(!t)throw new S(x.InvalidToken,"invalid token.");var e=t.split(":");if(1===e.length)throw new S(x.InvalidToken,"invalid token segments.");var r=e.length>3?e[1]:e[0];if(!r)throw new S(x.InvalidToken,"missing assess key field.");var n=null;try{n=JSON.parse(L(e[e.length-1].replace(/_/g,"/").replace(/-/g,"+")))}catch(i){throw new S(x.InvalidToken,"token parse failed.")}if(null==n)throw new S(x.InvalidToken,"putPolicy is null.");if(null==n.scope)throw new S(x.InvalidToken,"scope field is null.");var o=n.scope.split(":")[0];if(!o)throw new S(x.InvalidToken,"resolve bucketName failed.");return{assessKey:r,bucketName:o,scope:n.scope}}var Y,Z="z0",tt="z1",et="z2",rt="na0",nt="as0",ot="cn-east-2",it=((R={})[Z]={srcUphost:["up.qiniup.com"],cdnUphost:["upload.qiniup.com"]},R[tt]={srcUphost:["up-z1.qiniup.com"],cdnUphost:["upload-z1.qiniup.com"]},R[et]={srcUphost:["up-z2.qiniup.com"],cdnUphost:["upload-z2.qiniup.com"]},R[rt]={srcUphost:["up-na0.qiniup.com"],cdnUphost:["upload-na0.qiniup.com"]},R[nt]={srcUphost:["up-as0.qiniup.com"],cdnUphost:["upload-as0.qiniup.com"]},R[ot]={srcUphost:["up-cn-east-2.qiniup.com"],cdnUphost:["upload-cn-east-2.qiniup.com"]},R),at=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};Y=function(t,e,r,n){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(n){var o=encodeURIComponent(at(n))+r;return Array.isArray(t[n])?t[n].map((function(t){return o+encodeURIComponent(at(t))})).join(e):o+encodeURIComponent(at(t[n]))})).filter(Boolean).join(e):n?encodeURIComponent(at(n))+r+encodeURIComponent(at(t)):""};var st=globalThis&&globalThis.__assign||function(){return st=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},st.apply(this,arguments)},ut=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function s(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))},lt=globalThis&&globalThis.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function ct(t,e,r){return ut(this,void 0,void 0,(function(){var n;return lt(this,(function(o){return n=Y({ak:t,bucket:e}),[2,K(r+"://api.qiniu.com/v2/query?"+n,{method:"GET"})]}))}))}function ht(t,e,r){var n=r.url,o=r.id;return n+"/buckets/"+t+"/objects/"+(null!=e?E(e):"~")+"/uploads/"+o}function ft(t,e,r,n,o){var i=ht(Q(t).bucketName,e,n)+"/"+r,a=function(t){var e=V(t);return B({"content-type":"application/octet-stream"},e)}(t);return o.md5&&(a["Content-MD5"]=o.md5),K(i,st(st({},o),{method:"PUT",headers:a}))}function pt(t,e){return ut(this,void 0,void 0,(function(){var r,n,o,i,a;return lt(this,(function(s){switch(s.label){case 0:return r=function(t,e){var r=Lt({},t),n=r.upprotocol,o=r.uphost,i=Et(r,["upprotocol","uphost"]),a=Lt({uphost:[],retryCount:3,checkByMD5:!1,forceDirect:!1,useCdnDomain:!0,checkByServer:!1,concurrentRequestLimit:3,chunkSize:mt,upprotocol:"https",debugLogLevel:"OFF",disableStatisticsReport:!1},i);n&&(a.upprotocol=n.replace(/:$/,""));var s=[];e&&null!=(null==t?void 0:t.uphost)&&null!=(null==t?void 0:t.region)&&e.warn("do not use both the uphost and region config.");if(o)Array.isArray(o)?s.push.apply(s,qt(o)):s.push(o);else if(null==a?void 0:a.region){var u=it[null==a?void 0:a.region];a.useCdnDomain?s.push.apply(s,qt(u.cdnUphost)):s.push.apply(s,qt(u.srcUphost))}return Lt(Lt({},a),{uphost:s.filter(Boolean)})}(t),n=r.upprotocol,r.uphost.length>0?[2,n+"://"+r.uphost[0]]:[4,ct((o=Q(e)).assessKey,o.bucketName,n)];case 1:return i=s.sent(),a=i.data.up.acc.main,[2,n+"://"+a[0]]}}))}))}var dt=globalThis&&globalThis.__assign||function(){return dt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},dt.apply(this,arguments)},gt=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function s(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))},yt=globalThis&&globalThis.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},bt=globalThis&&globalThis.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},vt=globalThis&&globalThis.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t},mt=4,wt=[0,502,503,504,599],_t=vt(wt,[612]),kt=Math.pow(1024,3),Tt=function(){function t(t,e,r,n){this.hostPool=r,this.logger=n,this.aborted=!1,this.retryCount=0,this.xhrList=[],this.config=t.config,n.info("config inited.",this.config),this.putExtra=dt({fname:""},t.putExtra),n.info("putExtra inited.",this.putExtra),this.key=t.key,this.file=t.file,this.token=t.token,this.onData=e.onData,this.onError=e.onError,this.onComplete=e.onComplete;try{var o=Q(this.token);this.bucketName=o.bucketName,this.assessKey=o.assessKey}catch(i){n.error("get putPolicy from token failed.",i),this.onError(i)}}return t.prototype.checkAndUpdateUploadHost=function(){return gt(this,void 0,void 0,(function(){var t;return yt(this,(function(e){switch(e.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(null==(t=e.sent()))throw new S(x.NotAvailableUploadHost,"no available upload host.");return null!=this.uploadHost&&this.uploadHost.host!==t.host?this.logger.warn("host switches from "+this.uploadHost.host+" to "+t.host+"."):this.logger.info("use host "+t.host+"."),this.uploadHost=t,[2]}}))}))},t.prototype.checkAndUnfreezeHost=function(){this.logger.info("check unfreeze host."),null!=this.uploadHost&&this.uploadHost.isFrozen()&&(this.logger.warn(this.uploadHost.host+" will be unfrozen."),this.uploadHost.unfreeze())},t.prototype.checkAndFreezeHost=function(t){this.logger.info("check freeze host."),t instanceof I&&null!=this.uploadHost&&wt.includes(t.code)&&(this.logger.warn(this.uploadHost.host+" will be temporarily frozen."),this.uploadHost.freeze())},t.prototype.handleError=function(t){this.logger.error(t.message),this.onError(t)},t.prototype.putFile=function(){return gt(this,void 0,void 0,(function(){var t,e,r;return yt(this,(function(n){switch(n.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*kt)return this.handleError(new S(x.InvalidFile,"file size exceed maximum value 10000G")),[2];if(this.putExtra.customVars&&(o=this.putExtra.customVars,!Object.keys(o).every((function(t){return 0===t.indexOf("x:")}))))return this.handleError(new S(x.InvalidCustomVars,"customVars key should start width x:")),[2];if(this.putExtra.metadata&&!function(t){return Object.keys(t).every((function(t){return 0===t.indexOf("x-qn-meta-")}))}(this.putExtra.metadata))return this.handleError(new S(x.InvalidMetadata,"metadata key should start with x-qn-meta-")),[2];n.label=1;case 1:return n.trys.push([1,4,,5]),this.uploadAt=(new Date).getTime(),[4,this.checkAndUpdateUploadHost()];case 2:return n.sent(),[4,this.run()];case 3:return t=n.sent(),this.onComplete(t.data),this.checkAndUnfreezeHost(),this.sendLog(t.reqId,200),[2];case 4:return e=n.sent(),this.aborted?(this.logger.warn("upload is aborted."),this.sendLog("",-2),[2]):(this.clear(),this.logger.error(e),e instanceof I&&(this.sendLog(e.reqId,e.code),this.checkAndFreezeHost(e),r=++this.retryCount<=this.config.retryCount,_t.includes(e.code)&&r)?(this.logger.warn("error auto retry: "+this.retryCount+"/"+this.config.retryCount+"."),this.putFile(),[2]):(this.onError(e),[3,5]));case 5:return[2]}var o}))}))},t.prototype.clear=function(){this.xhrList.forEach((function(t){t.onreadystatechange=null,t.abort()})),this.xhrList=[],this.logger.info("cleanup uploading xhr.")},t.prototype.stop=function(){this.logger.info("aborted."),this.clear(),this.aborted=!0},t.prototype.addXhr=function(t){this.xhrList.push(t)},t.prototype.sendLog=function(t,e){var r,n;this.logger.report({code:e,reqId:t,remoteIp:"",upType:"jssdk-h5",size:this.file.size,time:Math.floor(this.uploadAt/1e3),port:J(null===(r=this.uploadHost)||void 0===r?void 0:r.getUrl()),host:W(null===(n=this.uploadHost)||void 0===n?void 0:n.getUrl()),bytesSent:this.progress?this.progress.total.loaded:0,duration:Math.floor(((new Date).getTime()-this.uploadAt)/1e3)})},t.prototype.getProgressInfoItem=function(t,e,r){return dt({size:e,loaded:t,percent:t/e*100},null==r?{}:{fromCache:r})},t}(),xt=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ct=globalThis&&globalThis.__assign||function(){return Ct=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ct.apply(this,arguments)},At=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function s(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))},St=globalThis&&globalThis.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}xt(e,t),e.prototype.run=function(){return At(this,void 0,void 0,(function(){var t,e,r,n,o,i=this;return St(this,(function(a){switch(a.label){case 0:if(this.logger.info("start run Resume."),!this.config.chunkSize||(s=this.config.chunkSize,!/^[1-9]\d*$/.test(String(s))))throw new S(x.InvalidChunkSize,"chunkSize must be a positive integer");if(this.config.chunkSize>1024)throw new S(x.InvalidChunkSize,"chunkSize maximum value is 1024");return[4,this.initBeforeUploadChunks()];case 1:a.sent(),t=new P((function(e){return At(i,void 0,void 0,(function(){return St(this,(function(r){switch(r.label){case 0:if(this.aborted)throw t.abort(),new Error("pool is aborted");return[4,this.uploadChunk(e)];case 1:return r.sent(),[2]}}))}))}),this.config.concurrentRequestLimit),e=null,r=this.getLocalKey(),n=this.chunks.map((function(e,r){return t.enqueue({chunk:e,index:r})})),a.label=2;case 2:return a.trys.push([2,5,,6]),[4,Promise.all(n)];case 3:return a.sent(),[4,this.mkFileReq()];case 4:return e=a.sent(),[3,6];case 5:throw(o=a.sent())instanceof I&&(612===o.code||400===o.code)&&N(r,this.logger),o;case 6:return N(r,this.logger),[2,e]}var s}))}))},e.prototype.uploadChunk=function(t){return At(this,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,l,c=this;return St(this,(function(h){switch(h.label){case 0:return e=t.index,r=t.chunk,n=this.cachedUploadedList[e],this.logger.info("upload part "+e+", cache:",n),o=this.config.checkByMD5,i=function(){c.usedCacheList[e]=!0,c.updateChunkProgress(r.size,e),c.uploadedList[e]=n,c.updateLocalCache()},n&&!o?(i(),[2]):[4,G(r)];case 1:return a=h.sent(),this.logger.info("computed part md5.",a),n&&a===n.md5?(i(),[2]):(this.usedCacheList[e]=!1,s=function(t){c.updateChunkProgress(t.loaded,e)},u={body:r,md5:this.config.checkByServer?a:void 0,onProgress:s,onCreate:function(t){return c.addXhr(t)}},this.logger.info("part "+e+" start uploading."),[4,ft(this.token,this.key,t.index+1,this.getUploadInfo(),u)]);case 2:return l=h.sent(),this.logger.info("part "+e+" upload completed."),s({loaded:r.size,total:r.size}),this.uploadedList[e]={etag:l.data.etag,md5:l.data.md5,size:r.size},this.updateLocalCache(),[2]}}))}))},e.prototype.mkFileReq=function(){return At(this,void 0,void 0,(function(){var t,e,r=this;return St(this,(function(n){switch(n.label){case 0:return t=Ct(Ct(Ct({parts:this.uploadedList.map((function(t,e){return{etag:t.etag,partNumber:e+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,(o=this.token,i=this.key,a=this.getUploadInfo(),s={onCreate:function(t){return r.addXhr(t)},body:JSON.stringify(t)},K(ht(Q(o).bucketName,i,a),st(st({},s),{method:"POST",headers:X(o)})))];case 1:return e=n.sent(),this.logger.info("finish Resume Progress."),this.updateMkFileProgress(1),[2,e]}var o,i,a,s}))}))},e.prototype.initBeforeUploadChunks=function(){return At(this,void 0,void 0,(function(){var t,e,r;return St(this,(function(n){switch(n.label){case 0:return this.uploadedList=[],this.usedCacheList=[],(t=function(t,e){var r=null;try{r=localStorage.getItem(t)}catch(n){e.warn(new S(x.ReadCacheFailed,"getLocalFileInfo failed. key: "+t))}if(null==r)return null;var o=null;try{o=JSON.parse(r)}catch(i){N(t,e),e.warn(new S(x.InvalidCacheData,"getLocalFileInfo failed to parse. key: "+t))}return o}(this.getLocalKey(),this.logger))?[3,2]:(this.logger.info("init upload parts from api."),[4,(o=this.token,i=this.bucketName,a=this.key,s=this.uploadHost.getUrl(),K(s+"/buckets/"+i+"/objects/"+(null!=a?E(a):"~")+"/uploads",{method:"POST",headers:V(o)}))]);case 1:return e=n.sent(),this.logger.info("initd upload parts of id: "+e.data.uploadId+"."),this.uploadId=e.data.uploadId,this.cachedUploadedList=[],[3,3];case 2:r=["resume upload parts from local cache,","total "+t.data.length+" part,","id is "+t.id+"."],this.logger.info(r.join(" ")),this.cachedUploadedList=t.data,this.uploadId=t.id,n.label=3;case 3:return this.chunks=function(t,e){var r=e*M;if(r>t.size)r=t.size;else for(;t.size>1e4*r;)r*=2;for(var n=[],o=Math.ceil(t.size/r),i=0;i<o;i++){var a=t.slice(r*i,i===o-1?t.size:r*(i+1));n.push(a)}return n}(this.file,this.config.chunkSize),this.loaded={mkFileProgress:0,chunks:this.chunks.map((function(t){return 0}))},this.notifyResumeProgress(),[2]}var o,i,a,s}))}))},e.prototype.getUploadInfo=function(){return{id:this.uploadId,url:this.uploadHost.getUrl()}},e.prototype.getLocalKey=function(){return t=this.file.name,e=this.key,r=this.file.size,"qiniu_js_sdk_upload_file_name_"+t+(null==e?"_":"_key_"+e+"_")+"size_"+r;var t,e,r},e.prototype.updateLocalCache=function(){!function(t,e,r){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){r.warn(new S(x.WriteCacheFailed,"setLocalFileInfo failed: "+t))}}(this.getLocalKey(),{id:this.uploadId,data:this.uploadedList},this.logger)},e.prototype.updateChunkProgress=function(t,e){this.loaded.chunks[e]=t,this.notifyResumeProgress()},e.prototype.updateMkFileProgress=function(t){this.loaded.mkFileProgress=t,this.notifyResumeProgress()},e.prototype.notifyResumeProgress=function(){var t,e=this;this.progress={total:this.getProgressInfoItem((t=this.loaded.chunks,t.reduce((function(t,e){return t+e}),0)+this.loaded.mkFileProgress),this.file.size+1),chunks:this.chunks.map((function(t,r){var n=e.usedCacheList[r];return e.getProgressInfoItem(e.loaded.chunks[r],t.size,n)})),uploadInfo:{id:this.uploadId,url:this.uploadHost.getUrl()}},this.onData(this.progress)}}(Tt);var It=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function s(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))},Ot=globalThis&&globalThis.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Pt=function(){function t(){this.crc=-1,this.table=this.makeTable()}return t.prototype.makeTable=function(){for(var t=new Array,e=0;e<256;e++){for(var r=e,n=0;n<8;n++)1&r?r=r>>>1^3988292384:r>>>=1;t[e]=r}return t},t.prototype.append=function(t){for(var e=this.crc,r=0;r<t.byteLength;r++)e=e>>>8^this.table[255&(e^t[r])];this.crc=e},t.prototype.compute=function(){return(-1^this.crc)>>>0},t.prototype.readAsUint8Array=function(t){return It(this,void 0,void 0,(function(){var e;return Ot(this,(function(r){switch(r.label){case 0:return"function"!=typeof t.arrayBuffer?[3,2]:(e=Uint8Array.bind,[4,t.arrayBuffer()]);case 1:return[2,new(e.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[2,new Promise((function(e,r){var n=new FileReader;n.onload=function(){null!=n.result&&"string"!=typeof n.result?e(new Uint8Array(n.result)):r()},n.readAsArrayBuffer(t)}))]}}))}))},t.prototype.file=function(t){return It(this,void 0,void 0,(function(){var e,r,n,o,i,a;return Ot(this,(function(s){switch(s.label){case 0:return t.size<=M?(e=this.append,[4,this.readAsUint8Array(t)]):[3,2];case 1:return e.apply(this,[s.sent()]),[2,this.compute()];case 2:r=Math.ceil(t.size/M),n=0,s.label=3;case 3:return n<r?(o=n*M,i=n===r-1?t.size:o+M,[4,this.readAsUint8Array(t.slice(o,i))]):[3,6];case 4:a=s.sent(),this.append(new Uint8Array(a)),s.label=5;case 5:return n++,[3,3];case 6:return[2,this.compute()]}}))}))},t.file=function(e){return(new t).file(e)},t}(),Ut=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),zt=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function s(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))},jt=globalThis&&globalThis.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Ut(e,t),e.prototype.run=function(){return zt(this,void 0,void 0,(function(){var t,e,r,n,o=this;return jt(this,(function(i){switch(i.label){case 0:return this.logger.info("start run Direct."),(t=new FormData).append("file",this.file),t.append("token",this.token),null!=this.key&&t.append("key",this.key),t.append("fname",this.putExtra.fname),this.config.checkByServer?[4,Pt.file(this.file)]:[3,2];case 1:e=i.sent(),t.append("crc32",e.toString()),i.label=2;case 2:return this.putExtra.customVars&&(this.logger.info("init customVars."),r=this.putExtra.customVars,Object.keys(r).forEach((function(e){return t.append(e,r[e].toString())})),this.logger.info("customVars inited.")),this.logger.info("formData inited."),[4,(a=this.uploadHost.getUrl(),s=t,u={onProgress:function(t){o.updateDirectProgress(t.loaded,t.total)},onCreate:function(t){return o.addXhr(t)}},K(a,st({method:"POST",body:s},u)))];case 3:return n=i.sent(),this.logger.info("Direct progress finish."),this.finishDirectProgress(),[2,n]}var a,s,u}))}))},e.prototype.updateDirectProgress=function(t,e){this.progress={total:this.getProgressInfoItem(t,e+1)},this.onData(this.progress)},e.prototype.finishDirectProgress=function(){if(!this.progress)return this.logger.warn("progress is null."),this.progress={total:this.getProgressInfoItem(this.file.size,this.file.size)},void this.onData(this.progress);var t=this.progress.total;this.progress={total:this.getProgressInfoItem(t.loaded+1,t.size)},this.onData(this.progress)}}(Tt);globalThis&&globalThis.__read;globalThis&&globalThis.__spread,globalThis&&globalThis.__awaiter,globalThis&&globalThis.__generator;globalThis&&globalThis.__read;globalThis&&globalThis.__spread;var Lt=globalThis&&globalThis.__assign||function(){return Lt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Lt.apply(this,arguments)},Et=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},Ft=globalThis&&globalThis.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},qt=globalThis&&globalThis.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ft(arguments[e]));return t};var Rt=globalThis&&globalThis.__assign||function(){return Rt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Rt.apply(this,arguments)};globalThis&&globalThis.__awaiter,globalThis&&globalThis.__generator;var Bt={PNG:"image/png",JPEG:"image/jpeg",WEBP:"image/webp",BMP:"image/bmp"};Object.keys(Bt).map((function(t){return Bt[t]}));const Dt={class:"el-upload__text"},Ht={class:"el-upload__tip"},Mt={key:0},Nt=_(t({__name:"VideoUploader",props:{acceptType:{default:".mp4"},acceptTypeDesc:{default:".mp4"},isMultiple:{type:Boolean,default:!0},isLimitSize:{type:Boolean,default:!1},isShowTips:{type:Boolean,default:!1},maxFileSize:{default:1e3},isCheckName:{type:Boolean,default:!0},limitNum:{default:10},formType:{default:"file"},buttonText:{default:"上传文件"},fileList:{default:[]},public_video_url:{default:""}},emits:["success","fileRemove"],setup(t,{emit:_}){const T=t,x=e(""),C=e({}),A=e(""),S=e({}),I=e(0),O=e(!1),P=r("video"),U=e({}),z=e([]),j=async()=>{try{const e=await k.get("/qiniu/upload/token",t);A.value=await e.data,A.value&&(S.value={Authorization:`${A.value}`}),pt({checkByServer:!0,checkByMD5:!0,forceDirect:!1,useCdnDomain:!0,disableStatisticsReport:!1,retryCount:6,region:Z,debugLogLevel:"INFO"},A.value).then((t=>{x.value=t}))}catch(e){console.error(e),y.error("获取上传凭证失败")}var t},L=t=>{const e=t.name.split(".")[0];if(t.name,!/^\d+$/.test(e)&&T.isCheckName)return y.error("文件命名错误,请以数字命名,例:1.mp4; 11.mp4; 333.mp4"),!1;const r=t.type;const n=T.acceptTypeDesc.split("/").map((t=>(t=>{let e="";switch(t){case".mp4":e="mp4";break;case".avi":e="avi";break;case".wmv":e="wmv"}return e})(t))).filter((t=>r.indexOf(t)>-1)),o=T.acceptTypeDesc.replace("/",", ");if(n.length<1)return y.error(`仅支持格式为${o}的图片`),!1;if(t.size/1024/1024>T.maxFileSize&&T.isLimitSize)return y.error(`文件大小不能超过${T.maxFileSize}MB!`),!1;O.value=!0;const i=`${Date.now()}_${t.name}`;if(C.value={key:`${i}`,token:A.value,"x:video_id":P.value.id},!R(t,!1))return R(t);U.value=b.service({text:"正在上传视频",background:"rgba(0,0,0,.2)"})},E=t=>{I.value=Math.floor(t.loaded/t.total*100)},F=(t,e)=>{t&&"success"===t.status&&_("fileRemove",t)},q=(t,e,r)=>{_("success",t),T.public_video_url,z.value.push(t),T.fileList.push({name:t.fname,url:T.public_video_url,...t}),y.success("上传成功"),r.length==z.value.length&&(U.value.close(),O.value=!1)},R=(t,e=!0)=>{const r=t.name;return B.value.includes(r)?(e&&v.alert(`上传失败,《${r}》文件名已存在,请修改后重新上传`),!1):(B.value.push(r),!0)},B=e([]);return n((()=>{j()})),(e,r)=>{const n=m,y=w;return o(),i(y,{class:"w-auto",action:x.value,headers:S.value,"list-type":"text","file-list":T.fileList,data:C.value,multiple:T.isMultiple,accept:T.acceptType,"auto-upload":!0,"on-remove":F,"show-file-list":!0,"before-upload":L,"on-progress":E,"on-success":q},a({default:s((()=>[u("div",Dt,[p(n,{class:"avatar-uploader-icon"},{default:s((()=>[p(d(g))])),_:1}),u("span",null,l(T.buttonText),1)])])),_:2},[!T.isDisableUpload&&t.isShowTips?{name:"tip",fn:s((()=>[u("div",Ht,[u("span",null,"支持"+l(t.acceptTypeDesc)+";",1),c(),t.isLimitSize?(o(),h("span",Mt,"文件大小不能超过"+l(T.maxFileSize)+"M",1)):f("",!0)])])),key:"0"}:void 0]),1032,["action","headers","file-list","data","multiple","accept"])}}}),[["__scopeId","data-v-f738cd19"]]);export{Nt as _};