UNPKG

libaria2-ts

Version:

A full-typing wrapper around `aria2`, `The next generation download utility`.

1 lines 50.3 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("events"),t=require("http"),r=require("https"),n=require("url"),o=require("stream"),s=require("assert"),i=require("tty"),a=require("util"),u=require("os"),c=require("zlib"),l=require("crypto");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=f(t),d=f(r),p=f(n),m=f(o),g=f(s),y=f(i),w=f(a),v=f(u),C=f(c),b=f(l);function _(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const O=new Uint8Array(256);let E=O.length;function S(){return E>O.length-16&&(b.default.randomFillSync(O),E=0),O.slice(E,E+=16)}var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const T=[];for(let e=0;e<256;++e)T.push((e+256).toString(16).substr(1));function x(e,t=0){const r=(T[e[t+0]]+T[e[t+1]]+T[e[t+2]]+T[e[t+3]]+"-"+T[e[t+4]]+T[e[t+5]]+"-"+T[e[t+6]]+T[e[t+7]]+"-"+T[e[t+8]]+T[e[t+9]]+"-"+T[e[t+10]]+T[e[t+11]]+T[e[t+12]]+T[e[t+13]]+T[e[t+14]]+T[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&R.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function A(e,t,r){const n=(e=e||{}).random||(e.rng||S)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return x(n)}function F(e){return e.toString()}function L(e){return e.toString()}function j(e){if(/^(false|true)$/.test(e))return"true"==e;throw"Unknown Boolean Value: "+e}function k(e){return Number(e)}function P(e){return BigInt(e)}function B(e){let t={};for(const r in e)if(null!=e[r])if("string"==typeof e[r])t[r]=e[r];else if("boolean"==typeof e[r])t[r]=e[r].toString();else if("number"==typeof e[r])t[r]=L(e[r]);else{if("bigint"!=typeof e[r])throw"Unknown Value: "+e[r];t[r]=F(e[r])}return t}function N(e){let t={};for(const r in e)if(null!=e[r])if("string"==typeof e[r])t[r]=e[r];else if("boolean"==typeof e[r])t[r]=j(e[r]);else if("number"==typeof e[r])t[r]=k(e[r]);else{if("bigint"!=typeof e[r])throw"Unknown Value: "+e[r];t[r]=P(e[r])}return t}function U(e){let t=Object.assign({},e);if(null!=e.totalLength&&(t.totalLength=P(e.totalLength)),null!=e.totalLength&&(t.completedLength=P(e.completedLength)),null!=e.totalLength&&(t.uploadLength=P(e.uploadLength)),null!=e.totalLength&&(t.downloadSpeed=P(e.downloadSpeed)),null!=e.totalLength&&(t.uploadSpeed=P(e.uploadSpeed)),null!=e.numSeeders&&(t.numSeeders=P(e.numSeeders)),null!=e.seeder&&(t.seeder=j(e.seeder)),null!=e.totalLength&&(t.pieceLength=P(e.pieceLength)),null!=e.totalLength&&(t.numPieces=P(e.numPieces)),null!=e.totalLength&&(t.connections=P(e.connections)),null!=e.errorCode&&(t.errorCode=k(e.errorCode)),null!=e.bittorrent&&null!=e.bittorrent.creationDate&&(t.bittorrent.creationDate=P(e.bittorrent.creationDate)),null!=e.files)for(const r in e.files)t.files[r]=q(e.files[r]);return t}function q(e){let t=Object.assign({},e);return t.length=P(e.length),t.completedLength=P(e.completedLength),t.index=k(e.index),t.selected=j(e.selected),t}function D(e){let t=Object.assign({},e);return t.amChoking=j(e.amChoking),t.downloadSpeed=P(e.downloadSpeed),t.peerChoking=j(e.peerChoking),t.port=k(e.port),t.seeder=j(e.seeder),t.uploadSpeed=P(e.uploadSpeed),t}function M(e){let t=Object.assign({},e);return t.downloadSpeed=P(e.downloadSpeed),t}function I(e){let t=Object.assign({},e);t.index=k(e.index);for(const r in e.servers)t.servers[r]=M(e.servers[r]);return t}var $;!function(e){e.atob=function(e){return Buffer.from(e,"base64").toString()},e.btoa=function(e){return Buffer.from(e).toString("base64")}}($||($={}));const z=()=>{var e,t;return"string"==typeof(null===globalThis||void 0===globalThis||null===(e=globalThis.process)||void 0===e||null===(t=e.versions)||void 0===t?void 0:t.node)};class H extends e.EventEmitter{constructor(){super()}async addMetalink(e,t,r){z()&&e instanceof Buffer&&(e=e.toString("base64"));let n=[e];if(null!=t&&n.push(t),null!=t&&null!=r)n.push(r);else if(null!=r)throw"Require `options`!";return await this.rawCall("aria2.addMetalink",...n)}async remove(e){return await this.rawCall("aria2.remove",e)}async forceRemove(e){return await this.rawCall("aria2.forceRemove",e)}async pause(e){return await this.rawCall("aria2.pause",e)}async forcePause(e){return await this.rawCall("aria2.forcePause",e)}async pauseAll(){return await this.rawCall("aria2.pauseAll")}async forcePauseAll(){return await this.rawCall("aria2.forcePauseAll")}async unpause(e){return await this.rawCall("aria2.unpause",e)}async unpauseAll(){return await this.rawCall("aria2.unpauseAll")}async tellStatus(e,t){if(null!=t){return U(await this.rawCall("aria2.tellStatus",e,t))}return U(await this.rawCall("aria2.tellStatus",e))}async getUris(e){return await this.rawCall("aria2.getUris",e)}async getFiles(e){return await this.rawCall("aria2.getFiles",e)}async getPeers(e){return(await this.rawCall("aria2.getPeers",e)).map(D)}async getServers(e){return(await this.rawCall("aria2.getServers",e)).map(I)}async tellActive(e){if(null!=e){return(await this.rawCall("aria2.tellActive",e)).map(U)}return(await this.rawCall("aria2.tellActive")).map(U)}async tellWaiting(e,t,r){if(null!=r){return(await this.rawCall("aria2.tellWaiting",e,t,r)).map(U)}return(await this.rawCall("aria2.tellWaiting",e,t)).map(U)}async tellStopped(e,t,r){if(null!=r){return(await this.rawCall("aria2.tellStopped",e,t,r)).map(U)}return(await this.rawCall("aria2.tellStopped",e,t)).map(U)}async changePosition(e,t,r){return await this.rawCall("aria2.changePosition",e,t,r)}async changeUri(e,t,r,n,o){return await this.rawCall("aria2.changeUri",e,t,r,n,o)}async getOption(e){return N(await this.rawCall("aria2.getOption",e))}async changeOption(e,t){return await this.rawCall("aria2.changeOption",e,B(t))}async getGlobalOption(){return N(await this.rawCall("aria2.getGlobalOption"))}async changeGlobalOption(e){return await this.rawCall("aria2.changeGlobalOption",B(e))}async getGlobalStat(){return function(e){let t=Object.assign({},e);return t.downloadSpeed=P(e.downloadSpeed),t.uploadSpeed=P(e.uploadSpeed),t.numActive=k(e.numActive),t.numWaiting=k(e.numWaiting),t.numStopped=k(e.numStopped),t.numStoppedTotal=k(e.numStoppedTotal),t}(await this.rawCall("aria2.getGlobalStat"))}async purgeDownloadResult(){return await this.rawCall("aria2.purgeDownloadResult")}async removeDownloadResult(e){return await this.rawCall("aria2.removeDownloadResult",e)}async getVersion(){return await this.rawCall("aria2.getVersion")}async shutdown(){return await this.rawCall("aria2.shutdown")}async forceShutdown(){return await this.rawCall("aria2.forceShutdown")}async saveSession(){return await this.rawCall("aria2.saveSession")}async getSessionInfo(){return await this.rawCall("aria2.getSessioninfo")}async addUri(e,t,r){"string"==typeof e&&(e=[e]);let n=[e];if(null!=t&&n.push(B(t)),null!=t&&null!=r)n.push(r);else if(null!=r)throw"Require `options`!";return await this.rawCall("aria2.addUri",...n)}async addTorrent(e,t,r,n){e instanceof Buffer&&(e=e.toString("base64")),"string"==typeof t&&(t=[t]);let o=[e,t];if(null!=r&&o.push(r),null!=r&&null!=n)o.push(n);else if(null!=n)throw"Require `options`!";return await this.rawCall("aria2.addTorrent",...o)}addListener(e,t){return super.on(e,t),this}on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}}var J,W,G,V;!function(e){e.Set="POS_SET",e.Cur="POS_CUR",e.End="POS_END"}(J||(J={})),function(e){e.Active="active",e.Waiting="waiting",e.Paused="paused",e.Error="error",e.Complete="complete",e.Removed="removed"}(W||(W={})),function(e){e.Waiting="waiting",e.Used="used"}(G||(G={})),function(e){e.Single="single",e.Multi="multi"}(V||(V={}));class X{constructor(e){_(this,"_client",void 0),this._client=e}}var Y=Object.freeze({__proto__:null,Aria2ClientBaseClass:H,get EAria2ChangePositionHow(){return J},get EAria2DownloadState(){return W},get EAria2UriStatusEnum(){return G},get EAria2DownloadBitTorrentMode(){return V},Aria2ClientSystemMethodsBaseClass:X});const K=null!=globalThis.WebSocket?class extends globalThis.WebSocket{constructor(e){super(e)}}:require("ws"),Z=(()=>{if(z())return $.btoa;if(null!=globalThis.btoa)return globalThis.btoa;throw new Error("`btoa()` is not defined!")})();(()=>{if(z())return $.atob;if(null!=globalThis.atob)return globalThis.atob;throw new Error("`atob()` is not defined!")})();var Q=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)}},ee=Object.prototype.toString;function te(e){return"[object Array]"===ee.call(e)}function re(e){return void 0===e}function ne(e){return null!==e&&"object"==typeof e}function oe(e){if("[object Object]"!==ee.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function se(e){return"[object Function]"===ee.call(e)}function ie(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),te(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 ae={isArray:te,isArrayBuffer:function(e){return"[object ArrayBuffer]"===ee.call(e)},isBuffer:function(e){return null!==e&&!re(e)&&null!==e.constructor&&!re(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:ne,isPlainObject:oe,isUndefined:re,isDate:function(e){return"[object Date]"===ee.call(e)},isFile:function(e){return"[object File]"===ee.call(e)},isBlob:function(e){return"[object Blob]"===ee.call(e)},isFunction:se,isStream:function(e){return ne(e)&&se(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:ie,merge:function e(){var t={};function r(r,n){oe(t[n])&&oe(r)?t[n]=e(t[n],r):oe(r)?t[n]=e({},r):te(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)ie(arguments[n],r);return t},extend:function(e,t,r){return ie(t,(function(t,n){e[n]=r&&"function"==typeof t?Q(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}};function ue(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ce=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(ae.isURLSearchParams(t))n=t.toString();else{var o=[];ae.forEach(t,(function(e,t){null!=e&&(ae.isArray(e)?t+="[]":e=[e],ae.forEach(e,(function(e){ae.isDate(e)?e=e.toISOString():ae.isObject(e)&&(e=JSON.stringify(e)),o.push(ue(t)+"="+ue(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 le(){this.handlers=[]}le.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},le.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},le.prototype.forEach=function(e){ae.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var fe=le,he=function(e,t){ae.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},de=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,status:this.response&&this.response.status?this.response.status:null}},e},pe=function(e,t,r,n,o){var s=new Error(e);return de(s,t,r,n,o)},me=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(pe("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},ge=ae.isStandardBrowserEnv()?{write:function(e,t,r,n,o,s){var i=[];i.push(e+"="+encodeURIComponent(t)),ae.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),ae.isString(n)&&i.push("path="+n),ae.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(){}},ye=function(e,t){return e&&!function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t},we=["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"],ve=ae.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=ae.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0};function Ce(e){this.message=e}Ce.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Ce.prototype.__CANCEL__=!0;var be=Ce,_e=wt,Oe=function(e){return new Promise((function(t,r){var n,o=e.data,s=e.headers,i=e.responseType;function a(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}ae.isFormData(o)&&delete s["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",l=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(c+":"+l)}var f=ye(e.baseURL,e.url);function h(){if(u){var n,o,s,c,l,f="getAllResponseHeaders"in u?(n=u.getAllResponseHeaders(),l={},n?(ae.forEach(n.split("\n"),(function(e){if(c=e.indexOf(":"),o=ae.trim(e.substr(0,c)).toLowerCase(),s=ae.trim(e.substr(c+1)),o){if(l[o]&&we.indexOf(o)>=0)return;l[o]="set-cookie"===o?(l[o]?l[o]:[]).concat([s]):l[o]?l[o]+", "+s:s}})),l):l):null,h={data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:f,config:e,request:u};me((function(e){t(e),a()}),(function(e){r(e),a()}),h),u=null}}if(u.open(e.method.toUpperCase(),ce(f,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(h)},u.onabort=function(){u&&(r(pe("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){r(pe("Network Error",e,null,u)),u=null},u.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded",n=e.transitional||_e.transitional;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(pe(t,e,n.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},ae.isStandardBrowserEnv()){var d=(e.withCredentials||ve(f))&&e.xsrfCookieName?ge.read(e.xsrfCookieName):void 0;d&&(s[e.xsrfHeaderName]=d)}"setRequestHeader"in u&&ae.forEach(s,(function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete s[t]:u.setRequestHeader(t,e)})),ae.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),i&&"json"!==i&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(e){u&&(r(!e||e&&e.type?new be("canceled"):e),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null),u.send(o)}))};function Ee(e){var t={exports:{}};return e(t,t.exports),t.exports}var Se=1e3,Re=60*Se,Te=60*Re,xe=24*Te,Ae=7*xe,Fe=365.25*xe,Le=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*Fe;case"weeks":case"week":case"w":return r*Ae;case"days":case"day":case"d":return r*xe;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Te;case"minutes":case"minute":case"mins":case"min":case"m":return r*Re;case"seconds":case"second":case"secs":case"sec":case"s":return r*Se;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=xe)return je(e,t,xe,"day");if(t>=Te)return je(e,t,Te,"hour");if(t>=Re)return je(e,t,Re,"minute");if(t>=Se)return je(e,t,Se,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=xe)return Math.round(e/xe)+"d";if(t>=Te)return Math.round(e/Te)+"h";if(t>=Re)return Math.round(e/Re)+"m";if(t>=Se)return Math.round(e/Se)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function je(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}var ke=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=Le,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t},Pe=Ee((function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ke(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}})),Be=(e,t=process.argv)=>{const r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return-1!==n&&(-1===o||n<o)};const{env:Ne}=process;let Ue;function qe(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function De(e,t){if(0===Ue)return 0;if(Be("color=16m")||Be("color=full")||Be("color=truecolor"))return 3;if(Be("color=256"))return 2;if(e&&!t&&void 0===Ue)return 0;const r=Ue||0;if("dumb"===Ne.TERM)return r;if("win32"===process.platform){const e=v.default.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in Ne)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in Ne))||"codeship"===Ne.CI_NAME?1:r;if("TEAMCITY_VERSION"in Ne)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ne.TEAMCITY_VERSION)?1:0;if("truecolor"===Ne.COLORTERM)return 3;if("TERM_PROGRAM"in Ne){const e=parseInt((Ne.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ne.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ne.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ne.TERM)||"COLORTERM"in Ne?1:r}Be("no-color")||Be("no-colors")||Be("color=false")||Be("color=never")?Ue=0:(Be("color")||Be("colors")||Be("color=true")||Be("color=always"))&&(Ue=1),"FORCE_COLOR"in Ne&&(Ue="true"===Ne.FORCE_COLOR?1:"false"===Ne.FORCE_COLOR?0:0===Ne.FORCE_COLOR.length?1:Math.min(parseInt(Ne.FORCE_COLOR,10),3));var Me,Ie={supportsColor:function(e){return qe(De(e,e&&e.isTTY))},stdout:qe(De(!0,y.default.isatty(1))),stderr:qe(De(!0,y.default.isatty(2)))},$e=Ee((function(e,t){t.init=function(e){e.inspectOpts={};const r=Object.keys(t.inspectOpts);for(let n=0;n<r.length;n++)e.inspectOpts[r[n]]=t.inspectOpts[r[n]]},t.log=function(...e){return process.stderr.write(w.default.format(...e)+"\n")},t.formatArgs=function(r){const{namespace:n,useColors:o}=this;if(o){const t=this.color,o="[3"+(t<8?t:"8;5;"+t),s=` ${o};1m${n} `;r[0]=s+r[0].split("\n").join("\n"+s),r.push(o+"m+"+e.exports.humanize(this.diff)+"")}else r[0]=function(){if(t.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+n+" "+r[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):y.default.isatty(process.stderr.fd)},t.destroy=w.default.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=Ie;e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const r=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e}),{}),e.exports=ke(t);const{formatters:r}=e.exports;r.o=function(e){return this.inspectOpts.colors=this.useColors,w.default.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},r.O=function(e){return this.inspectOpts.colors=this.useColors,w.default.inspect(e,this.inspectOpts)}})),ze=Ee((function(e){"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=Pe:e.exports=$e})),He=function(){if(!Me){try{Me=ze("follow-redirects")}catch(e){}"function"!=typeof Me&&(Me=function(){})}Me.apply(null,arguments)},Je=p.default.URL,We=m.default.Writable,Ge=["abort","aborted","connect","error","socket","timeout"],Ve=Object.create(null);Ge.forEach((function(e){Ve[e]=function(t,r,n){this._redirectable.emit(e,t,r,n)}}));var Xe=ot("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),Ye=ot("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded"),Ke=ot("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),Ze=ot("ERR_STREAM_WRITE_AFTER_END","write after end");function Qe(e,t){We.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var r=this;this._onNativeResponse=function(e){r._processResponse(e)},this._performRequest()}function et(e){var t={maxRedirects:21,maxBodyLength:10485760},r={};return Object.keys(e).forEach((function(n){var o=n+":",s=r[o]=e[n],i=t[n]=Object.create(s);Object.defineProperties(i,{request:{value:function(e,n,s){if("string"==typeof e){var i=e;try{e=rt(new Je(i))}catch(t){e=p.default.parse(i)}}else Je&&e instanceof Je?e=rt(e):(s=n,n=e,e={protocol:o});return"function"==typeof n&&(s=n,n=null),(n=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,n)).nativeProtocols=r,g.default.equal(n.protocol,o,"protocol mismatch"),He("options",n),new Qe(n,s)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,r){var n=i.request(e,t,r);return n.end(),n},configurable:!0,enumerable:!0,writable:!0}})})),t}function tt(){}function rt(e){var t={protocol:e.protocol,hostname:e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:e.pathname+e.search,href:e.href};return""!==e.port&&(t.port=Number(e.port)),t}function nt(e,t){var r;for(var n in t)e.test(n)&&(r=t[n].toString().trim(),delete t[n]);return r}function ot(e,t){function r(e){Error.captureStackTrace(this,this.constructor),e?(this.message=t+": "+e.message,this.cause=e):this.message=t}return r.prototype=new Error,r.prototype.constructor=r,r.prototype.name="Error ["+e+"]",r.prototype.code=e,r}function st(e){for(var t=0;t<Ge.length;t++)e.removeListener(Ge[t],Ve[Ge[t]]);e.on("error",tt),e.abort()}Qe.prototype=Object.create(We.prototype),Qe.prototype.abort=function(){st(this._currentRequest),this.emit("abort")},Qe.prototype.write=function(e,t,r){if(this._ending)throw new Ze;if(!("string"==typeof e||"object"==typeof e&&"length"in e))throw new TypeError("data should be a string, Buffer or Uint8Array");"function"==typeof t&&(r=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,r)):(this.emit("error",new Ke),this.abort()):r&&r()},Qe.prototype.end=function(e,t,r){if("function"==typeof e?(r=e,e=t=null):"function"==typeof t&&(r=t,t=null),e){var n=this,o=this._currentRequest;this.write(e,t,(function(){n._ended=!0,o.end(null,null,r)})),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,r)},Qe.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},Qe.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},Qe.prototype.setTimeout=function(e,t){var r=this;function n(t){t.setTimeout(e),t.removeListener("timeout",t.destroy),t.addListener("timeout",t.destroy)}function o(t){r._timeout&&clearTimeout(r._timeout),r._timeout=setTimeout((function(){r.emit("timeout"),s()}),e),n(t)}function s(){r._timeout&&(clearTimeout(r._timeout),r._timeout=null),r.removeListener("abort",s),r.removeListener("error",s),r.removeListener("response",s),t&&r.removeListener("timeout",t),r.socket||r._currentRequest.removeListener("socket",o)}return t&&this.on("timeout",t),this.socket?o(this.socket):this._currentRequest.once("socket",o),this.on("socket",n),this.on("abort",s),this.on("error",s),this.on("response",s),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach((function(e){Qe.prototype[e]=function(t,r){return this._currentRequest[e](t,r)}})),["aborted","connection","socket"].forEach((function(e){Object.defineProperty(Qe.prototype,e,{get:function(){return this._currentRequest[e]}})})),Qe.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}},Qe.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(t){if(this._options.agents){var r=e.substr(0,e.length-1);this._options.agent=this._options.agents[r]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);this._currentUrl=p.default.format(this._options),n._redirectable=this;for(var o=0;o<Ge.length;o++)n.on(Ge[o],Ve[Ge[o]]);if(this._isRedirect){var s=0,i=this,a=this._requestBodyBuffers;!function e(t){if(n===i._currentRequest)if(t)i.emit("error",t);else if(s<a.length){var r=a[s++];n.finished||n.write(r.data,r.encoding,e)}else i._ended&&n.end()}()}}else this.emit("error",new TypeError("Unsupported protocol "+e))},Qe.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var r=e.headers.location;if(r&&!1!==this._options.followRedirects&&t>=300&&t<400){if(st(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)return void this.emit("error",new Ye);((301===t||302===t)&&"POST"===this._options.method||303===t&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],nt(/^content-/i,this._options.headers));var n,o=nt(/^host$/i,this._options.headers),s=p.default.parse(this._currentUrl),i=o||s.host,a=/^\w+:/.test(r)?this._currentUrl:p.default.format(Object.assign(s,{host:i}));try{n=p.default.resolve(a,r)}catch(e){return void this.emit("error",new Xe(e))}He("redirecting to",n),this._isRedirect=!0;var u=p.default.parse(n);if(Object.assign(this._options,u),u.host===i||function(e,t){const r=e.length-t.length-1;return r>0&&"."===e[r]&&e.endsWith(t)}(u.host,i)||nt(/^authorization$/i,this._options.headers),"function"==typeof this._options.beforeRedirect){var c={headers:e.headers};try{this._options.beforeRedirect.call(null,this._options,c)}catch(e){return void this.emit("error",e)}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(e){this.emit("error",new Xe(e))}}else e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),this._requestBodyBuffers=[]};var it=et({http:h.default,https:d.default}),at=et;it.wrap=at;var ut="0.22.0",ct=it.http,lt=it.https,ft=ut,ht=/https:?/;function dt(e,t,r){if(e.hostname=t.host,e.host=t.host,e.port=t.port,e.path=r,t.auth){var n=Buffer.from(t.auth.username+":"+t.auth.password,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+n}e.beforeRedirect=function(e){e.headers.host=e.host,dt(e,t,e.href)}}var pt=function(e){return new Promise((function(t,r){var n;function o(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}var s=function(e){o(),t(e)},i=function(e){o(),r(e)},a=e.data,u=e.headers,c={};if(Object.keys(u).forEach((function(e){c[e.toLowerCase()]=e})),"user-agent"in c?u[c["user-agent"]]||delete u[c["user-agent"]]:u["User-Agent"]="axios/"+ft,a&&!ae.isStream(a)){if(Buffer.isBuffer(a));else if(ae.isArrayBuffer(a))a=Buffer.from(new Uint8Array(a));else{if(!ae.isString(a))return i(pe("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",e));a=Buffer.from(a,"utf-8")}c["content-length"]||(u["Content-Length"]=a.length)}var l=void 0;e.auth&&(l=(e.auth.username||"")+":"+(e.auth.password||""));var f=ye(e.baseURL,e.url),m=p.default.parse(f),g=m.protocol||"http:";if(!l&&m.auth){var y=m.auth.split(":");l=(y[0]||"")+":"+(y[1]||"")}l&&c.authorization&&delete u[c.authorization];var w=ht.test(g),v=w?e.httpsAgent:e.httpAgent,b={path:ce(m.path,e.params,e.paramsSerializer).replace(/^\?/,""),method:e.method.toUpperCase(),headers:u,agent:v,agents:{http:e.httpAgent,https:e.httpsAgent},auth:l};e.socketPath?b.socketPath=e.socketPath:(b.hostname=m.hostname,b.port=m.port);var _,O=e.proxy;if(!O&&!1!==O){var E=g.slice(0,-1)+"_proxy",S=process.env[E]||process.env[E.toUpperCase()];if(S){var R=p.default.parse(S),T=process.env.no_proxy||process.env.NO_PROXY,x=!0;if(T){var A=T.split(",").map((function(e){return e.trim()}));x=!A.some((function(e){return!!e&&("*"===e||("."===e[0]&&m.hostname.substr(m.hostname.length-e.length)===e||m.hostname===e))}))}if(x&&(O={host:R.hostname,port:R.port,protocol:R.protocol},R.auth)){var F=R.auth.split(":");O.auth={username:F[0],password:F[1]}}}}O&&(b.headers.host=m.hostname+(m.port?":"+m.port:""),dt(b,O,g+"//"+m.hostname+(m.port?":"+m.port:"")+b.path));var L=w&&(!O||ht.test(O.protocol));e.transport?_=e.transport:0===e.maxRedirects?_=L?d.default:h.default:(e.maxRedirects&&(b.maxRedirects=e.maxRedirects),_=L?lt:ct),e.maxBodyLength>-1&&(b.maxBodyLength=e.maxBodyLength),e.insecureHTTPParser&&(b.insecureHTTPParser=e.insecureHTTPParser);var j=_.request(b,(function(t){if(!j.aborted){var r=t,n=t.req||j;if(204!==t.statusCode&&"HEAD"!==n.method&&!1!==e.decompress)switch(t.headers["content-encoding"]){case"gzip":case"compress":case"deflate":r=r.pipe(C.default.createUnzip()),delete t.headers["content-encoding"]}var o={status:t.statusCode,statusText:t.statusMessage,headers:t.headers,config:e,request:n};if("stream"===e.responseType)o.data=r,me(s,i,o);else{var a=[],u=0;r.on("data",(function(t){a.push(t),u+=t.length,e.maxContentLength>-1&&u>e.maxContentLength&&(r.destroy(),i(pe("maxContentLength size of "+e.maxContentLength+" exceeded",e,null,n)))})),r.on("error",(function(t){j.aborted||i(de(t,e,null,n))})),r.on("end",(function(){var t=Buffer.concat(a);"arraybuffer"!==e.responseType&&(t=t.toString(e.responseEncoding),e.responseEncoding&&"utf8"!==e.responseEncoding||(t=ae.stripBOM(t))),o.data=t,me(s,i,o)}))}}}));if(j.on("error",(function(t){j.aborted&&"ERR_FR_TOO_MANY_REDIRECTS"!==t.code||i(de(t,e,null,j))})),e.timeout){var k=parseInt(e.timeout,10);if(isNaN(k))return void i(pe("error trying to parse `config.timeout` to int",e,"ERR_PARSE_TIMEOUT",j));j.setTimeout(k,(function(){j.abort();var t=e.transitional||_e.transitional;i(pe("timeout of "+k+"ms exceeded",e,t.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",j))}))}(e.cancelToken||e.signal)&&(n=function(e){j.aborted||(j.abort(),i(!e||e&&e.type?new be("canceled"):e))},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),ae.isStream(a)?a.on("error",(function(t){i(de(t,e,null,j))})).pipe(j):j.end(a)}))},mt={"Content-Type":"application/x-www-form-urlencoded"};function gt(e,t){!ae.isUndefined(e)&&ae.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var yt={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:function(){var e;return"undefined"!=typeof XMLHttpRequest?e=Oe:"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)&&(e=pt),e}(),transformRequest:[function(e,t){return he(t,"Accept"),he(t,"Content-Type"),ae.isFormData(e)||ae.isArrayBuffer(e)||ae.isBuffer(e)||ae.isStream(e)||ae.isFile(e)||ae.isBlob(e)?e:ae.isArrayBufferView(e)?e.buffer:ae.isURLSearchParams(e)?(gt(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):ae.isObject(e)||t&&"application/json"===t["Content-Type"]?(gt(t,"application/json"),function(e,t,r){if(ae.isString(e))try{return(t||JSON.parse)(e),ae.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||yt.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,o=!r&&"json"===this.responseType;if(o||n&&ae.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw de(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ae.forEach(["delete","get","head"],(function(e){yt.headers[e]={}})),ae.forEach(["post","put","patch"],(function(e){yt.headers[e]=ae.merge(mt)}));var wt=yt,vt=function(e,t,r){var n=this||_e;return ae.forEach(r,(function(r){e=r.call(n,e,t)})),e},Ct=function(e){return!(!e||!e.__CANCEL__)};function bt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new be("canceled")}var _t=function(e){return bt(e),e.headers=e.headers||{},e.data=vt.call(e,e.data,e.headers,e.transformRequest),e.headers=ae.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ae.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||_e.adapter)(e).then((function(t){return bt(e),t.data=vt.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Ct(t)||(bt(e),t&&t.response&&(t.response.data=vt.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Ot=function(e,t){t=t||{};var r={};function n(e,t){return ae.isPlainObject(e)&&ae.isPlainObject(t)?ae.merge(e,t):ae.isPlainObject(t)?ae.merge({},t):ae.isArray(t)?t.slice():t}function o(r){return ae.isUndefined(t[r])?ae.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function s(e){if(!ae.isUndefined(t[e]))return n(void 0,t[e])}function i(r){return ae.isUndefined(t[r])?ae.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function a(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var u={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a};return ae.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,n=t(e);ae.isUndefined(n)&&t!==a||(r[e]=n)})),r},Et=ut,St={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){St[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Rt={};St.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Et+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,o,s){if(!1===e)throw new Error(n(o," has been removed"+(t?" in "+t:"")));return t&&!Rt[o]&&(Rt[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,s)}};var Tt={assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var s=n[o],i=t[s];if(i){var a=e[s],u=void 0===a||i(a,s,e);if(!0!==u)throw new TypeError("option "+s+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:St},xt=Tt.validators;function At(e){this.defaults=e,this.interceptors={request:new fe,response:new fe}}At.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Ot(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&Tt.assertOptions(t,{silentJSONParsing:xt.transitional(xt.boolean),forcedJSONParsing:xt.transitional(xt.boolean),clarifyTimeoutError:xt.transitional(xt.boolean)},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var i=[_t,void 0];for(Array.prototype.unshift.apply(i,r),i=i.concat(s),o=Promise.resolve(e);i.length;)o=o.then(i.shift(),i.shift());return o}for(var a=e;r.length;){var u=r.shift(),c=r.shift();try{a=u(a)}catch(e){c(e);break}}try{o=_t(a)}catch(e){return Promise.reject(e)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},At.prototype.getUri=function(e){return e=Ot(this.defaults,e),ce(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ae.forEach(["delete","get","head","options"],(function(e){At.prototype[e]=function(t,r){return this.request(Ot(r||{},{method:e,url:t,data:(r||{}).data}))}})),ae.forEach(["post","put","patch"],(function(e){At.prototype[e]=function(t,r,n){return this.request(Ot(n||{},{method:e,url:t,data:r}))}}));var Ft=At;function Lt(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;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new be(e),t(r.reason))}))}Lt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Lt.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},Lt.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},Lt.source=function(){var e;return{token:new Lt((function(t){e=t})),cancel:e}};var jt=Lt;var kt=function e(t){var r=new Ft(t),n=Q(Ft.prototype.request,r);return ae.extend(n,Ft.prototype,r),ae.extend(n,r),n.create=function(r){return e(Ot(t,r))},n}(_e);kt.Axios=Ft,kt.Cancel=be,kt.CancelToken=jt,kt.isCancel=Ct,kt.VERSION=ut,kt.all=function(e){return Promise.all(e)},kt.spread=function(e){return function(t){return e.apply(null,t)}},kt.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError};var Pt=kt,Bt=kt;Pt.default=Bt;var Nt=Pt;exports.WebSocket=void 0,function(e){e.Client=class extends H{constructor(e){var r,n,o;super(),_(this,"_conn",void 0),_(this,"_options",void 0),_(this,"_cbs",new Map),_(this,"_open_cbs",[]),_(this,"_opened",!1),_(this,"_systemMethods",new t(this)),this._options=Object.assign({},e),this._conn=new K(`${null!==(r=e.protocol)&&void 0!==r?r:"ws"}://${e.host}:${e.port}${null!==(n=e.path)&&void 0!==n?n:"/jsonrpc"}`,z()?null!==(o=e.wsOptions)&&void 0!==o?o:{}:void 0),this._conn.onclose=()=>{this.emit("ws.close"),this._opened=!1,this._open_cbs=[]},this._conn.onopen=()=>{for(this.emit("ws.open"),this._opened=!0;this._open_cbs.length>0;){let e=this._open_cbs.pop();null!=e&&1==this._conn.readyState&&e()}},this._conn.onmessage=e=>{var t,r,n,o,s,i,a;("message"==(null===(t=e)||void 0===t?void 0:t.type)||z())&&(e=e.data);try{this.emit("ws.message",e);let t=JSON.parse(e.toString());if(t instanceof Array){let e=this._cbs.get(t[0].id);null!=e&&e(t),this._cbs.delete(t[0].id)}else if(null!=t.id&&this._cbs.has(null==t?void 0:t.id)){let e=this._cbs.get(t.id);null!=e&&e(t),this._cbs.delete(t.id)}else if(null!=t.method)switch(null==t?void 0:t.method){case"aria2.onDownloadStart":this.emit("aria2.onDownloadStart",...null!==(r=t.params)&&void 0!==r?r:[]);break;case"aria2.onDownloadPause":this.emit("aria2.onDownloadPause",...null!==(n=t.params)&&void 0!==n?n:[]);break;case"aria2.onDownloadStop":this.emit("aria2.onDownloadStop",...null!==(o=t.params)&&void 0!==o?o:[]);break;case"aria2.onDownloadComplete":this.emit("aria2.onDownloadComplete",...null!==(s=t.params)&&void 0!==s?s:[]);break;case"aria2.onDownloadError":this.emit("aria2.onDownloadError",...null!==(i=t.params)&&void 0!==i?i:[]);break;case"aria2.onBtDownloadComplete":this.emit("aria2.onBtDownloadComplete",...null!==(a=t.params)&&void 0!==a?a:[])}}catch(e){throw this.$errorHandle(e),e}}}$errorHandle(e){}_waitOpened(){return new Promise(((e,t)=>{this._opened&&1==this._conn.readyState?e():this._conn.readyState<1&&this._conn.readyState>1?t(this._conn.readyState):this._open_cbs.push(e)}))}_sendRaw(e){return new Promise(((t,r)=>{try{this._conn.send(e)}catch(e){r(e)}}))}_sendJson(e,...t){return new Promise((async(r,n)=>{var o,s;await this._waitOpened();let i=A(),a={jsonrpc:"2.0",id:i,method:e,params:[]};null!=(null===(o=this._options)||void 0===o||null===(s=o.auth)||void 0===s?void 0:s.secret)&&a.params.push("token:"+this._options.auth.secret),a.params=[...a.params,...t],this._cbs.set(i,r),this._sendRaw(JSON.stringify(a)).catch(n)}))}get system(){return this._systemMethods}async rawCall(e,...t){let r=await this._sendJson(e,...t);if(null!=r.error)throw r.error;return r.result}async rawSend(e){return await this._sendRaw(e)}async getCreateOptions(){return Object.freeze(this._options)}async close(e,t){this._conn.close(e,t)}on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}addListener(e,t){return super.on(e,t),this}};class t extends X{async listMethods(){return await this._client.rawCall("system.listMethods")}async listNotifications(){return await this._client.rawCall("system.listNotifications")}multicall(...e){return new Promise((async(t,r)=>{var n;let o=A(),s=!1,i=[],a=await this._client.getCreateOptions();var u;null!=(null==a||null===(n=a.auth)||void 0===n?void 0:n.secret)&&i.push("token:"+(null==a||null===(u=a.auth)||void 0===u?void 0:u.secret));let c=[];for(const t of e)1!=s?(c.push({jsonrpc:"2.0",id:o,method:t.methodName,params:[...i,...t.params]}),s=!0):c.push({jsonrpc:"2.0",id:A(),method:t.methodName,params:[...i,...t.params]});await this._client._waitOpened(),this._client._cbs.set(o,(e=>{let r=[];for(const t of e)null!=t.error?r.push(Promise.reject(t.error)):r.push(Promise.resolve(t.result));t(r)})),this._client.rawSend(JSON.stringify(c)).catch(r)}))}}e.SystemMethods=t}(exports.WebSocket||(exports.WebSocket={})),exports.Http=void 0,function(e){e.Client=class extends H{constructor(e){super(),_(this,"_options",void 0),_(this,"_system",void 0),this._options=e,this._system=new t(this)}get system(){return this._system}async rawCall(e,...t){var r,n,o;let s=A(),i=[...t];null!=(null===(r=this._options)||void 0===r||null===(n=r.auth)||void 0===n?void 0:n.secret)&&i.push("token:"+this._options.auth.secret);let a=`${null!==(o=this._options.protocol)&&void 0!==o?o:"http"}://${this._options.host}:${this._options.port}/jsonrpc?method=${decodeURIComponent(e)}&id=${decodeURIComponent(s)}&params=${Z(JSON.stringify(i))}`,u=(await Nt(a,{method:"GET",...this._options.fetchOptions})).data;if(null==u.error)return u.result;throw u.error}async rawSend(e){throw new Error("Method not implemented.")}async getCreateOptions(){return this._options}};class t extends X{async multicall(...e){let t={},r=[],n=[],o=await this._client.getCreateOptions();for(const a of e){var s,i;let e=A(),u=[];null!=(null==o||null===(s=o.auth)||void 0===s?void 0:s.secret)&&u.push(null==o||null===(i=o.auth)||void 0===i?void 0:i.secret),r.push({jsonrpc:"2.0",id:e,params:[...u,...a.params],method:a.methodName}),n.push(new Promise(((r,n)=>{t[e]={r:r,j:n}})))}return new Promise((async()=>{var e;let n=`${null!==(e=o.protocol)&&void 0!==e?e:"http"}://${o.host}:${o.port}/jsonrpc?method=&id=&params=${Z(JSON.stringify(r))}`,s=await Nt(n,{method:"GET",...o.fetchOptions});for(const e of s.data)null!=e.id&&null!=t[e.id]&&(null!=e.error?t[e.id].j(e.error):t[e.id].r(e.result))})),n}a