!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).superagent=t()}}((function(){var t={exports:{}};function e(t){if(t)return function(t){for(var r in e.prototype)t[r]=e.prototype[r];return t}(t)}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},e.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,o=this._callbacks["$"+t];if(!o)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n=0;nu.depthLimit)return void s("[...]",e,r,i);if(void 0!==u.edgesLimit&&o+1>u.edgesLimit)return void s("[...]",e,r,i);if(n.push(e),Array.isArray(e))for(p=0;pe?1:0}function p(t,e,r,a){void 0===a&&(a=i());var p,l=function t(e,r,n,i,a,p,c){var l;if(p+=1,"object"==typeof e&&null!==e){for(l=0;lc.depthLimit)return void s("[...]",e,r,a);if(void 0!==c.edgesLimit&&n+1>c.edgesLimit)return void s("[...]",e,r,a);if(i.push(e),Array.isArray(e))for(l=0;l0)for(var o=0;o1&&"boolean"!=typeof e)throw new g('"allowMissing" argument must be a boolean');if(null===N(/^%?[^%]*%?$/,t))throw new m("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=F(t,0,1),r=F(t,-1);if("%"===e&&"%"!==r)throw new m("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new m("invalid intrinsic syntax, expected opening `%`");var o=[];return C(t,D,(function(t,e,r,n){o[o.length]=r?C(n,U,"$1"):e||t})),o}(t),o=r.length>0?r[0]:"",n=M("%"+o+"%",e),i=n.name,a=n.value,s=!1,u=n.alias;u&&(o=u[0],I(r,R([0,1],u)));for(var p=1,c=!0;p=r.length){var h=w(a,l);a=(c=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[l]}else c=d(a,l),a=a[l];c&&!s&&(j[i]=a)}}return a},q=L("%Function.prototype.apply%"),B=L("%Function.prototype.call%"),W=L("%Reflect.apply%",!0)||h.call(B,q),$=L("%Object.getOwnPropertyDescriptor%",!0),H=L("%Object.defineProperty%",!0),z=L("%Math.max%");if(H)try{H({},"a",{value:1})}catch(or){H=null}x=function(t){var e=W(h,B,arguments);return $&&H&&$(e,"length").configurable&&H(e,"length",{value:1+z(0,t.length-(arguments.length-1))}),e};var G=function(){return W(h,q,arguments)};H?H(x,"apply",{value:G}):x.apply=G;var J=x(L("String.prototype.indexOf")),V=function(t,e){var r=L(t,!!e);return"function"==typeof r&&J(t,".prototype.")>-1?x(r):r},Q={},X="function"==typeof Map&&Map.prototype,K=Object.getOwnPropertyDescriptor&&X?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Y=X&&K&&"function"==typeof K.get?K.get:null,Z=X&&Map.prototype.forEach,tt="function"==typeof Set&&Set.prototype,et=Object.getOwnPropertyDescriptor&&tt?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,rt=tt&&et&&"function"==typeof et.get?et.get:null,ot=tt&&Set.prototype.forEach,nt="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,it="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,at="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,st=Boolean.prototype.valueOf,ut=Object.prototype.toString,pt=Function.prototype.toString,ct=String.prototype.match,lt=String.prototype.slice,ft=String.prototype.replace,yt=String.prototype.toUpperCase,ht=String.prototype.toLowerCase,dt=RegExp.prototype.test,mt=Array.prototype.concat,bt=Array.prototype.join,gt=Array.prototype.slice,vt=Math.floor,wt="function"==typeof BigInt?BigInt.prototype.valueOf:null,_t=Object.getOwnPropertySymbols,St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,At="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Et="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,Ot=Object.prototype.propertyIsEnumerable,Tt=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function jt(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||dt.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var o=t<0?-vt(-t):vt(t);if(o!==t){var n=String(o),i=lt.call(e,n.length+1);return ft.call(n,r,"$&_")+"."+ft.call(ft.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ft.call(e,r,"$&_")}var Pt=Q.custom,xt=Ft(Pt)?Pt:null;function kt(t,e,r){var o="double"===(r.quoteStyle||e)?'"':"'";return o+t+o}function Rt(t){return ft.call(String(t),/"/g,""")}function It(t){return!("[object Array]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}function Ct(t){return!("[object RegExp]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}function Ft(t){if(At)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!St)return!1;try{return St.call(t),!0}catch(or){}return!1}var Nt=Object.prototype.hasOwnProperty||function(t){return t in this};function Dt(t,e){return Nt.call(t,e)}function Ut(t){return ut.call(t)}function Mt(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,o=t.length;r0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Dt(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return function t(e,r){if(e.length>r.maxStringLength){var o=e.length-r.maxStringLength,n="... "+o+" more character"+(o>1?"s":"");return t(lt.call(e,0,r.maxStringLength),r)+n}return kt(ft.call(ft.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Lt),"single",r)}(e,i);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var u=String(e);return s?jt(e,u):u}if("bigint"==typeof e){var p=String(e)+"n";return s?jt(e,p):p}var c=void 0===i.depth?5:i.depth;if(void 0===o&&(o=0),o>=c&&c>0&&"object"==typeof e)return It(e)?"[Array]":"[Object]";var l,f=function(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=bt.call(Array(t.indent+1)," ")}return{base:r,prev:bt.call(Array(e+1),r)}}(i,o);if(void 0===n)n=[];else if(Mt(n,e)>=0)return"[Circular]";function y(e,r,a){if(r&&(n=gt.call(n)).push(r),a){var s={depth:i.depth};return Dt(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),t(e,s,o+1,n)}return t(e,i,o+1,n)}if("function"==typeof e&&!Ct(e)){var h=function(t){if(t.name)return t.name;var e=ct.call(pt.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}(e),d=Ht(e,y);return"[Function"+(h?": "+h:" (anonymous)")+"]"+(d.length>0?" { "+bt.call(d,", ")+" }":"")}if(Ft(e)){var m=At?ft.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):St.call(e);return"object"!=typeof e||At?m:qt(m)}if((l=e)&&"object"==typeof l&&("undefined"!=typeof HTMLElement&&l instanceof HTMLElement||"string"==typeof l.nodeName&&"function"==typeof l.getAttribute)){for(var b="<"+ht.call(String(e.nodeName)),g=e.attributes||[],v=0;v"}if(It(e)){if(0===e.length)return"[]";var w=Ht(e,y);return f&&!function(t){for(var e=0;e=0)return!1;return!0}(w)?"["+$t(w,f)+"]":"[ "+bt.call(w,", ")+" ]"}if(function(t){return!("[object Error]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}(e)){var _=Ht(e,y);return"cause"in Error.prototype||!("cause"in e)||Ot.call(e,"cause")?0===_.length?"["+String(e)+"]":"{ ["+String(e)+"] "+bt.call(_,", ")+" }":"{ ["+String(e)+"] "+bt.call(mt.call("[cause]: "+y(e.cause),_),", ")+" }"}if("object"==typeof e&&a){if(xt&&"function"==typeof e[xt]&&Q)return Q(e,{depth:c-o});if("symbol"!==a&&"function"==typeof e.inspect)return e.inspect()}if(function(t){if(!Y||!t||"object"!=typeof t)return!1;try{Y.call(t);try{rt.call(t)}catch(b){return!0}return t instanceof Map}catch(or){}return!1}(e)){var S=[];return Z&&Z.call(e,(function(t,r){S.push(y(r,e,!0)+" => "+y(t,e))})),Wt("Map",Y.call(e),S,f)}if(function(t){if(!rt||!t||"object"!=typeof t)return!1;try{rt.call(t);try{Y.call(t)}catch(e){return!0}return t instanceof Set}catch(or){}return!1}(e)){var A=[];return ot&&ot.call(e,(function(t){A.push(y(t,e))})),Wt("Set",rt.call(e),A,f)}if(function(t){if(!nt||!t||"object"!=typeof t)return!1;try{nt.call(t,nt);try{it.call(t,it)}catch(b){return!0}return t instanceof WeakMap}catch(or){}return!1}(e))return Bt("WeakMap");if(function(t){if(!it||!t||"object"!=typeof t)return!1;try{it.call(t,it);try{nt.call(t,nt)}catch(b){return!0}return t instanceof WeakSet}catch(or){}return!1}(e))return Bt("WeakSet");if(function(t){if(!at||!t||"object"!=typeof t)return!1;try{return at.call(t),!0}catch(or){}return!1}(e))return Bt("WeakRef");if(function(t){return!("[object Number]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}(e))return qt(y(Number(e)));if(function(t){if(!t||"object"!=typeof t||!wt)return!1;try{return wt.call(t),!0}catch(or){}return!1}(e))return qt(y(wt.call(e)));if(function(t){return!("[object Boolean]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}(e))return qt(st.call(e));if(function(t){return!("[object String]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}(e))return qt(y(String(e)));if(!function(t){return!("[object Date]"!==Ut(t)||Et&&"object"==typeof t&&Et in t)}(e)&&!Ct(e)){var E=Ht(e,y),O=Tt?Tt(e)===Object.prototype:e instanceof Object||e.constructor===Object,T=e instanceof Object?"":"null prototype",j=!O&&Et&&Object(e)===e&&Et in e?lt.call(Ut(e),8,-1):T?"Object":"",P=(O||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(j||T?"["+bt.call(mt.call([],j||[],T||[]),": ")+"] ":"");return 0===E.length?P+"{}":f?P+"{"+$t(E,f)+"}":P+"{ "+bt.call(E,", ")+" }"}return String(e)}(t))},get:function(o){if(Gt&&o&&("object"==typeof o||"function"==typeof o)){if(t)return Vt(t,o)}else if(Jt){if(e)return Kt(e,o)}else if(r)return function(t,e){var r=te(t,e);return r&&r.value}(r,o)},has:function(o){if(Gt&&o&&("object"==typeof o||"function"==typeof o)){if(t)return Xt(t,o)}else if(Jt){if(e)return Zt(e,o)}else if(r)return function(t,e){return!!te(t,e)}(r,o);return!1},set:function(o,n){Gt&&o&&("object"==typeof o||"function"==typeof o)?(t||(t=new Gt),Qt(t,o,n)):Jt?(e||(e=new Jt),Yt(e,o,n)):(r||(r={key:{},next:null}),function(t,e,r){var o=te(t,e);o?o.value=r:t.next={key:e,next:t.next,value:r}}(r,o,n))}};return o},re=String.prototype.replace,oe=/%20/g,ne={default:"RFC3986",formatters:{RFC1738:function(t){return re.call(t,oe,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:"RFC3986"},ie=Object.prototype.hasOwnProperty,ae=Array.isArray,se=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),ue={combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],o=0;o1;){var e=t.pop(),r=e.obj[e.prop];if(ae(r)){for(var o=[],n=0;n=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||n===ne.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=se[u]:u<2048?a+=se[192|u>>6]+se[128|63&u]:u<55296||u>=57344?a+=se[224|u>>12]+se[128|u>>6&63]+se[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=se[240|u>>18]+se[128|u>>12&63]+se[128|u>>6&63]+se[128|63&u])}return a},isBuffer:function(t){return!(!t||"object"!=typeof t||!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t)))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(ae(t)){for(var r=[],o=0;o0?g.join(",")||null:void 0}];else if(le(u))j=u;else{var x=Object.keys(g);j=p?x.sort(p):x}for(var k=n&&le(g)&&1===g.length?r+"[]":r,R=0;R0?y+f:""}}),_e={type:t=>t.split(/ *; */).shift(),params:t=>{const e={};for(const r of t.split(/ *; */)){const t=r.split(/ *= */),o=t.shift(),n=t.shift();o&&n&&(e[o]=n)}return e},parseLinks:t=>{const e={};for(const r of t.split(/ *, */)){const t=r.split(/ *; */),o=t[0].slice(1,-1);e[t[1].split(/ *= */)[1].slice(1,-1)]=o}return e},isObject:t=>null!==t&&"object"==typeof t};_e.hasOwn=Object.hasOwn||function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(t),e)},_e.mixin=(t,e)=>{for(const r in e)_e.hasOwn(e,r)&&(t[r]=e[r])};var Se,Ae,Ee,Oe=Se={};function Te(){throw new Error("setTimeout has not been defined")}function je(){throw new Error("clearTimeout has not been defined")}function Pe(t){if(Ae===setTimeout)return setTimeout(t,0);if((Ae===Te||!Ae)&&setTimeout)return Ae=setTimeout,setTimeout(t,0);try{return Ae(t,0)}catch(or){try{return Ae.call(null,t,0)}catch(or){return Ae.call(this,t,0)}}}!function(){try{Ae="function"==typeof setTimeout?setTimeout:Te}catch(or){Ae=Te}try{Ee="function"==typeof clearTimeout?clearTimeout:je}catch(or){Ee=je}}();var xe,ke=[],Re=!1,Ie=-1;function Ce(){Re&&xe&&(Re=!1,xe.length?ke=xe.concat(ke):Ie=-1,ke.length&&Fe())}function Fe(){if(!Re){var t=Pe(Ce);Re=!0;for(var e=ke.length;e;){for(xe=ke,ke=[];++Ie1)for(var r=1;r=this._maxRetries)return!1;if(this._retryCallback)try{const r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(r){console.error(r)}if(e&&e.status&&i.has(e.status))return!0;if(t){if(t.code&&n.has(t.code))return!0;if(t.timeout&&"ECONNABORTED"===t.code)return!0;if(t.crossDomain)return!0}return!1},o.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},o.prototype.then=function(t,e){if(!this._fullfilledPromise){const t=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((e,r)=>{t.on("abort",()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void r(this.timedoutError);const t=new Error("Aborted");t.code="ABORTED",t.status=this.status,t.method=this.method,t.url=this.url,r(t)}),t.end((t,o)=>{t?r(t):e(o)})})}return this._fullfilledPromise.then(t,e)},o.prototype.catch=function(t){return this.then(void 0,t)},o.prototype.use=function(t){return t(this),this},o.prototype.ok=function(t){if("function"!=typeof t)throw new Error("Callback required");return this._okCallback=t,this},o.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},o.prototype.get=function(t){return this._header[t.toLowerCase()]},o.prototype.getHeader=o.prototype.get,o.prototype.set=function(t,o){if(e(t)){for(const e in t)r(t,e)&&this.set(e,t[e]);return this}return this._header[t.toLowerCase()]=o,this.header[t]=o,this},o.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},o.prototype.field=function(t,o,n){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(e(t)){for(const e in t)r(t,e)&&this.field(e,t[e]);return this}if(Array.isArray(o)){for(const e in o)r(o,e)&&this.field(t,o[e]);return this}if(null==o)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof o&&(o=String(o)),n?this._getFormData().append(t,o,n):this._getFormData().append(t,o),this},o.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(Q.gte(t.version,"v13.0.0")&&Q.lt(t.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");Q.gte(t.version,"v14.0.0")&&(this.req.destroyed=!0),this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},o.prototype._auth=function(t,e,r,o){switch(r.type){case"basic":this.set("Authorization","Basic "+o(`${t}:${e}`));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},o.prototype.withCredentials=function(t){return void 0===t&&(t=!0),this._withCredentials=t,this},o.prototype.redirects=function(t){return this._maxRedirects=t,this},o.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw new TypeError("Invalid argument");return this._maxResponseSize=t,this},o.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},o.prototype.send=function(t){const o=e(t);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(o&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(o&&e(this._data))for(const e in t)r(t,e)&&(this._data[e]=t[e]);else"string"==typeof t?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${t}`:t:(this._data||"")+t):this._data=t;return!o||this._isHost(t)||n||this.type("json"),this},o.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},o.prototype._finalizeQueryString=function(){const t=this._query.join("&");if(t&&(this.url+=(this.url.includes("?")?"&":"?")+t),this._query.length=0,this._sort){const t=this.url.indexOf("?");if(t>=0){const e=this.url.slice(t+1).split("&");"function"==typeof this._sort?e.sort(this._sort):e.sort(),this.url=this.url.slice(0,t)+"?"+e.join("&")}}},o.prototype._appendQueryString=()=>{console.warn("Unsupported")},o.prototype._timeoutError=function(t,e,r){if(this._aborted)return;const o=new Error(t+e+"ms exceeded");o.timeout=e,o.code="ECONNABORTED",o.errno=r,this.timedout=!0,this.timedoutError=o,this.abort(),this.callback(o)},o.prototype._setTimeouts=function(){const t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(()=>{t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(()=>{t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}}).call(this)}).call(this,Se);var Me;function Le(){}Me=Le,Le.prototype.get=function(t){return this.header[t.toLowerCase()]},Le.prototype._setHeaderProperties=function(t){const e=t["content-type"]||"";this.type=_e.type(e);const r=_e.params(e);for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(this[n]=r[n]);this.links={};try{t.link&&(this.links=_e.parseLinks(t.link))}catch(o){}},Le.prototype._setStatusProperties=function(t){const e=Math.trunc(t/100);this.statusCode=t,this.status=this.statusCode,this.statusType=e,this.info=1===e,this.ok=2===e,this.redirect=3===e,this.clientError=4===e,this.serverError=5===e,this.error=(4===e||5===e)&&this.toError(),this.created=201===t,this.accepted=202===t,this.noContent=204===t,this.badRequest=400===t,this.unauthorized=401===t,this.notAcceptable=406===t,this.forbidden=403===t,this.notFound=404===t,this.unprocessableEntity=422===t};var qe={};function Be(){this._defaults=[]}for(const nr of["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"])Be.prototype[nr]=function(){for(var t=arguments.length,e=new Array(t),r=0;r{if($e.XMLHttpRequest)return new $e.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const Qe="".trim?t=>t.trim():t=>t.replace(/(^\s*|\s*$)/g,"");function Xe(t){if(!He(t))return t;const e=[];for(const r in t)Ge(t,r)&&Ke(e,r,t[r]);return e.join("&")}function Ke(t,e,r){if(void 0!==r)if(null!==r)if(Array.isArray(r))for(const o of r)Ke(t,e,o);else if(He(r))for(const o in r)Ge(r,o)&&Ke(t,`${e}[${o}]`,r[o]);else t.push(encodeURI(e)+"="+encodeURIComponent(r));else t.push(encodeURI(e))}function Ye(t){const e={},r=t.split("&");let o,n;for(let i=0,a=r.length;i{let t,e=null,o=null;try{o=new tr(r)}catch(n){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=n,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",o);try{r._isResponseOK(o)||(t=new Error(o.statusText||o.text||"Unsuccessful HTTP response"))}catch(n){t=n}t?(t.original=e,t.response=o,t.status=t.status||o.status,r.callback(t,o)):r.callback(null,o)})}Ve.serializeObject=Xe,Ve.parseString=Ye,Ve.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},Ve.serialize={"application/x-www-form-urlencoded":we.stringify,"application/json":r},Ve.parse={"application/x-www-form-urlencoded":Ye,"application/json":JSON.parse},ze(tr.prototype,Me.prototype),tr.prototype._parseBody=function(t){let e=Ve.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&Ze(this.type)&&(e=Ve.parse["application/json"]),e&&t&&(t.length>0||t instanceof Object)?e(t):null)},tr.prototype.toError=function(){const{req:t}=this,{method:e}=t,{url:r}=t,o=`cannot ${e} ${r} (${this.status})`,n=new Error(o);return n.status=this.status,n.method=e,n.url=r,n},Ve.Response=tr,t(er.prototype),ze(er.prototype,Ue.prototype),er.prototype.type=function(t){return this.set("Content-Type",Ve.types[t]||t),this},er.prototype.accept=function(t){return this.set("Accept",Ve.types[t]||t),this},er.prototype.auth=function(t,e,r){1===arguments.length&&(e=""),"object"==typeof e&&null!==e&&(r=e,e=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});const o=r.encoder?r.encoder:t=>{if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(t,e,r,o)},er.prototype.query=function(t){return"string"!=typeof t&&(t=Xe(t)),t&&this._query.push(t),this},er.prototype.attach=function(t,e,r){if(e){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},er.prototype._getFormData=function(){return this._formData||(this._formData=new $e.FormData),this._formData},er.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();const r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},er.prototype.crossDomainError=function(){const t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},er.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},er.prototype.ca=er.prototype.agent,er.prototype.buffer=er.prototype.ca,er.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},er.prototype.pipe=er.prototype.write,er.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},er.prototype.end=function(t){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||Je,this._finalizeQueryString(),this._end()},er.prototype._setUploadTimeout=function(){const t=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(()=>{t._timeoutError("Upload timeout of ",t._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},er.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const t=this;this.xhr=Ve.getXHR();const{xhr:e}=this;let r=this._formData||this._data;this._setTimeouts(),e.addEventListener("readystatechange",()=>{const{readyState:r}=e;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4!==r)return;let o;try{o=e.status}catch(n){o=0}if(!o){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")});const o=(e,r)=>{r.total>0&&(r.percent=r.loaded/r.total*100,100===r.percent&&clearTimeout(t._uploadTimeoutTimer)),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.addEventListener("progress",o.bind(null,"download")),e.upload&&e.upload.addEventListener("progress",o.bind(null,"upload"))}catch(n){}e.upload&&this._setUploadTimeout();try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(n){return this.callback(n)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof r&&!this._isHost(r)){const t=this._header["content-type"];let e=this._serializer||Ve.serialize[t?t.split(";")[0]:""];!e&&Ze(t)&&(e=Ve.serialize["application/json"]),e&&(r=e(r))}for(const i in this.header)null!==this.header[i]&&Ge(this.header,i)&&e.setRequestHeader(i,this.header[i]);this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0===r?null:r)},Ve.agent=()=>new qe;for(const nr of["GET","POST","OPTIONS","PATCH","PUT","DELETE"])qe.prototype[nr.toLowerCase()]=function(t,e){const r=new Ve.Request(nr,t);return this._setDefaults(r),e&&r.end(e),r};function rr(t,e,r){const o=Ve("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o}return qe.prototype.del=qe.prototype.delete,Ve.get=(t,e,r)=>{const o=Ve("GET",t);return"function"==typeof e&&(r=e,e=null),e&&o.query(e),r&&o.end(r),o},Ve.head=(t,e,r)=>{const o=Ve("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&o.query(e),r&&o.end(r),o},Ve.options=(t,e,r)=>{const o=Ve("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},Ve.del=rr,Ve.delete=rr,Ve.patch=(t,e,r)=>{const o=Ve("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},Ve.post=(t,e,r)=>{const o=Ve("POST",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},Ve.put=(t,e,r)=>{const o=Ve("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&o.send(e),r&&o.end(r),o},We}));