@nsshunt/stsutils 1.19.30 → 1.19.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/stsutils.mjs CHANGED
@@ -1199,7 +1199,7 @@ function requireTemplates() {
1199
1199
  ["e", "\x1B"],
1200
1200
  ["a", "\x07"]
1201
1201
  ]);
1202
- function unescape(c) {
1202
+ function unescape2(c) {
1203
1203
  const u = c[0] === "u";
1204
1204
  const bracket = c[1] === "{";
1205
1205
  if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
@@ -1219,7 +1219,7 @@ function requireTemplates() {
1219
1219
  if (!Number.isNaN(number)) {
1220
1220
  results.push(number);
1221
1221
  } else if (matches = chunk.match(STRING_REGEX)) {
1222
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1222
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape2(escape) : character));
1223
1223
  } else {
1224
1224
  throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1225
1225
  }
@@ -1266,7 +1266,7 @@ function requireTemplates() {
1266
1266
  let chunk = [];
1267
1267
  temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1268
1268
  if (escapeCharacter) {
1269
- chunk.push(unescape(escapeCharacter));
1269
+ chunk.push(unescape2(escapeCharacter));
1270
1270
  } else if (style) {
1271
1271
  const string = chunk.join("");
1272
1272
  chunk = [];
@@ -1303,7 +1303,7 @@ function requireSource() {
1303
1303
  stringReplaceAll,
1304
1304
  stringEncaseCRLFWithFirstIndex
1305
1305
  } = requireUtil();
1306
- const { isArray } = Array;
1306
+ const { isArray: isArray2 } = Array;
1307
1307
  const levelMapping = [
1308
1308
  "ansi",
1309
1309
  "ansi",
@@ -1409,24 +1409,24 @@ function requireSource() {
1409
1409
  parent
1410
1410
  };
1411
1411
  };
1412
- const createBuilder = (self, _styler, _isEmpty) => {
1412
+ const createBuilder = (self2, _styler, _isEmpty) => {
1413
1413
  const builder = (...arguments_) => {
1414
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1414
+ if (isArray2(arguments_[0]) && isArray2(arguments_[0].raw)) {
1415
1415
  return applyStyle(builder, chalkTag(builder, ...arguments_));
1416
1416
  }
1417
1417
  return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1418
1418
  };
1419
1419
  Object.setPrototypeOf(builder, proto);
1420
- builder._generator = self;
1420
+ builder._generator = self2;
1421
1421
  builder._styler = _styler;
1422
1422
  builder._isEmpty = _isEmpty;
1423
1423
  return builder;
1424
1424
  };
1425
- const applyStyle = (self, string) => {
1426
- if (self.level <= 0 || !string) {
1427
- return self._isEmpty ? "" : string;
1425
+ const applyStyle = (self2, string) => {
1426
+ if (self2.level <= 0 || !string) {
1427
+ return self2._isEmpty ? "" : string;
1428
1428
  }
1429
- let styler = self._styler;
1429
+ let styler = self2._styler;
1430
1430
  if (styler === void 0) {
1431
1431
  return string;
1432
1432
  }
@@ -1446,7 +1446,7 @@ function requireSource() {
1446
1446
  let template;
1447
1447
  const chalkTag = (chalk3, ...strings) => {
1448
1448
  const [firstString] = strings;
1449
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1449
+ if (!isArray2(firstString) || !isArray2(firstString.raw)) {
1450
1450
  return strings.join(" ");
1451
1451
  }
1452
1452
  const arguments_ = strings.slice(1);
@@ -1535,10 +1535,10 @@ function GetErrorPayload(errorCode, details = null) {
1535
1535
  };
1536
1536
  }
1537
1537
  const ajv = new Ajv();
1538
- const _Validate = (validator, payload) => {
1539
- const valid = validator(payload);
1538
+ const _Validate = (validator2, payload) => {
1539
+ const valid = validator2(payload);
1540
1540
  if (!valid) {
1541
- return validator.errors;
1541
+ return validator2.errors;
1542
1542
  } else {
1543
1543
  return null;
1544
1544
  }
@@ -1547,9 +1547,9 @@ function AddSchema(name, schema) {
1547
1547
  ajv.addSchema(schema, name);
1548
1548
  }
1549
1549
  function Validate(name, payload) {
1550
- const validator = ajv.getSchema(name);
1551
- if (validator) {
1552
- return _Validate(validator, payload);
1550
+ const validator2 = ajv.getSchema(name);
1551
+ if (validator2) {
1552
+ return _Validate(validator2, payload);
1553
1553
  }
1554
1554
  }
1555
1555
  class STSOptionsBase {
@@ -1685,11 +1685,11 @@ class STSAxiosConfig {
1685
1685
  __privateSet(this, _timeout, timeout);
1686
1686
  }
1687
1687
  }
1688
- withCookies(cookies) {
1688
+ withCookies(cookies2) {
1689
1689
  if (!__privateGet(this, _headers)) {
1690
1690
  __privateSet(this, _headers, {});
1691
1691
  }
1692
- __privateGet(this, _headers)["Cookie"] = cookies.join("; ");
1692
+ __privateGet(this, _headers)["Cookie"] = cookies2.join("; ");
1693
1693
  return this;
1694
1694
  }
1695
1695
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1885,6 +1885,2460 @@ _httpAgent = new WeakMap();
1885
1885
  _httpsAgent = new WeakMap();
1886
1886
  _SetupResetInterval = new WeakMap();
1887
1887
  _GetAgentOptions = new WeakMap();
1888
+ function bind(fn, thisArg) {
1889
+ return function wrap() {
1890
+ return fn.apply(thisArg, arguments);
1891
+ };
1892
+ }
1893
+ const { toString } = Object.prototype;
1894
+ const { getPrototypeOf } = Object;
1895
+ const { iterator, toStringTag } = Symbol;
1896
+ const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
1897
+ const str = toString.call(thing);
1898
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
1899
+ })(/* @__PURE__ */ Object.create(null));
1900
+ const kindOfTest = (type) => {
1901
+ type = type.toLowerCase();
1902
+ return (thing) => kindOf(thing) === type;
1903
+ };
1904
+ const typeOfTest = (type) => (thing) => typeof thing === type;
1905
+ const { isArray } = Array;
1906
+ const isUndefined = typeOfTest("undefined");
1907
+ function isBuffer(val) {
1908
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
1909
+ }
1910
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
1911
+ function isArrayBufferView(val) {
1912
+ let result;
1913
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
1914
+ result = ArrayBuffer.isView(val);
1915
+ } else {
1916
+ result = val && val.buffer && isArrayBuffer(val.buffer);
1917
+ }
1918
+ return result;
1919
+ }
1920
+ const isString = typeOfTest("string");
1921
+ const isFunction = typeOfTest("function");
1922
+ const isNumber = typeOfTest("number");
1923
+ const isObject = (thing) => thing !== null && typeof thing === "object";
1924
+ const isBoolean = (thing) => thing === true || thing === false;
1925
+ const isPlainObject = (val) => {
1926
+ if (kindOf(val) !== "object") {
1927
+ return false;
1928
+ }
1929
+ const prototype2 = getPrototypeOf(val);
1930
+ return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
1931
+ };
1932
+ const isDate = kindOfTest("Date");
1933
+ const isFile = kindOfTest("File");
1934
+ const isBlob = kindOfTest("Blob");
1935
+ const isFileList = kindOfTest("FileList");
1936
+ const isStream = (val) => isObject(val) && isFunction(val.pipe);
1937
+ const isFormData = (thing) => {
1938
+ let kind;
1939
+ return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
1940
+ kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
1941
+ };
1942
+ const isURLSearchParams = kindOfTest("URLSearchParams");
1943
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
1944
+ const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
1945
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
1946
+ if (obj === null || typeof obj === "undefined") {
1947
+ return;
1948
+ }
1949
+ let i;
1950
+ let l;
1951
+ if (typeof obj !== "object") {
1952
+ obj = [obj];
1953
+ }
1954
+ if (isArray(obj)) {
1955
+ for (i = 0, l = obj.length; i < l; i++) {
1956
+ fn.call(null, obj[i], i, obj);
1957
+ }
1958
+ } else {
1959
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
1960
+ const len = keys.length;
1961
+ let key;
1962
+ for (i = 0; i < len; i++) {
1963
+ key = keys[i];
1964
+ fn.call(null, obj[key], key, obj);
1965
+ }
1966
+ }
1967
+ }
1968
+ function findKey(obj, key) {
1969
+ key = key.toLowerCase();
1970
+ const keys = Object.keys(obj);
1971
+ let i = keys.length;
1972
+ let _key;
1973
+ while (i-- > 0) {
1974
+ _key = keys[i];
1975
+ if (key === _key.toLowerCase()) {
1976
+ return _key;
1977
+ }
1978
+ }
1979
+ return null;
1980
+ }
1981
+ const _global = (() => {
1982
+ if (typeof globalThis !== "undefined") return globalThis;
1983
+ return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
1984
+ })();
1985
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
1986
+ function merge() {
1987
+ const { caseless } = isContextDefined(this) && this || {};
1988
+ const result = {};
1989
+ const assignValue = (val, key) => {
1990
+ const targetKey = caseless && findKey(result, key) || key;
1991
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
1992
+ result[targetKey] = merge(result[targetKey], val);
1993
+ } else if (isPlainObject(val)) {
1994
+ result[targetKey] = merge({}, val);
1995
+ } else if (isArray(val)) {
1996
+ result[targetKey] = val.slice();
1997
+ } else {
1998
+ result[targetKey] = val;
1999
+ }
2000
+ };
2001
+ for (let i = 0, l = arguments.length; i < l; i++) {
2002
+ arguments[i] && forEach(arguments[i], assignValue);
2003
+ }
2004
+ return result;
2005
+ }
2006
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
2007
+ forEach(b, (val, key) => {
2008
+ if (thisArg && isFunction(val)) {
2009
+ a[key] = bind(val, thisArg);
2010
+ } else {
2011
+ a[key] = val;
2012
+ }
2013
+ }, { allOwnKeys });
2014
+ return a;
2015
+ };
2016
+ const stripBOM = (content) => {
2017
+ if (content.charCodeAt(0) === 65279) {
2018
+ content = content.slice(1);
2019
+ }
2020
+ return content;
2021
+ };
2022
+ const inherits = (constructor, superConstructor, props, descriptors2) => {
2023
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
2024
+ constructor.prototype.constructor = constructor;
2025
+ Object.defineProperty(constructor, "super", {
2026
+ value: superConstructor.prototype
2027
+ });
2028
+ props && Object.assign(constructor.prototype, props);
2029
+ };
2030
+ const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
2031
+ let props;
2032
+ let i;
2033
+ let prop;
2034
+ const merged = {};
2035
+ destObj = destObj || {};
2036
+ if (sourceObj == null) return destObj;
2037
+ do {
2038
+ props = Object.getOwnPropertyNames(sourceObj);
2039
+ i = props.length;
2040
+ while (i-- > 0) {
2041
+ prop = props[i];
2042
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
2043
+ destObj[prop] = sourceObj[prop];
2044
+ merged[prop] = true;
2045
+ }
2046
+ }
2047
+ sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
2048
+ } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
2049
+ return destObj;
2050
+ };
2051
+ const endsWith = (str, searchString, position) => {
2052
+ str = String(str);
2053
+ if (position === void 0 || position > str.length) {
2054
+ position = str.length;
2055
+ }
2056
+ position -= searchString.length;
2057
+ const lastIndex = str.indexOf(searchString, position);
2058
+ return lastIndex !== -1 && lastIndex === position;
2059
+ };
2060
+ const toArray = (thing) => {
2061
+ if (!thing) return null;
2062
+ if (isArray(thing)) return thing;
2063
+ let i = thing.length;
2064
+ if (!isNumber(i)) return null;
2065
+ const arr = new Array(i);
2066
+ while (i-- > 0) {
2067
+ arr[i] = thing[i];
2068
+ }
2069
+ return arr;
2070
+ };
2071
+ const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
2072
+ return (thing) => {
2073
+ return TypedArray && thing instanceof TypedArray;
2074
+ };
2075
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
2076
+ const forEachEntry = (obj, fn) => {
2077
+ const generator = obj && obj[iterator];
2078
+ const _iterator = generator.call(obj);
2079
+ let result;
2080
+ while ((result = _iterator.next()) && !result.done) {
2081
+ const pair = result.value;
2082
+ fn.call(obj, pair[0], pair[1]);
2083
+ }
2084
+ };
2085
+ const matchAll = (regExp, str) => {
2086
+ let matches;
2087
+ const arr = [];
2088
+ while ((matches = regExp.exec(str)) !== null) {
2089
+ arr.push(matches);
2090
+ }
2091
+ return arr;
2092
+ };
2093
+ const isHTMLForm = kindOfTest("HTMLFormElement");
2094
+ const toCamelCase = (str) => {
2095
+ return str.toLowerCase().replace(
2096
+ /[-_\s]([a-z\d])(\w*)/g,
2097
+ function replacer(m, p1, p2) {
2098
+ return p1.toUpperCase() + p2;
2099
+ }
2100
+ );
2101
+ };
2102
+ const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
2103
+ const isRegExp = kindOfTest("RegExp");
2104
+ const reduceDescriptors = (obj, reducer) => {
2105
+ const descriptors2 = Object.getOwnPropertyDescriptors(obj);
2106
+ const reducedDescriptors = {};
2107
+ forEach(descriptors2, (descriptor, name) => {
2108
+ let ret;
2109
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
2110
+ reducedDescriptors[name] = ret || descriptor;
2111
+ }
2112
+ });
2113
+ Object.defineProperties(obj, reducedDescriptors);
2114
+ };
2115
+ const freezeMethods = (obj) => {
2116
+ reduceDescriptors(obj, (descriptor, name) => {
2117
+ if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
2118
+ return false;
2119
+ }
2120
+ const value = obj[name];
2121
+ if (!isFunction(value)) return;
2122
+ descriptor.enumerable = false;
2123
+ if ("writable" in descriptor) {
2124
+ descriptor.writable = false;
2125
+ return;
2126
+ }
2127
+ if (!descriptor.set) {
2128
+ descriptor.set = () => {
2129
+ throw Error("Can not rewrite read-only method '" + name + "'");
2130
+ };
2131
+ }
2132
+ });
2133
+ };
2134
+ const toObjectSet = (arrayOrString, delimiter) => {
2135
+ const obj = {};
2136
+ const define = (arr) => {
2137
+ arr.forEach((value) => {
2138
+ obj[value] = true;
2139
+ });
2140
+ };
2141
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
2142
+ return obj;
2143
+ };
2144
+ const noop = () => {
2145
+ };
2146
+ const toFiniteNumber = (value, defaultValue) => {
2147
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
2148
+ };
2149
+ function isSpecCompliantForm(thing) {
2150
+ return !!(thing && isFunction(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
2151
+ }
2152
+ const toJSONObject = (obj) => {
2153
+ const stack = new Array(10);
2154
+ const visit = (source2, i) => {
2155
+ if (isObject(source2)) {
2156
+ if (stack.indexOf(source2) >= 0) {
2157
+ return;
2158
+ }
2159
+ if (!("toJSON" in source2)) {
2160
+ stack[i] = source2;
2161
+ const target = isArray(source2) ? [] : {};
2162
+ forEach(source2, (value, key) => {
2163
+ const reducedValue = visit(value, i + 1);
2164
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
2165
+ });
2166
+ stack[i] = void 0;
2167
+ return target;
2168
+ }
2169
+ }
2170
+ return source2;
2171
+ };
2172
+ return visit(obj, 0);
2173
+ };
2174
+ const isAsyncFn = kindOfTest("AsyncFunction");
2175
+ const isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
2176
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
2177
+ if (setImmediateSupported) {
2178
+ return setImmediate;
2179
+ }
2180
+ return postMessageSupported ? ((token, callbacks) => {
2181
+ _global.addEventListener("message", ({ source: source2, data }) => {
2182
+ if (source2 === _global && data === token) {
2183
+ callbacks.length && callbacks.shift()();
2184
+ }
2185
+ }, false);
2186
+ return (cb) => {
2187
+ callbacks.push(cb);
2188
+ _global.postMessage(token, "*");
2189
+ };
2190
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
2191
+ })(
2192
+ typeof setImmediate === "function",
2193
+ isFunction(_global.postMessage)
2194
+ );
2195
+ const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
2196
+ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
2197
+ const utils$1 = {
2198
+ isArray,
2199
+ isArrayBuffer,
2200
+ isBuffer,
2201
+ isFormData,
2202
+ isArrayBufferView,
2203
+ isString,
2204
+ isNumber,
2205
+ isBoolean,
2206
+ isObject,
2207
+ isPlainObject,
2208
+ isReadableStream,
2209
+ isRequest,
2210
+ isResponse,
2211
+ isHeaders,
2212
+ isUndefined,
2213
+ isDate,
2214
+ isFile,
2215
+ isBlob,
2216
+ isRegExp,
2217
+ isFunction,
2218
+ isStream,
2219
+ isURLSearchParams,
2220
+ isTypedArray,
2221
+ isFileList,
2222
+ forEach,
2223
+ merge,
2224
+ extend,
2225
+ trim,
2226
+ stripBOM,
2227
+ inherits,
2228
+ toFlatObject,
2229
+ kindOf,
2230
+ kindOfTest,
2231
+ endsWith,
2232
+ toArray,
2233
+ forEachEntry,
2234
+ matchAll,
2235
+ isHTMLForm,
2236
+ hasOwnProperty,
2237
+ hasOwnProp: hasOwnProperty,
2238
+ // an alias to avoid ESLint no-prototype-builtins detection
2239
+ reduceDescriptors,
2240
+ freezeMethods,
2241
+ toObjectSet,
2242
+ toCamelCase,
2243
+ noop,
2244
+ toFiniteNumber,
2245
+ findKey,
2246
+ global: _global,
2247
+ isContextDefined,
2248
+ isSpecCompliantForm,
2249
+ toJSONObject,
2250
+ isAsyncFn,
2251
+ isThenable,
2252
+ setImmediate: _setImmediate,
2253
+ asap,
2254
+ isIterable
2255
+ };
2256
+ function AxiosError$1(message, code, config, request, response) {
2257
+ Error.call(this);
2258
+ if (Error.captureStackTrace) {
2259
+ Error.captureStackTrace(this, this.constructor);
2260
+ } else {
2261
+ this.stack = new Error().stack;
2262
+ }
2263
+ this.message = message;
2264
+ this.name = "AxiosError";
2265
+ code && (this.code = code);
2266
+ config && (this.config = config);
2267
+ request && (this.request = request);
2268
+ if (response) {
2269
+ this.response = response;
2270
+ this.status = response.status ? response.status : null;
2271
+ }
2272
+ }
2273
+ utils$1.inherits(AxiosError$1, Error, {
2274
+ toJSON: function toJSON() {
2275
+ return {
2276
+ // Standard
2277
+ message: this.message,
2278
+ name: this.name,
2279
+ // Microsoft
2280
+ description: this.description,
2281
+ number: this.number,
2282
+ // Mozilla
2283
+ fileName: this.fileName,
2284
+ lineNumber: this.lineNumber,
2285
+ columnNumber: this.columnNumber,
2286
+ stack: this.stack,
2287
+ // Axios
2288
+ config: utils$1.toJSONObject(this.config),
2289
+ code: this.code,
2290
+ status: this.status
2291
+ };
2292
+ }
2293
+ });
2294
+ const prototype$1 = AxiosError$1.prototype;
2295
+ const descriptors = {};
2296
+ [
2297
+ "ERR_BAD_OPTION_VALUE",
2298
+ "ERR_BAD_OPTION",
2299
+ "ECONNABORTED",
2300
+ "ETIMEDOUT",
2301
+ "ERR_NETWORK",
2302
+ "ERR_FR_TOO_MANY_REDIRECTS",
2303
+ "ERR_DEPRECATED",
2304
+ "ERR_BAD_RESPONSE",
2305
+ "ERR_BAD_REQUEST",
2306
+ "ERR_CANCELED",
2307
+ "ERR_NOT_SUPPORT",
2308
+ "ERR_INVALID_URL"
2309
+ // eslint-disable-next-line func-names
2310
+ ].forEach((code) => {
2311
+ descriptors[code] = { value: code };
2312
+ });
2313
+ Object.defineProperties(AxiosError$1, descriptors);
2314
+ Object.defineProperty(prototype$1, "isAxiosError", { value: true });
2315
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
2316
+ const axiosError = Object.create(prototype$1);
2317
+ utils$1.toFlatObject(error, axiosError, function filter2(obj) {
2318
+ return obj !== Error.prototype;
2319
+ }, (prop) => {
2320
+ return prop !== "isAxiosError";
2321
+ });
2322
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
2323
+ axiosError.cause = error;
2324
+ axiosError.name = error.name;
2325
+ customProps && Object.assign(axiosError, customProps);
2326
+ return axiosError;
2327
+ };
2328
+ const httpAdapter = null;
2329
+ function isVisitable(thing) {
2330
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
2331
+ }
2332
+ function removeBrackets(key) {
2333
+ return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
2334
+ }
2335
+ function renderKey(path, key, dots) {
2336
+ if (!path) return key;
2337
+ return path.concat(key).map(function each(token, i) {
2338
+ token = removeBrackets(token);
2339
+ return !dots && i ? "[" + token + "]" : token;
2340
+ }).join(dots ? "." : "");
2341
+ }
2342
+ function isFlatArray(arr) {
2343
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
2344
+ }
2345
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
2346
+ return /^is[A-Z]/.test(prop);
2347
+ });
2348
+ function toFormData$1(obj, formData, options) {
2349
+ if (!utils$1.isObject(obj)) {
2350
+ throw new TypeError("target must be an object");
2351
+ }
2352
+ formData = formData || new FormData();
2353
+ options = utils$1.toFlatObject(options, {
2354
+ metaTokens: true,
2355
+ dots: false,
2356
+ indexes: false
2357
+ }, false, function defined(option, source2) {
2358
+ return !utils$1.isUndefined(source2[option]);
2359
+ });
2360
+ const metaTokens = options.metaTokens;
2361
+ const visitor = options.visitor || defaultVisitor;
2362
+ const dots = options.dots;
2363
+ const indexes = options.indexes;
2364
+ const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
2365
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
2366
+ if (!utils$1.isFunction(visitor)) {
2367
+ throw new TypeError("visitor must be a function");
2368
+ }
2369
+ function convertValue(value) {
2370
+ if (value === null) return "";
2371
+ if (utils$1.isDate(value)) {
2372
+ return value.toISOString();
2373
+ }
2374
+ if (utils$1.isBoolean(value)) {
2375
+ return value.toString();
2376
+ }
2377
+ if (!useBlob && utils$1.isBlob(value)) {
2378
+ throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
2379
+ }
2380
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2381
+ return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
2382
+ }
2383
+ return value;
2384
+ }
2385
+ function defaultVisitor(value, key, path) {
2386
+ let arr = value;
2387
+ if (value && !path && typeof value === "object") {
2388
+ if (utils$1.endsWith(key, "{}")) {
2389
+ key = metaTokens ? key : key.slice(0, -2);
2390
+ value = JSON.stringify(value);
2391
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
2392
+ key = removeBrackets(key);
2393
+ arr.forEach(function each(el, index) {
2394
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
2395
+ // eslint-disable-next-line no-nested-ternary
2396
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
2397
+ convertValue(el)
2398
+ );
2399
+ });
2400
+ return false;
2401
+ }
2402
+ }
2403
+ if (isVisitable(value)) {
2404
+ return true;
2405
+ }
2406
+ formData.append(renderKey(path, key, dots), convertValue(value));
2407
+ return false;
2408
+ }
2409
+ const stack = [];
2410
+ const exposedHelpers = Object.assign(predicates, {
2411
+ defaultVisitor,
2412
+ convertValue,
2413
+ isVisitable
2414
+ });
2415
+ function build(value, path) {
2416
+ if (utils$1.isUndefined(value)) return;
2417
+ if (stack.indexOf(value) !== -1) {
2418
+ throw Error("Circular reference detected in " + path.join("."));
2419
+ }
2420
+ stack.push(value);
2421
+ utils$1.forEach(value, function each(el, key) {
2422
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
2423
+ formData,
2424
+ el,
2425
+ utils$1.isString(key) ? key.trim() : key,
2426
+ path,
2427
+ exposedHelpers
2428
+ );
2429
+ if (result === true) {
2430
+ build(el, path ? path.concat(key) : [key]);
2431
+ }
2432
+ });
2433
+ stack.pop();
2434
+ }
2435
+ if (!utils$1.isObject(obj)) {
2436
+ throw new TypeError("data must be an object");
2437
+ }
2438
+ build(obj);
2439
+ return formData;
2440
+ }
2441
+ function encode$1(str) {
2442
+ const charMap = {
2443
+ "!": "%21",
2444
+ "'": "%27",
2445
+ "(": "%28",
2446
+ ")": "%29",
2447
+ "~": "%7E",
2448
+ "%20": "+",
2449
+ "%00": "\0"
2450
+ };
2451
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
2452
+ return charMap[match];
2453
+ });
2454
+ }
2455
+ function AxiosURLSearchParams(params, options) {
2456
+ this._pairs = [];
2457
+ params && toFormData$1(params, this, options);
2458
+ }
2459
+ const prototype = AxiosURLSearchParams.prototype;
2460
+ prototype.append = function append(name, value) {
2461
+ this._pairs.push([name, value]);
2462
+ };
2463
+ prototype.toString = function toString2(encoder) {
2464
+ const _encode = encoder ? function(value) {
2465
+ return encoder.call(this, value, encode$1);
2466
+ } : encode$1;
2467
+ return this._pairs.map(function each(pair) {
2468
+ return _encode(pair[0]) + "=" + _encode(pair[1]);
2469
+ }, "").join("&");
2470
+ };
2471
+ function encode(val) {
2472
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
2473
+ }
2474
+ function buildURL(url, params, options) {
2475
+ if (!params) {
2476
+ return url;
2477
+ }
2478
+ const _encode = options && options.encode || encode;
2479
+ if (utils$1.isFunction(options)) {
2480
+ options = {
2481
+ serialize: options
2482
+ };
2483
+ }
2484
+ const serializeFn = options && options.serialize;
2485
+ let serializedParams;
2486
+ if (serializeFn) {
2487
+ serializedParams = serializeFn(params, options);
2488
+ } else {
2489
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
2490
+ }
2491
+ if (serializedParams) {
2492
+ const hashmarkIndex = url.indexOf("#");
2493
+ if (hashmarkIndex !== -1) {
2494
+ url = url.slice(0, hashmarkIndex);
2495
+ }
2496
+ url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
2497
+ }
2498
+ return url;
2499
+ }
2500
+ class InterceptorManager {
2501
+ constructor() {
2502
+ this.handlers = [];
2503
+ }
2504
+ /**
2505
+ * Add a new interceptor to the stack
2506
+ *
2507
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
2508
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
2509
+ *
2510
+ * @return {Number} An ID used to remove interceptor later
2511
+ */
2512
+ use(fulfilled, rejected, options) {
2513
+ this.handlers.push({
2514
+ fulfilled,
2515
+ rejected,
2516
+ synchronous: options ? options.synchronous : false,
2517
+ runWhen: options ? options.runWhen : null
2518
+ });
2519
+ return this.handlers.length - 1;
2520
+ }
2521
+ /**
2522
+ * Remove an interceptor from the stack
2523
+ *
2524
+ * @param {Number} id The ID that was returned by `use`
2525
+ *
2526
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
2527
+ */
2528
+ eject(id) {
2529
+ if (this.handlers[id]) {
2530
+ this.handlers[id] = null;
2531
+ }
2532
+ }
2533
+ /**
2534
+ * Clear all interceptors from the stack
2535
+ *
2536
+ * @returns {void}
2537
+ */
2538
+ clear() {
2539
+ if (this.handlers) {
2540
+ this.handlers = [];
2541
+ }
2542
+ }
2543
+ /**
2544
+ * Iterate over all the registered interceptors
2545
+ *
2546
+ * This method is particularly useful for skipping over any
2547
+ * interceptors that may have become `null` calling `eject`.
2548
+ *
2549
+ * @param {Function} fn The function to call for each interceptor
2550
+ *
2551
+ * @returns {void}
2552
+ */
2553
+ forEach(fn) {
2554
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
2555
+ if (h !== null) {
2556
+ fn(h);
2557
+ }
2558
+ });
2559
+ }
2560
+ }
2561
+ const transitionalDefaults = {
2562
+ silentJSONParsing: true,
2563
+ forcedJSONParsing: true,
2564
+ clarifyTimeoutError: false
2565
+ };
2566
+ const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
2567
+ const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
2568
+ const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
2569
+ const platform$1 = {
2570
+ isBrowser: true,
2571
+ classes: {
2572
+ URLSearchParams: URLSearchParams$1,
2573
+ FormData: FormData$1,
2574
+ Blob: Blob$1
2575
+ },
2576
+ protocols: ["http", "https", "file", "blob", "url", "data"]
2577
+ };
2578
+ const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
2579
+ const _navigator = typeof navigator === "object" && navigator || void 0;
2580
+ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
2581
+ const hasStandardBrowserWebWorkerEnv = (() => {
2582
+ return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
2583
+ self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
2584
+ })();
2585
+ const origin = hasBrowserEnv && window.location.href || "http://localhost";
2586
+ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2587
+ __proto__: null,
2588
+ hasBrowserEnv,
2589
+ hasStandardBrowserEnv,
2590
+ hasStandardBrowserWebWorkerEnv,
2591
+ navigator: _navigator,
2592
+ origin
2593
+ }, Symbol.toStringTag, { value: "Module" }));
2594
+ const platform = {
2595
+ ...utils,
2596
+ ...platform$1
2597
+ };
2598
+ function toURLEncodedForm(data, options) {
2599
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
2600
+ visitor: function(value, key, path, helpers) {
2601
+ if (platform.isNode && utils$1.isBuffer(value)) {
2602
+ this.append(key, value.toString("base64"));
2603
+ return false;
2604
+ }
2605
+ return helpers.defaultVisitor.apply(this, arguments);
2606
+ }
2607
+ }, options));
2608
+ }
2609
+ function parsePropPath(name) {
2610
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
2611
+ return match[0] === "[]" ? "" : match[1] || match[0];
2612
+ });
2613
+ }
2614
+ function arrayToObject(arr) {
2615
+ const obj = {};
2616
+ const keys = Object.keys(arr);
2617
+ let i;
2618
+ const len = keys.length;
2619
+ let key;
2620
+ for (i = 0; i < len; i++) {
2621
+ key = keys[i];
2622
+ obj[key] = arr[key];
2623
+ }
2624
+ return obj;
2625
+ }
2626
+ function formDataToJSON(formData) {
2627
+ function buildPath(path, value, target, index) {
2628
+ let name = path[index++];
2629
+ if (name === "__proto__") return true;
2630
+ const isNumericKey = Number.isFinite(+name);
2631
+ const isLast = index >= path.length;
2632
+ name = !name && utils$1.isArray(target) ? target.length : name;
2633
+ if (isLast) {
2634
+ if (utils$1.hasOwnProp(target, name)) {
2635
+ target[name] = [target[name], value];
2636
+ } else {
2637
+ target[name] = value;
2638
+ }
2639
+ return !isNumericKey;
2640
+ }
2641
+ if (!target[name] || !utils$1.isObject(target[name])) {
2642
+ target[name] = [];
2643
+ }
2644
+ const result = buildPath(path, value, target[name], index);
2645
+ if (result && utils$1.isArray(target[name])) {
2646
+ target[name] = arrayToObject(target[name]);
2647
+ }
2648
+ return !isNumericKey;
2649
+ }
2650
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
2651
+ const obj = {};
2652
+ utils$1.forEachEntry(formData, (name, value) => {
2653
+ buildPath(parsePropPath(name), value, obj, 0);
2654
+ });
2655
+ return obj;
2656
+ }
2657
+ return null;
2658
+ }
2659
+ function stringifySafely(rawValue, parser, encoder) {
2660
+ if (utils$1.isString(rawValue)) {
2661
+ try {
2662
+ (parser || JSON.parse)(rawValue);
2663
+ return utils$1.trim(rawValue);
2664
+ } catch (e) {
2665
+ if (e.name !== "SyntaxError") {
2666
+ throw e;
2667
+ }
2668
+ }
2669
+ }
2670
+ return (encoder || JSON.stringify)(rawValue);
2671
+ }
2672
+ const defaults = {
2673
+ transitional: transitionalDefaults,
2674
+ adapter: ["xhr", "http", "fetch"],
2675
+ transformRequest: [function transformRequest(data, headers) {
2676
+ const contentType = headers.getContentType() || "";
2677
+ const hasJSONContentType = contentType.indexOf("application/json") > -1;
2678
+ const isObjectPayload = utils$1.isObject(data);
2679
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
2680
+ data = new FormData(data);
2681
+ }
2682
+ const isFormData2 = utils$1.isFormData(data);
2683
+ if (isFormData2) {
2684
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2685
+ }
2686
+ if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
2687
+ return data;
2688
+ }
2689
+ if (utils$1.isArrayBufferView(data)) {
2690
+ return data.buffer;
2691
+ }
2692
+ if (utils$1.isURLSearchParams(data)) {
2693
+ headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
2694
+ return data.toString();
2695
+ }
2696
+ let isFileList2;
2697
+ if (isObjectPayload) {
2698
+ if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
2699
+ return toURLEncodedForm(data, this.formSerializer).toString();
2700
+ }
2701
+ if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
2702
+ const _FormData = this.env && this.env.FormData;
2703
+ return toFormData$1(
2704
+ isFileList2 ? { "files[]": data } : data,
2705
+ _FormData && new _FormData(),
2706
+ this.formSerializer
2707
+ );
2708
+ }
2709
+ }
2710
+ if (isObjectPayload || hasJSONContentType) {
2711
+ headers.setContentType("application/json", false);
2712
+ return stringifySafely(data);
2713
+ }
2714
+ return data;
2715
+ }],
2716
+ transformResponse: [function transformResponse(data) {
2717
+ const transitional2 = this.transitional || defaults.transitional;
2718
+ const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
2719
+ const JSONRequested = this.responseType === "json";
2720
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2721
+ return data;
2722
+ }
2723
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
2724
+ const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
2725
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
2726
+ try {
2727
+ return JSON.parse(data);
2728
+ } catch (e) {
2729
+ if (strictJSONParsing) {
2730
+ if (e.name === "SyntaxError") {
2731
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
2732
+ }
2733
+ throw e;
2734
+ }
2735
+ }
2736
+ }
2737
+ return data;
2738
+ }],
2739
+ /**
2740
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
2741
+ * timeout is not created.
2742
+ */
2743
+ timeout: 0,
2744
+ xsrfCookieName: "XSRF-TOKEN",
2745
+ xsrfHeaderName: "X-XSRF-TOKEN",
2746
+ maxContentLength: -1,
2747
+ maxBodyLength: -1,
2748
+ env: {
2749
+ FormData: platform.classes.FormData,
2750
+ Blob: platform.classes.Blob
2751
+ },
2752
+ validateStatus: function validateStatus(status) {
2753
+ return status >= 200 && status < 300;
2754
+ },
2755
+ headers: {
2756
+ common: {
2757
+ "Accept": "application/json, text/plain, */*",
2758
+ "Content-Type": void 0
2759
+ }
2760
+ }
2761
+ };
2762
+ utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
2763
+ defaults.headers[method] = {};
2764
+ });
2765
+ const ignoreDuplicateOf = utils$1.toObjectSet([
2766
+ "age",
2767
+ "authorization",
2768
+ "content-length",
2769
+ "content-type",
2770
+ "etag",
2771
+ "expires",
2772
+ "from",
2773
+ "host",
2774
+ "if-modified-since",
2775
+ "if-unmodified-since",
2776
+ "last-modified",
2777
+ "location",
2778
+ "max-forwards",
2779
+ "proxy-authorization",
2780
+ "referer",
2781
+ "retry-after",
2782
+ "user-agent"
2783
+ ]);
2784
+ const parseHeaders = (rawHeaders) => {
2785
+ const parsed = {};
2786
+ let key;
2787
+ let val;
2788
+ let i;
2789
+ rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
2790
+ i = line.indexOf(":");
2791
+ key = line.substring(0, i).trim().toLowerCase();
2792
+ val = line.substring(i + 1).trim();
2793
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
2794
+ return;
2795
+ }
2796
+ if (key === "set-cookie") {
2797
+ if (parsed[key]) {
2798
+ parsed[key].push(val);
2799
+ } else {
2800
+ parsed[key] = [val];
2801
+ }
2802
+ } else {
2803
+ parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
2804
+ }
2805
+ });
2806
+ return parsed;
2807
+ };
2808
+ const $internals = Symbol("internals");
2809
+ function normalizeHeader(header) {
2810
+ return header && String(header).trim().toLowerCase();
2811
+ }
2812
+ function normalizeValue(value) {
2813
+ if (value === false || value == null) {
2814
+ return value;
2815
+ }
2816
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
2817
+ }
2818
+ function parseTokens(str) {
2819
+ const tokens = /* @__PURE__ */ Object.create(null);
2820
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2821
+ let match;
2822
+ while (match = tokensRE.exec(str)) {
2823
+ tokens[match[1]] = match[2];
2824
+ }
2825
+ return tokens;
2826
+ }
2827
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2828
+ function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
2829
+ if (utils$1.isFunction(filter2)) {
2830
+ return filter2.call(this, value, header);
2831
+ }
2832
+ if (isHeaderNameFilter) {
2833
+ value = header;
2834
+ }
2835
+ if (!utils$1.isString(value)) return;
2836
+ if (utils$1.isString(filter2)) {
2837
+ return value.indexOf(filter2) !== -1;
2838
+ }
2839
+ if (utils$1.isRegExp(filter2)) {
2840
+ return filter2.test(value);
2841
+ }
2842
+ }
2843
+ function formatHeader(header) {
2844
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2845
+ return char.toUpperCase() + str;
2846
+ });
2847
+ }
2848
+ function buildAccessors(obj, header) {
2849
+ const accessorName = utils$1.toCamelCase(" " + header);
2850
+ ["get", "set", "has"].forEach((methodName) => {
2851
+ Object.defineProperty(obj, methodName + accessorName, {
2852
+ value: function(arg1, arg2, arg3) {
2853
+ return this[methodName].call(this, header, arg1, arg2, arg3);
2854
+ },
2855
+ configurable: true
2856
+ });
2857
+ });
2858
+ }
2859
+ let AxiosHeaders$1 = class AxiosHeaders {
2860
+ constructor(headers) {
2861
+ headers && this.set(headers);
2862
+ }
2863
+ set(header, valueOrRewrite, rewrite) {
2864
+ const self2 = this;
2865
+ function setHeader(_value, _header, _rewrite) {
2866
+ const lHeader = normalizeHeader(_header);
2867
+ if (!lHeader) {
2868
+ throw new Error("header name must be a non-empty string");
2869
+ }
2870
+ const key = utils$1.findKey(self2, lHeader);
2871
+ if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
2872
+ self2[key || _header] = normalizeValue(_value);
2873
+ }
2874
+ }
2875
+ const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2876
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2877
+ setHeaders(header, valueOrRewrite);
2878
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2879
+ setHeaders(parseHeaders(header), valueOrRewrite);
2880
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2881
+ let obj = {}, dest, key;
2882
+ for (const entry of header) {
2883
+ if (!utils$1.isArray(entry)) {
2884
+ throw TypeError("Object iterator must return a key-value pair");
2885
+ }
2886
+ obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
2887
+ }
2888
+ setHeaders(obj, valueOrRewrite);
2889
+ } else {
2890
+ header != null && setHeader(valueOrRewrite, header, rewrite);
2891
+ }
2892
+ return this;
2893
+ }
2894
+ get(header, parser) {
2895
+ header = normalizeHeader(header);
2896
+ if (header) {
2897
+ const key = utils$1.findKey(this, header);
2898
+ if (key) {
2899
+ const value = this[key];
2900
+ if (!parser) {
2901
+ return value;
2902
+ }
2903
+ if (parser === true) {
2904
+ return parseTokens(value);
2905
+ }
2906
+ if (utils$1.isFunction(parser)) {
2907
+ return parser.call(this, value, key);
2908
+ }
2909
+ if (utils$1.isRegExp(parser)) {
2910
+ return parser.exec(value);
2911
+ }
2912
+ throw new TypeError("parser must be boolean|regexp|function");
2913
+ }
2914
+ }
2915
+ }
2916
+ has(header, matcher) {
2917
+ header = normalizeHeader(header);
2918
+ if (header) {
2919
+ const key = utils$1.findKey(this, header);
2920
+ return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2921
+ }
2922
+ return false;
2923
+ }
2924
+ delete(header, matcher) {
2925
+ const self2 = this;
2926
+ let deleted = false;
2927
+ function deleteHeader(_header) {
2928
+ _header = normalizeHeader(_header);
2929
+ if (_header) {
2930
+ const key = utils$1.findKey(self2, _header);
2931
+ if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
2932
+ delete self2[key];
2933
+ deleted = true;
2934
+ }
2935
+ }
2936
+ }
2937
+ if (utils$1.isArray(header)) {
2938
+ header.forEach(deleteHeader);
2939
+ } else {
2940
+ deleteHeader(header);
2941
+ }
2942
+ return deleted;
2943
+ }
2944
+ clear(matcher) {
2945
+ const keys = Object.keys(this);
2946
+ let i = keys.length;
2947
+ let deleted = false;
2948
+ while (i--) {
2949
+ const key = keys[i];
2950
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2951
+ delete this[key];
2952
+ deleted = true;
2953
+ }
2954
+ }
2955
+ return deleted;
2956
+ }
2957
+ normalize(format) {
2958
+ const self2 = this;
2959
+ const headers = {};
2960
+ utils$1.forEach(this, (value, header) => {
2961
+ const key = utils$1.findKey(headers, header);
2962
+ if (key) {
2963
+ self2[key] = normalizeValue(value);
2964
+ delete self2[header];
2965
+ return;
2966
+ }
2967
+ const normalized = format ? formatHeader(header) : String(header).trim();
2968
+ if (normalized !== header) {
2969
+ delete self2[header];
2970
+ }
2971
+ self2[normalized] = normalizeValue(value);
2972
+ headers[normalized] = true;
2973
+ });
2974
+ return this;
2975
+ }
2976
+ concat(...targets) {
2977
+ return this.constructor.concat(this, ...targets);
2978
+ }
2979
+ toJSON(asStrings) {
2980
+ const obj = /* @__PURE__ */ Object.create(null);
2981
+ utils$1.forEach(this, (value, header) => {
2982
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
2983
+ });
2984
+ return obj;
2985
+ }
2986
+ [Symbol.iterator]() {
2987
+ return Object.entries(this.toJSON())[Symbol.iterator]();
2988
+ }
2989
+ toString() {
2990
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
2991
+ }
2992
+ getSetCookie() {
2993
+ return this.get("set-cookie") || [];
2994
+ }
2995
+ get [Symbol.toStringTag]() {
2996
+ return "AxiosHeaders";
2997
+ }
2998
+ static from(thing) {
2999
+ return thing instanceof this ? thing : new this(thing);
3000
+ }
3001
+ static concat(first, ...targets) {
3002
+ const computed = new this(first);
3003
+ targets.forEach((target) => computed.set(target));
3004
+ return computed;
3005
+ }
3006
+ static accessor(header) {
3007
+ const internals = this[$internals] = this[$internals] = {
3008
+ accessors: {}
3009
+ };
3010
+ const accessors = internals.accessors;
3011
+ const prototype2 = this.prototype;
3012
+ function defineAccessor(_header) {
3013
+ const lHeader = normalizeHeader(_header);
3014
+ if (!accessors[lHeader]) {
3015
+ buildAccessors(prototype2, _header);
3016
+ accessors[lHeader] = true;
3017
+ }
3018
+ }
3019
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
3020
+ return this;
3021
+ }
3022
+ };
3023
+ AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
3024
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
3025
+ let mapped = key[0].toUpperCase() + key.slice(1);
3026
+ return {
3027
+ get: () => value,
3028
+ set(headerValue) {
3029
+ this[mapped] = headerValue;
3030
+ }
3031
+ };
3032
+ });
3033
+ utils$1.freezeMethods(AxiosHeaders$1);
3034
+ function transformData(fns, response) {
3035
+ const config = this || defaults;
3036
+ const context = response || config;
3037
+ const headers = AxiosHeaders$1.from(context.headers);
3038
+ let data = context.data;
3039
+ utils$1.forEach(fns, function transform(fn) {
3040
+ data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
3041
+ });
3042
+ headers.normalize();
3043
+ return data;
3044
+ }
3045
+ function isCancel$1(value) {
3046
+ return !!(value && value.__CANCEL__);
3047
+ }
3048
+ function CanceledError$1(message, config, request) {
3049
+ AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config, request);
3050
+ this.name = "CanceledError";
3051
+ }
3052
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
3053
+ __CANCEL__: true
3054
+ });
3055
+ function settle(resolve, reject, response) {
3056
+ const validateStatus2 = response.config.validateStatus;
3057
+ if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
3058
+ resolve(response);
3059
+ } else {
3060
+ reject(new AxiosError$1(
3061
+ "Request failed with status code " + response.status,
3062
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
3063
+ response.config,
3064
+ response.request,
3065
+ response
3066
+ ));
3067
+ }
3068
+ }
3069
+ function parseProtocol(url) {
3070
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
3071
+ return match && match[1] || "";
3072
+ }
3073
+ function speedometer(samplesCount, min) {
3074
+ samplesCount = samplesCount || 10;
3075
+ const bytes = new Array(samplesCount);
3076
+ const timestamps = new Array(samplesCount);
3077
+ let head = 0;
3078
+ let tail = 0;
3079
+ let firstSampleTS;
3080
+ min = min !== void 0 ? min : 1e3;
3081
+ return function push(chunkLength) {
3082
+ const now = Date.now();
3083
+ const startedAt = timestamps[tail];
3084
+ if (!firstSampleTS) {
3085
+ firstSampleTS = now;
3086
+ }
3087
+ bytes[head] = chunkLength;
3088
+ timestamps[head] = now;
3089
+ let i = tail;
3090
+ let bytesCount = 0;
3091
+ while (i !== head) {
3092
+ bytesCount += bytes[i++];
3093
+ i = i % samplesCount;
3094
+ }
3095
+ head = (head + 1) % samplesCount;
3096
+ if (head === tail) {
3097
+ tail = (tail + 1) % samplesCount;
3098
+ }
3099
+ if (now - firstSampleTS < min) {
3100
+ return;
3101
+ }
3102
+ const passed = startedAt && now - startedAt;
3103
+ return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
3104
+ };
3105
+ }
3106
+ function throttle(fn, freq) {
3107
+ let timestamp = 0;
3108
+ let threshold = 1e3 / freq;
3109
+ let lastArgs;
3110
+ let timer;
3111
+ const invoke = (args, now = Date.now()) => {
3112
+ timestamp = now;
3113
+ lastArgs = null;
3114
+ if (timer) {
3115
+ clearTimeout(timer);
3116
+ timer = null;
3117
+ }
3118
+ fn.apply(null, args);
3119
+ };
3120
+ const throttled = (...args) => {
3121
+ const now = Date.now();
3122
+ const passed = now - timestamp;
3123
+ if (passed >= threshold) {
3124
+ invoke(args, now);
3125
+ } else {
3126
+ lastArgs = args;
3127
+ if (!timer) {
3128
+ timer = setTimeout(() => {
3129
+ timer = null;
3130
+ invoke(lastArgs);
3131
+ }, threshold - passed);
3132
+ }
3133
+ }
3134
+ };
3135
+ const flush = () => lastArgs && invoke(lastArgs);
3136
+ return [throttled, flush];
3137
+ }
3138
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
3139
+ let bytesNotified = 0;
3140
+ const _speedometer = speedometer(50, 250);
3141
+ return throttle((e) => {
3142
+ const loaded = e.loaded;
3143
+ const total = e.lengthComputable ? e.total : void 0;
3144
+ const progressBytes = loaded - bytesNotified;
3145
+ const rate = _speedometer(progressBytes);
3146
+ const inRange = loaded <= total;
3147
+ bytesNotified = loaded;
3148
+ const data = {
3149
+ loaded,
3150
+ total,
3151
+ progress: total ? loaded / total : void 0,
3152
+ bytes: progressBytes,
3153
+ rate: rate ? rate : void 0,
3154
+ estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
3155
+ event: e,
3156
+ lengthComputable: total != null,
3157
+ [isDownloadStream ? "download" : "upload"]: true
3158
+ };
3159
+ listener(data);
3160
+ }, freq);
3161
+ };
3162
+ const progressEventDecorator = (total, throttled) => {
3163
+ const lengthComputable = total != null;
3164
+ return [(loaded) => throttled[0]({
3165
+ lengthComputable,
3166
+ total,
3167
+ loaded
3168
+ }), throttled[1]];
3169
+ };
3170
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
3171
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
3172
+ url = new URL(url, platform.origin);
3173
+ return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
3174
+ })(
3175
+ new URL(platform.origin),
3176
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
3177
+ ) : () => true;
3178
+ const cookies = platform.hasStandardBrowserEnv ? (
3179
+ // Standard browser envs support document.cookie
3180
+ {
3181
+ write(name, value, expires, path, domain, secure) {
3182
+ const cookie = [name + "=" + encodeURIComponent(value)];
3183
+ utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
3184
+ utils$1.isString(path) && cookie.push("path=" + path);
3185
+ utils$1.isString(domain) && cookie.push("domain=" + domain);
3186
+ secure === true && cookie.push("secure");
3187
+ document.cookie = cookie.join("; ");
3188
+ },
3189
+ read(name) {
3190
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
3191
+ return match ? decodeURIComponent(match[3]) : null;
3192
+ },
3193
+ remove(name) {
3194
+ this.write(name, "", Date.now() - 864e5);
3195
+ }
3196
+ }
3197
+ ) : (
3198
+ // Non-standard browser env (web workers, react-native) lack needed support.
3199
+ {
3200
+ write() {
3201
+ },
3202
+ read() {
3203
+ return null;
3204
+ },
3205
+ remove() {
3206
+ }
3207
+ }
3208
+ );
3209
+ function isAbsoluteURL(url) {
3210
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
3211
+ }
3212
+ function combineURLs(baseURL, relativeURL) {
3213
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
3214
+ }
3215
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
3216
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
3217
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
3218
+ return combineURLs(baseURL, requestedURL);
3219
+ }
3220
+ return requestedURL;
3221
+ }
3222
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3223
+ function mergeConfig$1(config1, config2) {
3224
+ config2 = config2 || {};
3225
+ const config = {};
3226
+ function getMergedValue(target, source2, prop, caseless) {
3227
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source2)) {
3228
+ return utils$1.merge.call({ caseless }, target, source2);
3229
+ } else if (utils$1.isPlainObject(source2)) {
3230
+ return utils$1.merge({}, source2);
3231
+ } else if (utils$1.isArray(source2)) {
3232
+ return source2.slice();
3233
+ }
3234
+ return source2;
3235
+ }
3236
+ function mergeDeepProperties(a, b, prop, caseless) {
3237
+ if (!utils$1.isUndefined(b)) {
3238
+ return getMergedValue(a, b, prop, caseless);
3239
+ } else if (!utils$1.isUndefined(a)) {
3240
+ return getMergedValue(void 0, a, prop, caseless);
3241
+ }
3242
+ }
3243
+ function valueFromConfig2(a, b) {
3244
+ if (!utils$1.isUndefined(b)) {
3245
+ return getMergedValue(void 0, b);
3246
+ }
3247
+ }
3248
+ function defaultToConfig2(a, b) {
3249
+ if (!utils$1.isUndefined(b)) {
3250
+ return getMergedValue(void 0, b);
3251
+ } else if (!utils$1.isUndefined(a)) {
3252
+ return getMergedValue(void 0, a);
3253
+ }
3254
+ }
3255
+ function mergeDirectKeys(a, b, prop) {
3256
+ if (prop in config2) {
3257
+ return getMergedValue(a, b);
3258
+ } else if (prop in config1) {
3259
+ return getMergedValue(void 0, a);
3260
+ }
3261
+ }
3262
+ const mergeMap = {
3263
+ url: valueFromConfig2,
3264
+ method: valueFromConfig2,
3265
+ data: valueFromConfig2,
3266
+ baseURL: defaultToConfig2,
3267
+ transformRequest: defaultToConfig2,
3268
+ transformResponse: defaultToConfig2,
3269
+ paramsSerializer: defaultToConfig2,
3270
+ timeout: defaultToConfig2,
3271
+ timeoutMessage: defaultToConfig2,
3272
+ withCredentials: defaultToConfig2,
3273
+ withXSRFToken: defaultToConfig2,
3274
+ adapter: defaultToConfig2,
3275
+ responseType: defaultToConfig2,
3276
+ xsrfCookieName: defaultToConfig2,
3277
+ xsrfHeaderName: defaultToConfig2,
3278
+ onUploadProgress: defaultToConfig2,
3279
+ onDownloadProgress: defaultToConfig2,
3280
+ decompress: defaultToConfig2,
3281
+ maxContentLength: defaultToConfig2,
3282
+ maxBodyLength: defaultToConfig2,
3283
+ beforeRedirect: defaultToConfig2,
3284
+ transport: defaultToConfig2,
3285
+ httpAgent: defaultToConfig2,
3286
+ httpsAgent: defaultToConfig2,
3287
+ cancelToken: defaultToConfig2,
3288
+ socketPath: defaultToConfig2,
3289
+ responseEncoding: defaultToConfig2,
3290
+ validateStatus: mergeDirectKeys,
3291
+ headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
3292
+ };
3293
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
3294
+ const merge2 = mergeMap[prop] || mergeDeepProperties;
3295
+ const configValue = merge2(config1[prop], config2[prop], prop);
3296
+ utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
3297
+ });
3298
+ return config;
3299
+ }
3300
+ const resolveConfig = (config) => {
3301
+ const newConfig = mergeConfig$1({}, config);
3302
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3303
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
3304
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
3305
+ if (auth) {
3306
+ headers.set(
3307
+ "Authorization",
3308
+ "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
3309
+ );
3310
+ }
3311
+ let contentType;
3312
+ if (utils$1.isFormData(data)) {
3313
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
3314
+ headers.setContentType(void 0);
3315
+ } else if ((contentType = headers.getContentType()) !== false) {
3316
+ const [type, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
3317
+ headers.setContentType([type || "multipart/form-data", ...tokens].join("; "));
3318
+ }
3319
+ }
3320
+ if (platform.hasStandardBrowserEnv) {
3321
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3322
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
3323
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3324
+ if (xsrfValue) {
3325
+ headers.set(xsrfHeaderName, xsrfValue);
3326
+ }
3327
+ }
3328
+ }
3329
+ return newConfig;
3330
+ };
3331
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
3332
+ const xhrAdapter = isXHRAdapterSupported && function(config) {
3333
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
3334
+ const _config = resolveConfig(config);
3335
+ let requestData = _config.data;
3336
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3337
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
3338
+ let onCanceled;
3339
+ let uploadThrottled, downloadThrottled;
3340
+ let flushUpload, flushDownload;
3341
+ function done() {
3342
+ flushUpload && flushUpload();
3343
+ flushDownload && flushDownload();
3344
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
3345
+ _config.signal && _config.signal.removeEventListener("abort", onCanceled);
3346
+ }
3347
+ let request = new XMLHttpRequest();
3348
+ request.open(_config.method.toUpperCase(), _config.url, true);
3349
+ request.timeout = _config.timeout;
3350
+ function onloadend() {
3351
+ if (!request) {
3352
+ return;
3353
+ }
3354
+ const responseHeaders = AxiosHeaders$1.from(
3355
+ "getAllResponseHeaders" in request && request.getAllResponseHeaders()
3356
+ );
3357
+ const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
3358
+ const response = {
3359
+ data: responseData,
3360
+ status: request.status,
3361
+ statusText: request.statusText,
3362
+ headers: responseHeaders,
3363
+ config,
3364
+ request
3365
+ };
3366
+ settle(function _resolve(value) {
3367
+ resolve(value);
3368
+ done();
3369
+ }, function _reject(err) {
3370
+ reject(err);
3371
+ done();
3372
+ }, response);
3373
+ request = null;
3374
+ }
3375
+ if ("onloadend" in request) {
3376
+ request.onloadend = onloadend;
3377
+ } else {
3378
+ request.onreadystatechange = function handleLoad() {
3379
+ if (!request || request.readyState !== 4) {
3380
+ return;
3381
+ }
3382
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
3383
+ return;
3384
+ }
3385
+ setTimeout(onloadend);
3386
+ };
3387
+ }
3388
+ request.onabort = function handleAbort() {
3389
+ if (!request) {
3390
+ return;
3391
+ }
3392
+ reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config, request));
3393
+ request = null;
3394
+ };
3395
+ request.onerror = function handleError() {
3396
+ reject(new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request));
3397
+ request = null;
3398
+ };
3399
+ request.ontimeout = function handleTimeout() {
3400
+ let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
3401
+ const transitional2 = _config.transitional || transitionalDefaults;
3402
+ if (_config.timeoutErrorMessage) {
3403
+ timeoutErrorMessage = _config.timeoutErrorMessage;
3404
+ }
3405
+ reject(new AxiosError$1(
3406
+ timeoutErrorMessage,
3407
+ transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
3408
+ config,
3409
+ request
3410
+ ));
3411
+ request = null;
3412
+ };
3413
+ requestData === void 0 && requestHeaders.setContentType(null);
3414
+ if ("setRequestHeader" in request) {
3415
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3416
+ request.setRequestHeader(key, val);
3417
+ });
3418
+ }
3419
+ if (!utils$1.isUndefined(_config.withCredentials)) {
3420
+ request.withCredentials = !!_config.withCredentials;
3421
+ }
3422
+ if (responseType && responseType !== "json") {
3423
+ request.responseType = _config.responseType;
3424
+ }
3425
+ if (onDownloadProgress) {
3426
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
3427
+ request.addEventListener("progress", downloadThrottled);
3428
+ }
3429
+ if (onUploadProgress && request.upload) {
3430
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
3431
+ request.upload.addEventListener("progress", uploadThrottled);
3432
+ request.upload.addEventListener("loadend", flushUpload);
3433
+ }
3434
+ if (_config.cancelToken || _config.signal) {
3435
+ onCanceled = (cancel) => {
3436
+ if (!request) {
3437
+ return;
3438
+ }
3439
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
3440
+ request.abort();
3441
+ request = null;
3442
+ };
3443
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3444
+ if (_config.signal) {
3445
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
3446
+ }
3447
+ }
3448
+ const protocol = parseProtocol(_config.url);
3449
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
3450
+ reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config));
3451
+ return;
3452
+ }
3453
+ request.send(requestData || null);
3454
+ });
3455
+ };
3456
+ const composeSignals = (signals, timeout) => {
3457
+ const { length } = signals = signals ? signals.filter(Boolean) : [];
3458
+ if (timeout || length) {
3459
+ let controller = new AbortController();
3460
+ let aborted;
3461
+ const onabort = function(reason) {
3462
+ if (!aborted) {
3463
+ aborted = true;
3464
+ unsubscribe();
3465
+ const err = reason instanceof Error ? reason : this.reason;
3466
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
3467
+ }
3468
+ };
3469
+ let timer = timeout && setTimeout(() => {
3470
+ timer = null;
3471
+ onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
3472
+ }, timeout);
3473
+ const unsubscribe = () => {
3474
+ if (signals) {
3475
+ timer && clearTimeout(timer);
3476
+ timer = null;
3477
+ signals.forEach((signal2) => {
3478
+ signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
3479
+ });
3480
+ signals = null;
3481
+ }
3482
+ };
3483
+ signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
3484
+ const { signal } = controller;
3485
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
3486
+ return signal;
3487
+ }
3488
+ };
3489
+ const streamChunk = function* (chunk, chunkSize) {
3490
+ let len = chunk.byteLength;
3491
+ if (len < chunkSize) {
3492
+ yield chunk;
3493
+ return;
3494
+ }
3495
+ let pos = 0;
3496
+ let end;
3497
+ while (pos < len) {
3498
+ end = pos + chunkSize;
3499
+ yield chunk.slice(pos, end);
3500
+ pos = end;
3501
+ }
3502
+ };
3503
+ const readBytes = async function* (iterable, chunkSize) {
3504
+ for await (const chunk of readStream(iterable)) {
3505
+ yield* streamChunk(chunk, chunkSize);
3506
+ }
3507
+ };
3508
+ const readStream = async function* (stream) {
3509
+ if (stream[Symbol.asyncIterator]) {
3510
+ yield* stream;
3511
+ return;
3512
+ }
3513
+ const reader = stream.getReader();
3514
+ try {
3515
+ for (; ; ) {
3516
+ const { done, value } = await reader.read();
3517
+ if (done) {
3518
+ break;
3519
+ }
3520
+ yield value;
3521
+ }
3522
+ } finally {
3523
+ await reader.cancel();
3524
+ }
3525
+ };
3526
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3527
+ const iterator2 = readBytes(stream, chunkSize);
3528
+ let bytes = 0;
3529
+ let done;
3530
+ let _onFinish = (e) => {
3531
+ if (!done) {
3532
+ done = true;
3533
+ onFinish && onFinish(e);
3534
+ }
3535
+ };
3536
+ return new ReadableStream({
3537
+ async pull(controller) {
3538
+ try {
3539
+ const { done: done2, value } = await iterator2.next();
3540
+ if (done2) {
3541
+ _onFinish();
3542
+ controller.close();
3543
+ return;
3544
+ }
3545
+ let len = value.byteLength;
3546
+ if (onProgress) {
3547
+ let loadedBytes = bytes += len;
3548
+ onProgress(loadedBytes);
3549
+ }
3550
+ controller.enqueue(new Uint8Array(value));
3551
+ } catch (err) {
3552
+ _onFinish(err);
3553
+ throw err;
3554
+ }
3555
+ },
3556
+ cancel(reason) {
3557
+ _onFinish(reason);
3558
+ return iterator2.return();
3559
+ }
3560
+ }, {
3561
+ highWaterMark: 2
3562
+ });
3563
+ };
3564
+ const isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
3565
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
3566
+ const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
3567
+ const test = (fn, ...args) => {
3568
+ try {
3569
+ return !!fn(...args);
3570
+ } catch (e) {
3571
+ return false;
3572
+ }
3573
+ };
3574
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
3575
+ let duplexAccessed = false;
3576
+ const hasContentType = new Request(platform.origin, {
3577
+ body: new ReadableStream(),
3578
+ method: "POST",
3579
+ get duplex() {
3580
+ duplexAccessed = true;
3581
+ return "half";
3582
+ }
3583
+ }).headers.has("Content-Type");
3584
+ return duplexAccessed && !hasContentType;
3585
+ });
3586
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3587
+ const supportsResponseStream = isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
3588
+ const resolvers = {
3589
+ stream: supportsResponseStream && ((res) => res.body)
3590
+ };
3591
+ isFetchSupported && ((res) => {
3592
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
3593
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res2) => res2[type]() : (_, config) => {
3594
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
3595
+ });
3596
+ });
3597
+ })(new Response());
3598
+ const getBodyLength = async (body) => {
3599
+ if (body == null) {
3600
+ return 0;
3601
+ }
3602
+ if (utils$1.isBlob(body)) {
3603
+ return body.size;
3604
+ }
3605
+ if (utils$1.isSpecCompliantForm(body)) {
3606
+ const _request = new Request(platform.origin, {
3607
+ method: "POST",
3608
+ body
3609
+ });
3610
+ return (await _request.arrayBuffer()).byteLength;
3611
+ }
3612
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3613
+ return body.byteLength;
3614
+ }
3615
+ if (utils$1.isURLSearchParams(body)) {
3616
+ body = body + "";
3617
+ }
3618
+ if (utils$1.isString(body)) {
3619
+ return (await encodeText(body)).byteLength;
3620
+ }
3621
+ };
3622
+ const resolveBodyLength = async (headers, body) => {
3623
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3624
+ return length == null ? getBodyLength(body) : length;
3625
+ };
3626
+ const fetchAdapter = isFetchSupported && (async (config) => {
3627
+ let {
3628
+ url,
3629
+ method,
3630
+ data,
3631
+ signal,
3632
+ cancelToken,
3633
+ timeout,
3634
+ onDownloadProgress,
3635
+ onUploadProgress,
3636
+ responseType,
3637
+ headers,
3638
+ withCredentials = "same-origin",
3639
+ fetchOptions
3640
+ } = resolveConfig(config);
3641
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
3642
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3643
+ let request;
3644
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3645
+ composedSignal.unsubscribe();
3646
+ });
3647
+ let requestContentLength;
3648
+ try {
3649
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
3650
+ let _request = new Request(url, {
3651
+ method: "POST",
3652
+ body: data,
3653
+ duplex: "half"
3654
+ });
3655
+ let contentTypeHeader;
3656
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
3657
+ headers.setContentType(contentTypeHeader);
3658
+ }
3659
+ if (_request.body) {
3660
+ const [onProgress, flush] = progressEventDecorator(
3661
+ requestContentLength,
3662
+ progressEventReducer(asyncDecorator(onUploadProgress))
3663
+ );
3664
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3665
+ }
3666
+ }
3667
+ if (!utils$1.isString(withCredentials)) {
3668
+ withCredentials = withCredentials ? "include" : "omit";
3669
+ }
3670
+ const isCredentialsSupported = "credentials" in Request.prototype;
3671
+ request = new Request(url, {
3672
+ ...fetchOptions,
3673
+ signal: composedSignal,
3674
+ method: method.toUpperCase(),
3675
+ headers: headers.normalize().toJSON(),
3676
+ body: data,
3677
+ duplex: "half",
3678
+ credentials: isCredentialsSupported ? withCredentials : void 0
3679
+ });
3680
+ let response = await fetch(request, fetchOptions);
3681
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
3682
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
3683
+ const options = {};
3684
+ ["status", "statusText", "headers"].forEach((prop) => {
3685
+ options[prop] = response[prop];
3686
+ });
3687
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
3688
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3689
+ responseContentLength,
3690
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3691
+ ) || [];
3692
+ response = new Response(
3693
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3694
+ flush && flush();
3695
+ unsubscribe && unsubscribe();
3696
+ }),
3697
+ options
3698
+ );
3699
+ }
3700
+ responseType = responseType || "text";
3701
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
3702
+ !isStreamResponse && unsubscribe && unsubscribe();
3703
+ return await new Promise((resolve, reject) => {
3704
+ settle(resolve, reject, {
3705
+ data: responseData,
3706
+ headers: AxiosHeaders$1.from(response.headers),
3707
+ status: response.status,
3708
+ statusText: response.statusText,
3709
+ config,
3710
+ request
3711
+ });
3712
+ });
3713
+ } catch (err) {
3714
+ unsubscribe && unsubscribe();
3715
+ if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
3716
+ throw Object.assign(
3717
+ new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request),
3718
+ {
3719
+ cause: err.cause || err
3720
+ }
3721
+ );
3722
+ }
3723
+ throw AxiosError$1.from(err, err && err.code, config, request);
3724
+ }
3725
+ });
3726
+ const knownAdapters = {
3727
+ http: httpAdapter,
3728
+ xhr: xhrAdapter,
3729
+ fetch: fetchAdapter
3730
+ };
3731
+ utils$1.forEach(knownAdapters, (fn, value) => {
3732
+ if (fn) {
3733
+ try {
3734
+ Object.defineProperty(fn, "name", { value });
3735
+ } catch (e) {
3736
+ }
3737
+ Object.defineProperty(fn, "adapterName", { value });
3738
+ }
3739
+ });
3740
+ const renderReason = (reason) => `- ${reason}`;
3741
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3742
+ const adapters = {
3743
+ getAdapter: (adapters2) => {
3744
+ adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
3745
+ const { length } = adapters2;
3746
+ let nameOrAdapter;
3747
+ let adapter;
3748
+ const rejectedReasons = {};
3749
+ for (let i = 0; i < length; i++) {
3750
+ nameOrAdapter = adapters2[i];
3751
+ let id;
3752
+ adapter = nameOrAdapter;
3753
+ if (!isResolvedHandle(nameOrAdapter)) {
3754
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3755
+ if (adapter === void 0) {
3756
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
3757
+ }
3758
+ }
3759
+ if (adapter) {
3760
+ break;
3761
+ }
3762
+ rejectedReasons[id || "#" + i] = adapter;
3763
+ }
3764
+ if (!adapter) {
3765
+ const reasons = Object.entries(rejectedReasons).map(
3766
+ ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
3767
+ );
3768
+ let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
3769
+ throw new AxiosError$1(
3770
+ `There is no suitable adapter to dispatch the request ` + s,
3771
+ "ERR_NOT_SUPPORT"
3772
+ );
3773
+ }
3774
+ return adapter;
3775
+ },
3776
+ adapters: knownAdapters
3777
+ };
3778
+ function throwIfCancellationRequested(config) {
3779
+ if (config.cancelToken) {
3780
+ config.cancelToken.throwIfRequested();
3781
+ }
3782
+ if (config.signal && config.signal.aborted) {
3783
+ throw new CanceledError$1(null, config);
3784
+ }
3785
+ }
3786
+ function dispatchRequest(config) {
3787
+ throwIfCancellationRequested(config);
3788
+ config.headers = AxiosHeaders$1.from(config.headers);
3789
+ config.data = transformData.call(
3790
+ config,
3791
+ config.transformRequest
3792
+ );
3793
+ if (["post", "put", "patch"].indexOf(config.method) !== -1) {
3794
+ config.headers.setContentType("application/x-www-form-urlencoded", false);
3795
+ }
3796
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
3797
+ return adapter(config).then(function onAdapterResolution(response) {
3798
+ throwIfCancellationRequested(config);
3799
+ response.data = transformData.call(
3800
+ config,
3801
+ config.transformResponse,
3802
+ response
3803
+ );
3804
+ response.headers = AxiosHeaders$1.from(response.headers);
3805
+ return response;
3806
+ }, function onAdapterRejection(reason) {
3807
+ if (!isCancel$1(reason)) {
3808
+ throwIfCancellationRequested(config);
3809
+ if (reason && reason.response) {
3810
+ reason.response.data = transformData.call(
3811
+ config,
3812
+ config.transformResponse,
3813
+ reason.response
3814
+ );
3815
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3816
+ }
3817
+ }
3818
+ return Promise.reject(reason);
3819
+ });
3820
+ }
3821
+ const VERSION$1 = "1.10.0";
3822
+ const validators$1 = {};
3823
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
3824
+ validators$1[type] = function validator2(thing) {
3825
+ return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
3826
+ };
3827
+ });
3828
+ const deprecatedWarnings = {};
3829
+ validators$1.transitional = function transitional(validator2, version, message) {
3830
+ function formatMessage(opt, desc) {
3831
+ return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
3832
+ }
3833
+ return (value, opt, opts) => {
3834
+ if (validator2 === false) {
3835
+ throw new AxiosError$1(
3836
+ formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
3837
+ AxiosError$1.ERR_DEPRECATED
3838
+ );
3839
+ }
3840
+ if (version && !deprecatedWarnings[opt]) {
3841
+ deprecatedWarnings[opt] = true;
3842
+ console.warn(
3843
+ formatMessage(
3844
+ opt,
3845
+ " has been deprecated since v" + version + " and will be removed in the near future"
3846
+ )
3847
+ );
3848
+ }
3849
+ return validator2 ? validator2(value, opt, opts) : true;
3850
+ };
3851
+ };
3852
+ validators$1.spelling = function spelling(correctSpelling) {
3853
+ return (value, opt) => {
3854
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3855
+ return true;
3856
+ };
3857
+ };
3858
+ function assertOptions(options, schema, allowUnknown) {
3859
+ if (typeof options !== "object") {
3860
+ throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
3861
+ }
3862
+ const keys = Object.keys(options);
3863
+ let i = keys.length;
3864
+ while (i-- > 0) {
3865
+ const opt = keys[i];
3866
+ const validator2 = schema[opt];
3867
+ if (validator2) {
3868
+ const value = options[opt];
3869
+ const result = value === void 0 || validator2(value, opt, options);
3870
+ if (result !== true) {
3871
+ throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
3872
+ }
3873
+ continue;
3874
+ }
3875
+ if (allowUnknown !== true) {
3876
+ throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
3877
+ }
3878
+ }
3879
+ }
3880
+ const validator = {
3881
+ assertOptions,
3882
+ validators: validators$1
3883
+ };
3884
+ const validators = validator.validators;
3885
+ let Axios$1 = class Axios {
3886
+ constructor(instanceConfig) {
3887
+ this.defaults = instanceConfig || {};
3888
+ this.interceptors = {
3889
+ request: new InterceptorManager(),
3890
+ response: new InterceptorManager()
3891
+ };
3892
+ }
3893
+ /**
3894
+ * Dispatch a request
3895
+ *
3896
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3897
+ * @param {?Object} config
3898
+ *
3899
+ * @returns {Promise} The Promise to be fulfilled
3900
+ */
3901
+ async request(configOrUrl, config) {
3902
+ try {
3903
+ return await this._request(configOrUrl, config);
3904
+ } catch (err) {
3905
+ if (err instanceof Error) {
3906
+ let dummy = {};
3907
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
3908
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
3909
+ try {
3910
+ if (!err.stack) {
3911
+ err.stack = stack;
3912
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
3913
+ err.stack += "\n" + stack;
3914
+ }
3915
+ } catch (e) {
3916
+ }
3917
+ }
3918
+ throw err;
3919
+ }
3920
+ }
3921
+ _request(configOrUrl, config) {
3922
+ if (typeof configOrUrl === "string") {
3923
+ config = config || {};
3924
+ config.url = configOrUrl;
3925
+ } else {
3926
+ config = configOrUrl || {};
3927
+ }
3928
+ config = mergeConfig$1(this.defaults, config);
3929
+ const { transitional: transitional2, paramsSerializer, headers } = config;
3930
+ if (transitional2 !== void 0) {
3931
+ validator.assertOptions(transitional2, {
3932
+ silentJSONParsing: validators.transitional(validators.boolean),
3933
+ forcedJSONParsing: validators.transitional(validators.boolean),
3934
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3935
+ }, false);
3936
+ }
3937
+ if (paramsSerializer != null) {
3938
+ if (utils$1.isFunction(paramsSerializer)) {
3939
+ config.paramsSerializer = {
3940
+ serialize: paramsSerializer
3941
+ };
3942
+ } else {
3943
+ validator.assertOptions(paramsSerializer, {
3944
+ encode: validators.function,
3945
+ serialize: validators.function
3946
+ }, true);
3947
+ }
3948
+ }
3949
+ if (config.allowAbsoluteUrls !== void 0) ;
3950
+ else if (this.defaults.allowAbsoluteUrls !== void 0) {
3951
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3952
+ } else {
3953
+ config.allowAbsoluteUrls = true;
3954
+ }
3955
+ validator.assertOptions(config, {
3956
+ baseUrl: validators.spelling("baseURL"),
3957
+ withXsrfToken: validators.spelling("withXSRFToken")
3958
+ }, true);
3959
+ config.method = (config.method || this.defaults.method || "get").toLowerCase();
3960
+ let contextHeaders = headers && utils$1.merge(
3961
+ headers.common,
3962
+ headers[config.method]
3963
+ );
3964
+ headers && utils$1.forEach(
3965
+ ["delete", "get", "head", "post", "put", "patch", "common"],
3966
+ (method) => {
3967
+ delete headers[method];
3968
+ }
3969
+ );
3970
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3971
+ const requestInterceptorChain = [];
3972
+ let synchronousRequestInterceptors = true;
3973
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3974
+ if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
3975
+ return;
3976
+ }
3977
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3978
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3979
+ });
3980
+ const responseInterceptorChain = [];
3981
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3982
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3983
+ });
3984
+ let promise;
3985
+ let i = 0;
3986
+ let len;
3987
+ if (!synchronousRequestInterceptors) {
3988
+ const chain = [dispatchRequest.bind(this), void 0];
3989
+ chain.unshift.apply(chain, requestInterceptorChain);
3990
+ chain.push.apply(chain, responseInterceptorChain);
3991
+ len = chain.length;
3992
+ promise = Promise.resolve(config);
3993
+ while (i < len) {
3994
+ promise = promise.then(chain[i++], chain[i++]);
3995
+ }
3996
+ return promise;
3997
+ }
3998
+ len = requestInterceptorChain.length;
3999
+ let newConfig = config;
4000
+ i = 0;
4001
+ while (i < len) {
4002
+ const onFulfilled = requestInterceptorChain[i++];
4003
+ const onRejected = requestInterceptorChain[i++];
4004
+ try {
4005
+ newConfig = onFulfilled(newConfig);
4006
+ } catch (error) {
4007
+ onRejected.call(this, error);
4008
+ break;
4009
+ }
4010
+ }
4011
+ try {
4012
+ promise = dispatchRequest.call(this, newConfig);
4013
+ } catch (error) {
4014
+ return Promise.reject(error);
4015
+ }
4016
+ i = 0;
4017
+ len = responseInterceptorChain.length;
4018
+ while (i < len) {
4019
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
4020
+ }
4021
+ return promise;
4022
+ }
4023
+ getUri(config) {
4024
+ config = mergeConfig$1(this.defaults, config);
4025
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
4026
+ return buildURL(fullPath, config.params, config.paramsSerializer);
4027
+ }
4028
+ };
4029
+ utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
4030
+ Axios$1.prototype[method] = function(url, config) {
4031
+ return this.request(mergeConfig$1(config || {}, {
4032
+ method,
4033
+ url,
4034
+ data: (config || {}).data
4035
+ }));
4036
+ };
4037
+ });
4038
+ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
4039
+ function generateHTTPMethod(isForm) {
4040
+ return function httpMethod(url, data, config) {
4041
+ return this.request(mergeConfig$1(config || {}, {
4042
+ method,
4043
+ headers: isForm ? {
4044
+ "Content-Type": "multipart/form-data"
4045
+ } : {},
4046
+ url,
4047
+ data
4048
+ }));
4049
+ };
4050
+ }
4051
+ Axios$1.prototype[method] = generateHTTPMethod();
4052
+ Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
4053
+ });
4054
+ let CancelToken$1 = class CancelToken {
4055
+ constructor(executor) {
4056
+ if (typeof executor !== "function") {
4057
+ throw new TypeError("executor must be a function.");
4058
+ }
4059
+ let resolvePromise;
4060
+ this.promise = new Promise(function promiseExecutor(resolve) {
4061
+ resolvePromise = resolve;
4062
+ });
4063
+ const token = this;
4064
+ this.promise.then((cancel) => {
4065
+ if (!token._listeners) return;
4066
+ let i = token._listeners.length;
4067
+ while (i-- > 0) {
4068
+ token._listeners[i](cancel);
4069
+ }
4070
+ token._listeners = null;
4071
+ });
4072
+ this.promise.then = (onfulfilled) => {
4073
+ let _resolve;
4074
+ const promise = new Promise((resolve) => {
4075
+ token.subscribe(resolve);
4076
+ _resolve = resolve;
4077
+ }).then(onfulfilled);
4078
+ promise.cancel = function reject() {
4079
+ token.unsubscribe(_resolve);
4080
+ };
4081
+ return promise;
4082
+ };
4083
+ executor(function cancel(message, config, request) {
4084
+ if (token.reason) {
4085
+ return;
4086
+ }
4087
+ token.reason = new CanceledError$1(message, config, request);
4088
+ resolvePromise(token.reason);
4089
+ });
4090
+ }
4091
+ /**
4092
+ * Throws a `CanceledError` if cancellation has been requested.
4093
+ */
4094
+ throwIfRequested() {
4095
+ if (this.reason) {
4096
+ throw this.reason;
4097
+ }
4098
+ }
4099
+ /**
4100
+ * Subscribe to the cancel signal
4101
+ */
4102
+ subscribe(listener) {
4103
+ if (this.reason) {
4104
+ listener(this.reason);
4105
+ return;
4106
+ }
4107
+ if (this._listeners) {
4108
+ this._listeners.push(listener);
4109
+ } else {
4110
+ this._listeners = [listener];
4111
+ }
4112
+ }
4113
+ /**
4114
+ * Unsubscribe from the cancel signal
4115
+ */
4116
+ unsubscribe(listener) {
4117
+ if (!this._listeners) {
4118
+ return;
4119
+ }
4120
+ const index = this._listeners.indexOf(listener);
4121
+ if (index !== -1) {
4122
+ this._listeners.splice(index, 1);
4123
+ }
4124
+ }
4125
+ toAbortSignal() {
4126
+ const controller = new AbortController();
4127
+ const abort = (err) => {
4128
+ controller.abort(err);
4129
+ };
4130
+ this.subscribe(abort);
4131
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
4132
+ return controller.signal;
4133
+ }
4134
+ /**
4135
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
4136
+ * cancels the `CancelToken`.
4137
+ */
4138
+ static source() {
4139
+ let cancel;
4140
+ const token = new CancelToken(function executor(c) {
4141
+ cancel = c;
4142
+ });
4143
+ return {
4144
+ token,
4145
+ cancel
4146
+ };
4147
+ }
4148
+ };
4149
+ function spread$1(callback) {
4150
+ return function wrap(arr) {
4151
+ return callback.apply(null, arr);
4152
+ };
4153
+ }
4154
+ function isAxiosError$1(payload) {
4155
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
4156
+ }
4157
+ const HttpStatusCode$1 = {
4158
+ Continue: 100,
4159
+ SwitchingProtocols: 101,
4160
+ Processing: 102,
4161
+ EarlyHints: 103,
4162
+ Ok: 200,
4163
+ Created: 201,
4164
+ Accepted: 202,
4165
+ NonAuthoritativeInformation: 203,
4166
+ NoContent: 204,
4167
+ ResetContent: 205,
4168
+ PartialContent: 206,
4169
+ MultiStatus: 207,
4170
+ AlreadyReported: 208,
4171
+ ImUsed: 226,
4172
+ MultipleChoices: 300,
4173
+ MovedPermanently: 301,
4174
+ Found: 302,
4175
+ SeeOther: 303,
4176
+ NotModified: 304,
4177
+ UseProxy: 305,
4178
+ Unused: 306,
4179
+ TemporaryRedirect: 307,
4180
+ PermanentRedirect: 308,
4181
+ BadRequest: 400,
4182
+ Unauthorized: 401,
4183
+ PaymentRequired: 402,
4184
+ Forbidden: 403,
4185
+ NotFound: 404,
4186
+ MethodNotAllowed: 405,
4187
+ NotAcceptable: 406,
4188
+ ProxyAuthenticationRequired: 407,
4189
+ RequestTimeout: 408,
4190
+ Conflict: 409,
4191
+ Gone: 410,
4192
+ LengthRequired: 411,
4193
+ PreconditionFailed: 412,
4194
+ PayloadTooLarge: 413,
4195
+ UriTooLong: 414,
4196
+ UnsupportedMediaType: 415,
4197
+ RangeNotSatisfiable: 416,
4198
+ ExpectationFailed: 417,
4199
+ ImATeapot: 418,
4200
+ MisdirectedRequest: 421,
4201
+ UnprocessableEntity: 422,
4202
+ Locked: 423,
4203
+ FailedDependency: 424,
4204
+ TooEarly: 425,
4205
+ UpgradeRequired: 426,
4206
+ PreconditionRequired: 428,
4207
+ TooManyRequests: 429,
4208
+ RequestHeaderFieldsTooLarge: 431,
4209
+ UnavailableForLegalReasons: 451,
4210
+ InternalServerError: 500,
4211
+ NotImplemented: 501,
4212
+ BadGateway: 502,
4213
+ ServiceUnavailable: 503,
4214
+ GatewayTimeout: 504,
4215
+ HttpVersionNotSupported: 505,
4216
+ VariantAlsoNegotiates: 506,
4217
+ InsufficientStorage: 507,
4218
+ LoopDetected: 508,
4219
+ NotExtended: 510,
4220
+ NetworkAuthenticationRequired: 511
4221
+ };
4222
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
4223
+ HttpStatusCode$1[value] = key;
4224
+ });
4225
+ function createInstance(defaultConfig) {
4226
+ const context = new Axios$1(defaultConfig);
4227
+ const instance = bind(Axios$1.prototype.request, context);
4228
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
4229
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
4230
+ instance.create = function create(instanceConfig) {
4231
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
4232
+ };
4233
+ return instance;
4234
+ }
4235
+ const axios = createInstance(defaults);
4236
+ axios.Axios = Axios$1;
4237
+ axios.CanceledError = CanceledError$1;
4238
+ axios.CancelToken = CancelToken$1;
4239
+ axios.isCancel = isCancel$1;
4240
+ axios.VERSION = VERSION$1;
4241
+ axios.toFormData = toFormData$1;
4242
+ axios.AxiosError = AxiosError$1;
4243
+ axios.Cancel = axios.CanceledError;
4244
+ axios.all = function all(promises) {
4245
+ return Promise.all(promises);
4246
+ };
4247
+ axios.spread = spread$1;
4248
+ axios.isAxiosError = isAxiosError$1;
4249
+ axios.mergeConfig = mergeConfig$1;
4250
+ axios.AxiosHeaders = AxiosHeaders$1;
4251
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4252
+ axios.getAdapter = adapters.getAdapter;
4253
+ axios.HttpStatusCode = HttpStatusCode$1;
4254
+ axios.default = axios;
4255
+ const {
4256
+ Axios: Axios2,
4257
+ AxiosError,
4258
+ CanceledError,
4259
+ isCancel,
4260
+ CancelToken: CancelToken2,
4261
+ VERSION,
4262
+ all: all2,
4263
+ Cancel,
4264
+ isAxiosError,
4265
+ spread,
4266
+ toFormData,
4267
+ AxiosHeaders: AxiosHeaders2,
4268
+ HttpStatusCode,
4269
+ formToJSON,
4270
+ getAdapter,
4271
+ mergeConfig
4272
+ } = axios;
4273
+ function sleep(ms) {
4274
+ return new Promise((resolve) => setTimeout(resolve, ms));
4275
+ }
4276
+ function getJitteredDelay(base, jitter) {
4277
+ const random = Math.floor(Math.random() * jitter);
4278
+ return base + random;
4279
+ }
4280
+ function createRetryAxiosClient(retryConfig) {
4281
+ const {
4282
+ maxRetries = 3,
4283
+ retryDelayMs = 300,
4284
+ retryJitterMs = 100,
4285
+ retryMethods = ["get", "head", "put", "delete", "options"],
4286
+ // post, patch
4287
+ retryStatusCodes = [408, 429, 500, 502, 503, 504],
4288
+ retryErrorCodes = [
4289
+ "ECONNRESET",
4290
+ "ETIMEDOUT",
4291
+ "EAI_AGAIN",
4292
+ "ECONNREFUSED",
4293
+ "ENOTFOUND",
4294
+ "EHOSTUNREACH",
4295
+ "EPIPE"
4296
+ ],
4297
+ maxRetryDurationMs = 1e4,
4298
+ onRetryAttempt,
4299
+ stsAxiosConfig
4300
+ } = retryConfig || {};
4301
+ const instance = axios.create();
4302
+ instance.interceptors.request.use((config) => {
4303
+ const now = Date.now();
4304
+ config.metadata = {
4305
+ startTime: now,
4306
+ __retryCount: 0
4307
+ };
4308
+ if (stsAxiosConfig) {
4309
+ Object.assign(config, stsAxiosConfig.config);
4310
+ }
4311
+ return config;
4312
+ });
4313
+ instance.interceptors.response.use(
4314
+ (response) => response,
4315
+ async (error) => {
4316
+ var _a;
4317
+ const config = error.config;
4318
+ if (!config || !config.method || !config.metadata) {
4319
+ return Promise.reject(error);
4320
+ }
4321
+ const now = Date.now();
4322
+ const elapsed = now - config.metadata.startTime;
4323
+ const method = config.method.toLowerCase();
4324
+ const status = (_a = error.response) == null ? void 0 : _a.status;
4325
+ const code = error.code;
4326
+ const isRetryable = retryMethods.includes(method) && (retryErrorCodes.includes(code || "") || retryStatusCodes.includes(status || 0));
4327
+ if (config.metadata.__retryCount < maxRetries && isRetryable && elapsed < maxRetryDurationMs) {
4328
+ config.metadata.__retryCount += 1;
4329
+ const delayBase = retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1);
4330
+ const jitteredDelay = getJitteredDelay(delayBase, retryJitterMs);
4331
+ if (onRetryAttempt) {
4332
+ onRetryAttempt(config.metadata.__retryCount, error, jitteredDelay);
4333
+ }
4334
+ await sleep(jitteredDelay);
4335
+ return instance(config);
4336
+ }
4337
+ return Promise.reject(error);
4338
+ }
4339
+ );
4340
+ return instance;
4341
+ }
1888
4342
  export {
1889
4343
  AddSchema,
1890
4344
  AgentManager,
@@ -1901,6 +4355,7 @@ export {
1901
4355
  Sleep,
1902
4356
  Validate,
1903
4357
  compareParameterTypes,
4358
+ createRetryAxiosClient,
1904
4359
  defaultLogger,
1905
4360
  edbaction
1906
4361
  };