tt-uploader 1.3.0 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TTUploader=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){a(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,r(s.key),s)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,i){return(t=r(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(N){return!1}}();return function(){var r,i=u(e);if(t){var s=u(this).constructor;r=Reflect.construct(i,arguments,s)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,r)}}function f(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),r}var _={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new s(i,n||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,o=new Array(n);s<n;s++)o[s]=i[s].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},a.prototype.emit=function(e,t,i,s,n,o){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,i),!0;case 4:return l.fn.call(l.context,t,i,s),!0;case 5:return l.fn.call(l.context,t,i,s,n),!0;case 6:return l.fn.call(l.context,t,i,s,n,o),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,i);break;case 4:l[u].fn.call(l[u].context,t,i,s);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||s&&!a.once||i&&a.context!==i||o(this,n);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||s&&!a[c].once||i&&a[c].context!==i)&&u.push(a[c]);u.length?this._events[n]=1===u.length?u[0]:u:o(this,n)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(_);var x=v(_.exports),k={region:"cn-north-1",getSliceFunc:null,uploadSliceCount:5,retryUploadTime:2,retryTaskTime:2,requestTimeout:3e5,uploadTimeout:18e5,retryInterval:1e3,schema:"https",useLocalStorage:!0,taskParallelLimit:3},M=function(){return(M=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,n=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(w(arguments[t]));return e}var T,N,C,D=function(e,t){var r,i,s=function(e){var t=document.createElement("a");return t.href=e,t},n=window.screen.width,o=window.screen.height,a=window.navigator.appVersion,c=window.navigator.userAgent,u=window.navigator.language,l=document.referrer,h=l?s(l).hostname:"",d=function(e){var t=s(e).search;t=t.slice(1);var r={};return t.split("&").forEach((function(e){var t,i,s=e.split("=");s.length&&(t=s[0],i=s[1]),i&&(i=i.replace(/\%/g,"%25")),r[t]=decodeURIComponent(void 0===i?"":i)})),r}(window.location.href),f="",p="",g="",y=""+parseFloat(a);-1!==(r=c.indexOf("Opera"))&&(g="Opera",y=c.substring(r+6),-1!==(r=c.indexOf("Version"))&&(y=c.substring(r+8))),-1!==(r=c.indexOf("Edge"))?(g="Microsoft Edge",y=c.substring(r+5)):-1!==(r=c.indexOf("MSIE"))?(g="Microsoft Internet Explorer",y=c.substring(r+5)):-1!==c.indexOf("Chrome")?-1!==(r=c.indexOf("MicroMessenger"))?(g="weixin",y=c.substring(r+15,r+20)):-1!==(r=c.indexOf("MQQBrowser"))?(g="qqbrowser",y=c.substring(r+11,r+15)):-1!==(r=c.indexOf("Chrome"))&&(g="Chrome",y=c.substring(r+7)):-1!==c.indexOf("Safari")?-1!==(r=c.indexOf("QQ"))?(g="qqbrowser",y=c.substring(r+10,r+16)):-1!==(r=c.indexOf("Safari"))&&(g="Safari",y=c.substring(r+7),-1!==(r=c.indexOf("Version"))&&(y=c.substring(r+8))):-1!==(r=c.indexOf("Firefox"))?(g="Firefox",y=c.substring(r+8)):-1!==(r=c.indexOf("MicroMessenger"))?(g="weixin",y=c.substring(r+15,r+20)):-1!==(r=c.indexOf("QQ"))&&(g="qqbrowser",y=c.substring(r+3,r+8)),-1!==(i=y.indexOf(";"))&&(y=y.substring(0,i)),-1!==(i=y.indexOf(" "))&&(y=y.substring(0,i)),-1!==(i=y.indexOf(")"))&&(y=y.substring(0,i));for(var v,m,_=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(a)?"wap":"web",x=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],k=0;k<x.length;k++){var M=x[k];if(M.r.test(c)){f=M.s;break}}function w(e,t){var r=e.exec(t);return r&&r[1]?r[1]:""}switch(/Windows/.test(f)&&(p=w(/Windows (.*)/,f),f="windows"),f){case"Mac OS X":p=w(/Mac OS X (10[\.\_\d]+)/,c),f="mac";break;case"Android":(m=w(/Android ([\.\_\d]+)/,v=c))||(m=w(/Android\/([\.\_\d]+)/,v)),p=m,f="android";break;case"iOS":p=(p=/OS (\d+)_(\d+)_?(\d+)?/.exec(a))?p[1]+"."+p[2]+"."+(0|p[3]):"",f="ios"}var b=e?function(){var e=t?"_tea_utm_cache_"+t:"_tea_utm_cache",r={},i={utm_source:d.utm_source,utm_medium:d.utm_medium,utm_campaign:d.utm_campaign,utm_term:d.utm_term,utm_content:d.utm_content};try{var s=window.sessionStorage,n=!1;for(var o in i)i[o]&&(r[o]=i[o],n=!0);if(n)s.setItem(e,JSON.stringify(r));else{var a=s.getItem(e);a&&(r=JSON.parse(a))}}catch(c){return i}return r}():{};return{browser:g,browser_version:y,platform:_,os_name:f,os_version:p,userAgent:c,screen_width:n,screen_height:o,device_model:function(e){var t="";try{if("android"===e)navigator.userAgent.split(";").forEach((function(e){e.indexOf("Build/")>-1&&(t=e.slice(0,e.indexOf("Build/")))}));else if("ios"===e||"mac"===e){var r=navigator.userAgent.replace("Mozilla/5.0 (",""),i=r.indexOf(";");t=r.slice(0,i)}}catch(s){}return t.trim()}(f),language:u,referrer:l,referrer_host:h,utm_source:b.utm_source,utm_medium:b.utm_medium,utm_campaign:b.utm_campaign,utm_term:b.utm_term,utm_content:b.utm_content,isSupportBeacon:("ios"!==f||"safari"!==g)&&(!(!window.navigator||!window.navigator.sendBeacon)||void 0)}},I=(N=T={exports:{}},C=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var i in r)t[i]=r[i]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(i){function s(){}function n(t,r,n){if("undefined"!=typeof document){"number"==typeof(n=e({path:"/"},s.defaults,n)).expires&&(n.expires=new Date(1*new Date+864e5*n.expires)),n.expires=n.expires?n.expires.toUTCString():"";try{var o=JSON.stringify(r);/^[\{\[]/.test(o)&&(r=o)}catch(u){}r=i.write?i.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in n)n[c]&&(a+="; "+c,!0!==n[c]&&(a+="="+n[c].split(";")[0]));return document.cookie=t+"="+r+a}}function o(e,r){if("undefined"!=typeof document){for(var s={},n=document.cookie?document.cookie.split("; "):[],o=0;o<n.length;o++){var a=n[o].split("="),c=a.slice(1).join("=");r||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=t(a[0]);if(c=(i.read||i)(c,u)||t(c),r)try{c=JSON.parse(c)}catch(l){}if(s[u]=c,e===u)break}catch(l){}}return e?s[e]:s}}return s.set=n,s.get=function(e){return o(e,!1)},s.getJSON=function(e){return o(e,!0)},s.remove=function(t,r){n(t,"",e(r,{expires:-1}))},s.defaults={},s.withConverter=r,s}((function(){}))},N.exports=C(),T.exports),O=function(){function e(){this.cache={}}return e.prototype.setItem=function(e,t){this.cache[e]=t},e.prototype.getItem=function(e){return this.cache[e]},e.prototype.removeItem=function(e){this.cache[e]=void 0},e}(),S={getItem:function(e){try{var t=localStorage.getItem(e),r=t;try{t&&"string"==typeof t&&(r=JSON.parse(t))}catch(i){}return r||void 0}catch(i){}},setItem:function(e,t){try{var r="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(e,r)}catch(i){}},removeItem:function(e){try{localStorage.removeItem(e)}catch(t){}},getCookie:function(e){try{var t=document.cookie.match(new RegExp("(?:^|;)\\s*"+e+"=([^;]+)")),r=t?t[1]:"";return decodeURIComponent(r)}catch(i){return""}},setCookie:function(e,t,r){try{var i=+new Date+r;I.set(e,t,{expires:new Date(i),path:"/",domain:document.domain.split(".").slice(-2).join(".")})}catch(s){}},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(N){return!1}}()},E=function(){function e(e){this._storage=!e&&S.isSupportLS?S:new O}return e.prototype.getItem=function(e){return this._storage.getItem(e)},e.prototype.setItem=function(e,t){this._storage.setItem(e,t)},e.prototype.getCookie=function(e){return this._storage.getCookie(e)},e.prototype.setCookie=function(e,t,r){this._storage.setCookie(e,t,r)},e.prototype.removeItem=function(e){this._storage.removeItem(e)},e}(),A={cn:"https://mcs.snssdk.com",sg:"https://sgali-mcs.byteoversea.com",va:"https://maliva-mcs.byteoversea.com"},z="/v1/user/webid",j=4001,U=4e3,R=4002,L=4003,P=500,F=function(e,t){return t?"__tea_cache_tokens_"+e:"__tea_cache_events_"+e},B=function(e,t,r,i){try{var s,n=e.match(/\/v\d\//);s=n?n[0]:-1!==e.indexOf("/v1/")?"/v1/":"/v2/";var o=e.split(s)[0];if(!o)return void i(e,t,j);t.forEach((function(s){var n=function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&(t+="&"+r+"="+encodeURIComponent(JSON.stringify(e[r])));return"&"===t[0]?t.slice(1):t}(s),a=new Image(1,1);a.onload=function(){a=null,r&&r()},a.onerror=function(){a=null,i&&i(e,t,U)},a.src=o+"/v1/gif?"+n}))}catch(a){i&&i(e,t,R,a.message)}},q=function(e,t,r,i,s,n,o,a){var c,u,l,h,d,f,p=window.navigator.userAgent,g=-1!==window.navigator.appName.indexOf("Microsoft Internet Explorer")&&(-1!==p.indexOf("MSIE 8.0")||-1!==p.indexOf("MSIE 9.0")),y=!!r;if(!y&&g)B(e,t,i,s);else if(!y&&o)return D(!1).isSupportBeacon?(a&&a(),void(window.navigator.sendBeacon(e,JSON.stringify(t))?i():s(e,t,L))):void B(e,t,i,s);n&&delete t.app_key,c=e,u=t,l=i,h=s,d=r,(f=new XMLHttpRequest).open("POST",""+c,!0),f.setRequestHeader("Content-Type","application/json; charset=utf-8"),d&&f.setRequestHeader("X-MCS-AppKey",""+d),f.onload=function(){if(l){var e=null;if(f.responseText){try{e=JSON.parse(f.responseText)}catch(t){e={}}l(e)}}},f.onerror=function(){f.abort(),h&&h(u,P)},f.send(JSON.stringify(u))};function H(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,H)}var K,Q=function(){return H().replace(/-/g,"").slice(0,19)},Y=function(){function e(e,t){this.browser=D(!0,e.app_id),this.config=e,this.cfg=t,this.storage=new E(!1),this.appInfo=e.app_key||e.app_id,this.isNoWebid=e.disable_webid,this.isNoSsid=e.disable_webid||e.disable_ssid,this.domain=e.channel_domain||A[e.channel],this.tokenReady=!1,this.checkExp=e.checkExp||!1,this.enableCookie=e.cross_subdomain||!1,this.expiresTime=this.enableCookie?94608e6:0,this.fetchUrl=""+this.domain+z}return e.prototype._getToken=function(){this.tokensKey=F(this.appInfo,!0),this.cookieKey="__tea_cookie_tokens_"+this.appInfo;var e=this.storage.getItem(this.tokensKey);if(this.enableCookie){var t=this.storage.getCookie(this.cookieKey);if(t){t=decodeURIComponent(t);var r=(t=JSON.parse(t)).user_unique_id,i=t.web_id,s=t.timestamp,n=t.ssid;this._setToken(i,r,n,s)}else{if(!e)return void this._requestWebId();this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(e)),this.expiresTime),this._checkLocal(e)}}else{if(!e)return void this._requestWebId();this._checkLocal(e)}},e.prototype._checkLocal=function(e){if(!e.web_id){var t=this.storage.getCookie("tt_webid"),r=this.storage.getCookie("__tea_sdk__ssid"),i=this.storage.getCookie("__tea_sdk__user_unique_id");if(t&&r&&i){var s={web_id:t,ssid:r,user_unique_id:i,timestamp:Date.now()};this.storage.setItem(this.tokensKey,s)}}var n=this.storage.getItem(this.tokensKey),o=(i=n.user_unique_id,t=n.web_id,n.timestamp);r=n.ssid,t&&i?this._setToken(t,i,r,o):this._requestWebId()},e.prototype._setToken=function(e,t,r,i){if(this.uuid=t,this.web_id=e,this.ssid=r,this.checkExp){var s=Date.now()-parseFloat(i);if(s>7344e6)return void this._requestWebId();if(s>432e7)return void this._updateWebId(e)}this._complete(e,t,r)},e.prototype._complete=function(e,t,r){this.cfg.envInfo.user.ssid=r,this.cfg.envInfo.user.web_id=e,this.cfg.envInfo.user.user_unique_id=t,this.tokenReady=!0},e.prototype._requestWebId=function(){this.isNoWebid?this._setwebId({web_id:Q(),ssid:""}):this._fetchWebId(this.fetchUrl,!1)},e.prototype._updateWebId=function(e){var t=""+this.domain+z+"/"+e+"/update";this._fetchWebId(t,!0)},e.prototype._fetchWebId=function(e,t){var r=this;this.isGetWebId=!0,q(e,{app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:this.browser.userAgent,referer:this.browser.referrer,user_unique_id:""},this.config.app_key,(function(e){if(e&&0===e.e)if(t){var i={web_id:r.web_id,ssid:r.ssid,user_unique_id:r.uuid,timestamp:Date.now()};r.enableCookie&&r.storage.setCookie(r.cookieKey,encodeURIComponent(JSON.stringify(i)),r.expiresTime),r.storage.setItem(r.tokensKey,i),r._complete(r.web_id,r.uuid,r.ssid),r.isGetSsid?r._requestSsId():r.callback&&r.callback()}else r.isGetWebId=!1,r._setwebId(e),r.isGetSsid?r._requestSsId():r.callback&&r.callback();else t?r._fetchWebId(r.fetchUrl,!1):r.isGetWebId=!1}),(function(){r.isGetWebId=!1}),!0)},e.prototype._setwebId=function(e){var t=this.cfg.envInfo.user.web_id||e.web_id,r={web_id:t,ssid:e.ssid,user_unique_id:this._uuid?this._uuid:t,timestamp:Date.now()};this.enableCookie&&this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(r)),this.expiresTime),this.storage.setItem(this.tokensKey,r),this.cfg.envInfo.user.ssid=e.ssid,this.cfg.envInfo.user.web_id=t,this.cfg.envInfo.user.user_unique_id=this._uuid?this._uuid:t,this.uuid=this._uuid?this._uuid:t,this.web_id=t,this.ssid=e.ssid,this.tokenReady=!0},e.prototype._getSsid=function(e){e&&-1===["0","Null","None","","undefined"].indexOf(e)&&(this.uuid===e&&this.web_id&&this.ssid?this.tokenReady=!0:(this._uuid=e,this.uuid=e,this.cfg.envInfo.user.user_unique_id=e,this.isGetSsid=!0,this.isNoSsid||this.isGetWebId?this.callback&&this.callback():(this.tokenReady=!1,this.isGetSsid=!1,this._requestSsId())))},e.prototype._requestSsId=function(){var e=this,t=this.domain+"/v1/user/ssid";q(t,{app_key:this.config.app_key,app_id:this.config.app_id,web_id:this.web_id,user_unique_id:this.uuid},this.config.app_key,(function(t){if(t&&0===t.e){e.cfg.envInfo.user.ssid=t.ssid;var r={web_id:e.web_id,ssid:t.ssid,user_unique_id:e.uuid,timestamp:Date.now()};e.enableCookie&&e.storage.setCookie(e.cookieKey,encodeURIComponent(JSON.stringify(r)),e.expiresTime),e.storage.setItem(e.tokensKey,r),e.tokenReady=!0}else e.tokenReady=!0;e.callback&&e.callback()}),(function(){e.tokenReady=!0,e.callback&&e.callback()}),!0)},e.prototype.isTokenReady=function(){return this.tokenReady},e}(),W=function(){function e(e,t,r,i){this.cfg=t,this.config=e,this._token=r,this.appInfo=e.app_key||e.app_id,this.debugMode=!!e.log,this.evtDataKey=F(this.appInfo,!1);var s=e.channel_domain||A[e.channel];this.reportUrl=e.report_url?e.report_url:s+"/v1/list",this.maxReport=e.max_report||20,this.storage=new E(!0),this.plugin=i,this.addListener()}return e.prototype.addListener=function(){var e=this;window.addEventListener("unload",(function(){e.report(!0)}),!1),window.addEventListener("beforeunload",(function(){e.report(!0)}),!1),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e.report(!0)}),!1)},e.prototype.setReady=function(){this.isReady=!0,this.report()},e.prototype.event=function(e,t){var r=this;void 0===e&&(e=[]),void 0===t&&(t=!1);var i=this.storage.getItem(this.evtDataKey)||[],s=t?b(e,i):b(i,e);this.storage.setItem(this.evtDataKey,s),this.reportTimer&&clearTimeout(this.reportTimer),s.length>=this.maxReport?this.report():this.reportTimer=setTimeout((function(){r.report(),r.reportTimer=null}),30)},e.prototype.report=function(e){if(void 0===e&&(e=!1),this._token.isTokenReady()&&this.isReady){var t=this.storage.getItem(this.evtDataKey)||[],r=this._mergeEvents(t);this.storage.removeItem(this.evtDataKey),this._dealData(r,e)}},e.prototype._mergeEvents=function(e){var t=this;if(!e.length)return e;var r=this.cfg.get();r.header.custom=JSON.stringify(r.header.custom);var i=[];return i.push(e),i.map((function(e){return{events:e.map((function(e){var r=M({},t.cfg.get("evtParams"),e.params);return delete r.__disable_storage__,M({},e,{params:JSON.stringify(r)})})),user:r.user,header:r.header,verbose:t.debugMode?1:void 0}}))},e.prototype._dealData=function(e,t){var r=this;if(!e.length)return e;e.map((function(e){var t=[];return t.push(e),t})).forEach((function(e){var i=Q();r._send(i,e,t)}))},e.prototype._send=function(e,t,r){var i=this;this.isSending=!0;var s=function(){i.isSending=!1};q(this.reportUrl,t,this.config.app_key,(function(){s()}),(function(e,t){s(),i.cfg.get("reportErrorCallback")(e,t)}),!1,r,s)},e}(),G=void 0,J=(new Date).getTimezoneOffset(),V=parseInt(""+-J/60,10),X=60*J,Z=function(){function e(e){var t=D(!0,e);this.envInfo={user:{user_unique_id:G,user_type:G,user_id:G,user_is_auth:G,user_is_login:G,device_id:G,web_id:G,ip_addr_id:G,ssid:G},header:{app_id:G,app_name:G,app_install_id:G,install_id:G,app_package:G,app_channel:G,app_version:G,os_name:t.os_name,os_version:t.os_version,device_model:t.device_model,ab_client:G,ab_version:G,ab_sdk_version:G,traffic_type:G,client_ip:G,device_brand:G,os_api:G,access:G,language:t.language,region:G,app_language:G,app_region:G,creative_id:G,ad_id:G,campaign_id:G,log_type:G,rnd:G,platform:t.platform,sdk_version:"4.1.15",province:G,city:G,timezone:V,tz_offset:X,tz_name:G,sim_region:G,carrier:G,resolution:t.screen_width+"x"+t.screen_height,browser:t.browser,browser_version:t.browser_version,referrer:t.referrer,referrer_host:t.referrer_host,width:t.screen_width,height:t.screen_height,screen_width:t.screen_width,screen_height:t.screen_height,utm_term:t.utm_term,utm_content:t.utm_content,utm_source:t.utm_source,utm_medium:t.utm_medium,utm_campaign:t.utm_campaign,custom:{}}},this.evtParams={},this.reportErrorCallback=function(){}}return e.prototype.set=function(e,t){var r=this;if("disable_auto_pv"!==e)if("evtParams"===e||"_staging_flag"===e){var i;i="evtParams"===e?t:{_staging_flag:Number(t)};var s=M({},i);Object.keys(s).forEach((function(e){r.evtParams[e]=s[e]}))}else if("reportErrorCallback"===e&&"function"==typeof t)this.reportErrorCallback=t;else{var n="";if(e.indexOf(".")>-1){var o=e.split(".");n=o[0],e=o[1]}if("user_unique_id"===e){if(!t)return;if(-1!==["0","Null","None","","undefined"].indexOf(t))return}if("os_version"===e&&(e=""+t),"web_id"===e){if(!t)return;(!this.envInfo.user.user_unique_id||this.envInfo.user.user_unique_id&&this.envInfo.user.user_unique_id===this.envInfo.user.web_id)&&(this.envInfo.user.user_unique_id=t)}n?"user"===n||"header"===n?this.envInfo[n][e]=t:this.envInfo.header.custom[e]=t:this.envInfo.user.hasOwnProperty(e)?["user_type","device_id","ip_addr_id"].indexOf(e)>-1?this.envInfo.user[e]=Number(t):["user_id","web_id","user_unique_id","ssid"].indexOf(e)>-1?this.envInfo.user[e]=String(t):["user_is_auth","user_is_login"].indexOf(e)>-1&&(this.envInfo.user[e]=Boolean(t)):this.envInfo.header.hasOwnProperty(e)?this.envInfo.header[e]=t:this.envInfo.header.custom[e]=t}},e.prototype.get=function(e){return e?"evtParams"===e?this.evtParams:"reportErrorCallback"===e?this.reportErrorCallback:JSON.parse(JSON.stringify(this.envInfo[e])):JSON.parse(JSON.stringify(this.envInfo))},e}(),$=function(){function e(e,t){this.isLog=t,this.name=e||""}var t=e.prototype;return t.info=function(e){this.isLog&&console.log(this.name+" "+e)},t.warn=function(e){this.isLog&&console.warn(this.name+" "+e)},t.error=function(e){this.isLog&&console.error(this.name+" "+e)},t.throw=function(e){throw this.error(this.name),new Error(e)},e}(),ee=b(["init","config","send","start"],[]),te=(K=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return K+=1}),re=function(){function e(e){var t=this;this.predefinePageView=function(e){void 0===e&&(e={});var r=M({title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer},t._event.closeStorage?{}:{__disable_storage__:1}),i=M({},r,e);t.event("predefine_pageview",i,!0)},this.name=e,this._isSend=!1,this.autoPV=!0}return e.prototype.init=function(e){var t=this;if(!this._inited){if(this._inited=!0,!e||"object"!=i(e))throw new Error("init参数有误,请检查");var r=e.app_id,s=e.app_key,n=e.log;this._config=new Z(r),this.logger=new $(this.name,n),s||r||this.logger.throw("没有传入 app_key 或 app_id "),r&&"number"!=typeof r&&this.logger.throw("app_id参数有误,请检查 "),s&&"string"!=typeof s&&this.logger.warn("app_key为空,如果有请传入"),e.channel_domain||-1!==["cn","sg","va"].indexOf(e.channel)||this.logger.throw("channel 变量只能是 `cn`, `sg`,`va`"),this._config.set("app_id",r),e.channel=e.channel?e.channel:"cn",this._initConfig=e,this._token=new Y(e,this._config),this._token.callback=function(){t.callbackSend&&t.start()},this._event=new W(e,this._config,this._token,this.plugin),this._token._getToken()}},e.prototype.config=function(e){if(this._inited)if(e&&"object"==i(e)){if(e.user_unique_id){if("string"!=typeof e.user_unique_id)throw new Error("user_unique_id 只能是string");this._token._getSsid(e.user_unique_id)}for(var t in e.disable_auto_pv&&(this.autoPV=!1),e)this._config.set(t,e[t])}else this.logger.warn("config参数有误,请检查");else this.logger.warn("config应在init之后调用")},e.prototype.send=function(){this.start()},e.prototype.start=function(){if(this._token.isTokenReady()){if(this._isSend)return;this._isSend=!0,this.logger.info("用户信息:"+JSON.stringify(this._config.get("user"))),this.autoPV&&this.predefinePageView(),this._event.setReady()}else this.callbackSend=!0},e.prototype.event=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="boolean"==typeof e[e.length-1]&&e[e.length-1],s="boolean"==typeof e[e.length-1]?e.slice(0,e.length-1):e,n=w(s,1)[0],o=[];"Array"!==Object.prototype.toString.call(n).slice(8,-1)?o[0]=s:o=s,o=o.map((function(e){return function(e,t){var r=e;/^event\./.test(e)&&(r=e.slice(6));var s=t;return"object"!=i(s)&&(s={}),s.event_index=te(),{event:r,params:s,local_time_ms:+new Date,is_bav:0}}(e[0],e[1])})),this._event.event(o,r)},e}();function ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var se=function(e){var t=this;return ie(this,"_exportCollect",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];t._isProcess?t._executeCmd.apply(t,r):(t.cmdQueue.push(r),t._processCmd())})),ie(this,"_processCmd",(function(){if(0!==t.cmdQueue.length){var e,r,i=(e=t.cmdQueue,"init","0",r=-1,e.forEach((function(e,t){"init"===e[0]&&(r=t)})),r);-1!==i&&(t._isProcess=!0,t._executeCmd.apply(t,t.cmdQueue[i]),t.cmdQueue.forEach((function(e,r){r!==i&&t._executeCmd.apply(t,e)})),t.cmdQueue=[])}})),ie(this,"_executeCmd",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var s,n,o=r[0];ee.indexOf(o)>-1?(s=t.colloctor)[o].apply(s,r.slice(1)):(n=t.colloctor).event.apply(n,r)})),this.cmdQueue=[],this.name=e,this.colloctor=new re(e),this._isProcess=!1,this._alias={},this._processCmd(),ee.forEach((function(e){t._exportCollect[e]=t._exportCollect.bind(t,e)})),this._exportCollect},ne={},oe={},ae=function(e){return oe[e]||(oe[e]=[]),oe[e]},ce=function(e){var t=w(e),r=t[0],i=t.slice(1),s=r.split(".");if(1===s.length)ae("default").push(b([r],i));else if(2===s.length)"event"===s[0]?ae("default").push(b([r],i)):ae(s[0]).push(b([s[1]],i));else{var n=s[0],o=[s[1],s[2]].join(".");ae(n).push(b([o],i))}},ue=function(){le.q.forEach((function(e){var t=[].slice.call(e);"Array"===Object.prototype.toString.call(t[0]).slice(8,-1)?t.forEach((function(e){ce(e)})):ce(t)})),Object.keys(oe).forEach((function(e){oe[e].forEach((function(t){var r;(r=e,ne[r]||(ne[r]=new se(r)),ne[r]).apply(void 0,b(t))})),oe[e]=[]})),le.q=[]},le=function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];e.q.push(t),ue()};le.q=[],le.l=Date.now(),le._instanceMap=ne,le._instanceCmdMap=oe,ee.forEach((function(e){le[e]=le.bind(null,e)})),function(e){if("undefined"!=typeof window){var t=function(){if("undefined"!=typeof window)return window.TeaAnalyticsObject}();if(t&&window[t]){var r=window[t];r.init||(e.q=r.q||[],e.l=r.l||Date.now(),window[t]=e)}}}(le),ue();var he=1e3,de=1001,fe=1002,pe=1003,ge=1004,ye=1005,ve={1e3:"crc32",1001:"preUpload",1002:"initUploadID",1003:"process",1004:"fileMerge",1005:"complete",error:"error",progress:"progress"},me=0,_e=1,xe=2,ke=3,Me=4,we=5,be="video",Te="image",Ne="object",Ce={video:"video_upload",image:"image_upload",object:"object_upload"},De={IDLE:0,UPLOADING:1,CANCEL:2,PAUSE:3,SUCCESS:4,FAILED:5,WAITING:6},Ie="vod",Oe="imagex",Se={vod:"video",imagex:"image"},Ee="cn-north-1",Ae="https://vod.volcengineapi.com",ze="https://imagex.volcengineapi.com",je=5242880,Ue="{tosDomain}/{oid}?uploads",Re="{tosDomain}/{oid}?partNumber={number}&uploadID={uploadId}",Le="{tosDomain}/{oid}?uploadID={uploadId}",Pe="{tosDomain}/{oid}?uploadID={uploadId}",Fe="{tosDomain}/{oid}",Be=a(a(a(a(a(a(a({FILE_ERROR:1000001,STSTOKEN_FORMAT_ERROR:1000002,FILE_ERROR_UPLOADING:1003003},de,{NETWORK_ERROR:1001e3,GENERAL_ERROR:1001001,TIMEOUT_ERROR:1001002}),fe,{NETWORK_ERROR:1002e3,GENERAL_ERROR:1002001,TIMEOUT_ERROR:1002002}),"UPLOAD_NETWORK_ERROR",1003e3),"UPLOAD_GENERAL_ERROR",1003001),"UPLOAD_TIMEOUT_ERROR",1003002),ge,{NETWORK_ERROR:1004e3,GENERAL_ERROR:1004001,TIMEOUT_ERROR:1004002}),ye,{NETWORK_ERROR:1005e3,GENERAL_ERROR:1005001,TIMEOUT_ERROR:1005002}),qe="An error occurred reading the file.",He=function(){function e(t,r){s(this,e),this.options=t,this.context=r,this.teaLog=le,this.teaLog.init({app_id:2562,channel:"cn",log:!1,disable_sdk_monitor:!0}),this.teaLog.config({evtParams:{sdk_version:"1.3.0",line_app_id:this.options.appId,page_url:window.location.href,toB:!0,imp:!1},user_unique_id:this.options.userId,disable_auto_pv:!0}),this.teaLog.start()}return o(e,[{key:"getBaseParams",value:function(e){var t=e.key,r=e.fileType,i=e.fileSize,s=e.serviceType,n=e.isDirect,o=e.isImageBatchUpload,a=e.extra,c=e.type,u=e.stage;return{type:c,log_type:Ce[r],stage:u,fk:t,fs:i,idu:n,ibu:o,idbp:e.isBreak,gwu:e.gatewayUpload,ss:e.sliceSize,sc:e.sliceCount,iie:e.imagexEnableEncrypt,ts:Math.round(Date.now()/1e3),msg:null==a?void 0:a.message,serviceType:s,omitInit:!!e.omitInit,pdur:e.pauseDuration}}},{key:"send",value:function(e){var r,i,s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var o=e.stage,a=e.serviceType,c=e.extra,u=e.oid,l=e.tosDomain,h=e.uploadId,d=e.uploadHeader,f=e.req,p=e.res,g=this.getBaseParams(e);o>=de&&Object.assign(g,{oid:u,upload_host:l,uploadId:h,uh:d,req:f,res:p});var y="".concat(Se[a],"_").concat(o);if(o===pe&&!e.allFinish)return this.teaLog(y,Object.assign(g,n));var v=e.duration,m=e.totalDuration,_=e.stageStartTime,x=e.stageEndTime;Object.assign(g,{sst:_,set:x,dur:v,durs:Math.round(v/1e3),tdur:m,tdurs:Math.round(m/1e3)});var k=null==c?void 0:c.message,M=e.crc32Array,w=e.isDirect;switch(o){case he:k="crc32 stage.len:".concat(M.length,",direct:").concat(w,".");break;case de:k+=".stk:".concat(JSON.stringify(e.proxyStsToken));break;case fe:g.omitInit=!!e.omitInit;break;case pe:delete g.res,delete g.req,g.speed=e.speed,g.af=!0;break;case ge:g.speed=e.speed;break;case ye:k+=null!==(r=e.uploadResult)&&void 0!==r&&r.Vid?".vid:".concat(null===(i=e.uploadResult)||void 0===i?void 0:i.Vid):"",Object.assign(g,{speed:e.speed,skipCommit:!!e.skipCommit,vid:null===(s=e.uploadResult)||void 0===s?void 0:s.Vid,omitInit:!!e.omitInit})}g.ex=k,this.teaLog(y,t(t({},g),n))}}},{key:"sendErrorLog",value:function(e,r){var i=e.serviceType,s=e.extra,n=e.oid,o=e.tosDomain,a=e.uploadId,c=e.req,u=e.res,l=e.stageStartTime,h=e.stageEndTime,d=e.duration,f=e.totalDuration,p=this.getBaseParams(e);Object.assign(p,t({type:"error",req:c,res:u,oid:n,upload_host:o,uploadId:a,errc:null==s?void 0:s.errorCode,errmsg:null==s?void 0:s.message,err:null==s?void 0:s.error,ex:"errorCode:".concat(null==s?void 0:s.errorCode,",").concat(null==s?void 0:s.message),sst:l,set:h,dur:d,durs:Math.round(d/1e3),tdur:f,tdurs:Math.round(f/1e3)},r)),this.teaLog("".concat(Se[i],"_error"),p)}},{key:"sendLogBase",value:function(e,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.teaLog(e,t(t({},this.getBaseParams(r)),i))}}]),e}(),Ke=function(e){var t=Number(e.substring(0,4)),r=Number(e.substring(4,6)),i=Number(e.substring(6,8)),s=Number(e.substring(8,10)),n=Number(e.substring(10,12)),o=Number(e.substring(12,14));return Date.UTC(t,r-1,i,s-8,n,o)-Date.now()},Qe=function(){for(var e=0,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];for(var s=0,n=r;s<n.length;s++){e+=n[s].byteLength}for(var o=new ArrayBuffer(e),a=new Uint8Array(o),c=0,u=0,l=r;u<l.length;u++){var h=l[u];a.set(new Uint8Array(h),c),c+=h.byteLength}return o},Ye=function(e){for(var t=e.length,r=new ArrayBuffer(t),i=new Uint8Array(r),s=0;s<t;s++)i[s]=e.charCodeAt(s);return r},We=function(e){for(var t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<e;i++)t+=r.charAt(Math.floor(62*Math.random()));return t},Ge=function(e){if(!e)return"";if(Array.isArray(e))return e.map((function(e){try{return"".concat(e.split("/")[0],"/").concat(encodeURIComponent(e.split("/").slice(1).join("/")))}catch(t){return e}}));try{return"".concat(e.split("/")[0],"/").concat(encodeURIComponent(e.split("/").slice(1).join("/")))}catch(t){return e}},Je=function(e,t){var r;return t=t||{},Object.keys(t).forEach((function(i){r=new RegExp("{".concat(i,"}"),"g"),e=e.replace(r,t[i])})),e},Ve=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[];return Object.keys(e).map((function(r){var i=e[r];"[object Array]"===Object.prototype.toString.call(i)?i.sort().forEach((function(e){t.push("".concat(r,"=").concat(encodeURIComponent(e)))})):t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},Xe=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{"x-storage-mode":"gateway"}:{};return Array.isArray(e)?(e.forEach((function(e){var r;e.Key&&e.Value&&(t[null===(r=e.Key)||void 0===r?void 0:r.toLowerCase()]=e.Value)})),t):"[object Object]"===Object.prototype.toString.call(e)?Object.assign(t,e):t},Ze=function(e){var t=e,r={removeItem:function(e){delete t.cache[e]},setItem:function(e,r){t.cache[e]=r},getItem:function(e){return t.cache[e]},clear:function(){delete t.cache,t.cache={}}};if(!(!(arguments.length>1&&void 0!==arguments[1])||arguments[1]))return r;try{if(window.localStorage)return window.localStorage.setItem("",""),window.localStorage}catch(N){return r}return r},$e=function(){},et=function(e){return"".concat(e,"_").concat(parseInt(1e7*Math.random()),"_").concat(parseInt(1e7*Math.random()))},tt=function(e,t){var r=1048576;return t&&"function"==typeof t?t(e)<je?je:t(e)||e:e<=200*r?5*r:e<=500*r?8*r:10*r},rt=function(e){if(Array.isArray(e)&&(e=e[0]),!e||"[object String]"!==Object.prototype.toString.call(e))return null;var t=e.lastIndexOf(".");return t>0?".".concat(e.substring(t+1)):null};function it(e){return{req:{url:null==e?void 0:e.currentUrl,param:null==e?void 0:e.params},res:{status:null==e?void 0:e.status,body:null==e?void 0:e.responseText}}}function st(e,t,r){return r=r||e.size,new Promise((function(i,s){var n=new FileReader;n.readAsArrayBuffer(function(e,t,r){var i=e.slice||e.webkitSlice||e.mozSlice;return i.call(e,t,r)}(e,t,r)),n.onload=function(e){i(e.target.result)},n.onerror=function(e){var t,r,i,n,o="";null!==(t=e.target.error)&&void 0!==t&&t.name||null!==(r=e.target.error)&&void 0!==r&&r.message?o="".concat(null===(i=e.target.error)||void 0===i?void 0:i.name,":").concat(null===(n=e.target.error)||void 0===n?void 0:n.message,"."):o="read file error,invalid file or destoryed.";s(Error(o))}}))}var nt=function(e,t){var r=t.sliceIndex;return e[r].loaded=Math.max(e[r].loaded||0,t.loaded),e.reduce((function(e,t){return e+(t.loaded||0)}),0)};function ot(e){return e.length<8?ot(e="0".concat(e)):e}function at(e){if(void 0!==e)return ot(Number(e).toString(16))}function ct(e,t){var r=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(r=new Int32Array(r));for(var i=-1^~~t,s=(e=new Uint8Array(e)).length,n=0;n<s;n++)i=r[255&(i^e[n])]^i>>>8;return at((-1^i)>>>0)}var ut={exports:{}};var lt,ht,dt={exports:{}},ft=new Proxy({},{get(e,t){throw new Error(`Module "" has been externalized for browser compatibility. Cannot access ".${t}" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}}),pt=m(Object.freeze({__proto__:null,default:ft}));function gt(){return lt||(lt=1,dt.exports=(e=e||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==y&&y.crypto&&(r=y.crypto),!r)try{r=pt}catch(g){}var i=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(g){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(g){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},o=n.lib={},a=o.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=o.WordArray=a.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,s=e.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var o=r[n>>>2]>>>24-n%4*8&255;t[i+n>>>2]|=o<<24-(i+n)%4*8}else for(var a=0;a<s;a+=4)t[i+a>>>2]=r[a>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new c.init(t,e)}}),u=n.enc={},l=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],s=0;s<r;s++){var n=t[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new c.init(r,t/2)}},h=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],s=0;s<r;s++){var n=t[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new c.init(r,t)}},d=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(N){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},f=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,i=this._data,s=i.words,n=i.sigBytes,o=this.blockSize,a=n/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*u,n);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(s,h);r=s.splice(0,u),i.sigBytes-=l}return new c.init(r,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=f.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new p.HMAC.init(e,r).finalize(t)}}});var p=n.algo={};return n}(Math),e)),dt.exports;var e}ut.exports=(ht=gt(),function(){if("function"==typeof ArrayBuffer){var e=ht.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,i=[],s=0;s<r;s++)i[s>>>2]|=e[s]<<24-s%4*8;t.call(this,i,r)}else t.apply(this,arguments)};r.prototype=e}}(),ht.lib.WordArray);var yt,vt=v(ut.exports),mt={exports:{}},_t={exports:{}};function xt(){return yt||(yt=1,function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.WordArray;function i(e,t,i){for(var s=[],n=0,o=0;o<t;o++)if(o%4){var a=i[e.charCodeAt(o-1)]<<o%4*2|i[e.charCodeAt(o)]>>>6-o%4*2;s[n>>>2]|=a<<24-n%4*8,n++}return r.create(s,n)}t.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,i=this._map;e.clamp();for(var s=[],n=0;n<r;n+=3)for(var o=(t[n>>>2]>>>24-n%4*8&255)<<16|(t[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|t[n+2>>>2]>>>24-(n+2)%4*8&255,a=0;a<4&&n+.75*a<r;a++)s.push(i.charAt(o>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,r=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var n=0;n<r.length;n++)s[r.charCodeAt(n)]=n}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return i(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(gt())}(_t)),_t.exports}var kt,Mt={exports:{}};function wt(){return kt||(kt=1,function(e,t){e.exports=function(e){return function(t){var r=e,i=r.lib,s=i.WordArray,n=i.Hasher,o=r.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=o.MD5=n.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,s=e[i];e[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n=this._hash.words,o=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],y=e[t+5],v=e[t+6],m=e[t+7],_=e[t+8],x=e[t+9],k=e[t+10],M=e[t+11],w=e[t+12],b=e[t+13],T=e[t+14],N=e[t+15],C=n[0],D=n[1],I=n[2],O=n[3];C=u(C,D,I,O,o,7,a[0]),O=u(O,C,D,I,c,12,a[1]),I=u(I,O,C,D,f,17,a[2]),D=u(D,I,O,C,p,22,a[3]),C=u(C,D,I,O,g,7,a[4]),O=u(O,C,D,I,y,12,a[5]),I=u(I,O,C,D,v,17,a[6]),D=u(D,I,O,C,m,22,a[7]),C=u(C,D,I,O,_,7,a[8]),O=u(O,C,D,I,x,12,a[9]),I=u(I,O,C,D,k,17,a[10]),D=u(D,I,O,C,M,22,a[11]),C=u(C,D,I,O,w,7,a[12]),O=u(O,C,D,I,b,12,a[13]),I=u(I,O,C,D,T,17,a[14]),C=l(C,D=u(D,I,O,C,N,22,a[15]),I,O,c,5,a[16]),O=l(O,C,D,I,v,9,a[17]),I=l(I,O,C,D,M,14,a[18]),D=l(D,I,O,C,o,20,a[19]),C=l(C,D,I,O,y,5,a[20]),O=l(O,C,D,I,k,9,a[21]),I=l(I,O,C,D,N,14,a[22]),D=l(D,I,O,C,g,20,a[23]),C=l(C,D,I,O,x,5,a[24]),O=l(O,C,D,I,T,9,a[25]),I=l(I,O,C,D,p,14,a[26]),D=l(D,I,O,C,_,20,a[27]),C=l(C,D,I,O,b,5,a[28]),O=l(O,C,D,I,f,9,a[29]),I=l(I,O,C,D,m,14,a[30]),C=h(C,D=l(D,I,O,C,w,20,a[31]),I,O,y,4,a[32]),O=h(O,C,D,I,_,11,a[33]),I=h(I,O,C,D,M,16,a[34]),D=h(D,I,O,C,T,23,a[35]),C=h(C,D,I,O,c,4,a[36]),O=h(O,C,D,I,g,11,a[37]),I=h(I,O,C,D,m,16,a[38]),D=h(D,I,O,C,k,23,a[39]),C=h(C,D,I,O,b,4,a[40]),O=h(O,C,D,I,o,11,a[41]),I=h(I,O,C,D,p,16,a[42]),D=h(D,I,O,C,v,23,a[43]),C=h(C,D,I,O,x,4,a[44]),O=h(O,C,D,I,w,11,a[45]),I=h(I,O,C,D,N,16,a[46]),C=d(C,D=h(D,I,O,C,f,23,a[47]),I,O,o,6,a[48]),O=d(O,C,D,I,m,10,a[49]),I=d(I,O,C,D,T,15,a[50]),D=d(D,I,O,C,y,21,a[51]),C=d(C,D,I,O,w,6,a[52]),O=d(O,C,D,I,p,10,a[53]),I=d(I,O,C,D,k,15,a[54]),D=d(D,I,O,C,c,21,a[55]),C=d(C,D,I,O,_,6,a[56]),O=d(O,C,D,I,N,10,a[57]),I=d(I,O,C,D,v,15,a[58]),D=d(D,I,O,C,b,21,a[59]),C=d(C,D,I,O,g,6,a[60]),O=d(O,C,D,I,M,10,a[61]),I=d(I,O,C,D,f,15,a[62]),D=d(D,I,O,C,x,21,a[63]),n[0]=n[0]+C|0,n[1]=n[1]+D|0,n[2]=n[2]+I|0,n[3]=n[3]+O|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296),o=i;r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),e.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,s,n,o){var a=e+(t&r|~t&i)+s+o;return(a<<n|a>>>32-n)+t}function l(e,t,r,i,s,n,o){var a=e+(t&i|r&~i)+s+o;return(a<<n|a>>>32-n)+t}function h(e,t,r,i,s,n,o){var a=e+(t^r^i)+s+o;return(a<<n|a>>>32-n)+t}function d(e,t,r,i,s,n,o){var a=e+(r^(t|~i))+s+o;return(a<<n|a>>>32-n)+t}r.MD5=n._createHelper(c),r.HmacMD5=n._createHmacHelper(c)}(Math),e.MD5}(gt())}(Mt)),Mt.exports}var bt,Tt={exports:{}},Nt={exports:{}};function Ct(){return bt||(bt=1,function(e,t){e.exports=function(e){return r=(t=e).lib,i=r.WordArray,s=r.Hasher,n=t.algo,o=[],a=n.SHA1=s.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|e[t+u];else{var l=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=l<<1|l>>>31}var h=(i<<5|i>>>27)+c+o[u];h+=u<20?1518500249+(s&n|~s&a):u<40?1859775393+(s^n^a):u<60?(s&n|s&a|n&a)-1894007588:(s^n^a)-899497514,c=a,a=n,n=s<<30|s>>>2,s=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(i+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=s._createHelper(a),t.HmacSHA1=s._createHmacHelper(a),e.SHA1;var t,r,i,s,n,o,a}(gt())}(Nt)),Nt.exports}var Dt,It,Ot={exports:{}};function St(){return Dt||(Dt=1,function(e,t){e.exports=function(e){var t,r,i;r=(t=e).lib.Base,i=t.enc.Utf8,t.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,s=4*r;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),o=this._iKey=t.clone(),a=n.words,c=o.words,u=0;u<r;u++)a[u]^=1549556828,c[u]^=909522486;n.sigBytes=o.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})}(gt())}(Ot)),Ot.exports}function Et(){return It||(It=1,function(e,t){e.exports=function(e){return r=(t=e).lib,i=r.Base,s=r.WordArray,n=t.algo,o=n.MD5,a=n.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:o,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,i=this.cfg,n=i.hasher.create(),o=s.create(),a=o.words,c=i.keySize,u=i.iterations;a.length<c;){r&&n.update(r),r=n.update(e).finalize(t),n.reset();for(var l=1;l<u;l++)r=n.finalize(r),n.reset();o.concat(r)}return o.sigBytes=4*c,o}}),t.EvpKDF=function(e,t,r){return a.create(r).compute(e,t)},e.EvpKDF;var t,r,i,s,n,o,a}(gt(),Ct(),St())}(Tt)),Tt.exports}var At,zt={exports:{}};function jt(){return At||(At=1,function(e,t){e.exports=function(e){e.lib.Cipher||function(t){var r=e,i=r.lib,s=i.Base,n=i.WordArray,o=i.BufferedBlockAlgorithm,a=r.enc;a.Utf8;var c=a.Base64,u=r.algo.EvpKDF,l=i.Cipher=o.extend({cfg:s.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?_:v}return function(t){return{encrypt:function(r,i,s){return e(i).encrypt(t,r,i,s)},decrypt:function(r,i,s){return e(i).decrypt(t,r,i,s)}}}}()});i.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=r.mode={},d=i.BlockCipherMode=s.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=h.CBC=function(){var e=d.extend();function r(e,r,i){var s,n=this._iv;n?(s=n,this._iv=t):s=this._prevBlock;for(var o=0;o<i;o++)e[r+o]^=s[o]}return e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;r.call(this,e,t,s),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+s)}}),e.Decryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,n=e.slice(t,t+s);i.decryptBlock(e,t),r.call(this,e,t,s),this._prevBlock=n}}),e}(),p=(r.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,i=r-e.sigBytes%r,s=i<<24|i<<16|i<<8|i,o=[],a=0;a<i;a+=4)o.push(s);var c=n.create(o,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};i.BlockCipher=l.extend({cfg:l.cfg.extend({mode:f,padding:p}),reset:function(){var e;l.reset.call(this);var t=this.cfg,r=t.iv,i=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(i,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var g=i.CipherParams=s.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),y=(r.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?n.create([1398893684,1701076831]).concat(r).concat(t):t).toString(c)},parse:function(e){var t,r=c.parse(e),i=r.words;return 1398893684==i[0]&&1701076831==i[1]&&(t=n.create(i.slice(2,4)),i.splice(0,4),r.sigBytes-=16),g.create({ciphertext:r,salt:t})}},v=i.SerializableCipher=s.extend({cfg:s.extend({format:y}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var s=e.createEncryptor(r,i),n=s.finalize(t),o=s.cfg;return g.create({ciphertext:n,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){return i=this.cfg.extend(i),t=this._parse(t,i.format),e.createDecryptor(r,i).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(r.kdf={}).OpenSSL={execute:function(e,t,r,i,s){if(i||(i=n.random(8)),s)o=u.create({keySize:t+r,hasher:s}).compute(e,i);else var o=u.create({keySize:t+r}).compute(e,i);var a=n.create(o.words.slice(t),4*r);return o.sigBytes=4*t,g.create({key:o,iv:a,salt:i})}},_=i.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:m}),encrypt:function(e,t,r,i){var s=(i=this.cfg.extend(i)).kdf.execute(r,e.keySize,e.ivSize,i.salt,i.hasher);i.iv=s.iv;var n=v.encrypt.call(this,e,t,s.key,i);return n.mixIn(s),n},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var s=i.kdf.execute(r,e.keySize,e.ivSize,t.salt,i.hasher);return i.iv=s.iv,v.decrypt.call(this,e,t,s.key,i)}})}()}(gt(),Et())}(zt)),zt.exports}!function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.BlockCipher,i=t.algo,s=[],n=[],o=[],a=[],c=[],u=[],l=[],h=[],d=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,s[r]=p,n[p]=r;var g=e[r],y=e[g],v=e[y],m=257*e[p]^16843008*p;o[r]=m<<24|m>>>8,a[r]=m<<16|m>>>16,c[r]=m<<8|m>>>24,u[r]=m,m=16843009*v^65537*y^257*g^16843008*r,l[p]=m<<24|m>>>8,h[p]=m<<16|m>>>16,d[p]=m<<8|m>>>24,f[p]=m,r?(r=g^e[e[e[v^g]]],i^=e[e[i]]):r=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=i.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,i=4*((this._nRounds=r+6)+1),n=this._keySchedule=[],o=0;o<i;o++)o<r?n[o]=t[o]:(u=n[o-1],o%r?r>6&&o%r==4&&(u=s[u>>>24]<<24|s[u>>>16&255]<<16|s[u>>>8&255]<<8|s[255&u]):(u=s[(u=u<<8|u>>>24)>>>24]<<24|s[u>>>16&255]<<16|s[u>>>8&255]<<8|s[255&u],u^=p[o/r|0]<<24),n[o]=n[o-r]^u);for(var a=this._invKeySchedule=[],c=0;c<i;c++){if(o=i-c,c%4)var u=n[o];else u=n[o-4];a[c]=c<4||o<=4?u:l[s[u>>>24]]^h[s[u>>>16&255]]^d[s[u>>>8&255]]^f[s[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,a,c,u,s)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,h,d,f,n),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,i,s,n,o,a){for(var c=this._nRounds,u=e[t]^r[0],l=e[t+1]^r[1],h=e[t+2]^r[2],d=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=i[u>>>24]^s[l>>>16&255]^n[h>>>8&255]^o[255&d]^r[f++],y=i[l>>>24]^s[h>>>16&255]^n[d>>>8&255]^o[255&u]^r[f++],v=i[h>>>24]^s[d>>>16&255]^n[u>>>8&255]^o[255&l]^r[f++],m=i[d>>>24]^s[u>>>16&255]^n[l>>>8&255]^o[255&h]^r[f++];u=g,l=y,h=v,d=m}g=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&d])^r[f++],y=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^r[f++],v=(a[h>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[f++],m=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=m},keySize:8});t.AES=r._createHelper(g)}(),e.AES}(gt(),xt(),wt(),Et(),jt())}(mt);var Ut=v(mt.exports),Rt={exports:{}};!function(e,t){e.exports=function(e){return e.enc.Utf8}(gt())}(Rt);var Lt=v(Rt.exports),Pt={exports:{}};!function(e,t){e.exports=function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();function r(e,t,r,i){var s,n=this._iv;n?(s=n.slice(0),this._iv=void 0):s=this._prevBlock,i.encryptBlock(s,0);for(var o=0;o<r;o++)e[t+o]^=s[o]}return t.Encryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;r.call(this,e,t,s,i),this._prevBlock=e.slice(t,t+s)}}),t.Decryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,n=e.slice(t,t+s);r.call(this,e,t,s,i),this._prevBlock=n}}),t}(),e.mode.CFB}(gt(),jt())}(Pt);var Ft=v(Pt.exports),Bt={exports:{}};!function(e,t){e.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(gt(),jt())}(Bt);var qt=v(Bt.exports);function Ht(e){var t=e.key,r=e.iv,i=e.data,s=function(e){for(var t=e.words,r=e.sigBytes,i=new Uint8Array(r),s=0;s<r;s+=1)i[s]=t[s>>>2]>>>24-s%4*8&255;return i}(Ut.encrypt(vt.create(i),Lt.parse(t),{mode:Ft,padding:qt,iv:Lt.parse(r)}).ciphertext);return s.buffer}var Kt,Qt=function(){function e(t,r){s(this,e),this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.config=r,this.isDirect=this.currFileCtx.isDirect,this.isImageBatchUpload=this.currFileCtx.isImageBatchUpload,this.serviceName=this.currFileCtx.serviceType||Ie,this.file=t.file,this.sliceLength=this.currFileCtx.sliceSize}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.currFileCtx.imagexEnableEncrypt&&this.isDirect?this.handleImagexEncryptDirect(this.file):this.currFileCtx.imagexEnableEncrypt&&!this.isDirect?this.handleImagexEncryptSlice(this.file,this.sliceLength):!this.currFileCtx.imagexEnableEncrypt&&this.isDirect?this.handleDirect(this.file):this.handleSlice(this.file,this.sliceLength)}},{key:"handleDirect",value:function(e){var t=this,r=this.isImageBatchUpload?e:[e];Promise.all(r.map((function(e){return st(e,0)}))).then((function(e){var r=e.map((function(e){return{start:0,end:e.byteLength,crc32:ct(e,0),buffer:e}}));t.success(r)}),(function(e){t.fail({errorCode:Be.FILE_ERROR,message:null==e?void 0:e.message,error:null==e?void 0:e.message})}))}},{key:"handleSlice",value:function(e,t){for(var r=this,i=[],s=e.size,n=0,o=0;o<s;)o=Math.min(n+t,s),s-o<=5242880&&(o=s),i.push({start:n,end:o,crc32:0}),n=o;if(this.currFileCtx.enableDiskBreakPoint&&i.length>2){var a=i.length;Promise.all([st(e,i[0].start,i[0].end),st(e,i[a-1].start,i[a-1].end)]).then((function(e){i[0].crc32=ct(e[0],0),i[a-1].crc32=ct(e[1],0),r.currFileCtx.crc32Key=r.getCrc32Key(i,s)})).catch((function(e){console.warn("[TTUploader]:",null==e?void 0:e.message),r.currFileCtx.enableDiskBreakPoint=!1})).finally((function(){r.success(i)}))}else this.success(i)}},{key:"handleImagexEncryptDirect",value:function(e){var t=this,r=this.currFileCtx.imagexEncryptKey,i=this.isImageBatchUpload?e:[e];Promise.all(i.map((function(e){return st(e,0)}))).then((function(e){var i=We(16),s=e.map((function(e){var t=Ht({key:r,iv:i,data:e}),s=Qe(Ye("aes256cfb-direct"),Ye(i),t);return{start:0,end:s.byteLength,crc32:ct(s,0),buffer:s}}));t.success(s)}),(function(e){t.fail({errorCode:Be.FILE_ERROR,message:null==e?void 0:e.message,error:null==e?void 0:e.message})}))}},{key:"handleImagexEncryptSlice",value:function(e,t){for(var r=new ArrayBuffer(36),i=new DataView(r),s=Ye("aes-256-cfb-part"),n=new Uint8Array(s),o=0;o<16;o++)i.setUint8(o,n[o]);i.setUint16(16,0,!0),i.setUint16(18,0,!0),i.setUint32(20,t,!0),i.setUint32(24,0,!0),i.setUint32(28,0,!0),i.setUint32(32,0,!0);for(var a=We(16),c=Qe(r,Ye(a)),u=[{crc32:ct(c,0),buffer:c,encryptMeta:!0,start:-52,end:0,iv:a}],l=e.size,h=0,d=0;d<l;)d=Math.min(h+t,l),u.push({start:h,end:d,crc32:0}),h=d;this.success(u)}},{key:"getCrc32Key",value:function(e,t){var r=[t];return r.push(e[0].crc32,e[e.length-1].crc32),r.join("_")}},{key:"success",value:function(e){var t=Object.assign(this.currFileCtx,{crc32Array:e,extra:{message:"crc32 stage success."}});this.successProcess(t)}},{key:"fail",value:function(e){var t=Object.assign(this.currFileCtx,{extra:{message:(null==e?void 0:e.message)||"crc32 stage error.",errorCode:e.errorCode||Be.FILE_ERROR,error:e.error||"%s"}});this.failProcess(t)}}]),e}(),Yt=globalThis,Wt=function(e){c(r,e);var t=d(r);function r(){var e;return s(this,r),(e=t.call(this)).xhr=new XMLHttpRequest,e._data=null,e}return o(r,[{key:"_ajax",value:function(e){var t=this,r=this.xhr;r.upload.onprogress=function(e){t.emit("progress",e)},r.onreadystatechange=function(){4===r.readyState&&(r.upload.onprogress=$e,r.onreadystatechange=$e,r.params=e,r.currentUrl=t._data.url,r.status>=200&&r.status<300?t.emit("complete",r):r.status>=400&&t.emit("error",r))},r.onerror=function(){r.errText="unknow net error",t.emit("error",r)},r.ontimeout=function(){r.errText="timeout",t.emit("timeout",r)},r.onabort=function(){r.errText="abort",t.emit("error",r)},r.send(e)}},{key:"send",value:function(e){var t=this;return this._data=e,this.xhr.open(e.method||"POST",e.url||"",!0),e.headers&&Object.keys(e.headers).forEach((function(r){t.xhr.setRequestHeader(r,e.headers[r])})),this.xhr.timeout=e.timeout||0,e.binary?(this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this._ajax(e.file)):e.custom?this._ajax(e.custom):this._ajax(null)}},{key:"abort",value:function(){this.xhr.onreadystatechange=$e,this.xhr.abort()}}]),r}(x),Gt=function(e,t){var r=new Wt;return new Promise((function(i,s){r.on("complete",(function(e){var r,n={};try{n=JSON.parse(e.response)}catch(c){var o={errorCode:Be[t].GENERAL_ERROR,message:"Parse response error:".concat(t),error:"".concat((null==c?void 0:c.message)||""),xhr:e};s(o)}if(null!==(r=n.ResponseMetadata)&&void 0!==r&&r.Error){var a={xhr:e,errorCode:n.ResponseMetadata.Error.CodeN,error:n.ResponseMetadata.Error.Code,message:n.ResponseMetadata.Error.Message,requestId:n.ResponseMetadata.RequestId};s(a)}else i({result:n.Result,xhr:e})})),r.on("error",(function(e){var r={errorCode:Be[t].NETWORK_ERROR,message:"Request failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(e.currentUrl),xhr:e};if(0!==e.status)try{var i,n=JSON.parse(e.response);null!==(i=n.ResponseMetadata)&&void 0!==i&&i.Error&&(r.errorCode=n.ResponseMetadata.Error.CodeN,r.error=n.ResponseMetadata.Error.Code,r.message=n.ResponseMetadata.Error.Message,r.requestId=n.ResponseMetadata.RequestId)}catch(o){r.errorCode=Be[t].GENERAL_ERROR,r.message="Parse response error.",r.error="".concat((null==o?void 0:o.message)||"")}s(r)})),r.on("timeout",(function(e){var r={errorCode:Be[t].TIMEOUT_ERROR,message:"Request timeout.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(e.currentUrl),xhr:e};s(r)})),r.send(e)}))},Jt=function(e,t){var r=new Wt;return new Promise((function(i,s){r.on("complete",(function(e){var r={};try{r=JSON.parse(e.response)}catch(N){var n={errorCode:Be[t].GENERAL_ERROR,message:"Parse server response error:".concat(t),error:"".concat((null==N?void 0:N.message)||""),xhr:e};s(n)}if(0===r.success){var o,a=null;if(t===fe)a=null===(o=r.payload)||void 0===o?void 0:o.uploadID;else if(t===de){var c;a=null===(c=r.payload)||void 0===c?void 0:c.partList}i({result:a,xhr:e})}else{var u,l,h,d={errorCode:(null===(u=r.error)||void 0===u?void 0:u.error_code)||Be[t].GENERAL_ERROR,message:null===(l=r.error)||void 0===l?void 0:l.message,error:null===(h=r)||void 0===h||null===(h=h.error)||void 0===h?void 0:h.error,xhr:e};Yt.fail(d)}})),r.on("error",(function(e){var r={errorCode:Be[t].NETWORK_ERROR,message:"Upload failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Failed at ").concat(e.currentUrl),xhr:e};if(0!==e.status)try{var i,n,o,a=JSON.parse(e.response);r.errorCode=null===(i=a.error)||void 0===i?void 0:i.error_code,r.message=null===(n=a.error)||void 0===n?void 0:n.message,r.error=null==a||null===(o=a.error)||void 0===o?void 0:o.error}catch(N){r.errorCode=Be[t].GENERAL_ERROR,r.message="Parse server response error:".concat(t),r.error="".concat((null==N?void 0:N.message)||"")}s(r)})),r.on("timeout",(function(e){var r={errorCode:Be[t].TIMEOUT_ERROR,message:"Request timeout:".concat(t),error:"HttpStatus:".concat(e.status,".Failed at ").concat(e.currentUrl),xhr:e};s(r)})),r.send(e)}))},Vt={exports:{}},Xt={exports:{}};function Zt(){return Kt||(Kt=1,function(e,t){e.exports=function(e){return function(t){var r=e,i=r.lib,s=i.WordArray,n=i.Hasher,o=r.algo,a=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),i=2;i<=r;i++)if(!(e%i))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var i=2,s=0;s<64;)e(i)&&(s<8&&(a[s]=r(t.pow(i,.5))),c[s]=r(t.pow(i,1/3)),s++),i++}();var u=[],l=o.SHA256=n.extend({_doReset:function(){this._hash=new s.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],o=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=0;f<64;f++){if(f<16)u[f]=0|e[t+f];else{var p=u[f-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[f-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[f]=g+u[f-7]+v+u[f-16]}var m=i&s^i&n^s&n,_=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),x=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[f]+u[f];d=h,h=l,l=a,a=o+x|0,o=n,n=s,s=i,i=x+(_+m)|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+d|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=n._createHelper(l),r.HmacSHA256=n._createHmacHelper(l)}(Math),e.SHA256}(gt())}(Xt)),Xt.exports}!function(e,t){e.exports=function(e){return e.HmacSHA256}(gt(),Zt(),St())}(Vt);var $t=v(Vt.exports),er=v(Zt()),tr=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],rr=function(e){try{return encodeURIComponent(e).replace(/[^A-Za-z0-9_.~\-%]+/g,escape).replace(/[*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}catch(N){return""}},ir=function(e){return Object.keys(e).sort().map((function(t){var r=e[t];if(null!=r){var i=rr(t);if(i)return Array.isArray(r)?"".concat(i,"=").concat(r.map(rr).sort().join("&".concat(i,"="))):"".concat(i,"=").concat(rr(r))}})).filter((function(e){return e})).join("&")},sr=function(){function e(t,r,i){s(this,e),this.request=t,this.request.headers=t.headers||{},this.serviceName=r,i=i||{},this.signatureCache="boolean"!=typeof i.signatureCache||i.signatureCache,this.operation=i.operation,this.signatureVersion=i.signatureVersion,this.constant=i.isVolcengine?{algorithm:"HMAC-SHA256",v4Identifier:"request",dateHeader:"X-Date",tokenHeader:"x-security-token",contentSha256Header:"X-Content-Sha256",kDatePrefix:""}:{algorithm:"AWS4-HMAC-SHA256",v4Identifier:"aws4_request",dateHeader:"X-Amz-Date",tokenHeader:"x-amz-security-token",contentSha256Header:"X-Amz-Content-Sha256",kDatePrefix:"AWS4"},this.bodySha256=i.bodySha256}return o(e,[{key:"addAuthorization",value:function(e,t){var r=this.iso8601(t).replace(/[:-]|\.\d{3}/g,"");this.addHeaders(e,r),this.request.headers.Authorization=this.authorization(e,r)}},{key:"addHeaders",value:function(e,t){if(this.request.headers[this.constant.dateHeader]=t,e.sessionToken&&(this.request.headers[this.constant.tokenHeader]=e.sessionToken),this.request.body){var r=this.request.body;"string"!=typeof r&&(r=r instanceof URLSearchParams?r.toString():JSON.stringify(r)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||er(r).toString()}}},{key:"authorization",value:function(e,t){var r=[],i=this.credentialString(t);return r.push("".concat(this.constant.algorithm," Credential=").concat(e.accessKeyId,"/").concat(i)),r.push("SignedHeaders=".concat(this.signedHeaders())),r.push("Signature=".concat(this.signature(e,t))),r.join(", ")}},{key:"signature",value:function(e,t){var r=this.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return $t(this.stringToSign(t),r)}},{key:"stringToSign",value:function(e){var t=[];return t.push(this.constant.algorithm),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")}},{key:"canonicalString",value:function(){var e=[],t=this.request.pathname||"/";return e.push(this.request.method.toUpperCase()),e.push(t),e.push(ir(this.request.params)||""),e.push("".concat(this.canonicalHeaders(),"\n")),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")}},{key:"canonicalHeaders",value:function(){var e=this,t=[];Object.keys(this.request.headers).forEach((function(r){t.push([r,e.request.headers[r]])})),t.sort((function(e,t){return e[0].toLowerCase()<t[0].toLowerCase()?-1:1}));var r=[];return t.forEach((function(t){var i=t[0].toLowerCase();if(e.isSignableHeader(i)){var s=t[1];if(null==s||"function"!=typeof s.toString)throw new Error("Header ".concat(i," contains invalid value"));r.push("".concat(i,":").concat(e.canonicalHeaderValues(s.toString())))}})),r.join("\n")}},{key:"canonicalHeaderValues",value:function(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}},{key:"signedHeaders",value:function(){var e=this,t=[];return Object.keys(this.request.headers).forEach((function(r){r=r.toLowerCase(),e.isSignableHeader(r)&&t.push(r)})),t.sort().join(";")}},{key:"credentialString",value:function(e){return this.createScope(e.substr(0,8),this.request.region,this.serviceName)}},{key:"hexEncodedHash",value:function(e){return er(e)}},{key:"hexEncodedBodyHash",value:function(){return this.request.headers[this.constant.contentSha256Header]?this.request.headers[this.constant.contentSha256Header]:this.request.body?this.hexEncodedHash(ir(this.request.body)):this.hexEncodedHash("")}},{key:"isSignableHeader",value:function(e){return 0===e.toLowerCase().indexOf("x-amz-")||tr.indexOf(e)<0}},{key:"iso8601",value:function(e){return void 0===e&&(e=new Date),e.toISOString().replace(/\.\d{3}Z$/,"Z")}},{key:"getSigningKey",value:function(e,t,r,i){var s=$t(t,"".concat(this.constant.kDatePrefix).concat(e.secretAccessKey)),n=$t(r,s),o=$t(i,n);return $t(this.constant.v4Identifier,o)}},{key:"createScope",value:function(e,t,r){return[e.substr(0,8),t,r,this.constant.v4Identifier].join("/")}}]),e}(),nr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.isImageBatchUpload=!!this.currFileCtx.isImageBatchUpload,this.serviceName=this.currFileCtx.serviceType,this.retryTime=r.retryTaskTime,this.retryCount=0}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e;var r=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),i={};try{i=r?JSON.parse(r):{}}catch(s){console.warn("[TTUploader]:","Parse cacheInfo from storage failed.")}i.oid&&i.uploadId&&i.tosDomain?this.resumeFromCache(i):this.startPreUpload()}},{key:"startPreUpload",value:function(){var e=this.createReqParamsByService(this.serviceName),t=e.host,r=e.params;if(this.config.useFileExtension){var i=rt(this.currFileCtx.fileName);i&&(r.FileExtension=i)}this.options.fileExtension&&(r.FileExtension=this.options.fileExtension),this.config.accountId&&(r["X-Account-Id"]=this.config.accountId),r.s=Math.random().toString(36).substr(2),this.uploaderCtx.priorInfo.topExpires>0&&(r["X-Expires"]=this.uploaderCtx.priorInfo.topExpires);var s=Ve(r),n={method:"GET",url:"".concat(t,"?").concat(s),timeout:this.config.requestTimeout,region:this.config.region||Ee,params:r},o=new sr(n,this.serviceName,{isVolcengine:!0}),a=this.currFileCtx.proxyStsToken||this.config.stsToken,c=a.AccessKeyID,u=a.AccessKeyId,l=a.SecretAccessKey,h=a.SessionToken,d=a.CurrentTime,f=null;f=this.config.useServerCurrentTime?new Date(d):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap),o.addAuthorization({accessKeyId:u||c,secretAccessKey:l,sessionToken:h},f),this.request(n)}},{key:"createReqParamsByService",value:function(e){var t={};if(e===Ie){var r,i;t.host=this.config.videoHost||Ae;var s,n=null===(r=this.config.videoConfig)||void 0===r?void 0:r.spaceName;if(this.currFileCtx.fileType===Ne&&null!==(i=this.config.objectConfig)&&void 0!==i&&i.spaceName)n=null===(s=this.config.objectConfig)||void 0===s?void 0:s.spaceName;t.params={Action:"ApplyUploadInfo",Version:"2022-01-01",SpaceName:n,FileSize:this.currFileCtx.fileSize,FileType:this.currFileCtx.fileType},this.options.fileName&&(t.params.FileName=this.options.fileName),this.options.fileExtension&&(t.params.FileExtension=this.options.fileExtension),this.options.storageClass&&(t.params.StorageClass=this.options.storageClass)}else{var o;if(t.host=this.config.imageHost||ze,t.params={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null===(o=this.config.imageConfig)||void 0===o?void 0:o.serviceId)},Array.isArray(this.currFileCtx.fileName)&&(t.params.UploadNum=this.currFileCtx.fileName.length),this.options.storeKey){var a=this.options.storeKey;t.params.StoreKeys=Array.isArray(a)?a:[a]}this.options.prefix&&(t.params.Prefix=this.options.prefix),this.options.overwrite&&(t.params.Overwrite=!0)}return t}},{key:"request",value:function(e){var t=this;Gt(e,de).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e,r){t.fail(e,r)}))}},{key:"resumeFromCache",value:function(e){var r=this,i={method:"GET",url:Je(Pe,{tosDomain:e.tosDomain,oid:e.oid,uploadId:e.uploadId}),headers:t({authorization:e.signature},e.uploadHeader),timeout:this.config.requestTimeout};Jt(i,de).then((function(t){var i=t.result,s=t.xhr;if(i&&i.length>0){var n=r.confirmCache(i),o=!!e.merged?we:n.isAllFinished?Me:ke,a=Object.assign(r.currFileCtx,e,{extra:{message:"resume upload from disk cache."},percent:0,cacheTaskIdx:o,isBreak:1,xhr:s});r.successProcess(a)}else r.startPreUpload()}),(function(e){var t=it(e.xhr),i=t.res,s=t.req;r.uploaderCtx.logger.sendLogBase("".concat(Se[r.currFileCtx.serviceType],"_999"),r.currFileCtx,{type:"warning",ex:"Resume from disk cache failed.",res:i,req:s,errc:null==e?void 0:e.errorCode,errmsg:null==e?void 0:e.message,err:null==e?void 0:e.error}),r.startPreUpload()}))}},{key:"confirmCache",value:function(e){var t=this.currFileCtx.crc32Array,r={};e.forEach((function(e){var t=parseInt(e.partNumber)-1;Number.isNaN(t)||void 0!==r[t]||(r[t]={tag:!0,crc32:e.crc32})}));var i=!0,s=t.map((function(e,t){return r[t]&&r[t].tag&&r[t].crc32?(e.crc32=r[t].crc32,e.finished=!0,e.loaded=e.end-e.start):i=!1,e}));return{isAllFinished:i,crc32Array:s}}},{key:"success",value:function(e,t){var r=this.serviceName===Oe?e.UploadAddress:e.Data.UploadAddress,i=r.StoreInfos,s=r.UploadHosts,n=r.SessionKey,o=r.UploadHeader,a=[],c=[];this.isImageBatchUpload&&i.length>1?i.forEach((function(e){a.push(e.Auth),c.push(e.StoreUri)})):(a=i[0].Auth,c=i[0].StoreUri);var u=Object.assign(this.currFileCtx,{signature:a,extra:{message:"prepare upload success"},oid:Ge(c),tosDomain:"".concat(this.config.schema,"://").concat(s[0]),xhr:t,uploadHeader:Xe(o,this.currFileCtx.gatewayUpload),sessionKey:n});this.successProcess(u)}},{key:"fail",value:function(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires){return this.uploaderCtx.priorInfo.topExpires=604800,this.startPreUpload()}if(0===this.uploaderCtx.priorInfo.systemTimeGap){var t=Ke(e.requestId);return this.uploaderCtx.priorInfo.systemTimeGap=t,this.startPreUpload()}}if(this.retryCount<this.retryTime)return this.retryCount+=1,this.startPreUpload();var r=Object.assign(this.currFileCtx,{extra:{message:e.message,errorCode:e.errorCode,error:e.error},xhr:e.xhr});this.failProcess(r)}}]),e}(),or=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.retryTime=r.retryTaskTime,this.req=null}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.retryCount=0,this.initUpload()}},{key:"initUpload",value:function(){var e={oid:this.currFileCtx.oid,tosDomain:this.currFileCtx.tosDomain},r={method:"POST",url:Je(Ue,e),headers:t({authorization:this.currFileCtx.signature},this.currFileCtx.uploadHeader),timeout:this.config.requestTimeout};this.req=r,this.request(r)}},{key:"request",value:function(e){var t=this;Jt(e,fe).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"success",value:function(e,t){var r=Object.assign(this.currFileCtx,{uploadId:e,extra:{message:"init upload id success."},xhr:t});this.successProcess(r)}},{key:"fail",value:function(e){if(this.retryCount<this.retryTime&&this.req)return this.retryCount+=1,this.request(this.req);var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}}]),e}(),ar=function(e){c(i,e);var r=d(i);function i(e){var t,n=e.sliceBuffer,o=e.crc32,a=e.url,c=e.signature,u=e.uploadHeader,l=e.retryTime,h=e.sliceIndex,d=e.uploadTimeout;return s(this,i),(t=r.call(this)).sliceBuffer=n,t.crc32=o,t.uploadUrl=a,t.uploadHeader=u,t.signature=c,t.sliceIndex=h,t.retryCount=0,t.retryTime=l,t.uploadTimeout=d,t.cancel=!1,t._st=Date.now(),t}return o(i,[{key:"upload",value:function(){var e=this;this.transport=null,this.transport=new Wt,this.transport.on("complete",(function(t){e.success(t)})),this.transport.on("error",(function(t){e.fail(t)})),this.transport.on("timeout",(function(t){e.fail(t,!0)})),this.transport.on("progress",(function(t){e.process(t)}));var r={method:this.method,url:this.uploadUrl,headers:t({authorization:this.signature,"content-crc32":this.crc32},this.uploadHeader),file:this.sliceBuffer,binary:1,timeout:this.uploadTimeout};this.transport.send(r)}},{key:"success",value:function(e){var t=this.sliceBuffer.size||this.sliceBuffer.byteLength;this.emit("complete",{crc32:this.crc32,size:t,xhr:e,duration:Date.now()-this._st,sliceIndex:this.sliceIndex})}},{key:"fail",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.cancel){var i={errorCode:Be.UPLOAD_NETWORK_ERROR,message:"Upload failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(this.uploadUrl)};if(r)i.errorCode=Be.UPLOAD_TIMEOUT_ERROR,i.message="Upload failed: Timeout.",i.error="HttpStatus:".concat(e.status,".Request fail at ").concat(this.uploadUrl);else if(0!==e.status)try{var s,n,o,a=JSON.parse(e.response);i.errorCode=null==a||null===(s=a.error)||void 0===s?void 0:s.error_code,i.message=null==a||null===(n=a.error)||void 0===n?void 0:n.message,i.error=null==a||null===(o=a.error)||void 0===o?void 0:o.error}catch(u){i.errorCode=Be.UPLOAD_GENERAL_ERROR,i.message="Parse response error.",i.error="".concat((null==u?void 0:u.message)||"")}var c=t({crc32:this.crc32,size:this.sliceBuffer.size||this.sliceBuffer.byteLength,xhr:e,duration:Date.now()-this._st,sliceIndex:this.sliceIndex,retryCount:this.retryCount},i);if(this.retryCount<this.retryTime)return this.retryCount+=1,this.emit("retry",c),void this.upload();this.emit("error",c)}}},{key:"process",value:function(e){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:e.loaded||0,total:e.total||0,sliceIndex:this.sliceIndex})}},{key:"abort",value:function(){var e;this.transport&&(this.cancel=!0,null===(e=this.transport)||void 0===e||e.abort())}},{key:"destroy",value:function(){this.transport=null}}]),i}(x),cr="IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIG4odCl7cmV0dXJuIHQubGVuZ3RoPDg/bih0PSIwIi5jb25jYXQodCkpOnR9ZnVuY3Rpb24gdCh0KXtpZih2b2lkIDAhPT10KXJldHVybiBuKE51bWJlcih0KS50b1N0cmluZygxNikpfXNlbGYub25tZXNzYWdlPWZ1bmN0aW9uKG4pe3ZhciByPW4uZGF0YSxlPXJbMF0sbz1yWzFdLGE9ZnVuY3Rpb24obixyKXt2YXIgZT1bMCwxOTk2OTU5ODk0LDM5OTM5MTk3ODgsMjU2NzUyNDc5NCwxMjQ2MzQxMzcsMTg4NjA1NzYxNSwzOTE1NjIxNjg1LDI2NTczOTIwMzUsMjQ5MjY4Mjc0LDIwNDQ1MDgzMjQsMzc3MjExNTIzMCwyNTQ3MTc3ODY0LDE2Mjk0MTk5NSwyMTI1NTYxMDIxLDM4ODc2MDcwNDcsMjQyODQ0NDA0OSw0OTg1MzY1NDgsMTc4OTkyNzY2Niw0MDg5MDE2NjQ4LDIyMjcwNjEyMTQsNDUwNTQ4ODYxLDE4NDMyNTg2MDMsNDEwNzU4MDc1MywyMjExNjc3NjM5LDMyNTg4Mzk5MCwxNjg0Nzc3MTUyLDQyNTExMjIwNDIsMjMyMTkyNjYzNiwzMzU2MzM0ODcsMTY2MTM2NTQ2NSw0MTk1MzAyNzU1LDIzNjYxMTUzMTcsOTk3MDczMDk2LDEyODE5NTM4ODYsMzU3OTg1NTMzMiwyNzI0Njg4MjQyLDEwMDY4ODgxNDUsMTI1ODYwNzY4NywzNTI0MTAxNjI5LDI3Njg5NDI0NDMsOTAxMDk3NzIyLDExMTkwMDA2ODQsMzY4NjUxNzIwNiwyODk4MDY1NzI4LDg1MzA0NDQ1MSwxMTcyMjY2MTAxLDM3MDUwMTU3NTksMjg4MjYxNjY2NSw2NTE3Njc5ODAsMTM3MzUwMzU0NiwzMzY5NTU0MzA0LDMyMTgxMDQ1OTgsNTY1NTA3MjUzLDE0NTQ2MjE3MzEsMzQ4NTExMTcwNSwzMDk5NDM2MzAzLDY3MTI2Njk3NCwxNTk0MTk4MDI0LDMzMjI3MzA5MzAsMjk3MDM0NzgxMiw3OTU4MzU1MjcsMTQ4MzIzMDIyNSwzMjQ0MzY3Mjc1LDMwNjAxNDk1NjUsMTk5NDE0NjE5MiwzMTE1ODUzNCwyNTYzOTA3NzcyLDQwMjM3MTc5MzAsMTkwNzQ1OTQ2NSwxMTI2MzcyMTUsMjY4MDE1MzI1MywzOTA0NDI3MDU5LDIwMTM3NzYyOTAsMjUxNzIyMDM2LDI1MTcyMTUzNzQsMzc3NTgzMDA0MCwyMTM3NjU2NzYzLDE0MTM3NjgxMywyNDM5Mjc3NzE5LDM4NjUyNzEyOTcsMTgwMjE5NTQ0NCw0NzY4NjQ4NjYsMjIzODAwMTM2OCw0MDY2NTA4ODc4LDE4MTIzNzA5MjUsNDUzMDkyNzMxLDIxODE2MjUwMjUsNDExMTQ1MTIyMywxNzA2MDg4OTAyLDMxNDA0MjcwNCwyMzQ0NTMyMjAyLDQyNDAwMTc1MzIsMTY1ODY1ODI3MSwzNjY2MTk5NzcsMjM2MjY3MDMyMyw0MjI0OTk0NDA1LDEzMDM1MzU5NjAsOTg0OTYxNDg2LDI3NDcwMDcwOTIsMzU2OTAzNzUzOCwxMjU2MTcwODE3LDEwMzc2MDQzMTEsMjc2NTIxMDczMywzNTU0MDc5OTk1LDExMzEwMTQ1MDYsODc5Njc5OTk2LDI5MDkyNDM0NjIsMzY2Mzc3MTg1NiwxMTQxMTI0NDY3LDg1NTg0MjI3NywyODUyODAxNjMxLDM3MDg2NDg2NDksMTM0MjUzMzk0OCw2NTQ0NTkzMDYsMzE4ODM5NjA0OCwzMzczMDE1MTc0LDE0NjY0Nzk5MDksNTQ0MTc5NjM1LDMxMTA1MjM5MTMsMzQ2MjUyMjAxNSwxNTkxNjcxMDU0LDcwMjEzODc3NiwyOTY2NDYwNDUwLDMzNTI3OTk0MTIsMTUwNDkxODgwNyw3ODM1NTE4NzMsMzA4MjY0MDQ0MywzMjMzNDQyOTg5LDM5ODgyOTIzODQsMjU5NjI1NDY0Niw2MjMxNzA2OCwxOTU3ODEwODQyLDM5Mzk4NDU5NDUsMjY0NzgxNjExMSw4MTQ3MDk5NywxOTQzODAzNTIzLDM4MTQ5MTg5MzAsMjQ4OTU5NjgwNCwyMjUyNzQ0MzAsMjA1Mzc5MDM3NiwzODI2MTc1NzU1LDI0NjY5MDYwMTMsMTY3ODE2NzQzLDIwOTc2NTEzNzcsNDAyNzU1MjU4MCwyMjY1NDkwMzg2LDUwMzQ0NDA3MiwxNzYyMDUwODE0LDQxNTA0MTcyNDUsMjE1NDEyOTM1NSw0MjY1MjIyMjUsMTg1MjUwNzg3OSw0Mjc1MzEzNTI2LDIzMTIzMTc5MjAsMjgyNzUzNjI2LDE3NDI1NTU4NTIsNDE4OTcwODE0MywyMzk0ODc3OTQ1LDM5NzkxNzc2MywxNjIyMTgzNjM3LDM2MDQzOTA4ODgsMjcxNDg2NjU1OCw5NTM3Mjk3MzIsMTM0MDA3NjYyNiwzNTE4NzE5OTg1LDI3OTczNjA5OTksMTA2ODgyODM4MSwxMjE5NjM4ODU5LDM2MjQ3NDE4NTAsMjkzNjY3NTE0OCw5MDYxODU0NjIsMTA5MDgxMjUxMiwzNzQ3NjcyMDAzLDI4MjUzNzk2NjksODI5MzI5MTM1LDExODEzMzUxNjEsMzQxMjE3NzgwNCwzMTYwODM0ODQyLDYyODA4NTQwOCwxMzgyNjA1MzY2LDM0MjMzNjkxMDksMzEzODA3ODQ2Nyw1NzA1NjIyMzMsMTQyNjQwMDgxNSwzMzE3MzE2NTQyLDI5OTg3MzM2MDgsNzMzMjM5OTU0LDE1NTUyNjE5NTYsMzI2ODkzNTU5MSwzMDUwMzYwNjI1LDc1MjQ1OTQwMywxNTQxMzIwMjIxLDI2MDcwNzE5MjAsMzk2NTk3MzAzMCwxOTY5OTIyOTcyLDQwNzM1NDk4LDI2MTc4MzcyMjUsMzk0MzU3NzE1MSwxOTEzMDg3ODc3LDgzOTA4MzcxLDI1MTIzNDE2MzQsMzgwMzc0MDY5MiwyMDc1MjA4NjIyLDIxMzI2MTExMiwyNDYzMjcyNjAzLDM4NTU5OTAyODUsMjA5NDg1NDA3MSwxOTg5NTg4ODEsMjI2MjAyOTAxMiw0MDU3MjYwNjEwLDE3NTkzNTk5OTIsNTM0NDE0MTkwLDIxNzY3MTg1NDEsNDEzOTMyOTExNSwxODczODM2MDAxLDQxNDY2NDU2NywyMjgyMjQ4OTM0LDQyNzkyMDAzNjgsMTcxMTY4NDU1NCwyODUyODExMTYsMjQwNTgwMTcyNyw0MTY3MjE2NzQ1LDE2MzQ0Njc3OTUsMzc2MjI5NzAxLDI2ODUwNjc4OTYsMzYwODAwNzQwNiwxMzA4OTE4NjEyLDk1NjU0MzkzOCwyODA4NTU1MTA1LDM0OTU5NTgyNjMsMTIzMTYzNjMwMSwxMDQ3NDI3MDM1LDI5MzI5NTk4MTgsMzY1NDcwMzgzNiwxMDg4MzU5MjcwLDkzNjkxOGUzLDI4NDc3MTQ4OTksMzczNjgzNzgyOSwxMjAyOTAwODYzLDgxNzIzMzg5NywzMTgzMzQyMTA4LDM0MDEyMzcxMzAsMTQwNDI3NzU1Miw2MTU4MTgxNTAsMzEzNDIwNzQ5MywzNDUzNDIxMjAzLDE0MjM4NTc0NDksNjAxNDUwNDMxLDMwMDk4Mzc2MTQsMzI5NDcxMDQ1NiwxNTY3MTAzNzQ2LDcxMTkyODcyNCwzMDIwNjY4NDcxLDMyNzIzODAwNjUsMTUxMDMzNDIzNSw3NTUxNjcxMTddOyJ1bmRlZmluZWQiIT10eXBlb2YgSW50MzJBcnJheSYmKGU9bmV3IEludDMyQXJyYXkoZSkpO2Zvcih2YXIgbz0tMV5+fnIsYT0obj1uZXcgVWludDhBcnJheShuKSkubGVuZ3RoLGk9MDtpPGE7aSsrKW89ZVsyNTUmKG9ebltpXSldXm8+Pj44O3JldHVybiB0KCgtMV5vKT4+PjApfShlLDApO3Bvc3RNZXNzYWdlKFtlLGEsb10sW2VdKX19KCk7Cg==",ur="undefined"!=typeof window&&window.Blob&&new Blob([atob(cr)],{type:"text/javascript;charset=utf-8"});function lr(){var e;try{if(!(e=ur&&(window.URL||window.webkitURL).createObjectURL(ur)))throw"";return new Worker(e)}catch(N){return new Worker("data:application/javascript;base64,"+cr)}finally{!("undefined"!=typeof window&&navigator.userAgent.indexOf("Trident/")>0)&&e&&(window.URL||window.webkitlRL).revokeObjectURL(e)}}var hr=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,e),this.file=t.file,this.uploaderCtx=t.context,this.key=t.key,this.config=r,this.finishArr=[],this.finishSize=0,this.retryUploadTime=Number(r.retryUploadTime),this.writenStorage=!1,this.uploadHandlers={}}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e,this.currFileCtx=this.uploaderCtx.tasks[this.key],this.crc32Array=this.currFileCtx.crc32Array,this.uploadSliceCount=Math.min(this.crc32Array.length,Number(this.config.uploadSliceCount)),this.lastIndex=0,this.uploading=[],this._uploadSize=this.crc32Array.reduce((function(e,t){return e+(t.finished?0:t.end-t.start)}),0),this._st=Date.now(),this.imagexEncrypt=this.currFileCtx.imagexEnableEncrypt,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function(){var e=this;if(!this.worker){try{this.worker=new lr}catch(r){return console.warn("[TTUploader]:worker not supported!"),void this.uploaderCtx.logger.sendLogBase("".concat(Se[this.currFileCtx.serviceType],"_999"),this.currFileCtx,{type:"warning",stage:pe,ex:"init worker failed:".concat(null==r?void 0:r.message),msg:"worker not supported."})}var t=this.crc32Array;this.worker.onmessage=function(r){var i=r.data[0],s=r.data[2],n=t[s];n.crc32=r.data[1],e.upload(n,i,s)}}}},{key:"read",value:function(e,t){var r=this;e.encryptMeta?this.upload(e,e.buffer,t):st(this.file,e.start,e.end).then((function(i){r.imagexEncrypt&&(i=Ht({iv:r.crc32Array[0].iv,key:r.currFileCtx.imagexEncryptKey,data:i})),r.worker?r.worker.postMessage([i,t],[i]):(e.crc32=ct(i,0),r.upload(e,i,t))}),(function(e){r.stop(),r.fail({extra:{errorCode:Be.FILE_ERROR_UPLOADING,message:qe,error:null==e?void 0:e.message}})}))}},{key:"threadUpload",value:function(){if(this.uploading.length<this.uploadSliceCount){var e=this.lastIndex,t=this.crc32Array[e];if(t){if(t.finished){if(-1===this.finishArr.indexOf(t.start)&&(this.finishArr.push(t.start),this.finishArr.length>=this.crc32Array.length))return this.stop(),void this.success()}else t.loaded=0,this.uploading.push(e),this.read(t,e);this.lastIndex++,this.threadUpload()}}}},{key:"upload",value:function(e,t,r){var i=this,s=e.crc32,n={number:r+1,uploadId:this.currFileCtx.uploadId,oid:this.currFileCtx.oid,tosDomain:this.currFileCtx.tosDomain},o=Je(Re,n),a=Object.assign({},this.currFileCtx.uploadHeader),c=new ar({sliceBuffer:t,crc32:s,url:o,signature:this.currFileCtx.signature,uploadHeader:a,retryTime:this.retryUploadTime,sliceIndex:r});c.on("complete",(function(t){t.start=e.start,i.singleSliceSuccess(t)})),c.on("error",(function(t){i.currFileCtx.status===De.UPLOADING&&(t.start=e.start,i.fail(t))})),c.on("progress",(function(t){i.currFileCtx.status===De.UPLOADING&&(t.start=e.start,i.process(t))})),c.on("retry",(function(e){var t=it(e.xhr),r=t.req,s=t.res;i.uploaderCtx.logger.sendLogBase("".concat(Se[i.currFileCtx.serviceType],"_retry"),i.currFileCtx,{type:"retry",ex:"upload retry, retry count:".concat(e.retryCount,",errorCode:").concat(e.errorCode),req:r,res:s,si:e.sliceIndex+1,errc:e.errorCode,err:e.error,errmsg:e.errmsg})})),c.upload(),this.uploadHandlers[r]=c}},{key:"singleSliceSuccess",value:function(e){var t=e.sliceIndex;-1===this.finishArr.indexOf(e.start)&&this.finishArr.push(e.start),this.crc32Array[t].finished=!0;var r=it(e.xhr),i=r.res,s=r.req;if(this.uploaderCtx.logger.send(this.currFileCtx,{type:"success",si:t+1,af:!1,ss:e.size,sldur:e.duration,ex:"Slice upload:".concat(t+1," success:").concat(e.crc32,",total:").concat(this.crc32Array.length,"."),req:s,res:i}),!this.writenStorage&&this.currFileCtx.enableDiskBreakPoint&&(this.writenStorage=!0,this.uploaderCtx._saveTask(this.key)),this.uploading.splice(this.uploading.indexOf(t),1),this.uploadHandlers[t]&&delete this.uploadHandlers[t],this.currFileCtx.status===De.UPLOADING)return this.finishArr.length>=this.crc32Array.length?(this.stop(),void this.success(e.xhr)):void(this.currFileCtx.status===De.UPLOADING&&this.threadUpload())}},{key:"process",value:function(e){var t=this.currFileCtx.fileSize;this.finishSize=Math.max(nt(this.crc32Array,e),this.finishSize);var r=Math.min(Math.round(this.finishSize/t*100),99);r>this.currFileCtx.percent&&(this.currFileCtx.percent=r,this.uploaderCtx._broadcast("progress",this.currFileCtx))}},{key:"success",value:function(e){var t,r;this.finishArr=[];var i=Date.now()-this._st,s=Math.round(this._uploadSize/1024)/(i/1e3),n=Object.assign(this.currFileCtx,{percent:99,extra:{message:"upload all slice success."},speed:s,allFinish:!0});null===(t=this.worker)||void 0===t||null===(r=t.terminate)||void 0===r||r.call(t),this.successProcess(n)}},{key:"fail",value:function(e){this.stop();var t={errorCode:e.errorCode,message:e.message,error:e.error},r=Object.assign(this.currFileCtx,{extra:t,type:"error",allFinish:!1});this.failProcess(r)}},{key:"stop",value:function(){var e,t;Object.values(this.uploadHandlers).forEach((function(e){null==e||e.abort()})),null===(e=this.worker)||void 0===e||null===(t=e.terminate)||void 0===t||t.call(e),this.worker=null}}]),e}(),dr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.retryTime=r.retryTaskTime,this.req=null}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.retryCount=0,this.mergeFile()}},{key:"mergeFile",value:function(){for(var e={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadId,tosDomain:this.currFileCtx.tosDomain},r=this.currFileCtx.crc32Array,i="",s=0;s<r.length;s++)i=i?"".concat(i,",").concat(s+1,":").concat(r[s].crc32):"".concat(s+1,":").concat(r[s].crc32);var n=Je(Le,e),o=Object.assign({},this.currFileCtx.uploadHeader),a={method:"POST",url:n,headers:t({authorization:this.currFileCtx.signature},o),custom:i};this.req=a,this.request(a)}},{key:"request",value:function(e){var t=this;Jt(e,ge).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"success",value:function(e,t){var r=Object.assign(this.currFileCtx,{merged:!0,extra:{message:"merge file success."},xhr:t});this.uploaderCtx._saveTask(this.options.key),this.successProcess(r)}},{key:"fail",value:function(e){if(this.retryCount<this.retryTime&&this.req)return this.retryCount+=1,this.request(this.req);var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}}]),e}(),fr=function(){function e(t,r){s(this,e),this.options=t,this.file=t.file,this.uploaderCtx=t.context,this.key=t.key,this.config=r,this.finishSize=0,this.retryUploadTime=Number(r.retryUploadTime),this.uploadSuccessNum=0,this.uploadFailNum=0}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e,this.currFileCtx=this.uploaderCtx.tasks[this.key],this.crc32Array=this.currFileCtx.crc32Array,this._uploadSize=this.currFileCtx.fileSize,this.uploadHandlers={},this._st=Date.now(),this.upload()}},{key:"upload",value:function(){for(var e=this,t=this.crc32Array.length,r=0;r<t;r++){var i=this.crc32Array[r];if(!i.finished){var s=i.buffer,n=i.crc32,o=this.currFileCtx.oid,a=this.currFileCtx.signature,c={oid:Array.isArray(o)?o[r]:o,tosDomain:this.currFileCtx.tosDomain},u=Je(Fe,c),l=new ar({sliceBuffer:s,crc32:n,url:u,signature:Array.isArray(a)?a[r]:a,uploadHeader:this.currFileCtx.uploadHeader,retryTime:this.retryUploadTime,sliceIndex:r});l.on("complete",(function(t){e.singleSliceSuccess(t)})),l.on("error",(function(t){e.singleSliceFailed(t)})),l.on("progress",(function(t){e.process(t)})),l.on("retry",(function(t){var r=it(t.xhr),i=r.req,s=r.res;e.uploaderCtx.logger.sendLogBase("".concat(Se[e.currFileCtx.serviceType],"_retry"),e.currFileCtx,{type:"retry",ex:"upload retry, retry count:".concat(t.retryCount,",errorCode:").concat(t.errorCode),req:i,res:s,si:t.sliceIndex+1,errc:t.errorCode,err:t.error,errmsg:t.errmsg})})),this.uploadHandlers["".concat(n,"_").concat(Math.round(1e3*Math.random()))]=l,l.upload()}}}},{key:"process",value:function(e){var t=this.currFileCtx.fileSize;this.finishSize=nt(this.currFileCtx.crc32Array,e);var r=Math.min(Math.round(this.finishSize/t*100),99);r>this.currFileCtx.percent&&(this.currFileCtx.percent=r),this.currFileCtx.status===De.UPLOADING&&this.uploaderCtx._broadcast("progress",this.currFileCtx)}},{key:"singleSliceSuccess",value:function(e){var t=e.sliceIndex;if(!this.crc32Array[t].finished){this.crc32Array[t].finished=!0,this.uploadSuccessNum+=1;var r=it(e.xhr),i=r.res,s=r.req;this.uploaderCtx.logger.send(this.currFileCtx,{type:"success",si:t+1,af:!1,ss:e.size,sldur:e.duration,ex:"Direct upload:".concat(t+1," success:").concat(e.crc32,",total:").concat(this.crc32Array.length,",batch:").concat(this.currFileCtx.isImageBatchUpload),req:s,res:i})}this.uploadSuccessNum+this.uploadFailNum===this.crc32Array.length&&this.success(e)}},{key:"singleSliceFailed",value:function(e){this.uploadFailNum+=1;var t=it(e.xhr),r=t.res,i=t.req;this.uploaderCtx.logger.sendLogBase("".concat(Se[this.currFileCtx.serviceType],"_999"),this.currFileCtx,{type:"warning",si:e.sliceIndex+1,ss:e.size,ex:"warning:direct upload idx:".concat(e.sliceIndex+1," failed,total:").concat(this.crc32Array.length,",batch:").concat(this.currFileCtx.isImageBatchUpload),req:i,res:r}),this.uploadFailNum===this.crc32Array.length&&this.fail(e)}},{key:"success",value:function(e){var t=Date.now()-this._st,r=Math.round(this._uploadSize/t),i=Object.assign(this.currFileCtx,{percent:99,extra:{message:"direct upload success"},speed:r,xhr:e.xhr,allFinish:!0});this.successProcess(i)}},{key:"fail",value:function(e){var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}},{key:"stop",value:function(){Object.values(this.uploadHandlers).forEach((function(e){null==e||e.abort()}))}}]),e}(),pr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.processAction=t.processAction,this.skipCommit=t.skipCommit,this.serviceName=this.currFileCtx.serviceType,this.isImageBatchUpload=!!this.currFileCtx.isImageBatchUpload,this.retryTime=r.retryTaskTime,this.retryCount=0}return o(e,[{key:"start",value:function(e,t){if(this.successProcess=e,this.failProcess=t,this.skipCommit){var r=Object.assign(this.currFileCtx,{type:"success",percent:100,extra:{message:"upload successful, skip commit."}});return this.successProcess(r)}this.commitUpload()}},{key:"commitUpload",value:function(){var e=this.config.region||Ee,t=this.createReqParamsByService(this.serviceName),r=t.host,i=t.params,s=t.body;t.data,this.config.accountId&&(i["X-Account-Id"]=this.config.accountId),this.uploaderCtx.priorInfo.topExpires>0&&(i["X-Expires"]=this.uploaderCtx.priorInfo.topExpires);var n=Ve(i),o={method:"POST",url:"".concat(r,"?").concat(n),timeout:this.config.requestTimeout,region:e,params:i,headers:{}};if(this.serviceName===Ie){var a=Object.keys(s).map((function(e){return"[object Array]"===Object.prototype.toString.call(s[e])||"[object Object]"===Object.prototype.toString.call(s[e])?"".concat(e,"=").concat(encodeURIComponent(JSON.stringify(s[e]))):"SessionKey"===e?"".concat(e,"=").concat(encodeURIComponent(s[e])):"".concat(e,"=").concat(s[e])})).join("&");o.headers["Content-Type"]="application/x-www-form-urlencoded",o.body=a,o.custom=o.body}else o.custom=JSON.stringify(s),o.headers["Content-Type"]="application/json",o.body=s;var c=new sr(o,this.serviceName,{isVolcengine:!0}),u=this.currFileCtx.proxyStsToken||this.config.stsToken,l=u.AccessKeyID,h=u.AccessKeyId,d=u.SecretAccessKey,f=u.SessionToken,p=u.CurrentTime,g=null;g=this.config.useServerCurrentTime?new Date(new Date(p).getTime()+(this.currFileCtx.totalDuration||0)):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap),c.addAuthorization({accessKeyId:h||l,secretAccessKey:d,sessionToken:f},g),this.request(o)}},{key:"createReqParamsByService",value:function(e){var t=this,r={body:{SessionKey:this.currFileCtx.sessionKey}};if(e===Ie){var i,s,n,o;r.host=this.config.videoHost||Ae;var a,c=null===(i=this.config.videoConfig)||void 0===i?void 0:i.spaceName;if(this.currFileCtx.fileType===Ne&&null!==(s=this.config.objectConfig)&&void 0!==s&&s.spaceName)c=null===(a=this.config.objectConfig)||void 0===a?void 0:a.spaceName;r.params={Action:"CommitUploadInfo",Version:"2022-01-01",SpaceName:c};var u,l=null===(n=this.config.videoConfig)||void 0===n?void 0:n.processAction;if(this.currFileCtx.fileType===Ne&&null!==(o=this.config.objectConfig)&&void 0!==o&&o.processAction)l=null===(u=this.config.objectConfig)||void 0===u?void 0:u.processAction;this.processAction&&(l=this.processAction),Array.isArray(l)&&l.length>0&&(r.body.Functions=l),(this.config.videoConfig&&this.config.videoConfig.callbackArgs||this.options.callbackArgs)&&(r.body.CallbackArgs=this.options.callbackArgs||this.config.videoConfig.callbackArgs)}else{var h;r.host=this.config.imageHost||ze,r.params={Action:"CommitImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null===(h=this.config.imageConfig)||void 0===h?void 0:h.serviceId)},this.options.skipMeta&&(r.params.SkipMeta=this.options.skipMeta),this.processAction&&Array.isArray(this.processAction)&&this.processAction.length>0&&(r.body.Functions=this.processAction);var d=this.currFileCtx,f=d.imagexEnableEncrypt,p=d.imagexPublicKey;f&&p&&!this.options.skipMeta&&this.uploaderCtx.plugins.forEach((function(e){if("imagex-encrypt-plugin"===(null==e?void 0:e._identifier))try{r.body.DecryptKeys=e.apply(t.currFileCtx)}catch(i){console.warn("[TTUploader]:",null==i?void 0:i.message)}}))}return r.data=JSON.stringify(r.body),r}},{key:"request",value:function(e){var t=this;Gt(e,ye).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"fail",value:function(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires){return this.uploaderCtx.priorInfo.topExpires=604800,this.commitUpload()}if(0===this.uploaderCtx.priorInfo.systemTimeGap){var t=Ke(e.requestId);return this.uploaderCtx.priorInfo.systemTimeGap=t,this.commitUpload()}}if(this.retryCount<this.retryTime)return this.retryCount+=1,this.commitUpload();var r=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(r)}},{key:"success",value:function(e,r){var i={};if(this.serviceName===Oe)if(this.isImageBatchUpload){var s=e.Results,n=e.PluginResult||[];s.forEach((function(e,r){s[r]=t(t({},s[r]),n[r])})),i=s}else i=e.Results[0],Object.assign(i,e.PluginResult&&e.PluginResult[0]);else i=e.Data;var o=Object.assign(this.currFileCtx,{percent:100,extra:{message:"upload successful."},uploadResult:i,xhr:r});return this.successProcess(o)}}]),e}(),gr=function(){function e(t,r,i){s(this,e),this.config=t,this.key=i,this.uploaderCtx=r,this.tasks=[]}return o(e,[{key:"addSubTask",value:function(e){this.tasks.push(e)}},{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.uploaderCtx.tasks[this.key];if(e){var r;if(t.requestPending)return;if(t.curTaskIdx===ke&&(null===(r=this.tasks[0])||void 0===r?void 0:r.index)===Me){var i=this.uploaderCtx.taskList[this.key].find((function(e){return e.index===ke}));i&&this.execTask(i)}else{var s=this.tasks.shift();s&&this.execTask(s)}}else{var n=this.tasks.shift();n&&this.execTask(n)}}},{key:"execTask",value:function(e){var t,r=this,i=e.key,s=this.uploaderCtx.tasks[i],n=s.cacheTaskIdx;n&&e.index>0&&e.index<n?this.start():(s.curTaskIdx=e.index,s.stage=e.stage,s.status===De.UPLOADING&&(s.stageStartTime=Date.now(),s.requestPending=!0,null==e||null===(t=e.func)||void 0===t||t.call(e.context,(function(e){r.finishTask(e,!0)}),(function(e){r.finishTask(e,!1)}))))}},{key:"finishTask",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.stageStartTime;if(e.stageEndTime=Date.now(),e.duration=Date.now()-r,e.totalDuration+=Date.now()-r,e.requestPending=!1,e.xhr){var i=it(e.xhr),s=i.req,n=i.res;e.req=s,e.res=n,delete e.xhr}t?this.success(e):this.fail(e)}},{key:"success",value:function(e){if(Object.assign(e,{type:"success"}),this.uploaderCtx.logger.send(e),this.tasks.length>0)this.start();else{if(this.uploaderCtx._taskFinish(e.key,!0),e.status===De.PAUSE||e.status===De.CANCEL)return;this.uploaderCtx._broadcast(e.stage,e)}}},{key:"fail",value:function(e){Object.assign(e,{type:"error"}),this.uploaderCtx.logger.sendErrorLog(e),this.uploaderCtx._taskFinish(e.key,!1),e.status!==De.PAUSE&&e.status!==De.CANCEL&&this.uploaderCtx._broadcast("error",e)}},{key:"cancel",value:function(e){var t=this.key,r=this.uploaderCtx.tasks[t];if(r&&(!e||!r.isDirect)){var i,s;if(r.stage===pe)null===(i=this.uploaderCtx.taskList[t].find((function(e){return e.index===ke})).context)||void 0===i||null===(s=i.stop)||void 0===s||s.call(i),r.requestPending=!1;e||(this.tasks=[])}}}]),e}(),yr=function(e){c(r,e);var t=d(r);function r(e){var i;return s(this,r),(i=t.call(this,e)).config=Object.assign({},k,e),i.tasks={},i.taskList={},i.cache={},i._schedulerMap=a(a(a(a(a(a(a({},De.IDLE,[]),De.UPLOADING,new Set),De.PAUSE,[]),De.WAITING,[]),De.CANCEL,[]),De.SUCCESS,[]),De.FAILED,[]),i.storage=Ze(h(i),i.config.useLocalStorage),i.logger=i.config.noLog?{send:function(){}}:new He(i.config,h(i)),i.plugins=[],i.priorInfo={systemTimeGap:0,topExpires:0},i}return o(r,[{key:"_use",value:function(e){var t,r=!1,i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=p(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,s=function(){};return{s:s,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw n}}}}(this.plugins);try{for(i.s();!(t=i.n()).done;){var s=t.value;if((null==s?void 0:s.stage)===(null==e?void 0:e.stage)&&(null==s?void 0:s._identifier)===e._identifier){r=!0;break}}}catch(n){i.e(n)}finally{i.f()}r||this.plugins.push(e)}},{key:"_mergeOptions",value:function(e,t){t&&"object"===i(t)&&Object.assign(e,t)}},{key:"_addAllUploadProcess",value:function(e,t,r){this.taskList[t]=[];var i={key:t,task:new gr(this.config,this,t),fileType:e.type||be,proxyStsToken:e.stsToken,serviceType:r,duration:0,totalDuration:0,percent:0,pauseDuration:0,skipCommit:r===Oe&&e.skipCommit,sliceSize:0,sliceCount:this.config.uploadSliceCount,requestPending:!1,taskAllFinish:!1},s=r===Oe&&Array.isArray(e.file);if(i.isImageBatchUpload=s,s?(i.fileSize=e.file.reduce((function(e,t){return e+t.size}),0),i.fileName=e.file.map((function(e){return e.name}))):(i.fileSize=e.file.size,i.fileName=e.file.name),!s){var n=this.config.sliceSize||tt(i.fileSize,this.config.getSliceFunc);i.sliceSize=n}var o=!1;if(o=!!s||i.fileSize<5242880,i.isDirect=o,r===Oe){var a,c,u,l=!(null===(a=this.config)||void 0===a||null===(a=a.imageConfig)||void 0===a||!a.imagexEnableEncrypt);if(i.imagexEnableEncrypt=l,l)i.imagexEncryptKey=(null===(c=this.config)||void 0===c||null===(c=c.imageConfig)||void 0===c?void 0:c.imagexEncryptKey)||We(32),i.imagexPublicKey=null===(u=this.config)||void 0===u||null===(u=u.imageConfig)||void 0===u?void 0:u.imagexPublicKey}o||i.imagexEnableEncrypt||(i.gatewayUpload=!0),o||i.imagexEnableEncrypt||!this.config.useLocalStorage||(i.enableDiskBreakPoint=!0),i.status=De.IDLE,this.tasks[t]=i,this._schedulerMap[De.IDLE].push(t),this._addCrc32ProcessTask(e,t),this._addPreUploadTask(e,t),o?this._addDirectUploadTask(e,t):(this._addInitUploadIDTask(t),this._addUploadProcessTask(e,t),this._mergeFileTask(t)),this._getMetaInfoTask(e,t)}},{key:"_addTask",value:function(e,t){var r=this.tasks;this.taskList[e].push(t),r[e].task.addSubTask(t)}},{key:"_addCrc32ProcessTask",value:function(e,t){var r=new Qt({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:me,stage:he};this._addTask(t,i)}},{key:"_addPreUploadTask",value:function(e,t){var r={context:this,key:t,fileName:e.fileName||null,fileExtension:e.fileExtension||null,storageClass:e.storageClass||null,serviceId:e.serviceId||null,prefix:e.prefix,storeKey:e.storeKey,overwrite:e.overwrite},i=new nr(r,this.config),s={context:i,func:i.start,key:t,index:_e,stage:de};this._addTask(t,s)}},{key:"_addInitUploadIDTask",value:function(e){var t=new or({context:this,key:e},this.config),r={context:t,func:t.start,key:e,index:xe,stage:fe};this._addTask(e,r)}},{key:"_addDirectUploadTask",value:function(e,t){var r=new fr({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:ke,stage:pe};this._addTask(t,i)}},{key:"_addUploadProcessTask",value:function(e,t){var r=new hr({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:ke,stage:pe};this._addTask(t,i)}},{key:"_mergeFileTask",value:function(e){var t=new dr({context:this,key:e},this.config),r={context:t,func:t.start,key:e,index:Me,stage:ge};this._addTask(e,r)}},{key:"_getMetaInfoTask",value:function(e,t){var r={context:this,key:t,callbackArgs:e.callbackArgs,serviceId:e.serviceId||null,processAction:e.processAction,skipMeta:e.skipMeta},i=new pr(r,this.config),s={context:i,func:i.start,key:t,index:we,stage:ye};this._addTask(t,s)}},{key:"_start",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.IDLE])).forEach((function(e){var r=t.tasks[e];r?r.status===De.IDLE&&(r.status=De.WAITING,t._updateSchduelerMap(e,De.IDLE,De.WAITING)):console.warn("[TTUploader]:".concat(e," is not exit in tasks."))})),this._taskStart()}},{key:"_pause",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.UPLOADING])).forEach((function(e){var r,i=t.tasks[e];if(i){if(i.status===De.UPLOADING){var s="".concat(Se[i.serviceType],"_999");t.logger.sendLogBase(s,i,{type:"pause",ex:"pause upload.".concat(e)}),i.pauseTime=Date.now(),i.status=De.PAUSE,null===(r=i.task)||void 0===r||r.cancel(!0),t._updateSchduelerMap(e,De.UPLOADING,De.PAUSE)}}else console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))})),e&&this._taskStart()}},{key:"_cancel",value:function(e){var t=this;(e?[e]:[].concat(f(this._schedulerMap[De.UPLOADING]),f(this._schedulerMap[De.IDLE]),f(this._schedulerMap[De.WAITING]),f(this._schedulerMap[De.PAUSE]))).forEach((function(e){var r,i=t.tasks[e];if(i){var s=i.status;if(![De.SUCCESS,De.FAILED,De.CANCEL].includes(s)){var n="".concat(Se[i.serviceType],"_999");t.logger.sendLogBase(n,i,{type:"cancel",ex:"cancel upload.".concat(e)}),null===(r=i.task)||void 0===r||r.cancel(!1),t._updateSchduelerMap(e,s,De.CANCEL),i.status=De.CANCEL,delete t.taskList[e],delete t.tasks[e],t._removeTaskCache(e)}}else console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))}))}},{key:"_restart",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.PAUSE])).forEach((function(e){var r=t.tasks[e];r?r.status===De.PAUSE&&(r.status=De.WAITING,t._updateSchduelerMap(e,De.PAUSE,De.WAITING)):console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))})),this._taskStart()}},{key:"_taskStart",value:function(){for(var e,t=this,r=Math.min(this.config.taskParallelLimit-this._schedulerMap[De.UPLOADING].size,this._schedulerMap[De.WAITING].length),i=function(){var e=t._schedulerMap[De.WAITING][0],r=t.tasks[e];if(r.status=De.UPLOADING,t._updateSchduelerMap(e,De.WAITING,De.UPLOADING),r.taskAllFinish){var i="success"===r.type?De.SUCCESS:De.FAILED;if(t._updateSchduelerMap(e,De.UPLOADING,i),r.status=i,t._broadcast(r.stage,r),t._schedulerMap[De.WAITING].length>0)return{v:t._taskStart()}}var s=r.task,n=null,o=!1;if(r.pauseTime){o=!0;var a=r.curTaskIdx;r.requestPending||(s.tasks=t.taskList[e].slice(t.taskList[e].findIndex((function(e){return e.index===a})))),n={type:"resume",ex:"resume upload."},r.pauseDuration+=Date.now()-r.pauseTime}else r.startTime=Date.now(),n={type:"start",ex:"start upload.".concat(e)};var c="".concat(Se[r.serviceType],"_999");t.logger.sendLogBase(c,r,n),s.start(o)},s=0;s<r;s++)if(e=i())return e.v}},{key:"_setCache",value:function(e,t){this.storage.setItem(e,t)}},{key:"_getCache",value:function(e){return this.storage.getItem(e)}},{key:"_removeCache",value:function(e){e?this.storage.removeItem(e):this.storage.clear()}},{key:"_broadcast",value:function(e,t){this.emit(ve[e],t)}},{key:"_removeTaskCache",value:function(e){var t=this.tasks[e];if(t){var r=t.crc32Key;if(r)try{this._removeCache(r)}catch(i){console.warn("[TTUploader]:",null==i?void 0:i.message)}}}},{key:"_saveTask",value:function(e){var t=this.tasks[e],r=t.crc32Key;if(r){var i={sessionKey:t.sessionKey,uploadHeader:t.uploadHeader,fileName:t.fileName,oid:t.oid,uploadId:t.uploadId,signature:t.signature,tosDomain:t.tosDomain,merged:t.merged};Object.keys(i).forEach((function(e){i[e]||delete i[e]}));try{this._setCache(r,JSON.stringify(i))}catch(N){this.logger.sendLogBase("".concat(Se[t.serviceType],"_999"),t,{type:"warning",ex:"Save to cache error:".concat(null==N?void 0:N.message)})}}}},{key:"_taskFinish",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tasks[e];r&&(r.endTime=Date.now(),r.time=r.endTime-r.startTime,r.taskAllFinish=!0,r.status===De.UPLOADING&&(t?(this.taskList[e]=[],r.status=De.SUCCESS,this._updateSchduelerMap(e,De.UPLOADING,De.SUCCESS),this._removeTaskCache(e)):(r.status=De.FAILED,this._updateSchduelerMap(e,De.UPLOADING,De.FAILED)),this._schedulerMap[De.WAITING].length>0&&this._taskStart()))}},{key:"_updateSchduelerMap",value:function(e,t,r){if(t===De.UPLOADING)this._schedulerMap[t].delete(e);else{var i=this._schedulerMap[t].indexOf(e);if(i<0)return;this._schedulerMap[t].splice(i,1)}r===De.UPLOADING?this._schedulerMap[r].add(e):this._schedulerMap[r].push(e)}},{key:"_removeFile",value:function(e){this.tasks.delete(e)}},{key:"_refreshStsToken",value:function(e){var t=this,r=this.tasks;Object.keys(r).forEach((function(i){var s=r[i],n=Object.assign({},s,{proxyStsToken:e});s.proxyStsToken=e;var o=n.crc32Key;o&&(delete n.task,delete n.xhr,delete n.crc32Array,s.proxyStsToken=e,t._setCache(o,JSON.stringify(n)))}))}},{key:"_setOption",value:function(e){this._mergeOptions(this.config,e)}},{key:"_setServiceId",value:function(e){!this.config.imageConfig&&e?this.config.imageConfig={serviceId:e}:this.config.imageConfig.serviceId=e}},{key:"_getServiceId",value:function(){var e;return null===(e=this.config.imageConfig)||void 0===e?void 0:e.serviceId}},{key:"_getOption",value:function(e){var t=Object.assign({},this.config);return e?t[e]:t}}]),r}(x),vr=function(e){c(r,e);var t=d(r);function r(){return s(this,r),t.apply(this,arguments)}return o(r,[{key:"use",value:function(e){this._use(e)}},{key:"addFile",value:function(e){if(e.file){var t=et(Ie);return this._addAllUploadProcess(e,t,Ie),t}return null}},{key:"addVodFile",value:function(e){return this.addFile(e)}},{key:"addImageFile",value:function(e){if(e.file){e.type=Te;var t=et(Oe);return this._addAllUploadProcess(e,t,Oe),t}return null}},{key:"addImageXFile",value:function(e){return this.addImageFile(e)}},{key:"setServiceId",value:function(e){this._setServiceId(e)}},{key:"getServiceId",value:function(){return this._getServiceId()}},{key:"removeFile",value:function(e){e&&this._removeFile(e)}},{key:"start",value:function(e){return this._start(e)}},{key:"restart",value:function(e){return this._restart(e)}},{key:"cancel",value:function(e){return this._cancel(e)}},{key:"pause",value:function(e){return this._pause(e)}},{key:"refreshAuth",value:function(e){this._refreshAuth(e)}},{key:"setOption",value:function(e){this._setOption(e)}},{key:"getOption",value:function(e){return this._getOption(e)}}]),r}(yr);return vr}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TTUploader=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){a(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,r(s.key),s)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,i){return(t=r(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(N){return!1}}();return function(){var r,i=u(e);if(t){var s=u(this).constructor;r=Reflect.construct(i,arguments,s)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,r)}}function f(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),r}var _={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new s(i,n||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,o=new Array(n);s<n;s++)o[s]=i[s].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},a.prototype.emit=function(e,t,i,s,n,o){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,i),!0;case 4:return l.fn.call(l.context,t,i,s),!0;case 5:return l.fn.call(l.context,t,i,s,n),!0;case 6:return l.fn.call(l.context,t,i,s,n,o),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,i);break;case 4:l[u].fn.call(l[u].context,t,i,s);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||s&&!a.once||i&&a.context!==i||o(this,n);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||s&&!a[c].once||i&&a[c].context!==i)&&u.push(a[c]);u.length?this._events[n]=1===u.length?u[0]:u:o(this,n)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(_);var x=v(_.exports),k={region:"cn-north-1",getSliceFunc:null,uploadSliceCount:5,retryUploadTime:2,retryTaskTime:2,requestTimeout:3e5,uploadTimeout:18e5,retryInterval:1e3,schema:"https",useLocalStorage:!0,taskParallelLimit:3},M=function(){return(M=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,n=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(w(arguments[t]));return e}var T,N,C,D=function(e,t){var r,i,s=function(e){var t=document.createElement("a");return t.href=e,t},n=window.screen.width,o=window.screen.height,a=window.navigator.appVersion,c=window.navigator.userAgent,u=window.navigator.language,l=document.referrer,h=l?s(l).hostname:"",d=function(e){var t=s(e).search;t=t.slice(1);var r={};return t.split("&").forEach((function(e){var t,i,s=e.split("=");s.length&&(t=s[0],i=s[1]),i&&(i=i.replace(/\%/g,"%25")),r[t]=decodeURIComponent(void 0===i?"":i)})),r}(window.location.href),f="",p="",g="",y=""+parseFloat(a);-1!==(r=c.indexOf("Opera"))&&(g="Opera",y=c.substring(r+6),-1!==(r=c.indexOf("Version"))&&(y=c.substring(r+8))),-1!==(r=c.indexOf("Edge"))?(g="Microsoft Edge",y=c.substring(r+5)):-1!==(r=c.indexOf("MSIE"))?(g="Microsoft Internet Explorer",y=c.substring(r+5)):-1!==c.indexOf("Chrome")?-1!==(r=c.indexOf("MicroMessenger"))?(g="weixin",y=c.substring(r+15,r+20)):-1!==(r=c.indexOf("MQQBrowser"))?(g="qqbrowser",y=c.substring(r+11,r+15)):-1!==(r=c.indexOf("Chrome"))&&(g="Chrome",y=c.substring(r+7)):-1!==c.indexOf("Safari")?-1!==(r=c.indexOf("QQ"))?(g="qqbrowser",y=c.substring(r+10,r+16)):-1!==(r=c.indexOf("Safari"))&&(g="Safari",y=c.substring(r+7),-1!==(r=c.indexOf("Version"))&&(y=c.substring(r+8))):-1!==(r=c.indexOf("Firefox"))?(g="Firefox",y=c.substring(r+8)):-1!==(r=c.indexOf("MicroMessenger"))?(g="weixin",y=c.substring(r+15,r+20)):-1!==(r=c.indexOf("QQ"))&&(g="qqbrowser",y=c.substring(r+3,r+8)),-1!==(i=y.indexOf(";"))&&(y=y.substring(0,i)),-1!==(i=y.indexOf(" "))&&(y=y.substring(0,i)),-1!==(i=y.indexOf(")"))&&(y=y.substring(0,i));for(var v,m,_=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(a)?"wap":"web",x=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],k=0;k<x.length;k++){var M=x[k];if(M.r.test(c)){f=M.s;break}}function w(e,t){var r=e.exec(t);return r&&r[1]?r[1]:""}switch(/Windows/.test(f)&&(p=w(/Windows (.*)/,f),f="windows"),f){case"Mac OS X":p=w(/Mac OS X (10[\.\_\d]+)/,c),f="mac";break;case"Android":(m=w(/Android ([\.\_\d]+)/,v=c))||(m=w(/Android\/([\.\_\d]+)/,v)),p=m,f="android";break;case"iOS":p=(p=/OS (\d+)_(\d+)_?(\d+)?/.exec(a))?p[1]+"."+p[2]+"."+(0|p[3]):"",f="ios"}var b=e?function(){var e=t?"_tea_utm_cache_"+t:"_tea_utm_cache",r={},i={utm_source:d.utm_source,utm_medium:d.utm_medium,utm_campaign:d.utm_campaign,utm_term:d.utm_term,utm_content:d.utm_content};try{var s=window.sessionStorage,n=!1;for(var o in i)i[o]&&(r[o]=i[o],n=!0);if(n)s.setItem(e,JSON.stringify(r));else{var a=s.getItem(e);a&&(r=JSON.parse(a))}}catch(c){return i}return r}():{};return{browser:g,browser_version:y,platform:_,os_name:f,os_version:p,userAgent:c,screen_width:n,screen_height:o,device_model:function(e){var t="";try{if("android"===e)navigator.userAgent.split(";").forEach((function(e){e.indexOf("Build/")>-1&&(t=e.slice(0,e.indexOf("Build/")))}));else if("ios"===e||"mac"===e){var r=navigator.userAgent.replace("Mozilla/5.0 (",""),i=r.indexOf(";");t=r.slice(0,i)}}catch(s){}return t.trim()}(f),language:u,referrer:l,referrer_host:h,utm_source:b.utm_source,utm_medium:b.utm_medium,utm_campaign:b.utm_campaign,utm_term:b.utm_term,utm_content:b.utm_content,isSupportBeacon:("ios"!==f||"safari"!==g)&&(!(!window.navigator||!window.navigator.sendBeacon)||void 0)}},I=(N=T={exports:{}},C=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var i in r)t[i]=r[i]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(i){function s(){}function n(t,r,n){if("undefined"!=typeof document){"number"==typeof(n=e({path:"/"},s.defaults,n)).expires&&(n.expires=new Date(1*new Date+864e5*n.expires)),n.expires=n.expires?n.expires.toUTCString():"";try{var o=JSON.stringify(r);/^[\{\[]/.test(o)&&(r=o)}catch(u){}r=i.write?i.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in n)n[c]&&(a+="; "+c,!0!==n[c]&&(a+="="+n[c].split(";")[0]));return document.cookie=t+"="+r+a}}function o(e,r){if("undefined"!=typeof document){for(var s={},n=document.cookie?document.cookie.split("; "):[],o=0;o<n.length;o++){var a=n[o].split("="),c=a.slice(1).join("=");r||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=t(a[0]);if(c=(i.read||i)(c,u)||t(c),r)try{c=JSON.parse(c)}catch(l){}if(s[u]=c,e===u)break}catch(l){}}return e?s[e]:s}}return s.set=n,s.get=function(e){return o(e,!1)},s.getJSON=function(e){return o(e,!0)},s.remove=function(t,r){n(t,"",e(r,{expires:-1}))},s.defaults={},s.withConverter=r,s}((function(){}))},N.exports=C(),T.exports),O=function(){function e(){this.cache={}}return e.prototype.setItem=function(e,t){this.cache[e]=t},e.prototype.getItem=function(e){return this.cache[e]},e.prototype.removeItem=function(e){this.cache[e]=void 0},e}(),S={getItem:function(e){try{var t=localStorage.getItem(e),r=t;try{t&&"string"==typeof t&&(r=JSON.parse(t))}catch(i){}return r||void 0}catch(i){}},setItem:function(e,t){try{var r="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(e,r)}catch(i){}},removeItem:function(e){try{localStorage.removeItem(e)}catch(t){}},getCookie:function(e){try{var t=document.cookie.match(new RegExp("(?:^|;)\\s*"+e+"=([^;]+)")),r=t?t[1]:"";return decodeURIComponent(r)}catch(i){return""}},setCookie:function(e,t,r){try{var i=+new Date+r;I.set(e,t,{expires:new Date(i),path:"/",domain:document.domain.split(".").slice(-2).join(".")})}catch(s){}},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(N){return!1}}()},E=function(){function e(e){this._storage=!e&&S.isSupportLS?S:new O}return e.prototype.getItem=function(e){return this._storage.getItem(e)},e.prototype.setItem=function(e,t){this._storage.setItem(e,t)},e.prototype.getCookie=function(e){return this._storage.getCookie(e)},e.prototype.setCookie=function(e,t,r){this._storage.setCookie(e,t,r)},e.prototype.removeItem=function(e){this._storage.removeItem(e)},e}(),A={cn:"https://mcs.snssdk.com",sg:"https://sgali-mcs.byteoversea.com",va:"https://maliva-mcs.byteoversea.com"},z="/v1/user/webid",j=4001,U=4e3,R=4002,L=4003,P=500,F=function(e,t){return t?"__tea_cache_tokens_"+e:"__tea_cache_events_"+e},B=function(e,t,r,i){try{var s,n=e.match(/\/v\d\//);s=n?n[0]:-1!==e.indexOf("/v1/")?"/v1/":"/v2/";var o=e.split(s)[0];if(!o)return void i(e,t,j);t.forEach((function(s){var n=function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&(t+="&"+r+"="+encodeURIComponent(JSON.stringify(e[r])));return"&"===t[0]?t.slice(1):t}(s),a=new Image(1,1);a.onload=function(){a=null,r&&r()},a.onerror=function(){a=null,i&&i(e,t,U)},a.src=o+"/v1/gif?"+n}))}catch(a){i&&i(e,t,R,a.message)}},q=function(e,t,r,i,s,n,o,a){var c,u,l,h,d,f,p=window.navigator.userAgent,g=-1!==window.navigator.appName.indexOf("Microsoft Internet Explorer")&&(-1!==p.indexOf("MSIE 8.0")||-1!==p.indexOf("MSIE 9.0")),y=!!r;if(!y&&g)B(e,t,i,s);else if(!y&&o)return D(!1).isSupportBeacon?(a&&a(),void(window.navigator.sendBeacon(e,JSON.stringify(t))?i():s(e,t,L))):void B(e,t,i,s);n&&delete t.app_key,c=e,u=t,l=i,h=s,d=r,(f=new XMLHttpRequest).open("POST",""+c,!0),f.setRequestHeader("Content-Type","application/json; charset=utf-8"),d&&f.setRequestHeader("X-MCS-AppKey",""+d),f.onload=function(){if(l){var e=null;if(f.responseText){try{e=JSON.parse(f.responseText)}catch(t){e={}}l(e)}}},f.onerror=function(){f.abort(),h&&h(u,P)},f.send(JSON.stringify(u))};function H(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,H)}var K,Q=function(){return H().replace(/-/g,"").slice(0,19)},Y=function(){function e(e,t){this.browser=D(!0,e.app_id),this.config=e,this.cfg=t,this.storage=new E(!1),this.appInfo=e.app_key||e.app_id,this.isNoWebid=e.disable_webid,this.isNoSsid=e.disable_webid||e.disable_ssid,this.domain=e.channel_domain||A[e.channel],this.tokenReady=!1,this.checkExp=e.checkExp||!1,this.enableCookie=e.cross_subdomain||!1,this.expiresTime=this.enableCookie?94608e6:0,this.fetchUrl=""+this.domain+z}return e.prototype._getToken=function(){this.tokensKey=F(this.appInfo,!0),this.cookieKey="__tea_cookie_tokens_"+this.appInfo;var e=this.storage.getItem(this.tokensKey);if(this.enableCookie){var t=this.storage.getCookie(this.cookieKey);if(t){t=decodeURIComponent(t);var r=(t=JSON.parse(t)).user_unique_id,i=t.web_id,s=t.timestamp,n=t.ssid;this._setToken(i,r,n,s)}else{if(!e)return void this._requestWebId();this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(e)),this.expiresTime),this._checkLocal(e)}}else{if(!e)return void this._requestWebId();this._checkLocal(e)}},e.prototype._checkLocal=function(e){if(!e.web_id){var t=this.storage.getCookie("tt_webid"),r=this.storage.getCookie("__tea_sdk__ssid"),i=this.storage.getCookie("__tea_sdk__user_unique_id");if(t&&r&&i){var s={web_id:t,ssid:r,user_unique_id:i,timestamp:Date.now()};this.storage.setItem(this.tokensKey,s)}}var n=this.storage.getItem(this.tokensKey),o=(i=n.user_unique_id,t=n.web_id,n.timestamp);r=n.ssid,t&&i?this._setToken(t,i,r,o):this._requestWebId()},e.prototype._setToken=function(e,t,r,i){if(this.uuid=t,this.web_id=e,this.ssid=r,this.checkExp){var s=Date.now()-parseFloat(i);if(s>7344e6)return void this._requestWebId();if(s>432e7)return void this._updateWebId(e)}this._complete(e,t,r)},e.prototype._complete=function(e,t,r){this.cfg.envInfo.user.ssid=r,this.cfg.envInfo.user.web_id=e,this.cfg.envInfo.user.user_unique_id=t,this.tokenReady=!0},e.prototype._requestWebId=function(){this.isNoWebid?this._setwebId({web_id:Q(),ssid:""}):this._fetchWebId(this.fetchUrl,!1)},e.prototype._updateWebId=function(e){var t=""+this.domain+z+"/"+e+"/update";this._fetchWebId(t,!0)},e.prototype._fetchWebId=function(e,t){var r=this;this.isGetWebId=!0,q(e,{app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:this.browser.userAgent,referer:this.browser.referrer,user_unique_id:""},this.config.app_key,(function(e){if(e&&0===e.e)if(t){var i={web_id:r.web_id,ssid:r.ssid,user_unique_id:r.uuid,timestamp:Date.now()};r.enableCookie&&r.storage.setCookie(r.cookieKey,encodeURIComponent(JSON.stringify(i)),r.expiresTime),r.storage.setItem(r.tokensKey,i),r._complete(r.web_id,r.uuid,r.ssid),r.isGetSsid?r._requestSsId():r.callback&&r.callback()}else r.isGetWebId=!1,r._setwebId(e),r.isGetSsid?r._requestSsId():r.callback&&r.callback();else t?r._fetchWebId(r.fetchUrl,!1):r.isGetWebId=!1}),(function(){r.isGetWebId=!1}),!0)},e.prototype._setwebId=function(e){var t=this.cfg.envInfo.user.web_id||e.web_id,r={web_id:t,ssid:e.ssid,user_unique_id:this._uuid?this._uuid:t,timestamp:Date.now()};this.enableCookie&&this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(r)),this.expiresTime),this.storage.setItem(this.tokensKey,r),this.cfg.envInfo.user.ssid=e.ssid,this.cfg.envInfo.user.web_id=t,this.cfg.envInfo.user.user_unique_id=this._uuid?this._uuid:t,this.uuid=this._uuid?this._uuid:t,this.web_id=t,this.ssid=e.ssid,this.tokenReady=!0},e.prototype._getSsid=function(e){e&&-1===["0","Null","None","","undefined"].indexOf(e)&&(this.uuid===e&&this.web_id&&this.ssid?this.tokenReady=!0:(this._uuid=e,this.uuid=e,this.cfg.envInfo.user.user_unique_id=e,this.isGetSsid=!0,this.isNoSsid||this.isGetWebId?this.callback&&this.callback():(this.tokenReady=!1,this.isGetSsid=!1,this._requestSsId())))},e.prototype._requestSsId=function(){var e=this,t=this.domain+"/v1/user/ssid";q(t,{app_key:this.config.app_key,app_id:this.config.app_id,web_id:this.web_id,user_unique_id:this.uuid},this.config.app_key,(function(t){if(t&&0===t.e){e.cfg.envInfo.user.ssid=t.ssid;var r={web_id:e.web_id,ssid:t.ssid,user_unique_id:e.uuid,timestamp:Date.now()};e.enableCookie&&e.storage.setCookie(e.cookieKey,encodeURIComponent(JSON.stringify(r)),e.expiresTime),e.storage.setItem(e.tokensKey,r),e.tokenReady=!0}else e.tokenReady=!0;e.callback&&e.callback()}),(function(){e.tokenReady=!0,e.callback&&e.callback()}),!0)},e.prototype.isTokenReady=function(){return this.tokenReady},e}(),W=function(){function e(e,t,r,i){this.cfg=t,this.config=e,this._token=r,this.appInfo=e.app_key||e.app_id,this.debugMode=!!e.log,this.evtDataKey=F(this.appInfo,!1);var s=e.channel_domain||A[e.channel];this.reportUrl=e.report_url?e.report_url:s+"/v1/list",this.maxReport=e.max_report||20,this.storage=new E(!0),this.plugin=i,this.addListener()}return e.prototype.addListener=function(){var e=this;window.addEventListener("unload",(function(){e.report(!0)}),!1),window.addEventListener("beforeunload",(function(){e.report(!0)}),!1),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e.report(!0)}),!1)},e.prototype.setReady=function(){this.isReady=!0,this.report()},e.prototype.event=function(e,t){var r=this;void 0===e&&(e=[]),void 0===t&&(t=!1);var i=this.storage.getItem(this.evtDataKey)||[],s=t?b(e,i):b(i,e);this.storage.setItem(this.evtDataKey,s),this.reportTimer&&clearTimeout(this.reportTimer),s.length>=this.maxReport?this.report():this.reportTimer=setTimeout((function(){r.report(),r.reportTimer=null}),30)},e.prototype.report=function(e){if(void 0===e&&(e=!1),this._token.isTokenReady()&&this.isReady){var t=this.storage.getItem(this.evtDataKey)||[],r=this._mergeEvents(t);this.storage.removeItem(this.evtDataKey),this._dealData(r,e)}},e.prototype._mergeEvents=function(e){var t=this;if(!e.length)return e;var r=this.cfg.get();r.header.custom=JSON.stringify(r.header.custom);var i=[];return i.push(e),i.map((function(e){return{events:e.map((function(e){var r=M({},t.cfg.get("evtParams"),e.params);return delete r.__disable_storage__,M({},e,{params:JSON.stringify(r)})})),user:r.user,header:r.header,verbose:t.debugMode?1:void 0}}))},e.prototype._dealData=function(e,t){var r=this;if(!e.length)return e;e.map((function(e){var t=[];return t.push(e),t})).forEach((function(e){var i=Q();r._send(i,e,t)}))},e.prototype._send=function(e,t,r){var i=this;this.isSending=!0;var s=function(){i.isSending=!1};q(this.reportUrl,t,this.config.app_key,(function(){s()}),(function(e,t){s(),i.cfg.get("reportErrorCallback")(e,t)}),!1,r,s)},e}(),G=void 0,J=(new Date).getTimezoneOffset(),V=parseInt(""+-J/60,10),X=60*J,Z=function(){function e(e){var t=D(!0,e);this.envInfo={user:{user_unique_id:G,user_type:G,user_id:G,user_is_auth:G,user_is_login:G,device_id:G,web_id:G,ip_addr_id:G,ssid:G},header:{app_id:G,app_name:G,app_install_id:G,install_id:G,app_package:G,app_channel:G,app_version:G,os_name:t.os_name,os_version:t.os_version,device_model:t.device_model,ab_client:G,ab_version:G,ab_sdk_version:G,traffic_type:G,client_ip:G,device_brand:G,os_api:G,access:G,language:t.language,region:G,app_language:G,app_region:G,creative_id:G,ad_id:G,campaign_id:G,log_type:G,rnd:G,platform:t.platform,sdk_version:"4.1.15",province:G,city:G,timezone:V,tz_offset:X,tz_name:G,sim_region:G,carrier:G,resolution:t.screen_width+"x"+t.screen_height,browser:t.browser,browser_version:t.browser_version,referrer:t.referrer,referrer_host:t.referrer_host,width:t.screen_width,height:t.screen_height,screen_width:t.screen_width,screen_height:t.screen_height,utm_term:t.utm_term,utm_content:t.utm_content,utm_source:t.utm_source,utm_medium:t.utm_medium,utm_campaign:t.utm_campaign,custom:{}}},this.evtParams={},this.reportErrorCallback=function(){}}return e.prototype.set=function(e,t){var r=this;if("disable_auto_pv"!==e)if("evtParams"===e||"_staging_flag"===e){var i;i="evtParams"===e?t:{_staging_flag:Number(t)};var s=M({},i);Object.keys(s).forEach((function(e){r.evtParams[e]=s[e]}))}else if("reportErrorCallback"===e&&"function"==typeof t)this.reportErrorCallback=t;else{var n="";if(e.indexOf(".")>-1){var o=e.split(".");n=o[0],e=o[1]}if("user_unique_id"===e){if(!t)return;if(-1!==["0","Null","None","","undefined"].indexOf(t))return}if("os_version"===e&&(e=""+t),"web_id"===e){if(!t)return;(!this.envInfo.user.user_unique_id||this.envInfo.user.user_unique_id&&this.envInfo.user.user_unique_id===this.envInfo.user.web_id)&&(this.envInfo.user.user_unique_id=t)}n?"user"===n||"header"===n?this.envInfo[n][e]=t:this.envInfo.header.custom[e]=t:this.envInfo.user.hasOwnProperty(e)?["user_type","device_id","ip_addr_id"].indexOf(e)>-1?this.envInfo.user[e]=Number(t):["user_id","web_id","user_unique_id","ssid"].indexOf(e)>-1?this.envInfo.user[e]=String(t):["user_is_auth","user_is_login"].indexOf(e)>-1&&(this.envInfo.user[e]=Boolean(t)):this.envInfo.header.hasOwnProperty(e)?this.envInfo.header[e]=t:this.envInfo.header.custom[e]=t}},e.prototype.get=function(e){return e?"evtParams"===e?this.evtParams:"reportErrorCallback"===e?this.reportErrorCallback:JSON.parse(JSON.stringify(this.envInfo[e])):JSON.parse(JSON.stringify(this.envInfo))},e}(),$=function(){function e(e,t){this.isLog=t,this.name=e||""}var t=e.prototype;return t.info=function(e){this.isLog&&console.log(this.name+" "+e)},t.warn=function(e){this.isLog&&console.warn(this.name+" "+e)},t.error=function(e){this.isLog&&console.error(this.name+" "+e)},t.throw=function(e){throw this.error(this.name),new Error(e)},e}(),ee=b(["init","config","send","start"],[]),te=(K=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return K+=1}),re=function(){function e(e){var t=this;this.predefinePageView=function(e){void 0===e&&(e={});var r=M({title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer},t._event.closeStorage?{}:{__disable_storage__:1}),i=M({},r,e);t.event("predefine_pageview",i,!0)},this.name=e,this._isSend=!1,this.autoPV=!0}return e.prototype.init=function(e){var t=this;if(!this._inited){if(this._inited=!0,!e||"object"!=i(e))throw new Error("init参数有误,请检查");var r=e.app_id,s=e.app_key,n=e.log;this._config=new Z(r),this.logger=new $(this.name,n),s||r||this.logger.throw("没有传入 app_key 或 app_id "),r&&"number"!=typeof r&&this.logger.throw("app_id参数有误,请检查 "),s&&"string"!=typeof s&&this.logger.warn("app_key为空,如果有请传入"),e.channel_domain||-1!==["cn","sg","va"].indexOf(e.channel)||this.logger.throw("channel 变量只能是 `cn`, `sg`,`va`"),this._config.set("app_id",r),e.channel=e.channel?e.channel:"cn",this._initConfig=e,this._token=new Y(e,this._config),this._token.callback=function(){t.callbackSend&&t.start()},this._event=new W(e,this._config,this._token,this.plugin),this._token._getToken()}},e.prototype.config=function(e){if(this._inited)if(e&&"object"==i(e)){if(e.user_unique_id){if("string"!=typeof e.user_unique_id)throw new Error("user_unique_id 只能是string");this._token._getSsid(e.user_unique_id)}for(var t in e.disable_auto_pv&&(this.autoPV=!1),e)this._config.set(t,e[t])}else this.logger.warn("config参数有误,请检查");else this.logger.warn("config应在init之后调用")},e.prototype.send=function(){this.start()},e.prototype.start=function(){if(this._token.isTokenReady()){if(this._isSend)return;this._isSend=!0,this.logger.info("用户信息:"+JSON.stringify(this._config.get("user"))),this.autoPV&&this.predefinePageView(),this._event.setReady()}else this.callbackSend=!0},e.prototype.event=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="boolean"==typeof e[e.length-1]&&e[e.length-1],s="boolean"==typeof e[e.length-1]?e.slice(0,e.length-1):e,n=w(s,1)[0],o=[];"Array"!==Object.prototype.toString.call(n).slice(8,-1)?o[0]=s:o=s,o=o.map((function(e){return function(e,t){var r=e;/^event\./.test(e)&&(r=e.slice(6));var s=t;return"object"!=i(s)&&(s={}),s.event_index=te(),{event:r,params:s,local_time_ms:+new Date,is_bav:0}}(e[0],e[1])})),this._event.event(o,r)},e}();function ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var se=function(e){var t=this;return ie(this,"_exportCollect",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];t._isProcess?t._executeCmd.apply(t,r):(t.cmdQueue.push(r),t._processCmd())})),ie(this,"_processCmd",(function(){if(0!==t.cmdQueue.length){var e,r,i=(e=t.cmdQueue,"init","0",r=-1,e.forEach((function(e,t){"init"===e[0]&&(r=t)})),r);-1!==i&&(t._isProcess=!0,t._executeCmd.apply(t,t.cmdQueue[i]),t.cmdQueue.forEach((function(e,r){r!==i&&t._executeCmd.apply(t,e)})),t.cmdQueue=[])}})),ie(this,"_executeCmd",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var s,n,o=r[0];ee.indexOf(o)>-1?(s=t.colloctor)[o].apply(s,r.slice(1)):(n=t.colloctor).event.apply(n,r)})),this.cmdQueue=[],this.name=e,this.colloctor=new re(e),this._isProcess=!1,this._alias={},this._processCmd(),ee.forEach((function(e){t._exportCollect[e]=t._exportCollect.bind(t,e)})),this._exportCollect},ne={},oe={},ae=function(e){return oe[e]||(oe[e]=[]),oe[e]},ce=function(e){var t=w(e),r=t[0],i=t.slice(1),s=r.split(".");if(1===s.length)ae("default").push(b([r],i));else if(2===s.length)"event"===s[0]?ae("default").push(b([r],i)):ae(s[0]).push(b([s[1]],i));else{var n=s[0],o=[s[1],s[2]].join(".");ae(n).push(b([o],i))}},ue=function(){le.q.forEach((function(e){var t=[].slice.call(e);"Array"===Object.prototype.toString.call(t[0]).slice(8,-1)?t.forEach((function(e){ce(e)})):ce(t)})),Object.keys(oe).forEach((function(e){oe[e].forEach((function(t){var r;(r=e,ne[r]||(ne[r]=new se(r)),ne[r]).apply(void 0,b(t))})),oe[e]=[]})),le.q=[]},le=function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];e.q.push(t),ue()};le.q=[],le.l=Date.now(),le._instanceMap=ne,le._instanceCmdMap=oe,ee.forEach((function(e){le[e]=le.bind(null,e)})),function(e){if("undefined"!=typeof window){var t=function(){if("undefined"!=typeof window)return window.TeaAnalyticsObject}();if(t&&window[t]){var r=window[t];r.init||(e.q=r.q||[],e.l=r.l||Date.now(),window[t]=e)}}}(le),ue();var he=1e3,de=1001,fe=1002,pe=1003,ge=1004,ye=1005,ve={1e3:"crc32",1001:"preUpload",1002:"initUploadID",1003:"process",1004:"fileMerge",1005:"complete",error:"error",progress:"progress"},me=0,_e=1,xe=2,ke=3,Me=4,we=5,be="video",Te="image",Ne="object",Ce={video:"video_upload",image:"image_upload",object:"object_upload"},De={IDLE:0,UPLOADING:1,CANCEL:2,PAUSE:3,SUCCESS:4,FAILED:5,WAITING:6},Ie="vod",Oe="imagex",Se={vod:"video",imagex:"image"},Ee="cn-north-1",Ae="ap-southeast-1",ze="https://vod.volcengineapi.com",je="https://vod.ap-southeast-1.volcengineapi.com",Ue="https://imagex.volcengineapi.com",Re="https://vod.ap-southeast-1.volcengineapi.com",Le=5242880,Pe="{tosDomain}/{oid}?uploads",Fe="{tosDomain}/{oid}?partNumber={number}&uploadID={uploadId}",Be="{tosDomain}/{oid}?uploadID={uploadId}",qe="{tosDomain}/{oid}?uploadID={uploadId}",He="{tosDomain}/{oid}",Ke=a(a(a(a(a(a(a({FILE_ERROR:1000001,STSTOKEN_FORMAT_ERROR:1000002,FILE_ERROR_UPLOADING:1003003},de,{NETWORK_ERROR:1001e3,GENERAL_ERROR:1001001,TIMEOUT_ERROR:1001002}),fe,{NETWORK_ERROR:1002e3,GENERAL_ERROR:1002001,TIMEOUT_ERROR:1002002}),"UPLOAD_NETWORK_ERROR",1003e3),"UPLOAD_GENERAL_ERROR",1003001),"UPLOAD_TIMEOUT_ERROR",1003002),ge,{NETWORK_ERROR:1004e3,GENERAL_ERROR:1004001,TIMEOUT_ERROR:1004002}),ye,{NETWORK_ERROR:1005e3,GENERAL_ERROR:1005001,TIMEOUT_ERROR:1005002}),Qe="An error occurred reading the file.",Ye=function(){function e(t,r){s(this,e),this.options=t,this.context=r,this.teaLog=le,this.teaLog.init({app_id:2562,channel:"cn",log:!1,disable_sdk_monitor:!0}),this.teaLog.config({evtParams:{sdk_version:"1.3.1",line_app_id:this.options.appId,page_url:window.location.href,toB:!0,imp:!1},user_unique_id:this.options.userId,disable_auto_pv:!0}),this.teaLog.start()}return o(e,[{key:"getBaseParams",value:function(e){var t=e.key,r=e.fileType,i=e.fileSize,s=e.serviceType,n=e.isDirect,o=e.isImageBatchUpload,a=e.extra,c=e.type,u=e.stage;return{type:c,log_type:Ce[r],stage:u,fk:t,fs:i,idu:n,ibu:o,idbp:e.isBreak,gwu:e.gatewayUpload,ss:e.sliceSize,sc:e.sliceCount,iie:e.imagexEnableEncrypt,ts:Math.round(Date.now()/1e3),msg:null==a?void 0:a.message,serviceType:s,omitInit:!!e.omitInit,pdur:e.pauseDuration}}},{key:"send",value:function(e){var r,i,s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var o=e.stage,a=e.serviceType,c=e.extra,u=e.oid,l=e.tosDomain,h=e.uploadId,d=e.uploadHeader,f=e.req,p=e.res,g=this.getBaseParams(e);o>=de&&Object.assign(g,{oid:u,upload_host:l,uploadId:h,uh:d,req:f,res:p});var y="".concat(Se[a],"_").concat(o);if(o===pe&&!e.allFinish)return this.teaLog(y,Object.assign(g,n));var v=e.duration,m=e.totalDuration,_=e.stageStartTime,x=e.stageEndTime;Object.assign(g,{sst:_,set:x,dur:v,durs:Math.round(v/1e3),tdur:m,tdurs:Math.round(m/1e3)});var k=null==c?void 0:c.message,M=e.crc32Array,w=e.isDirect;switch(o){case he:k="crc32 stage.len:".concat(M.length,",direct:").concat(w,".");break;case de:k+=".stk:".concat(JSON.stringify(e.proxyStsToken));break;case fe:g.omitInit=!!e.omitInit;break;case pe:delete g.res,delete g.req,g.speed=e.speed,g.af=!0;break;case ge:g.speed=e.speed;break;case ye:k+=null!==(r=e.uploadResult)&&void 0!==r&&r.Vid?".vid:".concat(null===(i=e.uploadResult)||void 0===i?void 0:i.Vid):"",Object.assign(g,{speed:e.speed,skipCommit:!!e.skipCommit,vid:null===(s=e.uploadResult)||void 0===s?void 0:s.Vid,omitInit:!!e.omitInit})}g.ex=k,this.teaLog(y,t(t({},g),n))}}},{key:"sendErrorLog",value:function(e,r){var i=e.serviceType,s=e.extra,n=e.oid,o=e.tosDomain,a=e.uploadId,c=e.req,u=e.res,l=e.stageStartTime,h=e.stageEndTime,d=e.duration,f=e.totalDuration,p=this.getBaseParams(e);Object.assign(p,t({type:"error",req:c,res:u,oid:n,upload_host:o,uploadId:a,errc:null==s?void 0:s.errorCode,errmsg:null==s?void 0:s.message,err:null==s?void 0:s.error,ex:"errorCode:".concat(null==s?void 0:s.errorCode,",").concat(null==s?void 0:s.message),sst:l,set:h,dur:d,durs:Math.round(d/1e3),tdur:f,tdurs:Math.round(f/1e3)},r)),this.teaLog("".concat(Se[i],"_error"),p)}},{key:"sendLogBase",value:function(e,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.teaLog(e,t(t({},this.getBaseParams(r)),i))}}]),e}(),We=function(e){var t=Number(e.substring(0,4)),r=Number(e.substring(4,6)),i=Number(e.substring(6,8)),s=Number(e.substring(8,10)),n=Number(e.substring(10,12)),o=Number(e.substring(12,14));return Date.UTC(t,r-1,i,s-8,n,o)-Date.now()},Ge=function(){for(var e=0,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];for(var s=0,n=r;s<n.length;s++){e+=n[s].byteLength}for(var o=new ArrayBuffer(e),a=new Uint8Array(o),c=0,u=0,l=r;u<l.length;u++){var h=l[u];a.set(new Uint8Array(h),c),c+=h.byteLength}return o},Je=function(e){for(var t=e.length,r=new ArrayBuffer(t),i=new Uint8Array(r),s=0;s<t;s++)i[s]=e.charCodeAt(s);return r},Ve=function(e){for(var t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<e;i++)t+=r.charAt(Math.floor(62*Math.random()));return t},Xe=function(e){if(!e)return"";if(Array.isArray(e))return e.map((function(e){try{return"".concat(e.split("/")[0],"/").concat(encodeURIComponent(e.split("/").slice(1).join("/")))}catch(t){return e}}));try{return"".concat(e.split("/")[0],"/").concat(encodeURIComponent(e.split("/").slice(1).join("/")))}catch(t){return e}},Ze=function(e,t){var r;return t=t||{},Object.keys(t).forEach((function(i){r=new RegExp("{".concat(i,"}"),"g"),e=e.replace(r,t[i])})),e},$e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[];return Object.keys(e).map((function(r){var i=e[r];"[object Array]"===Object.prototype.toString.call(i)?i.sort().forEach((function(e){t.push("".concat(r,"=").concat(encodeURIComponent(e)))})):t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},et=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{"x-storage-mode":"gateway"}:{};return Array.isArray(e)?(e.forEach((function(e){var r;e.Key&&e.Value&&(t[null===(r=e.Key)||void 0===r?void 0:r.toLowerCase()]=e.Value)})),t):"[object Object]"===Object.prototype.toString.call(e)?Object.assign(t,e):t},tt=function(e){var t=e,r={removeItem:function(e){delete t.cache[e]},setItem:function(e,r){t.cache[e]=r},getItem:function(e){return t.cache[e]},clear:function(){delete t.cache,t.cache={}}};if(!(!(arguments.length>1&&void 0!==arguments[1])||arguments[1]))return r;try{if(window.localStorage)return window.localStorage.setItem("",""),window.localStorage}catch(N){return r}return r},rt=function(){},it=function(e){return"".concat(e,"_").concat(parseInt(1e7*Math.random()),"_").concat(parseInt(1e7*Math.random()))},st=function(e,t){var r=1048576;return t&&"function"==typeof t?t(e)<Le?Le:t(e)||e:e<=200*r?5*r:e<=500*r?8*r:10*r},nt=function(e){if(Array.isArray(e)&&(e=e[0]),!e||"[object String]"!==Object.prototype.toString.call(e))return null;var t=e.lastIndexOf(".");return t>0?".".concat(e.substring(t+1)):null};function ot(e){return{req:{url:null==e?void 0:e.currentUrl,param:null==e?void 0:e.params},res:{status:null==e?void 0:e.status,body:null==e?void 0:e.responseText}}}function at(e,t,r){return r=r||e.size,new Promise((function(i,s){var n=new FileReader;n.readAsArrayBuffer(function(e,t,r){var i=e.slice||e.webkitSlice||e.mozSlice;return i.call(e,t,r)}(e,t,r)),n.onload=function(e){i(e.target.result)},n.onerror=function(e){var t,r,i,n,o="";null!==(t=e.target.error)&&void 0!==t&&t.name||null!==(r=e.target.error)&&void 0!==r&&r.message?o="".concat(null===(i=e.target.error)||void 0===i?void 0:i.name,":").concat(null===(n=e.target.error)||void 0===n?void 0:n.message,"."):o="read file error,invalid file or destoryed.";s(Error(o))}}))}var ct=function(e,t){var r=t.sliceIndex;return e[r].loaded=Math.max(e[r].loaded||0,t.loaded),e.reduce((function(e,t){return e+(t.loaded||0)}),0)},ut=function(e,t){return t===Ie?e===Ae?je:ze:e===Ae?Re:Ue};function lt(e){return e.length<8?lt(e="0".concat(e)):e}function ht(e){if(void 0!==e)return lt(Number(e).toString(16))}function dt(e,t){var r=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(r=new Int32Array(r));for(var i=-1^~~t,s=(e=new Uint8Array(e)).length,n=0;n<s;n++)i=r[255&(i^e[n])]^i>>>8;return ht((-1^i)>>>0)}var ft={exports:{}};var pt,gt,yt={exports:{}},vt=new Proxy({},{get(e,t){throw new Error(`Module "" has been externalized for browser compatibility. Cannot access ".${t}" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}}),mt=m(Object.freeze({__proto__:null,default:vt}));function _t(){return pt||(pt=1,yt.exports=(e=e||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==y&&y.crypto&&(r=y.crypto),!r)try{r=mt}catch(g){}var i=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(g){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(g){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},o=n.lib={},a=o.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=o.WordArray=a.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,s=e.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var o=r[n>>>2]>>>24-n%4*8&255;t[i+n>>>2]|=o<<24-(i+n)%4*8}else for(var a=0;a<s;a+=4)t[i+a>>>2]=r[a>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new c.init(t,e)}}),u=n.enc={},l=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],s=0;s<r;s++){var n=t[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new c.init(r,t/2)}},h=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],s=0;s<r;s++){var n=t[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new c.init(r,t)}},d=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(N){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},f=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,i=this._data,s=i.words,n=i.sigBytes,o=this.blockSize,a=n/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*u,n);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(s,h);r=s.splice(0,u),i.sigBytes-=l}return new c.init(r,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=f.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new p.HMAC.init(e,r).finalize(t)}}});var p=n.algo={};return n}(Math),e)),yt.exports;var e}ft.exports=(gt=_t(),function(){if("function"==typeof ArrayBuffer){var e=gt.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,i=[],s=0;s<r;s++)i[s>>>2]|=e[s]<<24-s%4*8;t.call(this,i,r)}else t.apply(this,arguments)};r.prototype=e}}(),gt.lib.WordArray);var xt,kt=v(ft.exports),Mt={exports:{}},wt={exports:{}};function bt(){return xt||(xt=1,function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.WordArray;function i(e,t,i){for(var s=[],n=0,o=0;o<t;o++)if(o%4){var a=i[e.charCodeAt(o-1)]<<o%4*2|i[e.charCodeAt(o)]>>>6-o%4*2;s[n>>>2]|=a<<24-n%4*8,n++}return r.create(s,n)}t.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,i=this._map;e.clamp();for(var s=[],n=0;n<r;n+=3)for(var o=(t[n>>>2]>>>24-n%4*8&255)<<16|(t[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|t[n+2>>>2]>>>24-(n+2)%4*8&255,a=0;a<4&&n+.75*a<r;a++)s.push(i.charAt(o>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,r=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var n=0;n<r.length;n++)s[r.charCodeAt(n)]=n}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return i(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(_t())}(wt)),wt.exports}var Tt,Nt={exports:{}};function Ct(){return Tt||(Tt=1,function(e,t){e.exports=function(e){return function(t){var r=e,i=r.lib,s=i.WordArray,n=i.Hasher,o=r.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=o.MD5=n.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,s=e[i];e[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n=this._hash.words,o=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],y=e[t+5],v=e[t+6],m=e[t+7],_=e[t+8],x=e[t+9],k=e[t+10],M=e[t+11],w=e[t+12],b=e[t+13],T=e[t+14],N=e[t+15],C=n[0],D=n[1],I=n[2],O=n[3];C=u(C,D,I,O,o,7,a[0]),O=u(O,C,D,I,c,12,a[1]),I=u(I,O,C,D,f,17,a[2]),D=u(D,I,O,C,p,22,a[3]),C=u(C,D,I,O,g,7,a[4]),O=u(O,C,D,I,y,12,a[5]),I=u(I,O,C,D,v,17,a[6]),D=u(D,I,O,C,m,22,a[7]),C=u(C,D,I,O,_,7,a[8]),O=u(O,C,D,I,x,12,a[9]),I=u(I,O,C,D,k,17,a[10]),D=u(D,I,O,C,M,22,a[11]),C=u(C,D,I,O,w,7,a[12]),O=u(O,C,D,I,b,12,a[13]),I=u(I,O,C,D,T,17,a[14]),C=l(C,D=u(D,I,O,C,N,22,a[15]),I,O,c,5,a[16]),O=l(O,C,D,I,v,9,a[17]),I=l(I,O,C,D,M,14,a[18]),D=l(D,I,O,C,o,20,a[19]),C=l(C,D,I,O,y,5,a[20]),O=l(O,C,D,I,k,9,a[21]),I=l(I,O,C,D,N,14,a[22]),D=l(D,I,O,C,g,20,a[23]),C=l(C,D,I,O,x,5,a[24]),O=l(O,C,D,I,T,9,a[25]),I=l(I,O,C,D,p,14,a[26]),D=l(D,I,O,C,_,20,a[27]),C=l(C,D,I,O,b,5,a[28]),O=l(O,C,D,I,f,9,a[29]),I=l(I,O,C,D,m,14,a[30]),C=h(C,D=l(D,I,O,C,w,20,a[31]),I,O,y,4,a[32]),O=h(O,C,D,I,_,11,a[33]),I=h(I,O,C,D,M,16,a[34]),D=h(D,I,O,C,T,23,a[35]),C=h(C,D,I,O,c,4,a[36]),O=h(O,C,D,I,g,11,a[37]),I=h(I,O,C,D,m,16,a[38]),D=h(D,I,O,C,k,23,a[39]),C=h(C,D,I,O,b,4,a[40]),O=h(O,C,D,I,o,11,a[41]),I=h(I,O,C,D,p,16,a[42]),D=h(D,I,O,C,v,23,a[43]),C=h(C,D,I,O,x,4,a[44]),O=h(O,C,D,I,w,11,a[45]),I=h(I,O,C,D,N,16,a[46]),C=d(C,D=h(D,I,O,C,f,23,a[47]),I,O,o,6,a[48]),O=d(O,C,D,I,m,10,a[49]),I=d(I,O,C,D,T,15,a[50]),D=d(D,I,O,C,y,21,a[51]),C=d(C,D,I,O,w,6,a[52]),O=d(O,C,D,I,p,10,a[53]),I=d(I,O,C,D,k,15,a[54]),D=d(D,I,O,C,c,21,a[55]),C=d(C,D,I,O,_,6,a[56]),O=d(O,C,D,I,N,10,a[57]),I=d(I,O,C,D,v,15,a[58]),D=d(D,I,O,C,b,21,a[59]),C=d(C,D,I,O,g,6,a[60]),O=d(O,C,D,I,M,10,a[61]),I=d(I,O,C,D,f,15,a[62]),D=d(D,I,O,C,x,21,a[63]),n[0]=n[0]+C|0,n[1]=n[1]+D|0,n[2]=n[2]+I|0,n[3]=n[3]+O|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296),o=i;r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),e.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,s,n,o){var a=e+(t&r|~t&i)+s+o;return(a<<n|a>>>32-n)+t}function l(e,t,r,i,s,n,o){var a=e+(t&i|r&~i)+s+o;return(a<<n|a>>>32-n)+t}function h(e,t,r,i,s,n,o){var a=e+(t^r^i)+s+o;return(a<<n|a>>>32-n)+t}function d(e,t,r,i,s,n,o){var a=e+(r^(t|~i))+s+o;return(a<<n|a>>>32-n)+t}r.MD5=n._createHelper(c),r.HmacMD5=n._createHmacHelper(c)}(Math),e.MD5}(_t())}(Nt)),Nt.exports}var Dt,It={exports:{}},Ot={exports:{}};function St(){return Dt||(Dt=1,function(e,t){e.exports=function(e){return r=(t=e).lib,i=r.WordArray,s=r.Hasher,n=t.algo,o=[],a=n.SHA1=s.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|e[t+u];else{var l=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=l<<1|l>>>31}var h=(i<<5|i>>>27)+c+o[u];h+=u<20?1518500249+(s&n|~s&a):u<40?1859775393+(s^n^a):u<60?(s&n|s&a|n&a)-1894007588:(s^n^a)-899497514,c=a,a=n,n=s<<30|s>>>2,s=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(i+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=s._createHelper(a),t.HmacSHA1=s._createHmacHelper(a),e.SHA1;var t,r,i,s,n,o,a}(_t())}(Ot)),Ot.exports}var Et,At,zt={exports:{}};function jt(){return Et||(Et=1,function(e,t){e.exports=function(e){var t,r,i;r=(t=e).lib.Base,i=t.enc.Utf8,t.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,s=4*r;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),o=this._iKey=t.clone(),a=n.words,c=o.words,u=0;u<r;u++)a[u]^=1549556828,c[u]^=909522486;n.sigBytes=o.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})}(_t())}(zt)),zt.exports}function Ut(){return At||(At=1,function(e,t){e.exports=function(e){return r=(t=e).lib,i=r.Base,s=r.WordArray,n=t.algo,o=n.MD5,a=n.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:o,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,i=this.cfg,n=i.hasher.create(),o=s.create(),a=o.words,c=i.keySize,u=i.iterations;a.length<c;){r&&n.update(r),r=n.update(e).finalize(t),n.reset();for(var l=1;l<u;l++)r=n.finalize(r),n.reset();o.concat(r)}return o.sigBytes=4*c,o}}),t.EvpKDF=function(e,t,r){return a.create(r).compute(e,t)},e.EvpKDF;var t,r,i,s,n,o,a}(_t(),St(),jt())}(It)),It.exports}var Rt,Lt={exports:{}};function Pt(){return Rt||(Rt=1,function(e,t){e.exports=function(e){e.lib.Cipher||function(t){var r=e,i=r.lib,s=i.Base,n=i.WordArray,o=i.BufferedBlockAlgorithm,a=r.enc;a.Utf8;var c=a.Base64,u=r.algo.EvpKDF,l=i.Cipher=o.extend({cfg:s.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?_:v}return function(t){return{encrypt:function(r,i,s){return e(i).encrypt(t,r,i,s)},decrypt:function(r,i,s){return e(i).decrypt(t,r,i,s)}}}}()});i.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=r.mode={},d=i.BlockCipherMode=s.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=h.CBC=function(){var e=d.extend();function r(e,r,i){var s,n=this._iv;n?(s=n,this._iv=t):s=this._prevBlock;for(var o=0;o<i;o++)e[r+o]^=s[o]}return e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;r.call(this,e,t,s),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+s)}}),e.Decryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,n=e.slice(t,t+s);i.decryptBlock(e,t),r.call(this,e,t,s),this._prevBlock=n}}),e}(),p=(r.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,i=r-e.sigBytes%r,s=i<<24|i<<16|i<<8|i,o=[],a=0;a<i;a+=4)o.push(s);var c=n.create(o,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};i.BlockCipher=l.extend({cfg:l.cfg.extend({mode:f,padding:p}),reset:function(){var e;l.reset.call(this);var t=this.cfg,r=t.iv,i=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(i,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var g=i.CipherParams=s.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),y=(r.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?n.create([1398893684,1701076831]).concat(r).concat(t):t).toString(c)},parse:function(e){var t,r=c.parse(e),i=r.words;return 1398893684==i[0]&&1701076831==i[1]&&(t=n.create(i.slice(2,4)),i.splice(0,4),r.sigBytes-=16),g.create({ciphertext:r,salt:t})}},v=i.SerializableCipher=s.extend({cfg:s.extend({format:y}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var s=e.createEncryptor(r,i),n=s.finalize(t),o=s.cfg;return g.create({ciphertext:n,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){return i=this.cfg.extend(i),t=this._parse(t,i.format),e.createDecryptor(r,i).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(r.kdf={}).OpenSSL={execute:function(e,t,r,i,s){if(i||(i=n.random(8)),s)o=u.create({keySize:t+r,hasher:s}).compute(e,i);else var o=u.create({keySize:t+r}).compute(e,i);var a=n.create(o.words.slice(t),4*r);return o.sigBytes=4*t,g.create({key:o,iv:a,salt:i})}},_=i.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:m}),encrypt:function(e,t,r,i){var s=(i=this.cfg.extend(i)).kdf.execute(r,e.keySize,e.ivSize,i.salt,i.hasher);i.iv=s.iv;var n=v.encrypt.call(this,e,t,s.key,i);return n.mixIn(s),n},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var s=i.kdf.execute(r,e.keySize,e.ivSize,t.salt,i.hasher);return i.iv=s.iv,v.decrypt.call(this,e,t,s.key,i)}})}()}(_t(),Ut())}(Lt)),Lt.exports}!function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.BlockCipher,i=t.algo,s=[],n=[],o=[],a=[],c=[],u=[],l=[],h=[],d=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,s[r]=p,n[p]=r;var g=e[r],y=e[g],v=e[y],m=257*e[p]^16843008*p;o[r]=m<<24|m>>>8,a[r]=m<<16|m>>>16,c[r]=m<<8|m>>>24,u[r]=m,m=16843009*v^65537*y^257*g^16843008*r,l[p]=m<<24|m>>>8,h[p]=m<<16|m>>>16,d[p]=m<<8|m>>>24,f[p]=m,r?(r=g^e[e[e[v^g]]],i^=e[e[i]]):r=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=i.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,i=4*((this._nRounds=r+6)+1),n=this._keySchedule=[],o=0;o<i;o++)o<r?n[o]=t[o]:(u=n[o-1],o%r?r>6&&o%r==4&&(u=s[u>>>24]<<24|s[u>>>16&255]<<16|s[u>>>8&255]<<8|s[255&u]):(u=s[(u=u<<8|u>>>24)>>>24]<<24|s[u>>>16&255]<<16|s[u>>>8&255]<<8|s[255&u],u^=p[o/r|0]<<24),n[o]=n[o-r]^u);for(var a=this._invKeySchedule=[],c=0;c<i;c++){if(o=i-c,c%4)var u=n[o];else u=n[o-4];a[c]=c<4||o<=4?u:l[s[u>>>24]]^h[s[u>>>16&255]]^d[s[u>>>8&255]]^f[s[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,a,c,u,s)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,h,d,f,n),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,i,s,n,o,a){for(var c=this._nRounds,u=e[t]^r[0],l=e[t+1]^r[1],h=e[t+2]^r[2],d=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=i[u>>>24]^s[l>>>16&255]^n[h>>>8&255]^o[255&d]^r[f++],y=i[l>>>24]^s[h>>>16&255]^n[d>>>8&255]^o[255&u]^r[f++],v=i[h>>>24]^s[d>>>16&255]^n[u>>>8&255]^o[255&l]^r[f++],m=i[d>>>24]^s[u>>>16&255]^n[l>>>8&255]^o[255&h]^r[f++];u=g,l=y,h=v,d=m}g=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&d])^r[f++],y=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^r[f++],v=(a[h>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[f++],m=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=m},keySize:8});t.AES=r._createHelper(g)}(),e.AES}(_t(),bt(),Ct(),Ut(),Pt())}(Mt);var Ft=v(Mt.exports),Bt={exports:{}};!function(e,t){e.exports=function(e){return e.enc.Utf8}(_t())}(Bt);var qt=v(Bt.exports),Ht={exports:{}};!function(e,t){e.exports=function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();function r(e,t,r,i){var s,n=this._iv;n?(s=n.slice(0),this._iv=void 0):s=this._prevBlock,i.encryptBlock(s,0);for(var o=0;o<r;o++)e[t+o]^=s[o]}return t.Encryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;r.call(this,e,t,s,i),this._prevBlock=e.slice(t,t+s)}}),t.Decryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,n=e.slice(t,t+s);r.call(this,e,t,s,i),this._prevBlock=n}}),t}(),e.mode.CFB}(_t(),Pt())}(Ht);var Kt=v(Ht.exports),Qt={exports:{}};!function(e,t){e.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(_t(),Pt())}(Qt);var Yt=v(Qt.exports);function Wt(e){var t=e.key,r=e.iv,i=e.data,s=function(e){for(var t=e.words,r=e.sigBytes,i=new Uint8Array(r),s=0;s<r;s+=1)i[s]=t[s>>>2]>>>24-s%4*8&255;return i}(Ft.encrypt(kt.create(i),qt.parse(t),{mode:Kt,padding:Yt,iv:qt.parse(r)}).ciphertext);return s.buffer}var Gt,Jt=function(){function e(t,r){s(this,e),this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.config=r,this.isDirect=this.currFileCtx.isDirect,this.isImageBatchUpload=this.currFileCtx.isImageBatchUpload,this.serviceName=this.currFileCtx.serviceType||Ie,this.file=t.file,this.sliceLength=this.currFileCtx.sliceSize}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.currFileCtx.imagexEnableEncrypt&&this.isDirect?this.handleImagexEncryptDirect(this.file):this.currFileCtx.imagexEnableEncrypt&&!this.isDirect?this.handleImagexEncryptSlice(this.file,this.sliceLength):!this.currFileCtx.imagexEnableEncrypt&&this.isDirect?this.handleDirect(this.file):this.handleSlice(this.file,this.sliceLength)}},{key:"handleDirect",value:function(e){var t=this,r=this.isImageBatchUpload?e:[e];Promise.all(r.map((function(e){return at(e,0)}))).then((function(e){var r=e.map((function(e){return{start:0,end:e.byteLength,crc32:dt(e,0),buffer:e}}));t.success(r)}),(function(e){t.fail({errorCode:Ke.FILE_ERROR,message:null==e?void 0:e.message,error:null==e?void 0:e.message})}))}},{key:"handleSlice",value:function(e,t){for(var r=this,i=[],s=e.size,n=0,o=0;o<s;)o=Math.min(n+t,s),s-o<=5242880&&(o=s),i.push({start:n,end:o,crc32:0}),n=o;if(this.currFileCtx.enableDiskBreakPoint&&i.length>2){var a=i.length;Promise.all([at(e,i[0].start,i[0].end),at(e,i[a-1].start,i[a-1].end)]).then((function(e){i[0].crc32=dt(e[0],0),i[a-1].crc32=dt(e[1],0),r.currFileCtx.crc32Key=r.getCrc32Key(i,s)})).catch((function(e){console.warn("[TTUploader]:",null==e?void 0:e.message),r.currFileCtx.enableDiskBreakPoint=!1})).finally((function(){r.success(i)}))}else this.success(i)}},{key:"handleImagexEncryptDirect",value:function(e){var t=this,r=this.currFileCtx.imagexEncryptKey,i=this.isImageBatchUpload?e:[e];Promise.all(i.map((function(e){return at(e,0)}))).then((function(e){var i=Ve(16),s=e.map((function(e){var t=Wt({key:r,iv:i,data:e}),s=Ge(Je("aes256cfb-direct"),Je(i),t);return{start:0,end:s.byteLength,crc32:dt(s,0),buffer:s}}));t.success(s)}),(function(e){t.fail({errorCode:Ke.FILE_ERROR,message:null==e?void 0:e.message,error:null==e?void 0:e.message})}))}},{key:"handleImagexEncryptSlice",value:function(e,t){for(var r=new ArrayBuffer(36),i=new DataView(r),s=Je("aes-256-cfb-part"),n=new Uint8Array(s),o=0;o<16;o++)i.setUint8(o,n[o]);i.setUint16(16,0,!0),i.setUint16(18,0,!0),i.setUint32(20,t,!0),i.setUint32(24,0,!0),i.setUint32(28,0,!0),i.setUint32(32,0,!0);for(var a=Ve(16),c=Ge(r,Je(a)),u=[{crc32:dt(c,0),buffer:c,encryptMeta:!0,start:-52,end:0,iv:a}],l=e.size,h=0,d=0;d<l;)d=Math.min(h+t,l),u.push({start:h,end:d,crc32:0}),h=d;this.success(u)}},{key:"getCrc32Key",value:function(e,t){var r=[t];return r.push(e[0].crc32,e[e.length-1].crc32),r.join("_")}},{key:"success",value:function(e){var t=Object.assign(this.currFileCtx,{crc32Array:e,extra:{message:"crc32 stage success."}});this.successProcess(t)}},{key:"fail",value:function(e){var t=Object.assign(this.currFileCtx,{extra:{message:(null==e?void 0:e.message)||"crc32 stage error.",errorCode:e.errorCode||Ke.FILE_ERROR,error:e.error||"%s"}});this.failProcess(t)}}]),e}(),Vt=globalThis,Xt=function(e){c(r,e);var t=d(r);function r(){var e;return s(this,r),(e=t.call(this)).xhr=new XMLHttpRequest,e._data=null,e}return o(r,[{key:"_ajax",value:function(e){var t=this,r=this.xhr;r.upload.onprogress=function(e){t.emit("progress",e)},r.onreadystatechange=function(){4===r.readyState&&(r.upload.onprogress=rt,r.onreadystatechange=rt,r.params=e,r.currentUrl=t._data.url,r.status>=200&&r.status<300?t.emit("complete",r):r.status>=400&&t.emit("error",r))},r.onerror=function(){r.errText="unknow net error",t.emit("error",r)},r.ontimeout=function(){r.errText="timeout",t.emit("timeout",r)},r.onabort=function(){r.errText="abort",t.emit("error",r)},r.send(e)}},{key:"send",value:function(e){var t=this;return this._data=e,this.xhr.open(e.method||"POST",e.url||"",!0),e.headers&&Object.keys(e.headers).forEach((function(r){t.xhr.setRequestHeader(r,e.headers[r])})),this.xhr.timeout=e.timeout||0,e.binary?(this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this._ajax(e.file)):e.custom?this._ajax(e.custom):this._ajax(null)}},{key:"abort",value:function(){this.xhr.onreadystatechange=rt,this.xhr.abort()}}]),r}(x),Zt=function(e,t){var r=new Xt;return new Promise((function(i,s){r.on("complete",(function(e){var r,n={};try{n=JSON.parse(e.response)}catch(c){var o={errorCode:Ke[t].GENERAL_ERROR,message:"Parse response error:".concat(t),error:"".concat((null==c?void 0:c.message)||""),xhr:e};s(o)}if(null!==(r=n.ResponseMetadata)&&void 0!==r&&r.Error){var a={xhr:e,errorCode:n.ResponseMetadata.Error.CodeN,error:n.ResponseMetadata.Error.Code,message:n.ResponseMetadata.Error.Message,requestId:n.ResponseMetadata.RequestId};s(a)}else i({result:n.Result,xhr:e})})),r.on("error",(function(e){var r={errorCode:Ke[t].NETWORK_ERROR,message:"Request failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(e.currentUrl),xhr:e};if(0!==e.status)try{var i,n=JSON.parse(e.response);null!==(i=n.ResponseMetadata)&&void 0!==i&&i.Error&&(r.errorCode=n.ResponseMetadata.Error.CodeN,r.error=n.ResponseMetadata.Error.Code,r.message=n.ResponseMetadata.Error.Message,r.requestId=n.ResponseMetadata.RequestId)}catch(o){r.errorCode=Ke[t].GENERAL_ERROR,r.message="Parse response error.",r.error="".concat((null==o?void 0:o.message)||"")}s(r)})),r.on("timeout",(function(e){var r={errorCode:Ke[t].TIMEOUT_ERROR,message:"Request timeout.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(e.currentUrl),xhr:e};s(r)})),r.send(e)}))},$t=function(e,t){var r=new Xt;return new Promise((function(i,s){r.on("complete",(function(e){var r={};try{r=JSON.parse(e.response)}catch(N){var n={errorCode:Ke[t].GENERAL_ERROR,message:"Parse server response error:".concat(t),error:"".concat((null==N?void 0:N.message)||""),xhr:e};s(n)}if(0===r.success){var o,a=null;if(t===fe)a=null===(o=r.payload)||void 0===o?void 0:o.uploadID;else if(t===de){var c;a=null===(c=r.payload)||void 0===c?void 0:c.partList}i({result:a,xhr:e})}else{var u,l,h,d={errorCode:(null===(u=r.error)||void 0===u?void 0:u.error_code)||Ke[t].GENERAL_ERROR,message:null===(l=r.error)||void 0===l?void 0:l.message,error:null===(h=r)||void 0===h||null===(h=h.error)||void 0===h?void 0:h.error,xhr:e};Vt.fail(d)}})),r.on("error",(function(e){var r={errorCode:Ke[t].NETWORK_ERROR,message:"Upload failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Failed at ").concat(e.currentUrl),xhr:e};if(0!==e.status)try{var i,n,o,a=JSON.parse(e.response);r.errorCode=null===(i=a.error)||void 0===i?void 0:i.error_code,r.message=null===(n=a.error)||void 0===n?void 0:n.message,r.error=null==a||null===(o=a.error)||void 0===o?void 0:o.error}catch(N){r.errorCode=Ke[t].GENERAL_ERROR,r.message="Parse server response error:".concat(t),r.error="".concat((null==N?void 0:N.message)||"")}s(r)})),r.on("timeout",(function(e){var r={errorCode:Ke[t].TIMEOUT_ERROR,message:"Request timeout:".concat(t),error:"HttpStatus:".concat(e.status,".Failed at ").concat(e.currentUrl),xhr:e};s(r)})),r.send(e)}))},er={exports:{}},tr={exports:{}};function rr(){return Gt||(Gt=1,function(e,t){e.exports=function(e){return function(t){var r=e,i=r.lib,s=i.WordArray,n=i.Hasher,o=r.algo,a=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),i=2;i<=r;i++)if(!(e%i))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var i=2,s=0;s<64;)e(i)&&(s<8&&(a[s]=r(t.pow(i,.5))),c[s]=r(t.pow(i,1/3)),s++),i++}();var u=[],l=o.SHA256=n.extend({_doReset:function(){this._hash=new s.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],o=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=0;f<64;f++){if(f<16)u[f]=0|e[t+f];else{var p=u[f-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[f-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[f]=g+u[f-7]+v+u[f-16]}var m=i&s^i&n^s&n,_=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),x=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[f]+u[f];d=h,h=l,l=a,a=o+x|0,o=n,n=s,s=i,i=x+(_+m)|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+d|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=n._createHelper(l),r.HmacSHA256=n._createHmacHelper(l)}(Math),e.SHA256}(_t())}(tr)),tr.exports}!function(e,t){e.exports=function(e){return e.HmacSHA256}(_t(),rr(),jt())}(er);var ir=v(er.exports),sr=v(rr()),nr=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],or=function(e){try{return encodeURIComponent(e).replace(/[^A-Za-z0-9_.~\-%]+/g,escape).replace(/[*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}catch(N){return""}},ar=function(e){return Object.keys(e).sort().map((function(t){var r=e[t];if(null!=r){var i=or(t);if(i)return Array.isArray(r)?"".concat(i,"=").concat(r.map(or).sort().join("&".concat(i,"="))):"".concat(i,"=").concat(or(r))}})).filter((function(e){return e})).join("&")},cr=function(){function e(t,r,i){s(this,e),this.request=t,this.request.headers=t.headers||{},this.serviceName=r,i=i||{},this.signatureCache="boolean"!=typeof i.signatureCache||i.signatureCache,this.operation=i.operation,this.signatureVersion=i.signatureVersion,this.constant=i.isVolcengine?{algorithm:"HMAC-SHA256",v4Identifier:"request",dateHeader:"X-Date",tokenHeader:"x-security-token",contentSha256Header:"X-Content-Sha256",kDatePrefix:""}:{algorithm:"AWS4-HMAC-SHA256",v4Identifier:"aws4_request",dateHeader:"X-Amz-Date",tokenHeader:"x-amz-security-token",contentSha256Header:"X-Amz-Content-Sha256",kDatePrefix:"AWS4"},this.bodySha256=i.bodySha256}return o(e,[{key:"addAuthorization",value:function(e,t){var r=this.iso8601(t).replace(/[:-]|\.\d{3}/g,"");this.addHeaders(e,r),this.request.headers.Authorization=this.authorization(e,r)}},{key:"addHeaders",value:function(e,t){if(this.request.headers[this.constant.dateHeader]=t,e.sessionToken&&(this.request.headers[this.constant.tokenHeader]=e.sessionToken),this.request.body){var r=this.request.body;"string"!=typeof r&&(r=r instanceof URLSearchParams?r.toString():JSON.stringify(r)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||sr(r).toString()}}},{key:"authorization",value:function(e,t){var r=[],i=this.credentialString(t);return r.push("".concat(this.constant.algorithm," Credential=").concat(e.accessKeyId,"/").concat(i)),r.push("SignedHeaders=".concat(this.signedHeaders())),r.push("Signature=".concat(this.signature(e,t))),r.join(", ")}},{key:"signature",value:function(e,t){var r=this.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return ir(this.stringToSign(t),r)}},{key:"stringToSign",value:function(e){var t=[];return t.push(this.constant.algorithm),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")}},{key:"canonicalString",value:function(){var e=[],t=this.request.pathname||"/";return e.push(this.request.method.toUpperCase()),e.push(t),e.push(ar(this.request.params)||""),e.push("".concat(this.canonicalHeaders(),"\n")),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")}},{key:"canonicalHeaders",value:function(){var e=this,t=[];Object.keys(this.request.headers).forEach((function(r){t.push([r,e.request.headers[r]])})),t.sort((function(e,t){return e[0].toLowerCase()<t[0].toLowerCase()?-1:1}));var r=[];return t.forEach((function(t){var i=t[0].toLowerCase();if(e.isSignableHeader(i)){var s=t[1];if(null==s||"function"!=typeof s.toString)throw new Error("Header ".concat(i," contains invalid value"));r.push("".concat(i,":").concat(e.canonicalHeaderValues(s.toString())))}})),r.join("\n")}},{key:"canonicalHeaderValues",value:function(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}},{key:"signedHeaders",value:function(){var e=this,t=[];return Object.keys(this.request.headers).forEach((function(r){r=r.toLowerCase(),e.isSignableHeader(r)&&t.push(r)})),t.sort().join(";")}},{key:"credentialString",value:function(e){return this.createScope(e.substr(0,8),this.request.region,this.serviceName)}},{key:"hexEncodedHash",value:function(e){return sr(e)}},{key:"hexEncodedBodyHash",value:function(){return this.request.headers[this.constant.contentSha256Header]?this.request.headers[this.constant.contentSha256Header]:this.request.body?this.hexEncodedHash(ar(this.request.body)):this.hexEncodedHash("")}},{key:"isSignableHeader",value:function(e){return 0===e.toLowerCase().indexOf("x-amz-")||nr.indexOf(e)<0}},{key:"iso8601",value:function(e){return void 0===e&&(e=new Date),e.toISOString().replace(/\.\d{3}Z$/,"Z")}},{key:"getSigningKey",value:function(e,t,r,i){var s=ir(t,"".concat(this.constant.kDatePrefix).concat(e.secretAccessKey)),n=ir(r,s),o=ir(i,n);return ir(this.constant.v4Identifier,o)}},{key:"createScope",value:function(e,t,r){return[e.substr(0,8),t,r,this.constant.v4Identifier].join("/")}}]),e}(),ur=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.isImageBatchUpload=!!this.currFileCtx.isImageBatchUpload,this.serviceName=this.currFileCtx.serviceType,this.retryTime=r.retryTaskTime,this.retryCount=0}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e;var r=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),i={};try{i=r?JSON.parse(r):{}}catch(s){console.warn("[TTUploader]:","Parse cacheInfo from storage failed.")}i.oid&&i.uploadId&&i.tosDomain?this.resumeFromCache(i):this.startPreUpload()}},{key:"startPreUpload",value:function(){var e=this.createReqParamsByService(this.serviceName),t=e.host,r=e.params;if(this.config.useFileExtension){var i=nt(this.currFileCtx.fileName);i&&(r.FileExtension=i)}this.options.fileExtension&&(r.FileExtension=this.options.fileExtension),this.config.accountId&&(r["X-Account-Id"]=this.config.accountId),r.s=Math.random().toString(36).substr(2),this.uploaderCtx.priorInfo.topExpires>0&&(r["X-Expires"]=this.uploaderCtx.priorInfo.topExpires);var s=$e(r),n={method:"GET",url:"".concat(t,"?").concat(s),timeout:this.config.requestTimeout,region:this.config.region||Ee,params:r},o=new cr(n,this.serviceName,{isVolcengine:!0}),a=this.currFileCtx.proxyStsToken||this.config.stsToken,c=a.AccessKeyID,u=a.AccessKeyId,l=a.SecretAccessKey,h=a.SessionToken,d=a.CurrentTime,f=null;f=this.config.useServerCurrentTime?new Date(d):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap),o.addAuthorization({accessKeyId:u||c,secretAccessKey:l,sessionToken:h},f),this.request(n)}},{key:"createReqParamsByService",value:function(e){var t={};if(e===Ie){var r,i;t.host=this.config.videoHost||ut(this.config.region,e);var s,n=null===(r=this.config.videoConfig)||void 0===r?void 0:r.spaceName;if(this.currFileCtx.fileType===Ne&&null!==(i=this.config.objectConfig)&&void 0!==i&&i.spaceName)n=null===(s=this.config.objectConfig)||void 0===s?void 0:s.spaceName;t.params={Action:"ApplyUploadInfo",Version:"2022-01-01",SpaceName:n,FileSize:this.currFileCtx.fileSize,FileType:this.currFileCtx.fileType},this.options.fileName&&(t.params.FileName=this.options.fileName),this.options.fileExtension&&(t.params.FileExtension=this.options.fileExtension),this.options.storageClass&&(t.params.StorageClass=this.options.storageClass)}else{var o;if(t.host=this.config.imageHost||ut(this.config.region,e),t.params={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null===(o=this.config.imageConfig)||void 0===o?void 0:o.serviceId)},Array.isArray(this.currFileCtx.fileName)&&(t.params.UploadNum=this.currFileCtx.fileName.length),this.options.storeKey){var a=this.options.storeKey;t.params.StoreKeys=Array.isArray(a)?a:[a]}this.options.prefix&&(t.params.Prefix=this.options.prefix),this.options.overwrite&&(t.params.Overwrite=!0)}return t}},{key:"request",value:function(e){var t=this;Zt(e,de).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e,r){t.fail(e,r)}))}},{key:"resumeFromCache",value:function(e){var r=this,i={method:"GET",url:Ze(qe,{tosDomain:e.tosDomain,oid:e.oid,uploadId:e.uploadId}),headers:t({authorization:e.signature},e.uploadHeader),timeout:this.config.requestTimeout};$t(i,de).then((function(t){var i=t.result,s=t.xhr;if(i&&i.length>0){var n=r.confirmCache(i),o=!!e.merged?we:n.isAllFinished?Me:ke,a=Object.assign(r.currFileCtx,e,{extra:{message:"resume upload from disk cache."},percent:0,cacheTaskIdx:o,isBreak:1,xhr:s});r.successProcess(a)}else r.startPreUpload()}),(function(e){var t=ot(e.xhr),i=t.res,s=t.req;r.uploaderCtx.logger.sendLogBase("".concat(Se[r.currFileCtx.serviceType],"_999"),r.currFileCtx,{type:"warning",ex:"Resume from disk cache failed.",res:i,req:s,errc:null==e?void 0:e.errorCode,errmsg:null==e?void 0:e.message,err:null==e?void 0:e.error}),r.startPreUpload()}))}},{key:"confirmCache",value:function(e){var t=this.currFileCtx.crc32Array,r={};e.forEach((function(e){var t=parseInt(e.partNumber)-1;Number.isNaN(t)||void 0!==r[t]||(r[t]={tag:!0,crc32:e.crc32})}));var i=!0,s=t.map((function(e,t){return r[t]&&r[t].tag&&r[t].crc32?(e.crc32=r[t].crc32,e.finished=!0,e.loaded=e.end-e.start):i=!1,e}));return{isAllFinished:i,crc32Array:s}}},{key:"success",value:function(e,t){var r=this.serviceName===Oe?e.UploadAddress:e.Data.UploadAddress,i=r.StoreInfos,s=r.UploadHosts,n=r.SessionKey,o=r.UploadHeader,a=[],c=[];this.isImageBatchUpload&&i.length>1?i.forEach((function(e){a.push(e.Auth),c.push(e.StoreUri)})):(a=i[0].Auth,c=i[0].StoreUri);var u=Object.assign(this.currFileCtx,{signature:a,extra:{message:"prepare upload success"},oid:Xe(c),tosDomain:"".concat(this.config.schema,"://").concat(s[0]),xhr:t,uploadHeader:et(o,this.currFileCtx.gatewayUpload),sessionKey:n});this.successProcess(u)}},{key:"fail",value:function(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires){return this.uploaderCtx.priorInfo.topExpires=604800,this.startPreUpload()}if(0===this.uploaderCtx.priorInfo.systemTimeGap){var t=We(e.requestId);return this.uploaderCtx.priorInfo.systemTimeGap=t,this.startPreUpload()}}if(this.retryCount<this.retryTime)return this.retryCount+=1,this.startPreUpload();var r=Object.assign(this.currFileCtx,{extra:{message:e.message,errorCode:e.errorCode,error:e.error},xhr:e.xhr});this.failProcess(r)}}]),e}(),lr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.retryTime=r.retryTaskTime,this.req=null}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.retryCount=0,this.initUpload()}},{key:"initUpload",value:function(){var e={oid:this.currFileCtx.oid,tosDomain:this.currFileCtx.tosDomain},r={method:"POST",url:Ze(Pe,e),headers:t({authorization:this.currFileCtx.signature},this.currFileCtx.uploadHeader),timeout:this.config.requestTimeout};this.req=r,this.request(r)}},{key:"request",value:function(e){var t=this;$t(e,fe).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"success",value:function(e,t){var r=Object.assign(this.currFileCtx,{uploadId:e,extra:{message:"init upload id success."},xhr:t});this.successProcess(r)}},{key:"fail",value:function(e){if(this.retryCount<this.retryTime&&this.req)return this.retryCount+=1,this.request(this.req);var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}}]),e}(),hr=function(e){c(i,e);var r=d(i);function i(e){var t,n=e.sliceBuffer,o=e.crc32,a=e.url,c=e.signature,u=e.uploadHeader,l=e.retryTime,h=e.sliceIndex,d=e.uploadTimeout;return s(this,i),(t=r.call(this)).sliceBuffer=n,t.crc32=o,t.uploadUrl=a,t.uploadHeader=u,t.signature=c,t.sliceIndex=h,t.retryCount=0,t.retryTime=l,t.uploadTimeout=d,t.cancel=!1,t._st=Date.now(),t}return o(i,[{key:"upload",value:function(){var e=this;this.transport=null,this.transport=new Xt,this.transport.on("complete",(function(t){e.success(t)})),this.transport.on("error",(function(t){e.fail(t)})),this.transport.on("timeout",(function(t){e.fail(t,!0)})),this.transport.on("progress",(function(t){e.process(t)}));var r={method:this.method,url:this.uploadUrl,headers:t({authorization:this.signature,"content-crc32":this.crc32},this.uploadHeader),file:this.sliceBuffer,binary:1,timeout:this.uploadTimeout};this.transport.send(r)}},{key:"success",value:function(e){var t=this.sliceBuffer.size||this.sliceBuffer.byteLength;this.emit("complete",{crc32:this.crc32,size:t,xhr:e,duration:Date.now()-this._st,sliceIndex:this.sliceIndex})}},{key:"fail",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.cancel){var i={errorCode:Ke.UPLOAD_NETWORK_ERROR,message:"Upload failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(this.uploadUrl)};if(r)i.errorCode=Ke.UPLOAD_TIMEOUT_ERROR,i.message="Upload failed: Timeout.",i.error="HttpStatus:".concat(e.status,".Request fail at ").concat(this.uploadUrl);else if(0!==e.status)try{var s,n,o,a=JSON.parse(e.response);i.errorCode=null==a||null===(s=a.error)||void 0===s?void 0:s.error_code,i.message=null==a||null===(n=a.error)||void 0===n?void 0:n.message,i.error=null==a||null===(o=a.error)||void 0===o?void 0:o.error}catch(u){i.errorCode=Ke.UPLOAD_GENERAL_ERROR,i.message="Parse response error.",i.error="".concat((null==u?void 0:u.message)||"")}var c=t({crc32:this.crc32,size:this.sliceBuffer.size||this.sliceBuffer.byteLength,xhr:e,duration:Date.now()-this._st,sliceIndex:this.sliceIndex,retryCount:this.retryCount},i);if(this.retryCount<this.retryTime)return this.retryCount+=1,this.emit("retry",c),void this.upload();this.emit("error",c)}}},{key:"process",value:function(e){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:e.loaded||0,total:e.total||0,sliceIndex:this.sliceIndex})}},{key:"abort",value:function(){var e;this.transport&&(this.cancel=!0,null===(e=this.transport)||void 0===e||e.abort())}},{key:"destroy",value:function(){this.transport=null}}]),i}(x),dr="IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIG4odCl7cmV0dXJuIHQubGVuZ3RoPDg/bih0PSIwIi5jb25jYXQodCkpOnR9ZnVuY3Rpb24gdCh0KXtpZih2b2lkIDAhPT10KXJldHVybiBuKE51bWJlcih0KS50b1N0cmluZygxNikpfXNlbGYub25tZXNzYWdlPWZ1bmN0aW9uKG4pe3ZhciByPW4uZGF0YSxlPXJbMF0sbz1yWzFdLGE9ZnVuY3Rpb24obixyKXt2YXIgZT1bMCwxOTk2OTU5ODk0LDM5OTM5MTk3ODgsMjU2NzUyNDc5NCwxMjQ2MzQxMzcsMTg4NjA1NzYxNSwzOTE1NjIxNjg1LDI2NTczOTIwMzUsMjQ5MjY4Mjc0LDIwNDQ1MDgzMjQsMzc3MjExNTIzMCwyNTQ3MTc3ODY0LDE2Mjk0MTk5NSwyMTI1NTYxMDIxLDM4ODc2MDcwNDcsMjQyODQ0NDA0OSw0OTg1MzY1NDgsMTc4OTkyNzY2Niw0MDg5MDE2NjQ4LDIyMjcwNjEyMTQsNDUwNTQ4ODYxLDE4NDMyNTg2MDMsNDEwNzU4MDc1MywyMjExNjc3NjM5LDMyNTg4Mzk5MCwxNjg0Nzc3MTUyLDQyNTExMjIwNDIsMjMyMTkyNjYzNiwzMzU2MzM0ODcsMTY2MTM2NTQ2NSw0MTk1MzAyNzU1LDIzNjYxMTUzMTcsOTk3MDczMDk2LDEyODE5NTM4ODYsMzU3OTg1NTMzMiwyNzI0Njg4MjQyLDEwMDY4ODgxNDUsMTI1ODYwNzY4NywzNTI0MTAxNjI5LDI3Njg5NDI0NDMsOTAxMDk3NzIyLDExMTkwMDA2ODQsMzY4NjUxNzIwNiwyODk4MDY1NzI4LDg1MzA0NDQ1MSwxMTcyMjY2MTAxLDM3MDUwMTU3NTksMjg4MjYxNjY2NSw2NTE3Njc5ODAsMTM3MzUwMzU0NiwzMzY5NTU0MzA0LDMyMTgxMDQ1OTgsNTY1NTA3MjUzLDE0NTQ2MjE3MzEsMzQ4NTExMTcwNSwzMDk5NDM2MzAzLDY3MTI2Njk3NCwxNTk0MTk4MDI0LDMzMjI3MzA5MzAsMjk3MDM0NzgxMiw3OTU4MzU1MjcsMTQ4MzIzMDIyNSwzMjQ0MzY3Mjc1LDMwNjAxNDk1NjUsMTk5NDE0NjE5MiwzMTE1ODUzNCwyNTYzOTA3NzcyLDQwMjM3MTc5MzAsMTkwNzQ1OTQ2NSwxMTI2MzcyMTUsMjY4MDE1MzI1MywzOTA0NDI3MDU5LDIwMTM3NzYyOTAsMjUxNzIyMDM2LDI1MTcyMTUzNzQsMzc3NTgzMDA0MCwyMTM3NjU2NzYzLDE0MTM3NjgxMywyNDM5Mjc3NzE5LDM4NjUyNzEyOTcsMTgwMjE5NTQ0NCw0NzY4NjQ4NjYsMjIzODAwMTM2OCw0MDY2NTA4ODc4LDE4MTIzNzA5MjUsNDUzMDkyNzMxLDIxODE2MjUwMjUsNDExMTQ1MTIyMywxNzA2MDg4OTAyLDMxNDA0MjcwNCwyMzQ0NTMyMjAyLDQyNDAwMTc1MzIsMTY1ODY1ODI3MSwzNjY2MTk5NzcsMjM2MjY3MDMyMyw0MjI0OTk0NDA1LDEzMDM1MzU5NjAsOTg0OTYxNDg2LDI3NDcwMDcwOTIsMzU2OTAzNzUzOCwxMjU2MTcwODE3LDEwMzc2MDQzMTEsMjc2NTIxMDczMywzNTU0MDc5OTk1LDExMzEwMTQ1MDYsODc5Njc5OTk2LDI5MDkyNDM0NjIsMzY2Mzc3MTg1NiwxMTQxMTI0NDY3LDg1NTg0MjI3NywyODUyODAxNjMxLDM3MDg2NDg2NDksMTM0MjUzMzk0OCw2NTQ0NTkzMDYsMzE4ODM5NjA0OCwzMzczMDE1MTc0LDE0NjY0Nzk5MDksNTQ0MTc5NjM1LDMxMTA1MjM5MTMsMzQ2MjUyMjAxNSwxNTkxNjcxMDU0LDcwMjEzODc3NiwyOTY2NDYwNDUwLDMzNTI3OTk0MTIsMTUwNDkxODgwNyw3ODM1NTE4NzMsMzA4MjY0MDQ0MywzMjMzNDQyOTg5LDM5ODgyOTIzODQsMjU5NjI1NDY0Niw2MjMxNzA2OCwxOTU3ODEwODQyLDM5Mzk4NDU5NDUsMjY0NzgxNjExMSw4MTQ3MDk5NywxOTQzODAzNTIzLDM4MTQ5MTg5MzAsMjQ4OTU5NjgwNCwyMjUyNzQ0MzAsMjA1Mzc5MDM3NiwzODI2MTc1NzU1LDI0NjY5MDYwMTMsMTY3ODE2NzQzLDIwOTc2NTEzNzcsNDAyNzU1MjU4MCwyMjY1NDkwMzg2LDUwMzQ0NDA3MiwxNzYyMDUwODE0LDQxNTA0MTcyNDUsMjE1NDEyOTM1NSw0MjY1MjIyMjUsMTg1MjUwNzg3OSw0Mjc1MzEzNTI2LDIzMTIzMTc5MjAsMjgyNzUzNjI2LDE3NDI1NTU4NTIsNDE4OTcwODE0MywyMzk0ODc3OTQ1LDM5NzkxNzc2MywxNjIyMTgzNjM3LDM2MDQzOTA4ODgsMjcxNDg2NjU1OCw5NTM3Mjk3MzIsMTM0MDA3NjYyNiwzNTE4NzE5OTg1LDI3OTczNjA5OTksMTA2ODgyODM4MSwxMjE5NjM4ODU5LDM2MjQ3NDE4NTAsMjkzNjY3NTE0OCw5MDYxODU0NjIsMTA5MDgxMjUxMiwzNzQ3NjcyMDAzLDI4MjUzNzk2NjksODI5MzI5MTM1LDExODEzMzUxNjEsMzQxMjE3NzgwNCwzMTYwODM0ODQyLDYyODA4NTQwOCwxMzgyNjA1MzY2LDM0MjMzNjkxMDksMzEzODA3ODQ2Nyw1NzA1NjIyMzMsMTQyNjQwMDgxNSwzMzE3MzE2NTQyLDI5OTg3MzM2MDgsNzMzMjM5OTU0LDE1NTUyNjE5NTYsMzI2ODkzNTU5MSwzMDUwMzYwNjI1LDc1MjQ1OTQwMywxNTQxMzIwMjIxLDI2MDcwNzE5MjAsMzk2NTk3MzAzMCwxOTY5OTIyOTcyLDQwNzM1NDk4LDI2MTc4MzcyMjUsMzk0MzU3NzE1MSwxOTEzMDg3ODc3LDgzOTA4MzcxLDI1MTIzNDE2MzQsMzgwMzc0MDY5MiwyMDc1MjA4NjIyLDIxMzI2MTExMiwyNDYzMjcyNjAzLDM4NTU5OTAyODUsMjA5NDg1NDA3MSwxOTg5NTg4ODEsMjI2MjAyOTAxMiw0MDU3MjYwNjEwLDE3NTkzNTk5OTIsNTM0NDE0MTkwLDIxNzY3MTg1NDEsNDEzOTMyOTExNSwxODczODM2MDAxLDQxNDY2NDU2NywyMjgyMjQ4OTM0LDQyNzkyMDAzNjgsMTcxMTY4NDU1NCwyODUyODExMTYsMjQwNTgwMTcyNyw0MTY3MjE2NzQ1LDE2MzQ0Njc3OTUsMzc2MjI5NzAxLDI2ODUwNjc4OTYsMzYwODAwNzQwNiwxMzA4OTE4NjEyLDk1NjU0MzkzOCwyODA4NTU1MTA1LDM0OTU5NTgyNjMsMTIzMTYzNjMwMSwxMDQ3NDI3MDM1LDI5MzI5NTk4MTgsMzY1NDcwMzgzNiwxMDg4MzU5MjcwLDkzNjkxOGUzLDI4NDc3MTQ4OTksMzczNjgzNzgyOSwxMjAyOTAwODYzLDgxNzIzMzg5NywzMTgzMzQyMTA4LDM0MDEyMzcxMzAsMTQwNDI3NzU1Miw2MTU4MTgxNTAsMzEzNDIwNzQ5MywzNDUzNDIxMjAzLDE0MjM4NTc0NDksNjAxNDUwNDMxLDMwMDk4Mzc2MTQsMzI5NDcxMDQ1NiwxNTY3MTAzNzQ2LDcxMTkyODcyNCwzMDIwNjY4NDcxLDMyNzIzODAwNjUsMTUxMDMzNDIzNSw3NTUxNjcxMTddOyJ1bmRlZmluZWQiIT10eXBlb2YgSW50MzJBcnJheSYmKGU9bmV3IEludDMyQXJyYXkoZSkpO2Zvcih2YXIgbz0tMV5+fnIsYT0obj1uZXcgVWludDhBcnJheShuKSkubGVuZ3RoLGk9MDtpPGE7aSsrKW89ZVsyNTUmKG9ebltpXSldXm8+Pj44O3JldHVybiB0KCgtMV5vKT4+PjApfShlLDApO3Bvc3RNZXNzYWdlKFtlLGEsb10sW2VdKX19KCk7Cg==",fr="undefined"!=typeof window&&window.Blob&&new Blob([atob(dr)],{type:"text/javascript;charset=utf-8"});function pr(){var e;try{if(!(e=fr&&(window.URL||window.webkitURL).createObjectURL(fr)))throw"";return new Worker(e)}catch(N){return new Worker("data:application/javascript;base64,"+dr)}finally{!("undefined"!=typeof window&&navigator.userAgent.indexOf("Trident/")>0)&&e&&(window.URL||window.webkitlRL).revokeObjectURL(e)}}var gr=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,e),this.file=t.file,this.uploaderCtx=t.context,this.key=t.key,this.config=r,this.finishArr=[],this.finishSize=0,this.retryUploadTime=Number(r.retryUploadTime),this.writenStorage=!1,this.uploadHandlers={}}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e,this.currFileCtx=this.uploaderCtx.tasks[this.key],this.crc32Array=this.currFileCtx.crc32Array,this.uploadSliceCount=Math.min(this.crc32Array.length,Number(this.config.uploadSliceCount)),this.lastIndex=0,this.uploading=[],this._uploadSize=this.crc32Array.reduce((function(e,t){return e+(t.finished?0:t.end-t.start)}),0),this._st=Date.now(),this.imagexEncrypt=this.currFileCtx.imagexEnableEncrypt,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function(){var e=this;if(!this.worker){try{this.worker=new pr}catch(r){return console.warn("[TTUploader]:worker not supported!"),void this.uploaderCtx.logger.sendLogBase("".concat(Se[this.currFileCtx.serviceType],"_999"),this.currFileCtx,{type:"warning",stage:pe,ex:"init worker failed:".concat(null==r?void 0:r.message),msg:"worker not supported."})}var t=this.crc32Array;this.worker.onmessage=function(r){var i=r.data[0],s=r.data[2],n=t[s];n.crc32=r.data[1],e.upload(n,i,s)}}}},{key:"read",value:function(e,t){var r=this;e.encryptMeta?this.upload(e,e.buffer,t):at(this.file,e.start,e.end).then((function(i){r.imagexEncrypt&&(i=Wt({iv:r.crc32Array[0].iv,key:r.currFileCtx.imagexEncryptKey,data:i})),r.worker?r.worker.postMessage([i,t],[i]):(e.crc32=dt(i,0),r.upload(e,i,t))}),(function(e){r.stop(),r.fail({extra:{errorCode:Ke.FILE_ERROR_UPLOADING,message:Qe,error:null==e?void 0:e.message}})}))}},{key:"threadUpload",value:function(){if(this.uploading.length<this.uploadSliceCount){var e=this.lastIndex,t=this.crc32Array[e];if(t){if(t.finished){if(-1===this.finishArr.indexOf(t.start)&&(this.finishArr.push(t.start),this.finishArr.length>=this.crc32Array.length))return this.stop(),void this.success()}else t.loaded=0,this.uploading.push(e),this.read(t,e);this.lastIndex++,this.threadUpload()}}}},{key:"upload",value:function(e,t,r){var i=this,s=e.crc32,n={number:r+1,uploadId:this.currFileCtx.uploadId,oid:this.currFileCtx.oid,tosDomain:this.currFileCtx.tosDomain},o=Ze(Fe,n),a=Object.assign({},this.currFileCtx.uploadHeader),c=new hr({sliceBuffer:t,crc32:s,url:o,signature:this.currFileCtx.signature,uploadHeader:a,retryTime:this.retryUploadTime,sliceIndex:r});c.on("complete",(function(t){t.start=e.start,i.singleSliceSuccess(t)})),c.on("error",(function(t){i.currFileCtx.status===De.UPLOADING&&(t.start=e.start,i.fail(t))})),c.on("progress",(function(t){i.currFileCtx.status===De.UPLOADING&&(t.start=e.start,i.process(t))})),c.on("retry",(function(e){var t=ot(e.xhr),r=t.req,s=t.res;i.uploaderCtx.logger.sendLogBase("".concat(Se[i.currFileCtx.serviceType],"_retry"),i.currFileCtx,{type:"retry",ex:"upload retry, retry count:".concat(e.retryCount,",errorCode:").concat(e.errorCode),req:r,res:s,si:e.sliceIndex+1,errc:e.errorCode,err:e.error,errmsg:e.errmsg})})),c.upload(),this.uploadHandlers[r]=c}},{key:"singleSliceSuccess",value:function(e){var t=e.sliceIndex;-1===this.finishArr.indexOf(e.start)&&this.finishArr.push(e.start),this.crc32Array[t].finished=!0;var r=ot(e.xhr),i=r.res,s=r.req;if(this.uploaderCtx.logger.send(this.currFileCtx,{type:"success",si:t+1,af:!1,ss:e.size,sldur:e.duration,ex:"Slice upload:".concat(t+1," success:").concat(e.crc32,",total:").concat(this.crc32Array.length,"."),req:s,res:i}),!this.writenStorage&&this.currFileCtx.enableDiskBreakPoint&&(this.writenStorage=!0,this.uploaderCtx._saveTask(this.key)),this.uploading.splice(this.uploading.indexOf(t),1),this.uploadHandlers[t]&&delete this.uploadHandlers[t],this.currFileCtx.status===De.UPLOADING)return this.finishArr.length>=this.crc32Array.length?(this.stop(),void this.success(e.xhr)):void(this.currFileCtx.status===De.UPLOADING&&this.threadUpload())}},{key:"process",value:function(e){var t=this.currFileCtx.fileSize;this.finishSize=Math.max(ct(this.crc32Array,e),this.finishSize);var r=Math.min(Math.round(this.finishSize/t*100),99);r>this.currFileCtx.percent&&(this.currFileCtx.percent=r,this.uploaderCtx._broadcast("progress",this.currFileCtx))}},{key:"success",value:function(e){var t,r;this.finishArr=[];var i=Date.now()-this._st,s=Math.round(this._uploadSize/1024)/(i/1e3),n=Object.assign(this.currFileCtx,{percent:99,extra:{message:"upload all slice success."},speed:s,allFinish:!0});null===(t=this.worker)||void 0===t||null===(r=t.terminate)||void 0===r||r.call(t),this.successProcess(n)}},{key:"fail",value:function(e){this.stop();var t={errorCode:e.errorCode,message:e.message,error:e.error},r=Object.assign(this.currFileCtx,{extra:t,type:"error",allFinish:!1});this.failProcess(r)}},{key:"stop",value:function(){var e,t;Object.values(this.uploadHandlers).forEach((function(e){null==e||e.abort()})),null===(e=this.worker)||void 0===e||null===(t=e.terminate)||void 0===t||t.call(e),this.worker=null}}]),e}(),yr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.retryTime=r.retryTaskTime,this.req=null}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.retryCount=0,this.mergeFile()}},{key:"mergeFile",value:function(){for(var e={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadId,tosDomain:this.currFileCtx.tosDomain},r=this.currFileCtx.crc32Array,i="",s=0;s<r.length;s++)i=i?"".concat(i,",").concat(s+1,":").concat(r[s].crc32):"".concat(s+1,":").concat(r[s].crc32);var n=Ze(Be,e),o=Object.assign({},this.currFileCtx.uploadHeader),a={method:"POST",url:n,headers:t({authorization:this.currFileCtx.signature},o),custom:i};this.req=a,this.request(a)}},{key:"request",value:function(e){var t=this;$t(e,ge).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"success",value:function(e,t){var r=Object.assign(this.currFileCtx,{merged:!0,extra:{message:"merge file success."},xhr:t});this.uploaderCtx._saveTask(this.options.key),this.successProcess(r)}},{key:"fail",value:function(e){if(this.retryCount<this.retryTime&&this.req)return this.retryCount+=1,this.request(this.req);var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}}]),e}(),vr=function(){function e(t,r){s(this,e),this.options=t,this.file=t.file,this.uploaderCtx=t.context,this.key=t.key,this.config=r,this.finishSize=0,this.retryUploadTime=Number(r.retryUploadTime),this.uploadSuccessNum=0,this.uploadFailNum=0}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e,this.currFileCtx=this.uploaderCtx.tasks[this.key],this.crc32Array=this.currFileCtx.crc32Array,this._uploadSize=this.currFileCtx.fileSize,this.uploadHandlers={},this._st=Date.now(),this.upload()}},{key:"upload",value:function(){for(var e=this,t=this.crc32Array.length,r=0;r<t;r++){var i=this.crc32Array[r];if(!i.finished){var s=i.buffer,n=i.crc32,o=this.currFileCtx.oid,a=this.currFileCtx.signature,c={oid:Array.isArray(o)?o[r]:o,tosDomain:this.currFileCtx.tosDomain},u=Ze(He,c),l=new hr({sliceBuffer:s,crc32:n,url:u,signature:Array.isArray(a)?a[r]:a,uploadHeader:this.currFileCtx.uploadHeader,retryTime:this.retryUploadTime,sliceIndex:r});l.on("complete",(function(t){e.singleSliceSuccess(t)})),l.on("error",(function(t){e.singleSliceFailed(t)})),l.on("progress",(function(t){e.process(t)})),l.on("retry",(function(t){var r=ot(t.xhr),i=r.req,s=r.res;e.uploaderCtx.logger.sendLogBase("".concat(Se[e.currFileCtx.serviceType],"_retry"),e.currFileCtx,{type:"retry",ex:"upload retry, retry count:".concat(t.retryCount,",errorCode:").concat(t.errorCode),req:i,res:s,si:t.sliceIndex+1,errc:t.errorCode,err:t.error,errmsg:t.errmsg})})),this.uploadHandlers["".concat(n,"_").concat(Math.round(1e3*Math.random()))]=l,l.upload()}}}},{key:"process",value:function(e){var t=this.currFileCtx.fileSize;this.finishSize=ct(this.currFileCtx.crc32Array,e);var r=Math.min(Math.round(this.finishSize/t*100),99);r>this.currFileCtx.percent&&(this.currFileCtx.percent=r),this.currFileCtx.status===De.UPLOADING&&this.uploaderCtx._broadcast("progress",this.currFileCtx)}},{key:"singleSliceSuccess",value:function(e){var t=e.sliceIndex;if(!this.crc32Array[t].finished){this.crc32Array[t].finished=!0,this.uploadSuccessNum+=1;var r=ot(e.xhr),i=r.res,s=r.req;this.uploaderCtx.logger.send(this.currFileCtx,{type:"success",si:t+1,af:!1,ss:e.size,sldur:e.duration,ex:"Direct upload:".concat(t+1," success:").concat(e.crc32,",total:").concat(this.crc32Array.length,",batch:").concat(this.currFileCtx.isImageBatchUpload),req:s,res:i})}this.uploadSuccessNum+this.uploadFailNum===this.crc32Array.length&&this.success(e)}},{key:"singleSliceFailed",value:function(e){this.uploadFailNum+=1;var t=ot(e.xhr),r=t.res,i=t.req;this.uploaderCtx.logger.sendLogBase("".concat(Se[this.currFileCtx.serviceType],"_999"),this.currFileCtx,{type:"warning",si:e.sliceIndex+1,ss:e.size,ex:"warning:direct upload idx:".concat(e.sliceIndex+1," failed,total:").concat(this.crc32Array.length,",batch:").concat(this.currFileCtx.isImageBatchUpload),req:i,res:r}),this.uploadFailNum===this.crc32Array.length&&this.fail(e)}},{key:"success",value:function(e){var t=Date.now()-this._st,r=Math.round(this._uploadSize/t),i=Object.assign(this.currFileCtx,{percent:99,extra:{message:"direct upload success"},speed:r,xhr:e.xhr,allFinish:!0});this.successProcess(i)}},{key:"fail",value:function(e){var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}},{key:"stop",value:function(){Object.values(this.uploadHandlers).forEach((function(e){null==e||e.abort()}))}}]),e}(),mr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.processAction=t.processAction,this.serviceName=this.currFileCtx.serviceType,this.isImageBatchUpload=!!this.currFileCtx.isImageBatchUpload,this.retryTime=r.retryTaskTime,this.retryCount=0}return o(e,[{key:"start",value:function(e,t){if(this.successProcess=e,this.failProcess=t,this.currFileCtx.skipCommit){var r=Object.assign(this.currFileCtx,{type:"success",percent:100,extra:{message:"upload successful, skip commit."}});return this.successProcess(r)}this.commitUpload()}},{key:"commitUpload",value:function(){var e=this.config.region||Ee,t=this.createReqParamsByService(this.serviceName),r=t.host,i=t.params,s=t.body;t.data,this.config.accountId&&(i["X-Account-Id"]=this.config.accountId),this.uploaderCtx.priorInfo.topExpires>0&&(i["X-Expires"]=this.uploaderCtx.priorInfo.topExpires);var n=$e(i),o={method:"POST",url:"".concat(r,"?").concat(n),timeout:this.config.requestTimeout,region:e,params:i,headers:{}};if(this.serviceName===Ie){var a=Object.keys(s).map((function(e){return"[object Array]"===Object.prototype.toString.call(s[e])||"[object Object]"===Object.prototype.toString.call(s[e])?"".concat(e,"=").concat(encodeURIComponent(JSON.stringify(s[e]))):"SessionKey"===e?"".concat(e,"=").concat(encodeURIComponent(s[e])):"".concat(e,"=").concat(s[e])})).join("&");o.headers["Content-Type"]="application/x-www-form-urlencoded",o.body=a,o.custom=o.body}else o.custom=JSON.stringify(s),o.headers["Content-Type"]="application/json",o.body=s;var c=new cr(o,this.serviceName,{isVolcengine:!0}),u=this.currFileCtx.proxyStsToken||this.config.stsToken,l=u.AccessKeyID,h=u.AccessKeyId,d=u.SecretAccessKey,f=u.SessionToken,p=u.CurrentTime,g=null;g=this.config.useServerCurrentTime?new Date(new Date(p).getTime()+(this.currFileCtx.totalDuration||0)):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap),c.addAuthorization({accessKeyId:h||l,secretAccessKey:d,sessionToken:f},g),this.request(o)}},{key:"createReqParamsByService",value:function(e){var t=this,r={body:{SessionKey:this.currFileCtx.sessionKey}};if(e===Ie){var i,s,n,o;r.host=this.config.videoHost||ut(this.config.region,e);var a,c=null===(i=this.config.videoConfig)||void 0===i?void 0:i.spaceName;if(this.currFileCtx.fileType===Ne&&null!==(s=this.config.objectConfig)&&void 0!==s&&s.spaceName)c=null===(a=this.config.objectConfig)||void 0===a?void 0:a.spaceName;r.params={Action:"CommitUploadInfo",Version:"2022-01-01",SpaceName:c};var u,l=null===(n=this.config.videoConfig)||void 0===n?void 0:n.processAction;if(this.currFileCtx.fileType===Ne&&null!==(o=this.config.objectConfig)&&void 0!==o&&o.processAction)l=null===(u=this.config.objectConfig)||void 0===u?void 0:u.processAction;this.processAction&&(l=this.processAction),Array.isArray(l)&&l.length>0&&(r.body.Functions=l),(this.config.videoConfig&&this.config.videoConfig.callbackArgs||this.options.callbackArgs)&&(r.body.CallbackArgs=this.options.callbackArgs||this.config.videoConfig.callbackArgs)}else{var h;r.host=this.config.imageHost||ut(this.config.region,e),r.params={Action:"CommitImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null===(h=this.config.imageConfig)||void 0===h?void 0:h.serviceId)},r.body.SuccessOids=Array.isArray(this.currFileCtx.oid)?this.currFileCtx.oid:[this.currFileCtx.oid],this.options.skipMeta&&(r.params.SkipMeta=this.options.skipMeta),this.processAction&&Array.isArray(this.processAction)&&this.processAction.length>0&&(r.body.Functions=this.processAction);var d=this.currFileCtx,f=d.imagexEnableEncrypt,p=d.imagexPublicKey;f&&p&&!this.options.skipMeta&&this.uploaderCtx.plugins.forEach((function(e){if("imagex-encrypt-plugin"===(null==e?void 0:e._identifier))try{r.body.DecryptKeys=e.apply(t.currFileCtx)}catch(i){console.warn("[TTUploader]:",null==i?void 0:i.message)}}))}return r.data=JSON.stringify(r.body),r}},{key:"request",value:function(e){var t=this;Zt(e,ye).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"fail",value:function(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires){return this.uploaderCtx.priorInfo.topExpires=604800,this.commitUpload()}if(0===this.uploaderCtx.priorInfo.systemTimeGap){var t=We(e.requestId);return this.uploaderCtx.priorInfo.systemTimeGap=t,this.commitUpload()}}if(this.retryCount<this.retryTime)return this.retryCount+=1,this.commitUpload();var r=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(r)}},{key:"success",value:function(e,r){var i={};if(this.serviceName===Oe)if(this.isImageBatchUpload){var s=e.Results,n=e.PluginResult||[];s.forEach((function(e,r){s[r]=t(t({},s[r]),n[r])})),i=s}else i=e.Results[0],Object.assign(i,e.PluginResult&&e.PluginResult[0]);else i=e.Data;var o=Object.assign(this.currFileCtx,{percent:100,extra:{message:"upload successful."},uploadResult:i,xhr:r});return this.successProcess(o)}}]),e}(),_r=function(){function e(t,r,i){s(this,e),this.config=t,this.key=i,this.uploaderCtx=r,this.tasks=[]}return o(e,[{key:"addSubTask",value:function(e){this.tasks.push(e)}},{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.uploaderCtx.tasks[this.key];if(e){var r;if(t.requestPending)return;if(t.curTaskIdx===ke&&(null===(r=this.tasks[0])||void 0===r?void 0:r.index)===Me){var i=this.uploaderCtx.taskList[this.key].find((function(e){return e.index===ke}));i&&this.execTask(i)}else{var s=this.tasks.shift();s&&this.execTask(s)}}else{var n=this.tasks.shift();n&&this.execTask(n)}}},{key:"execTask",value:function(e){var t,r=this,i=e.key,s=this.uploaderCtx.tasks[i],n=s.cacheTaskIdx;n&&e.index>0&&e.index<n?this.start():(s.curTaskIdx=e.index,s.stage=e.stage,s.status===De.UPLOADING&&(s.stageStartTime=Date.now(),s.requestPending=!0,null==e||null===(t=e.func)||void 0===t||t.call(e.context,(function(e){r.finishTask(e,!0)}),(function(e){r.finishTask(e,!1)}))))}},{key:"finishTask",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.stageStartTime;if(e.stageEndTime=Date.now(),e.duration=Date.now()-r,e.totalDuration+=Date.now()-r,e.requestPending=!1,e.xhr){var i=ot(e.xhr),s=i.req,n=i.res;e.req=s,e.res=n,delete e.xhr}t?this.success(e):this.fail(e)}},{key:"success",value:function(e){if(Object.assign(e,{type:"success"}),this.uploaderCtx.logger.send(e),this.tasks.length>0)this.start();else{if(this.uploaderCtx._taskFinish(e.key,!0),e.status===De.PAUSE||e.status===De.CANCEL)return;this.uploaderCtx._broadcast(e.stage,e)}}},{key:"fail",value:function(e){Object.assign(e,{type:"error"}),this.uploaderCtx.logger.sendErrorLog(e),this.uploaderCtx._taskFinish(e.key,!1),e.status!==De.PAUSE&&e.status!==De.CANCEL&&this.uploaderCtx._broadcast("error",e)}},{key:"cancel",value:function(e){var t=this.key,r=this.uploaderCtx.tasks[t];if(r&&(!e||!r.isDirect)){var i,s;if(r.stage===pe)null===(i=this.uploaderCtx.taskList[t].find((function(e){return e.index===ke})).context)||void 0===i||null===(s=i.stop)||void 0===s||s.call(i),r.requestPending=!1;e||(this.tasks=[])}}}]),e}(),xr=function(e){c(r,e);var t=d(r);function r(e){var i;return s(this,r),(i=t.call(this,e)).config=Object.assign({},k,e),i.tasks={},i.taskList={},i.cache={},i._schedulerMap=a(a(a(a(a(a(a({},De.IDLE,[]),De.UPLOADING,new Set),De.PAUSE,[]),De.WAITING,[]),De.CANCEL,[]),De.SUCCESS,[]),De.FAILED,[]),i.storage=tt(h(i),i.config.useLocalStorage),i.logger=i.config.noLog?{send:function(){}}:new Ye(i.config,h(i)),i.plugins=[],i.priorInfo={systemTimeGap:0,topExpires:0},i}return o(r,[{key:"_use",value:function(e){var t,r=!1,i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=p(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,s=function(){};return{s:s,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw n}}}}(this.plugins);try{for(i.s();!(t=i.n()).done;){var s=t.value;if((null==s?void 0:s.stage)===(null==e?void 0:e.stage)&&(null==s?void 0:s._identifier)===e._identifier){r=!0;break}}}catch(n){i.e(n)}finally{i.f()}r||this.plugins.push(e)}},{key:"_mergeOptions",value:function(e,t){t&&"object"===i(t)&&Object.assign(e,t)}},{key:"_addAllUploadProcess",value:function(e,t,r){this.taskList[t]=[];var i={key:t,task:new _r(this.config,this,t),fileType:e.type||be,proxyStsToken:e.stsToken,serviceType:r,duration:0,totalDuration:0,percent:0,pauseDuration:0,skipCommit:r===Oe&&e.skipCommit,sliceSize:0,sliceCount:this.config.uploadSliceCount,requestPending:!1,taskAllFinish:!1},s=r===Oe&&Array.isArray(e.file);if(i.isImageBatchUpload=s,s?(i.fileSize=e.file.reduce((function(e,t){return e+t.size}),0),i.fileName=e.file.map((function(e){return e.name}))):(i.fileSize=e.file.size,i.fileName=e.file.name),!s){var n=this.config.sliceSize||st(i.fileSize,this.config.getSliceFunc);i.sliceSize=n}var o=!1;if(o=!!s||i.fileSize<5242880,i.isDirect=o,r===Oe){var a,c,u,l=!(null===(a=this.config)||void 0===a||null===(a=a.imageConfig)||void 0===a||!a.imagexEnableEncrypt);if(i.imagexEnableEncrypt=l,l)i.imagexEncryptKey=(null===(c=this.config)||void 0===c||null===(c=c.imageConfig)||void 0===c?void 0:c.imagexEncryptKey)||Ve(32),i.imagexPublicKey=null===(u=this.config)||void 0===u||null===(u=u.imageConfig)||void 0===u?void 0:u.imagexPublicKey}o||i.imagexEnableEncrypt||(i.gatewayUpload=!0),o||i.imagexEnableEncrypt||!this.config.useLocalStorage||(i.enableDiskBreakPoint=!0),i.status=De.IDLE,this.tasks[t]=i,this._schedulerMap[De.IDLE].push(t),this._addCrc32ProcessTask(e,t),this._addPreUploadTask(e,t),o?this._addDirectUploadTask(e,t):(this._addInitUploadIDTask(t),this._addUploadProcessTask(e,t),this._mergeFileTask(t)),this._getMetaInfoTask(e,t)}},{key:"_addTask",value:function(e,t){var r=this.tasks;this.taskList[e].push(t),r[e].task.addSubTask(t)}},{key:"_addCrc32ProcessTask",value:function(e,t){var r=new Jt({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:me,stage:he};this._addTask(t,i)}},{key:"_addPreUploadTask",value:function(e,t){var r={context:this,key:t,fileName:e.fileName||null,fileExtension:e.fileExtension||null,storageClass:e.storageClass||null,serviceId:e.serviceId||null,prefix:e.prefix,storeKey:e.storeKey,overwrite:e.overwrite},i=new ur(r,this.config),s={context:i,func:i.start,key:t,index:_e,stage:de};this._addTask(t,s)}},{key:"_addInitUploadIDTask",value:function(e){var t=new lr({context:this,key:e},this.config),r={context:t,func:t.start,key:e,index:xe,stage:fe};this._addTask(e,r)}},{key:"_addDirectUploadTask",value:function(e,t){var r=new vr({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:ke,stage:pe};this._addTask(t,i)}},{key:"_addUploadProcessTask",value:function(e,t){var r=new gr({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:ke,stage:pe};this._addTask(t,i)}},{key:"_mergeFileTask",value:function(e){var t=new yr({context:this,key:e},this.config),r={context:t,func:t.start,key:e,index:Me,stage:ge};this._addTask(e,r)}},{key:"_getMetaInfoTask",value:function(e,t){var r={context:this,key:t,callbackArgs:e.callbackArgs,serviceId:e.serviceId||null,processAction:e.processAction,skipMeta:e.skipMeta},i=new mr(r,this.config),s={context:i,func:i.start,key:t,index:we,stage:ye};this._addTask(t,s)}},{key:"_start",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.IDLE])).forEach((function(e){var r=t.tasks[e];r?r.status===De.IDLE&&(r.status=De.WAITING,t._updateSchduelerMap(e,De.IDLE,De.WAITING)):console.warn("[TTUploader]:".concat(e," is not exit in tasks."))})),this._taskStart()}},{key:"_pause",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.UPLOADING])).forEach((function(e){var r,i=t.tasks[e];if(i){if(i.status===De.UPLOADING){var s="".concat(Se[i.serviceType],"_999");t.logger.sendLogBase(s,i,{type:"pause",ex:"pause upload.".concat(e)}),i.pauseTime=Date.now(),i.status=De.PAUSE,null===(r=i.task)||void 0===r||r.cancel(!0),t._updateSchduelerMap(e,De.UPLOADING,De.PAUSE)}}else console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))})),e&&this._taskStart()}},{key:"_cancel",value:function(e){var t=this;(e?[e]:[].concat(f(this._schedulerMap[De.UPLOADING]),f(this._schedulerMap[De.IDLE]),f(this._schedulerMap[De.WAITING]),f(this._schedulerMap[De.PAUSE]))).forEach((function(e){var r,i=t.tasks[e];if(i){var s=i.status;if(![De.SUCCESS,De.FAILED,De.CANCEL].includes(s)){var n="".concat(Se[i.serviceType],"_999");t.logger.sendLogBase(n,i,{type:"cancel",ex:"cancel upload.".concat(e)}),null===(r=i.task)||void 0===r||r.cancel(!1),t._updateSchduelerMap(e,s,De.CANCEL),i.status=De.CANCEL,delete t.taskList[e],delete t.tasks[e],t._removeTaskCache(e)}}else console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))}))}},{key:"_restart",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.PAUSE])).forEach((function(e){var r=t.tasks[e];r?r.status===De.PAUSE&&(r.status=De.WAITING,t._updateSchduelerMap(e,De.PAUSE,De.WAITING)):console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))})),this._taskStart()}},{key:"_taskStart",value:function(){for(var e,t=this,r=Math.min(this.config.taskParallelLimit-this._schedulerMap[De.UPLOADING].size,this._schedulerMap[De.WAITING].length),i=function(){var e=t._schedulerMap[De.WAITING][0],r=t.tasks[e];if(r.status=De.UPLOADING,t._updateSchduelerMap(e,De.WAITING,De.UPLOADING),r.taskAllFinish){var i="success"===r.type?De.SUCCESS:De.FAILED;if(t._updateSchduelerMap(e,De.UPLOADING,i),r.status=i,t._broadcast(r.stage,r),t._schedulerMap[De.WAITING].length>0)return{v:t._taskStart()}}var s=r.task,n=null,o=!1;if(r.pauseTime){o=!0;var a=r.curTaskIdx;r.requestPending||(s.tasks=t.taskList[e].slice(t.taskList[e].findIndex((function(e){return e.index===a})))),n={type:"resume",ex:"resume upload."},r.pauseDuration+=Date.now()-r.pauseTime}else r.startTime=Date.now(),n={type:"start",ex:"start upload.".concat(e)};var c="".concat(Se[r.serviceType],"_999");t.logger.sendLogBase(c,r,n),s.start(o)},s=0;s<r;s++)if(e=i())return e.v}},{key:"_setCache",value:function(e,t){this.storage.setItem(e,t)}},{key:"_getCache",value:function(e){return this.storage.getItem(e)}},{key:"_removeCache",value:function(e){e?this.storage.removeItem(e):this.storage.clear()}},{key:"_broadcast",value:function(e,t){this.emit(ve[e],t)}},{key:"_removeTaskCache",value:function(e){var t=this.tasks[e];if(t){var r=t.crc32Key;if(r)try{this._removeCache(r)}catch(i){console.warn("[TTUploader]:",null==i?void 0:i.message)}}}},{key:"_saveTask",value:function(e){var t=this.tasks[e],r=t.crc32Key;if(r){var i={sessionKey:t.sessionKey,uploadHeader:t.uploadHeader,fileName:t.fileName,oid:t.oid,uploadId:t.uploadId,signature:t.signature,tosDomain:t.tosDomain,merged:t.merged};Object.keys(i).forEach((function(e){i[e]||delete i[e]}));try{this._setCache(r,JSON.stringify(i))}catch(N){this.logger.sendLogBase("".concat(Se[t.serviceType],"_999"),t,{type:"warning",ex:"Save to cache error:".concat(null==N?void 0:N.message)})}}}},{key:"_taskFinish",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tasks[e];r&&(r.endTime=Date.now(),r.time=r.endTime-r.startTime,r.taskAllFinish=!0,r.status===De.UPLOADING&&(t?(this.taskList[e]=[],r.status=De.SUCCESS,this._updateSchduelerMap(e,De.UPLOADING,De.SUCCESS),this._removeTaskCache(e)):(r.status=De.FAILED,this._updateSchduelerMap(e,De.UPLOADING,De.FAILED)),this._schedulerMap[De.WAITING].length>0&&this._taskStart()))}},{key:"_updateSchduelerMap",value:function(e,t,r){if(t===De.UPLOADING)this._schedulerMap[t].delete(e);else{var i=this._schedulerMap[t].indexOf(e);if(i<0)return;this._schedulerMap[t].splice(i,1)}r===De.UPLOADING?this._schedulerMap[r].add(e):this._schedulerMap[r].push(e)}},{key:"_removeFile",value:function(e){this.tasks.delete(e)}},{key:"_refreshStsToken",value:function(e){var t=this,r=this.tasks;Object.keys(r).forEach((function(i){var s=r[i],n=Object.assign({},s,{proxyStsToken:e});s.proxyStsToken=e;var o=n.crc32Key;o&&(delete n.task,delete n.xhr,delete n.crc32Array,s.proxyStsToken=e,t._setCache(o,JSON.stringify(n)))}))}},{key:"_setOption",value:function(e){this._mergeOptions(this.config,e)}},{key:"_setServiceId",value:function(e){!this.config.imageConfig&&e?this.config.imageConfig={serviceId:e}:this.config.imageConfig.serviceId=e}},{key:"_getServiceId",value:function(){var e;return null===(e=this.config.imageConfig)||void 0===e?void 0:e.serviceId}},{key:"_getOption",value:function(e){var t=Object.assign({},this.config);return e?t[e]:t}}]),r}(x),kr=function(e){c(r,e);var t=d(r);function r(){return s(this,r),t.apply(this,arguments)}return o(r,[{key:"use",value:function(e){this._use(e)}},{key:"addFile",value:function(e){if(e.file){var t=it(Ie);return this._addAllUploadProcess(e,t,Ie),t}return null}},{key:"addVodFile",value:function(e){return this.addFile(e)}},{key:"addImageFile",value:function(e){if(e.file){e.type=Te;var t=it(Oe);return this._addAllUploadProcess(e,t,Oe),t}return null}},{key:"addImageXFile",value:function(e){return this.addImageFile(e)}},{key:"setServiceId",value:function(e){this._setServiceId(e)}},{key:"getServiceId",value:function(){return this._getServiceId()}},{key:"removeFile",value:function(e){e&&this._removeFile(e)}},{key:"start",value:function(e){return this._start(e)}},{key:"restart",value:function(e){return this._restart(e)}},{key:"cancel",value:function(e){return this._cancel(e)}},{key:"pause",value:function(e){return this._pause(e)}},{key:"refreshAuth",value:function(e){this._refreshAuth(e)}},{key:"setOption",value:function(e){this._setOption(e)}},{key:"getOption",value:function(e){return this._getOption(e)}}]),r}(xr);return kr}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-uploader",
3
- "version": "1.3.0",
3
+ "version": "1.3.3",
4
4
  "description": "upload component for veVod and veImageX",
5
5
  "main": "dist/index.js",
6
6
  "typings": "./types/index.d.ts",