var e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t="object"==typeof e&&e&&e.Object===Object&&e,r="object"==typeof self&&self&&self.Object===Object&&self,n=t||r||Function("return this")(),o=n.Symbol,s=Object.prototype,i=s.hasOwnProperty,a=s.toString,u=o?o.toStringTag:void 0;var c=Object.prototype.toString;var f=o?o.toStringTag:void 0;function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":f&&f in Object(e)?function(e){var t=i.call(e,u),r=e[u];try{e[u]=void 0;var n=!0}catch(e){}var o=a.call(e);return n&&(t?e[u]=r:delete e[u]),o}(e):function(e){return c.call(e)}(e)}function p(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==l(e)}var h=Array.isArray,d=o?o.prototype:void 0,m=d?d.toString:void 0;function E(e){if("string"==typeof e)return e;if(h(e))return function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}(e,E)+"";if(p(e))return m?m.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function g(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var v=/^\s+|\s+$/g,y=/^[-+]0x[0-9a-f]+$/i,w=/^0b[01]+$/i,T=/^0o[0-7]+$/i,S=parseInt;function b(e){if("number"==typeof e)return e;if(p(e))return NaN;if(g(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=g(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(v,"");var r=w.test(e);return r||T.test(e)?S(e.slice(2),r?2:8):y.test(e)?NaN:+e}function N(e){var t=function(e){return e?(e=b(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}function R(e){return e}function O(e){return null==e?"":E(e)}var _=n.isFinite,P=Math.min;function x(e,t){return e>t}function A(e,t){return e<t}function C(e,t,r){for(var n=-1,o=e.length;++n<o;){var s=e[n],i=t(s);if(null!=i&&(void 0===a?i==i&&!p(i):r(i,a)))var a=i,u=s}return u}function D(e){return e&&e.length?C(e,R,x):void 0}var j,U=(j=Math["round"],function(e,t){if(e=b(e),(t=null==t?0:P(N(t),292))&&_(e)){var r=(O(e)+"e").split("e");return+((r=(O(j(r[0]+"e"+(+r[1]+t)))+"e").split("e"))[0]+"e"+(+r[1]-t))}return j(e)});let k=()=>({events:{},emit(e,...t){for(let r of this.events[e]||[])r(...t)},on(e,t){return(this.events[e]=this.events[e]||[]).push(t),()=>this.events[e]=this.events[e].filter(e=>e!==t)}});class L{constructor(){this.emitter=k()}on(e,t){return this.emitter.on(e,t)}}class B extends L{constructor(e){super(),this.PACKAGES_TOTAL=10,this.TIMEOUR_BETWEEN_PACKETS=100,this.PERCENTAGE_100=100,this.TIMEOUT_MS=1e4,this.packagesSent=0,this.urlSocket=e}start(){return new Promise((e,t)=>{const r=setTimeout(()=>{this.postError("Ping timeout err. Please, check internet connection.")},this.TIMEOUT_MS);if(this.on(B.EVENT_DONE,t=>{e(t),clearTimeout(r)}),this.on(B.EVENT_ERR,e=>{t(e)}),this.urlSocket){const e=new WebSocket(this.urlSocket);e.addEventListener("open",t=>{this.sendPacket(e),this.postProgress()});const t=[];e.addEventListener("message",r=>{var n;t.push(Date.now()-Number(String(r.data)));if(this.packagesSent>=this.PACKAGES_TOTAL){e.close();const r=U(.7*(null!==(n=(o=t)&&o.length?C(o,R,A):void 0)&&void 0!==n?n:0));this.postDone(r)}else setTimeout(()=>{this.sendPacket(e),this.postProgress()},this.TIMEOUR_BETWEEN_PACKETS);var o})}else this.postError("Please, use correct 'x-api-key' to run ping.")})}sendPacket(e){this.packagesSent++,e.send(Date.now().toString())}postProgress(){this.emitter.emit(B.EVENT_PROGRESS,this.packagesSent/this.PACKAGES_TOTAL*this.PERCENTAGE_100)}postError(e){this.emitter.emit(B.EVENT_ERR,e)}postDone(e){this.emitter.emit(B.EVENT_DONE,e)}}B.EVENT_PROGRESS="ping-progress",B.EVENT_ERR="ping-err",B.EVENT_DONE="ping-done";var V=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},M=Object.prototype.toString;function q(e){return"[object Array]"===M.call(e)}function F(e){return void 0===e}function I(e){return null!==e&&"object"==typeof e}function $(e){return"[object Function]"===M.call(e)}function G(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),q(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var H={isArray:q,isArrayBuffer:function(e){return"[object ArrayBuffer]"===M.call(e)},isBuffer:function(e){return null!==e&&!F(e)&&null!==e.constructor&&!F(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:I,isUndefined:F,isDate:function(e){return"[object Date]"===M.call(e)},isFile:function(e){return"[object File]"===M.call(e)},isBlob:function(e){return"[object Blob]"===M.call(e)},isFunction:$,isStream:function(e){return I(e)&&$(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:G,merge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]=r}for(var n=0,o=arguments.length;n<o;n++)G(arguments[n],r);return t},deepMerge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]="object"==typeof r?e({},r):r}for(var n=0,o=arguments.length;n<o;n++)G(arguments[n],r);return t},extend:function(e,t,r){return G(t,(function(t,n){e[n]=r&&"function"==typeof t?V(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function K(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var z=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(H.isURLSearchParams(t))n=t.toString();else{var o=[];H.forEach(t,(function(e,t){null!=e&&(H.isArray(e)?t+="[]":e=[e],H.forEach(e,(function(e){H.isDate(e)?e=e.toISOString():H.isObject(e)&&(e=JSON.stringify(e)),o.push(K(t)+"="+K(e))})))})),n=o.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e};function X(){this.handlers=[]}X.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},X.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},X.prototype.forEach=function(e){H.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var J=X,W=function(e,t,r){return H.forEach(r,(function(r){e=r(e,t)})),e},Z=function(e){return!(!e||!e.__CANCEL__)};var Q=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,u=[],c=!1,f=-1;function l(){c&&a&&(c=!1,a.length?u=a.concat(u):f=-1,u.length&&p())}function p(){if(!c){var e=i(l);c=!0;for(var t=u.length;t;){for(a=u,u=[];++f<t;)a&&a[f].run();f=-1,t=u.length}a=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function d(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||c||i(p)},h.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}})),Y=function(e,t){H.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},ee=function(e,t,r,n,o){return function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,r,n,o)},te=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],re=H.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=H.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},ne=H.isStandardBrowserEnv()?{write:function(e,t,r,n,o,s){var i=[];i.push(e+"="+encodeURIComponent(t)),H.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),H.isString(n)&&i.push("path="+n),H.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},oe=function(e){return new Promise((function(t,r){var n=e.data,o=e.headers;H.isFormData(n)&&delete o["Content-Type"];var s=new XMLHttpRequest;if(e.auth){var i=e.auth.username||"",a=e.auth.password||"";o.Authorization="Basic "+btoa(i+":"+a)}var u,c,f=(u=e.baseURL,c=e.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(c)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(u,c):c);if(s.open(e.method.toUpperCase(),z(f,e.params,e.paramsSerializer),!0),s.timeout=e.timeout,s.onreadystatechange=function(){if(s&&4===s.readyState&&(0!==s.status||s.responseURL&&0===s.responseURL.indexOf("file:"))){var n,o,i,a,u,c="getAllResponseHeaders"in s?(n=s.getAllResponseHeaders(),u={},n?(H.forEach(n.split("\n"),(function(e){if(a=e.indexOf(":"),o=H.trim(e.substr(0,a)).toLowerCase(),i=H.trim(e.substr(a+1)),o){if(u[o]&&te.indexOf(o)>=0)return;u[o]="set-cookie"===o?(u[o]?u[o]:[]).concat([i]):u[o]?u[o]+", "+i:i}})),u):u):null,f={data:e.responseType&&"text"!==e.responseType?s.response:s.responseText,status:s.status,statusText:s.statusText,headers:c,config:e,request:s};!function(e,t,r){var n=r.config.validateStatus;!n||n(r.status)?e(r):t(ee("Request failed with status code "+r.status,r.config,null,r.request,r))}(t,r,f),s=null}},s.onabort=function(){s&&(r(ee("Request aborted",e,"ECONNABORTED",s)),s=null)},s.onerror=function(){r(ee("Network Error",e,null,s)),s=null},s.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(ee(t,e,"ECONNABORTED",s)),s=null},H.isStandardBrowserEnv()){var l=ne,p=(e.withCredentials||re(f))&&e.xsrfCookieName?l.read(e.xsrfCookieName):void 0;p&&(o[e.xsrfHeaderName]=p)}if("setRequestHeader"in s&&H.forEach(o,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete o[t]:s.setRequestHeader(t,e)})),H.isUndefined(e.withCredentials)||(s.withCredentials=!!e.withCredentials),e.responseType)try{s.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&s.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&s.upload&&s.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){s&&(s.abort(),r(e),s=null)})),void 0===n&&(n=null),s.send(n)}))},se={"Content-Type":"application/x-www-form-urlencoded"};function ie(e,t){!H.isUndefined(e)&&H.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var ae,ue={adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==Q&&"[object process]"===Object.prototype.toString.call(Q))&&(ae=oe),ae),transformRequest:[function(e,t){return Y(t,"Accept"),Y(t,"Content-Type"),H.isFormData(e)||H.isArrayBuffer(e)||H.isBuffer(e)||H.isStream(e)||H.isFile(e)||H.isBlob(e)?e:H.isArrayBufferView(e)?e.buffer:H.isURLSearchParams(e)?(ie(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):H.isObject(e)?(ie(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};ue.headers={common:{Accept:"application/json, text/plain, */*"}},H.forEach(["delete","get","head"],(function(e){ue.headers[e]={}})),H.forEach(["post","put","patch"],(function(e){ue.headers[e]=H.merge(se)}));var ce=ue;function fe(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var le=function(e){return fe(e),e.headers=e.headers||{},e.data=W(e.data,e.headers,e.transformRequest),e.headers=H.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),H.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||ce.adapter)(e).then((function(t){return fe(e),t.data=W(t.data,t.headers,e.transformResponse),t}),(function(t){return Z(t)||(fe(e),t&&t.response&&(t.response.data=W(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},pe=function(e,t){t=t||{};var r={},n=["url","method","params","data"],o=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];H.forEach(n,(function(e){void 0!==t[e]&&(r[e]=t[e])})),H.forEach(o,(function(n){H.isObject(t[n])?r[n]=H.deepMerge(e[n],t[n]):void 0!==t[n]?r[n]=t[n]:H.isObject(e[n])?r[n]=H.deepMerge(e[n]):void 0!==e[n]&&(r[n]=e[n])})),H.forEach(s,(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])}));var i=n.concat(o).concat(s),a=Object.keys(t).filter((function(e){return-1===i.indexOf(e)}));return H.forEach(a,(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])})),r};function he(e){this.defaults=e,this.interceptors={request:new J,response:new J}}he.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=pe(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[le,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},he.prototype.getUri=function(e){return e=pe(this.defaults,e),z(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},H.forEach(["delete","get","head","options"],(function(e){he.prototype[e]=function(t,r){return this.request(H.merge(r||{},{method:e,url:t}))}})),H.forEach(["post","put","patch"],(function(e){he.prototype[e]=function(t,r,n){return this.request(H.merge(n||{},{method:e,url:t,data:r}))}}));var de=he;function me(e){this.message=e}me.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},me.prototype.__CANCEL__=!0;var Ee=me;function ge(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new Ee(e),t(r.reason))}))}ge.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ge.source=function(){var e;return{token:new ge((function(t){e=t})),cancel:e}};var ve=ge;function ye(e){var t=new de(e),r=V(de.prototype.request,t);return H.extend(r,de.prototype,t),H.extend(r,t),r}var we=ye(ce);we.Axios=de,we.create=function(e){return ye(pe(we.defaults,e))},we.Cancel=Ee,we.CancelToken=ve,we.isCancel=Z,we.all=function(e){return Promise.all(e)},we.spread=function(e){return function(t){return e.apply(null,t)}};var Te=we,Se=we;Te.default=Se;var be=Te;self.fetch||(self.fetch=function(e,t){return t=t||{},new Promise((r,n)=>{const o=new XMLHttpRequest,s=[],i=[],a={},u=()=>({ok:2==(o.status/100|0),statusText:o.statusText,status:o.status,url:o.responseURL,text:()=>Promise.resolve(o.responseText),json:()=>Promise.resolve(JSON.parse(o.responseText)),blob:()=>Promise.resolve(new Blob([o.response])),clone:u,headers:{keys:()=>s,entries:()=>i,get:e=>a[e.toLowerCase()],has:e=>e.toLowerCase()in a}});o.open(t.method||"get",e,!0),o.onload=()=>{o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(e,t,r)=>{s.push(t=t.toLowerCase()),i.push([t,r]),a[t]=a[t]?`${a[t]},${r}`:r}),r(u())},o.onerror=n,o.withCredentials="include"==t.credentials;for(const e in t.headers)o.setRequestHeader(e,t.headers[e]);o.send(t.body||null)})});class Ne extends L{constructor(e){super(),this.TIMEOUT_SEC=10,this.urlDownload=e}start(){return new Promise((e,t)=>{if(this.on(Ne.EVENT_DONE,t=>{e(t)}),this.on(Ne.EVENT_ERR,e=>{t(e)}),this.urlDownload){const e=[],t=Date.now();let r,n=0;be.create().get(this.urlDownload,{timeout:1e3*this.TIMEOUT_SEC,onDownloadProgress:({loaded:o,total:s})=>{var i,a;r||(r=s),n=o/s;const u=(Date.now()-t)/1e3/this.TIMEOUT_SEC,c=U(100*(null!==(i=D([n,u]))&&void 0!==i?i:0));(null!==(a=D(e))&&void 0!==a?a:0)<c&&(e.push(c),this.postProgress(c)),o===s&&this.onFinishedDownload(t,s)}}).catch(()=>r*=n).then(()=>{n<1&&this.onFinishedDownload(t,r)}).catch(()=>this.postError("Downloading err. Please, check internet connection."))}else this.postError("Please, use correct 'x-api-key' to run downlaod.")})}onFinishedDownload(e,t){const r=(Date.now()-e)/1e3,n=U(t/1048576/r*8*1.2,3);this.postDone(n)}postProgress(e){this.emitter.emit(Ne.EVENT_PROGRESS,e)}postError(e){this.emitter.emit(Ne.EVENT_ERR,e)}postDone(e){this.emitter.emit(Ne.EVENT_DONE,e)}}Ne.EVENT_PROGRESS="download-progress",Ne.EVENT_ERR="download-err",Ne.EVENT_DONE="download-done";class Re extends L{constructor(e){super(),this.UPLOAD_SIZE_MB=200,this.TIMEOUT_SEC=10,this.urlUpload=e}start(){return new Promise((e,t)=>{if(this.on(Re.EVENT_DONE,t=>{e(t)}),this.on(Re.EVENT_ERR,e=>{t(e)}),this.urlUpload){let e=0,t=0;const r=[],n=new Blob([new ArrayBuffer(1048576*this.UPLOAD_SIZE_MB)]),o=Date.now(),s=be.create();s.interceptors.request.use(e=>(e.headers={},e)),s.put(this.urlUpload,n,{timeout:1e3*this.TIMEOUT_SEC,onUploadProgress:({loaded:n,total:s})=>{var i,a;e||(e=s);const u=U((Date.now()-o)/1e3/this.TIMEOUT_SEC*100);t=n/(1048576*s)*100;const c=null!==(i=D([U(t),u]))&&void 0!==i?i:0;(null!==(a=D(r))&&void 0!==a?a:0)<c&&(r.push(c),this.postProgress(c)),100===U(t)&&this.onUploadFinished(o,s)}}).catch(r=>(e=e*t/100,String(r).indexOf("timeout")<0&&this.postError(String(r)),r)).then(()=>{t<100&&this.onUploadFinished(o,e)}).catch(e=>this.postError(e))}else this.postError("Please, use correct 'x-api-key' to run upload.")})}onUploadFinished(e,t){const r=(Date.now()-e)/1e3,n=U(t/r*8*1.4,3);this.postDone(n)}postProgress(e){this.emitter.emit(Re.EVENT_PROGRESS,e)}postError(e){this.emitter.emit(Re.EVENT_ERR,e)}postDone(e){this.emitter.emit(Re.EVENT_DONE,e)}}Re.EVENT_PROGRESS="upload-progress",Re.EVENT_ERR="upload-err",Re.EVENT_DONE="upload-done";class Oe{constructor(e){this.BASE_URL="https://ib7k1hv8ra.execute-api.eu-central-1.amazonaws.com/dev",this._apiKey=e}init(){return be.create().get(this.BASE_URL+"/auth",{headers:{"x-api-key":this._apiKey}}).then(({data:e})=>{const t=new B(e.ping),r=new Ne(e.download),n=new Re(e.upload);return t.on(B.EVENT_DONE,t=>{this.updateSession(e.session,"ping",t)}),r.on(Ne.EVENT_DONE,t=>{this.updateSession(e.session,"download",t)}),n.on(Re.EVENT_DONE,t=>{this.updateSession(e.session,"upload",t)}),{ping:t,download:r,upload:n}}).catch(e=>{throw e})}updateSession(e,t,r){be.create().get(`${this.BASE_URL}/${t}`,{headers:{"x-api-key":this._apiKey},params:{session:e,value:r}}).then().catch()}}export{Ne as Download,B as Ping,Oe as Speedtest,Re as Upload};
//# sourceMappingURL=index.esm.min.js.map
