版博士V2.0程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

3218 righe
82 KiB

  1. // Axios v1.3.5 Copyright (c) 2023 Matt Zabriskie and contributors
  2. function bind(fn, thisArg) {
  3. return function wrap() {
  4. return fn.apply(thisArg, arguments);
  5. };
  6. }
  7. // utils is a library of generic helper functions non-specific to axios
  8. const {toString} = Object.prototype;
  9. const {getPrototypeOf} = Object;
  10. const kindOf = (cache => thing => {
  11. const str = toString.call(thing);
  12. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  13. })(Object.create(null));
  14. const kindOfTest = (type) => {
  15. type = type.toLowerCase();
  16. return (thing) => kindOf(thing) === type
  17. };
  18. const typeOfTest = type => thing => typeof thing === type;
  19. /**
  20. * Determine if a value is an Array
  21. *
  22. * @param {Object} val The value to test
  23. *
  24. * @returns {boolean} True if value is an Array, otherwise false
  25. */
  26. const {isArray} = Array;
  27. /**
  28. * Determine if a value is undefined
  29. *
  30. * @param {*} val The value to test
  31. *
  32. * @returns {boolean} True if the value is undefined, otherwise false
  33. */
  34. const isUndefined = typeOfTest('undefined');
  35. /**
  36. * Determine if a value is a Buffer
  37. *
  38. * @param {*} val The value to test
  39. *
  40. * @returns {boolean} True if value is a Buffer, otherwise false
  41. */
  42. function isBuffer(val) {
  43. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  44. && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  45. }
  46. /**
  47. * Determine if a value is an ArrayBuffer
  48. *
  49. * @param {*} val The value to test
  50. *
  51. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  52. */
  53. const isArrayBuffer = kindOfTest('ArrayBuffer');
  54. /**
  55. * Determine if a value is a view on an ArrayBuffer
  56. *
  57. * @param {*} val The value to test
  58. *
  59. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  60. */
  61. function isArrayBufferView(val) {
  62. let result;
  63. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  64. result = ArrayBuffer.isView(val);
  65. } else {
  66. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  67. }
  68. return result;
  69. }
  70. /**
  71. * Determine if a value is a String
  72. *
  73. * @param {*} val The value to test
  74. *
  75. * @returns {boolean} True if value is a String, otherwise false
  76. */
  77. const isString = typeOfTest('string');
  78. /**
  79. * Determine if a value is a Function
  80. *
  81. * @param {*} val The value to test
  82. * @returns {boolean} True if value is a Function, otherwise false
  83. */
  84. const isFunction = typeOfTest('function');
  85. /**
  86. * Determine if a value is a Number
  87. *
  88. * @param {*} val The value to test
  89. *
  90. * @returns {boolean} True if value is a Number, otherwise false
  91. */
  92. const isNumber = typeOfTest('number');
  93. /**
  94. * Determine if a value is an Object
  95. *
  96. * @param {*} thing The value to test
  97. *
  98. * @returns {boolean} True if value is an Object, otherwise false
  99. */
  100. const isObject = (thing) => thing !== null && typeof thing === 'object';
  101. /**
  102. * Determine if a value is a Boolean
  103. *
  104. * @param {*} thing The value to test
  105. * @returns {boolean} True if value is a Boolean, otherwise false
  106. */
  107. const isBoolean = thing => thing === true || thing === false;
  108. /**
  109. * Determine if a value is a plain Object
  110. *
  111. * @param {*} val The value to test
  112. *
  113. * @returns {boolean} True if value is a plain Object, otherwise false
  114. */
  115. const isPlainObject = (val) => {
  116. if (kindOf(val) !== 'object') {
  117. return false;
  118. }
  119. const prototype = getPrototypeOf(val);
  120. return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
  121. };
  122. /**
  123. * Determine if a value is a Date
  124. *
  125. * @param {*} val The value to test
  126. *
  127. * @returns {boolean} True if value is a Date, otherwise false
  128. */
  129. const isDate = kindOfTest('Date');
  130. /**
  131. * Determine if a value is a File
  132. *
  133. * @param {*} val The value to test
  134. *
  135. * @returns {boolean} True if value is a File, otherwise false
  136. */
  137. const isFile = kindOfTest('File');
  138. /**
  139. * Determine if a value is a Blob
  140. *
  141. * @param {*} val The value to test
  142. *
  143. * @returns {boolean} True if value is a Blob, otherwise false
  144. */
  145. const isBlob = kindOfTest('Blob');
  146. /**
  147. * Determine if a value is a FileList
  148. *
  149. * @param {*} val The value to test
  150. *
  151. * @returns {boolean} True if value is a File, otherwise false
  152. */
  153. const isFileList = kindOfTest('FileList');
  154. /**
  155. * Determine if a value is a Stream
  156. *
  157. * @param {*} val The value to test
  158. *
  159. * @returns {boolean} True if value is a Stream, otherwise false
  160. */
  161. const isStream = (val) => isObject(val) && isFunction(val.pipe);
  162. /**
  163. * Determine if a value is a FormData
  164. *
  165. * @param {*} thing The value to test
  166. *
  167. * @returns {boolean} True if value is an FormData, otherwise false
  168. */
  169. const isFormData = (thing) => {
  170. const pattern = '[object FormData]';
  171. return thing && (
  172. (typeof FormData === 'function' && thing instanceof FormData) ||
  173. toString.call(thing) === pattern ||
  174. (isFunction(thing.toString) && thing.toString() === pattern)
  175. );
  176. };
  177. /**
  178. * Determine if a value is a URLSearchParams object
  179. *
  180. * @param {*} val The value to test
  181. *
  182. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  183. */
  184. const isURLSearchParams = kindOfTest('URLSearchParams');
  185. /**
  186. * Trim excess whitespace off the beginning and end of a string
  187. *
  188. * @param {String} str The String to trim
  189. *
  190. * @returns {String} The String freed of excess whitespace
  191. */
  192. const trim = (str) => str.trim ?
  193. str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  194. /**
  195. * Iterate over an Array or an Object invoking a function for each item.
  196. *
  197. * If `obj` is an Array callback will be called passing
  198. * the value, index, and complete array for each item.
  199. *
  200. * If 'obj' is an Object callback will be called passing
  201. * the value, key, and complete object for each property.
  202. *
  203. * @param {Object|Array} obj The object to iterate
  204. * @param {Function} fn The callback to invoke for each item
  205. *
  206. * @param {Boolean} [allOwnKeys = false]
  207. * @returns {any}
  208. */
  209. function forEach(obj, fn, {allOwnKeys = false} = {}) {
  210. // Don't bother if no value provided
  211. if (obj === null || typeof obj === 'undefined') {
  212. return;
  213. }
  214. let i;
  215. let l;
  216. // Force an array if not already something iterable
  217. if (typeof obj !== 'object') {
  218. /*eslint no-param-reassign:0*/
  219. obj = [obj];
  220. }
  221. if (isArray(obj)) {
  222. // Iterate over array values
  223. for (i = 0, l = obj.length; i < l; i++) {
  224. fn.call(null, obj[i], i, obj);
  225. }
  226. } else {
  227. // Iterate over object keys
  228. const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  229. const len = keys.length;
  230. let key;
  231. for (i = 0; i < len; i++) {
  232. key = keys[i];
  233. fn.call(null, obj[key], key, obj);
  234. }
  235. }
  236. }
  237. function findKey(obj, key) {
  238. key = key.toLowerCase();
  239. const keys = Object.keys(obj);
  240. let i = keys.length;
  241. let _key;
  242. while (i-- > 0) {
  243. _key = keys[i];
  244. if (key === _key.toLowerCase()) {
  245. return _key;
  246. }
  247. }
  248. return null;
  249. }
  250. const _global = (() => {
  251. /*eslint no-undef:0*/
  252. if (typeof globalThis !== "undefined") return globalThis;
  253. return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
  254. })();
  255. const isContextDefined = (context) => !isUndefined(context) && context !== _global;
  256. /**
  257. * Accepts varargs expecting each argument to be an object, then
  258. * immutably merges the properties of each object and returns result.
  259. *
  260. * When multiple objects contain the same key the later object in
  261. * the arguments list will take precedence.
  262. *
  263. * Example:
  264. *
  265. * ```js
  266. * var result = merge({foo: 123}, {foo: 456});
  267. * console.log(result.foo); // outputs 456
  268. * ```
  269. *
  270. * @param {Object} obj1 Object to merge
  271. *
  272. * @returns {Object} Result of all merge properties
  273. */
  274. function merge(/* obj1, obj2, obj3, ... */) {
  275. const {caseless} = isContextDefined(this) && this || {};
  276. const result = {};
  277. const assignValue = (val, key) => {
  278. const targetKey = caseless && findKey(result, key) || key;
  279. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  280. result[targetKey] = merge(result[targetKey], val);
  281. } else if (isPlainObject(val)) {
  282. result[targetKey] = merge({}, val);
  283. } else if (isArray(val)) {
  284. result[targetKey] = val.slice();
  285. } else {
  286. result[targetKey] = val;
  287. }
  288. };
  289. for (let i = 0, l = arguments.length; i < l; i++) {
  290. arguments[i] && forEach(arguments[i], assignValue);
  291. }
  292. return result;
  293. }
  294. /**
  295. * Extends object a by mutably adding to it the properties of object b.
  296. *
  297. * @param {Object} a The object to be extended
  298. * @param {Object} b The object to copy properties from
  299. * @param {Object} thisArg The object to bind function to
  300. *
  301. * @param {Boolean} [allOwnKeys]
  302. * @returns {Object} The resulting value of object a
  303. */
  304. const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
  305. forEach(b, (val, key) => {
  306. if (thisArg && isFunction(val)) {
  307. a[key] = bind(val, thisArg);
  308. } else {
  309. a[key] = val;
  310. }
  311. }, {allOwnKeys});
  312. return a;
  313. };
  314. /**
  315. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  316. *
  317. * @param {string} content with BOM
  318. *
  319. * @returns {string} content value without BOM
  320. */
  321. const stripBOM = (content) => {
  322. if (content.charCodeAt(0) === 0xFEFF) {
  323. content = content.slice(1);
  324. }
  325. return content;
  326. };
  327. /**
  328. * Inherit the prototype methods from one constructor into another
  329. * @param {function} constructor
  330. * @param {function} superConstructor
  331. * @param {object} [props]
  332. * @param {object} [descriptors]
  333. *
  334. * @returns {void}
  335. */
  336. const inherits = (constructor, superConstructor, props, descriptors) => {
  337. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  338. constructor.prototype.constructor = constructor;
  339. Object.defineProperty(constructor, 'super', {
  340. value: superConstructor.prototype
  341. });
  342. props && Object.assign(constructor.prototype, props);
  343. };
  344. /**
  345. * Resolve object with deep prototype chain to a flat object
  346. * @param {Object} sourceObj source object
  347. * @param {Object} [destObj]
  348. * @param {Function|Boolean} [filter]
  349. * @param {Function} [propFilter]
  350. *
  351. * @returns {Object}
  352. */
  353. const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
  354. let props;
  355. let i;
  356. let prop;
  357. const merged = {};
  358. destObj = destObj || {};
  359. // eslint-disable-next-line no-eq-null,eqeqeq
  360. if (sourceObj == null) return destObj;
  361. do {
  362. props = Object.getOwnPropertyNames(sourceObj);
  363. i = props.length;
  364. while (i-- > 0) {
  365. prop = props[i];
  366. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  367. destObj[prop] = sourceObj[prop];
  368. merged[prop] = true;
  369. }
  370. }
  371. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  372. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  373. return destObj;
  374. };
  375. /**
  376. * Determines whether a string ends with the characters of a specified string
  377. *
  378. * @param {String} str
  379. * @param {String} searchString
  380. * @param {Number} [position= 0]
  381. *
  382. * @returns {boolean}
  383. */
  384. const endsWith = (str, searchString, position) => {
  385. str = String(str);
  386. if (position === undefined || position > str.length) {
  387. position = str.length;
  388. }
  389. position -= searchString.length;
  390. const lastIndex = str.indexOf(searchString, position);
  391. return lastIndex !== -1 && lastIndex === position;
  392. };
  393. /**
  394. * Returns new array from array like object or null if failed
  395. *
  396. * @param {*} [thing]
  397. *
  398. * @returns {?Array}
  399. */
  400. const toArray = (thing) => {
  401. if (!thing) return null;
  402. if (isArray(thing)) return thing;
  403. let i = thing.length;
  404. if (!isNumber(i)) return null;
  405. const arr = new Array(i);
  406. while (i-- > 0) {
  407. arr[i] = thing[i];
  408. }
  409. return arr;
  410. };
  411. /**
  412. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  413. * thing passed in is an instance of Uint8Array
  414. *
  415. * @param {TypedArray}
  416. *
  417. * @returns {Array}
  418. */
  419. // eslint-disable-next-line func-names
  420. const isTypedArray = (TypedArray => {
  421. // eslint-disable-next-line func-names
  422. return thing => {
  423. return TypedArray && thing instanceof TypedArray;
  424. };
  425. })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  426. /**
  427. * For each entry in the object, call the function with the key and value.
  428. *
  429. * @param {Object<any, any>} obj - The object to iterate over.
  430. * @param {Function} fn - The function to call for each entry.
  431. *
  432. * @returns {void}
  433. */
  434. const forEachEntry = (obj, fn) => {
  435. const generator = obj && obj[Symbol.iterator];
  436. const iterator = generator.call(obj);
  437. let result;
  438. while ((result = iterator.next()) && !result.done) {
  439. const pair = result.value;
  440. fn.call(obj, pair[0], pair[1]);
  441. }
  442. };
  443. /**
  444. * It takes a regular expression and a string, and returns an array of all the matches
  445. *
  446. * @param {string} regExp - The regular expression to match against.
  447. * @param {string} str - The string to search.
  448. *
  449. * @returns {Array<boolean>}
  450. */
  451. const matchAll = (regExp, str) => {
  452. let matches;
  453. const arr = [];
  454. while ((matches = regExp.exec(str)) !== null) {
  455. arr.push(matches);
  456. }
  457. return arr;
  458. };
  459. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  460. const isHTMLForm = kindOfTest('HTMLFormElement');
  461. const toCamelCase = str => {
  462. return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
  463. function replacer(m, p1, p2) {
  464. return p1.toUpperCase() + p2;
  465. }
  466. );
  467. };
  468. /* Creating a function that will check if an object has a property. */
  469. const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
  470. /**
  471. * Determine if a value is a RegExp object
  472. *
  473. * @param {*} val The value to test
  474. *
  475. * @returns {boolean} True if value is a RegExp object, otherwise false
  476. */
  477. const isRegExp = kindOfTest('RegExp');
  478. const reduceDescriptors = (obj, reducer) => {
  479. const descriptors = Object.getOwnPropertyDescriptors(obj);
  480. const reducedDescriptors = {};
  481. forEach(descriptors, (descriptor, name) => {
  482. if (reducer(descriptor, name, obj) !== false) {
  483. reducedDescriptors[name] = descriptor;
  484. }
  485. });
  486. Object.defineProperties(obj, reducedDescriptors);
  487. };
  488. /**
  489. * Makes all methods read-only
  490. * @param {Object} obj
  491. */
  492. const freezeMethods = (obj) => {
  493. reduceDescriptors(obj, (descriptor, name) => {
  494. // skip restricted props in strict mode
  495. if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
  496. return false;
  497. }
  498. const value = obj[name];
  499. if (!isFunction(value)) return;
  500. descriptor.enumerable = false;
  501. if ('writable' in descriptor) {
  502. descriptor.writable = false;
  503. return;
  504. }
  505. if (!descriptor.set) {
  506. descriptor.set = () => {
  507. throw Error('Can not rewrite read-only method \'' + name + '\'');
  508. };
  509. }
  510. });
  511. };
  512. const toObjectSet = (arrayOrString, delimiter) => {
  513. const obj = {};
  514. const define = (arr) => {
  515. arr.forEach(value => {
  516. obj[value] = true;
  517. });
  518. };
  519. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  520. return obj;
  521. };
  522. const noop = () => {};
  523. const toFiniteNumber = (value, defaultValue) => {
  524. value = +value;
  525. return Number.isFinite(value) ? value : defaultValue;
  526. };
  527. const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
  528. const DIGIT = '0123456789';
  529. const ALPHABET = {
  530. DIGIT,
  531. ALPHA,
  532. ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
  533. };
  534. const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
  535. let str = '';
  536. const {length} = alphabet;
  537. while (size--) {
  538. str += alphabet[Math.random() * length|0];
  539. }
  540. return str;
  541. };
  542. /**
  543. * If the thing is a FormData object, return true, otherwise return false.
  544. *
  545. * @param {unknown} thing - The thing to check.
  546. *
  547. * @returns {boolean}
  548. */
  549. function isSpecCompliantForm(thing) {
  550. return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
  551. }
  552. const toJSONObject = (obj) => {
  553. const stack = new Array(10);
  554. const visit = (source, i) => {
  555. if (isObject(source)) {
  556. if (stack.indexOf(source) >= 0) {
  557. return;
  558. }
  559. if(!('toJSON' in source)) {
  560. stack[i] = source;
  561. const target = isArray(source) ? [] : {};
  562. forEach(source, (value, key) => {
  563. const reducedValue = visit(value, i + 1);
  564. !isUndefined(reducedValue) && (target[key] = reducedValue);
  565. });
  566. stack[i] = undefined;
  567. return target;
  568. }
  569. }
  570. return source;
  571. };
  572. return visit(obj, 0);
  573. };
  574. const utils = {
  575. isArray,
  576. isArrayBuffer,
  577. isBuffer,
  578. isFormData,
  579. isArrayBufferView,
  580. isString,
  581. isNumber,
  582. isBoolean,
  583. isObject,
  584. isPlainObject,
  585. isUndefined,
  586. isDate,
  587. isFile,
  588. isBlob,
  589. isRegExp,
  590. isFunction,
  591. isStream,
  592. isURLSearchParams,
  593. isTypedArray,
  594. isFileList,
  595. forEach,
  596. merge,
  597. extend,
  598. trim,
  599. stripBOM,
  600. inherits,
  601. toFlatObject,
  602. kindOf,
  603. kindOfTest,
  604. endsWith,
  605. toArray,
  606. forEachEntry,
  607. matchAll,
  608. isHTMLForm,
  609. hasOwnProperty,
  610. hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
  611. reduceDescriptors,
  612. freezeMethods,
  613. toObjectSet,
  614. toCamelCase,
  615. noop,
  616. toFiniteNumber,
  617. findKey,
  618. global: _global,
  619. isContextDefined,
  620. ALPHABET,
  621. generateString,
  622. isSpecCompliantForm,
  623. toJSONObject
  624. };
  625. /**
  626. * Create an Error with the specified message, config, error code, request and response.
  627. *
  628. * @param {string} message The error message.
  629. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  630. * @param {Object} [config] The config.
  631. * @param {Object} [request] The request.
  632. * @param {Object} [response] The response.
  633. *
  634. * @returns {Error} The created error.
  635. */
  636. function AxiosError$1(message, code, config, request, response) {
  637. Error.call(this);
  638. if (Error.captureStackTrace) {
  639. Error.captureStackTrace(this, this.constructor);
  640. } else {
  641. this.stack = (new Error()).stack;
  642. }
  643. this.message = message;
  644. this.name = 'AxiosError';
  645. code && (this.code = code);
  646. config && (this.config = config);
  647. request && (this.request = request);
  648. response && (this.response = response);
  649. }
  650. utils.inherits(AxiosError$1, Error, {
  651. toJSON: function toJSON() {
  652. return {
  653. // Standard
  654. message: this.message,
  655. name: this.name,
  656. // Microsoft
  657. description: this.description,
  658. number: this.number,
  659. // Mozilla
  660. fileName: this.fileName,
  661. lineNumber: this.lineNumber,
  662. columnNumber: this.columnNumber,
  663. stack: this.stack,
  664. // Axios
  665. config: utils.toJSONObject(this.config),
  666. code: this.code,
  667. status: this.response && this.response.status ? this.response.status : null
  668. };
  669. }
  670. });
  671. const prototype$1 = AxiosError$1.prototype;
  672. const descriptors = {};
  673. [
  674. 'ERR_BAD_OPTION_VALUE',
  675. 'ERR_BAD_OPTION',
  676. 'ECONNABORTED',
  677. 'ETIMEDOUT',
  678. 'ERR_NETWORK',
  679. 'ERR_FR_TOO_MANY_REDIRECTS',
  680. 'ERR_DEPRECATED',
  681. 'ERR_BAD_RESPONSE',
  682. 'ERR_BAD_REQUEST',
  683. 'ERR_CANCELED',
  684. 'ERR_NOT_SUPPORT',
  685. 'ERR_INVALID_URL'
  686. // eslint-disable-next-line func-names
  687. ].forEach(code => {
  688. descriptors[code] = {value: code};
  689. });
  690. Object.defineProperties(AxiosError$1, descriptors);
  691. Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
  692. // eslint-disable-next-line func-names
  693. AxiosError$1.from = (error, code, config, request, response, customProps) => {
  694. const axiosError = Object.create(prototype$1);
  695. utils.toFlatObject(error, axiosError, function filter(obj) {
  696. return obj !== Error.prototype;
  697. }, prop => {
  698. return prop !== 'isAxiosError';
  699. });
  700. AxiosError$1.call(axiosError, error.message, code, config, request, response);
  701. axiosError.cause = error;
  702. axiosError.name = error.name;
  703. customProps && Object.assign(axiosError, customProps);
  704. return axiosError;
  705. };
  706. // eslint-disable-next-line strict
  707. const httpAdapter = null;
  708. /**
  709. * Determines if the given thing is a array or js object.
  710. *
  711. * @param {string} thing - The object or array to be visited.
  712. *
  713. * @returns {boolean}
  714. */
  715. function isVisitable(thing) {
  716. return utils.isPlainObject(thing) || utils.isArray(thing);
  717. }
  718. /**
  719. * It removes the brackets from the end of a string
  720. *
  721. * @param {string} key - The key of the parameter.
  722. *
  723. * @returns {string} the key without the brackets.
  724. */
  725. function removeBrackets(key) {
  726. return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
  727. }
  728. /**
  729. * It takes a path, a key, and a boolean, and returns a string
  730. *
  731. * @param {string} path - The path to the current key.
  732. * @param {string} key - The key of the current object being iterated over.
  733. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  734. *
  735. * @returns {string} The path to the current key.
  736. */
  737. function renderKey(path, key, dots) {
  738. if (!path) return key;
  739. return path.concat(key).map(function each(token, i) {
  740. // eslint-disable-next-line no-param-reassign
  741. token = removeBrackets(token);
  742. return !dots && i ? '[' + token + ']' : token;
  743. }).join(dots ? '.' : '');
  744. }
  745. /**
  746. * If the array is an array and none of its elements are visitable, then it's a flat array.
  747. *
  748. * @param {Array<any>} arr - The array to check
  749. *
  750. * @returns {boolean}
  751. */
  752. function isFlatArray(arr) {
  753. return utils.isArray(arr) && !arr.some(isVisitable);
  754. }
  755. const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
  756. return /^is[A-Z]/.test(prop);
  757. });
  758. /**
  759. * Convert a data object to FormData
  760. *
  761. * @param {Object} obj
  762. * @param {?Object} [formData]
  763. * @param {?Object} [options]
  764. * @param {Function} [options.visitor]
  765. * @param {Boolean} [options.metaTokens = true]
  766. * @param {Boolean} [options.dots = false]
  767. * @param {?Boolean} [options.indexes = false]
  768. *
  769. * @returns {Object}
  770. **/
  771. /**
  772. * It converts an object into a FormData object
  773. *
  774. * @param {Object<any, any>} obj - The object to convert to form data.
  775. * @param {string} formData - The FormData object to append to.
  776. * @param {Object<string, any>} options
  777. *
  778. * @returns
  779. */
  780. function toFormData$1(obj, formData, options) {
  781. if (!utils.isObject(obj)) {
  782. throw new TypeError('target must be an object');
  783. }
  784. // eslint-disable-next-line no-param-reassign
  785. formData = formData || new (FormData)();
  786. // eslint-disable-next-line no-param-reassign
  787. options = utils.toFlatObject(options, {
  788. metaTokens: true,
  789. dots: false,
  790. indexes: false
  791. }, false, function defined(option, source) {
  792. // eslint-disable-next-line no-eq-null,eqeqeq
  793. return !utils.isUndefined(source[option]);
  794. });
  795. const metaTokens = options.metaTokens;
  796. // eslint-disable-next-line no-use-before-define
  797. const visitor = options.visitor || defaultVisitor;
  798. const dots = options.dots;
  799. const indexes = options.indexes;
  800. const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  801. const useBlob = _Blob && utils.isSpecCompliantForm(formData);
  802. if (!utils.isFunction(visitor)) {
  803. throw new TypeError('visitor must be a function');
  804. }
  805. function convertValue(value) {
  806. if (value === null) return '';
  807. if (utils.isDate(value)) {
  808. return value.toISOString();
  809. }
  810. if (!useBlob && utils.isBlob(value)) {
  811. throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
  812. }
  813. if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
  814. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  815. }
  816. return value;
  817. }
  818. /**
  819. * Default visitor.
  820. *
  821. * @param {*} value
  822. * @param {String|Number} key
  823. * @param {Array<String|Number>} path
  824. * @this {FormData}
  825. *
  826. * @returns {boolean} return true to visit the each prop of the value recursively
  827. */
  828. function defaultVisitor(value, key, path) {
  829. let arr = value;
  830. if (value && !path && typeof value === 'object') {
  831. if (utils.endsWith(key, '{}')) {
  832. // eslint-disable-next-line no-param-reassign
  833. key = metaTokens ? key : key.slice(0, -2);
  834. // eslint-disable-next-line no-param-reassign
  835. value = JSON.stringify(value);
  836. } else if (
  837. (utils.isArray(value) && isFlatArray(value)) ||
  838. ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
  839. )) {
  840. // eslint-disable-next-line no-param-reassign
  841. key = removeBrackets(key);
  842. arr.forEach(function each(el, index) {
  843. !(utils.isUndefined(el) || el === null) && formData.append(
  844. // eslint-disable-next-line no-nested-ternary
  845. indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
  846. convertValue(el)
  847. );
  848. });
  849. return false;
  850. }
  851. }
  852. if (isVisitable(value)) {
  853. return true;
  854. }
  855. formData.append(renderKey(path, key, dots), convertValue(value));
  856. return false;
  857. }
  858. const stack = [];
  859. const exposedHelpers = Object.assign(predicates, {
  860. defaultVisitor,
  861. convertValue,
  862. isVisitable
  863. });
  864. function build(value, path) {
  865. if (utils.isUndefined(value)) return;
  866. if (stack.indexOf(value) !== -1) {
  867. throw Error('Circular reference detected in ' + path.join('.'));
  868. }
  869. stack.push(value);
  870. utils.forEach(value, function each(el, key) {
  871. const result = !(utils.isUndefined(el) || el === null) && visitor.call(
  872. formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
  873. );
  874. if (result === true) {
  875. build(el, path ? path.concat(key) : [key]);
  876. }
  877. });
  878. stack.pop();
  879. }
  880. if (!utils.isObject(obj)) {
  881. throw new TypeError('data must be an object');
  882. }
  883. build(obj);
  884. return formData;
  885. }
  886. /**
  887. * It encodes a string by replacing all characters that are not in the unreserved set with
  888. * their percent-encoded equivalents
  889. *
  890. * @param {string} str - The string to encode.
  891. *
  892. * @returns {string} The encoded string.
  893. */
  894. function encode$1(str) {
  895. const charMap = {
  896. '!': '%21',
  897. "'": '%27',
  898. '(': '%28',
  899. ')': '%29',
  900. '~': '%7E',
  901. '%20': '+',
  902. '%00': '\x00'
  903. };
  904. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  905. return charMap[match];
  906. });
  907. }
  908. /**
  909. * It takes a params object and converts it to a FormData object
  910. *
  911. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  912. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  913. *
  914. * @returns {void}
  915. */
  916. function AxiosURLSearchParams(params, options) {
  917. this._pairs = [];
  918. params && toFormData$1(params, this, options);
  919. }
  920. const prototype = AxiosURLSearchParams.prototype;
  921. prototype.append = function append(name, value) {
  922. this._pairs.push([name, value]);
  923. };
  924. prototype.toString = function toString(encoder) {
  925. const _encode = encoder ? function(value) {
  926. return encoder.call(this, value, encode$1);
  927. } : encode$1;
  928. return this._pairs.map(function each(pair) {
  929. return _encode(pair[0]) + '=' + _encode(pair[1]);
  930. }, '').join('&');
  931. };
  932. /**
  933. * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
  934. * URI encoded counterparts
  935. *
  936. * @param {string} val The value to be encoded.
  937. *
  938. * @returns {string} The encoded value.
  939. */
  940. function encode(val) {
  941. return encodeURIComponent(val).
  942. replace(/%3A/gi, ':').
  943. replace(/%24/g, '$').
  944. replace(/%2C/gi, ',').
  945. replace(/%20/g, '+').
  946. replace(/%5B/gi, '[').
  947. replace(/%5D/gi, ']');
  948. }
  949. /**
  950. * Build a URL by appending params to the end
  951. *
  952. * @param {string} url The base of the url (e.g., http://www.google.com)
  953. * @param {object} [params] The params to be appended
  954. * @param {?object} options
  955. *
  956. * @returns {string} The formatted url
  957. */
  958. function buildURL(url, params, options) {
  959. /*eslint no-param-reassign:0*/
  960. if (!params) {
  961. return url;
  962. }
  963. const _encode = options && options.encode || encode;
  964. const serializeFn = options && options.serialize;
  965. let serializedParams;
  966. if (serializeFn) {
  967. serializedParams = serializeFn(params, options);
  968. } else {
  969. serializedParams = utils.isURLSearchParams(params) ?
  970. params.toString() :
  971. new AxiosURLSearchParams(params, options).toString(_encode);
  972. }
  973. if (serializedParams) {
  974. const hashmarkIndex = url.indexOf("#");
  975. if (hashmarkIndex !== -1) {
  976. url = url.slice(0, hashmarkIndex);
  977. }
  978. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  979. }
  980. return url;
  981. }
  982. class InterceptorManager {
  983. constructor() {
  984. this.handlers = [];
  985. }
  986. /**
  987. * Add a new interceptor to the stack
  988. *
  989. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  990. * @param {Function} rejected The function to handle `reject` for a `Promise`
  991. *
  992. * @return {Number} An ID used to remove interceptor later
  993. */
  994. use(fulfilled, rejected, options) {
  995. this.handlers.push({
  996. fulfilled,
  997. rejected,
  998. synchronous: options ? options.synchronous : false,
  999. runWhen: options ? options.runWhen : null
  1000. });
  1001. return this.handlers.length - 1;
  1002. }
  1003. /**
  1004. * Remove an interceptor from the stack
  1005. *
  1006. * @param {Number} id The ID that was returned by `use`
  1007. *
  1008. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  1009. */
  1010. eject(id) {
  1011. if (this.handlers[id]) {
  1012. this.handlers[id] = null;
  1013. }
  1014. }
  1015. /**
  1016. * Clear all interceptors from the stack
  1017. *
  1018. * @returns {void}
  1019. */
  1020. clear() {
  1021. if (this.handlers) {
  1022. this.handlers = [];
  1023. }
  1024. }
  1025. /**
  1026. * Iterate over all the registered interceptors
  1027. *
  1028. * This method is particularly useful for skipping over any
  1029. * interceptors that may have become `null` calling `eject`.
  1030. *
  1031. * @param {Function} fn The function to call for each interceptor
  1032. *
  1033. * @returns {void}
  1034. */
  1035. forEach(fn) {
  1036. utils.forEach(this.handlers, function forEachHandler(h) {
  1037. if (h !== null) {
  1038. fn(h);
  1039. }
  1040. });
  1041. }
  1042. }
  1043. const InterceptorManager$1 = InterceptorManager;
  1044. const transitionalDefaults = {
  1045. silentJSONParsing: true,
  1046. forcedJSONParsing: true,
  1047. clarifyTimeoutError: false
  1048. };
  1049. const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  1050. const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
  1051. const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
  1052. /**
  1053. * Determine if we're running in a standard browser environment
  1054. *
  1055. * This allows axios to run in a web worker, and react-native.
  1056. * Both environments support XMLHttpRequest, but not fully standard globals.
  1057. *
  1058. * web workers:
  1059. * typeof window -> undefined
  1060. * typeof document -> undefined
  1061. *
  1062. * react-native:
  1063. * navigator.product -> 'ReactNative'
  1064. * nativescript
  1065. * navigator.product -> 'NativeScript' or 'NS'
  1066. *
  1067. * @returns {boolean}
  1068. */
  1069. const isStandardBrowserEnv = (() => {
  1070. let product;
  1071. if (typeof navigator !== 'undefined' && (
  1072. (product = navigator.product) === 'ReactNative' ||
  1073. product === 'NativeScript' ||
  1074. product === 'NS')
  1075. ) {
  1076. return false;
  1077. }
  1078. return typeof window !== 'undefined' && typeof document !== 'undefined';
  1079. })();
  1080. /**
  1081. * Determine if we're running in a standard browser webWorker environment
  1082. *
  1083. * Although the `isStandardBrowserEnv` method indicates that
  1084. * `allows axios to run in a web worker`, the WebWorker will still be
  1085. * filtered out due to its judgment standard
  1086. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  1087. * This leads to a problem when axios post `FormData` in webWorker
  1088. */
  1089. const isStandardBrowserWebWorkerEnv = (() => {
  1090. return (
  1091. typeof WorkerGlobalScope !== 'undefined' &&
  1092. // eslint-disable-next-line no-undef
  1093. self instanceof WorkerGlobalScope &&
  1094. typeof self.importScripts === 'function'
  1095. );
  1096. })();
  1097. const platform = {
  1098. isBrowser: true,
  1099. classes: {
  1100. URLSearchParams: URLSearchParams$1,
  1101. FormData: FormData$1,
  1102. Blob: Blob$1
  1103. },
  1104. isStandardBrowserEnv,
  1105. isStandardBrowserWebWorkerEnv,
  1106. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  1107. };
  1108. function toURLEncodedForm(data, options) {
  1109. return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
  1110. visitor: function(value, key, path, helpers) {
  1111. if (platform.isNode && utils.isBuffer(value)) {
  1112. this.append(key, value.toString('base64'));
  1113. return false;
  1114. }
  1115. return helpers.defaultVisitor.apply(this, arguments);
  1116. }
  1117. }, options));
  1118. }
  1119. /**
  1120. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1121. *
  1122. * @param {string} name - The name of the property to get.
  1123. *
  1124. * @returns An array of strings.
  1125. */
  1126. function parsePropPath(name) {
  1127. // foo[x][y][z]
  1128. // foo.x.y.z
  1129. // foo-x-y-z
  1130. // foo x y z
  1131. return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
  1132. return match[0] === '[]' ? '' : match[1] || match[0];
  1133. });
  1134. }
  1135. /**
  1136. * Convert an array to an object.
  1137. *
  1138. * @param {Array<any>} arr - The array to convert to an object.
  1139. *
  1140. * @returns An object with the same keys and values as the array.
  1141. */
  1142. function arrayToObject(arr) {
  1143. const obj = {};
  1144. const keys = Object.keys(arr);
  1145. let i;
  1146. const len = keys.length;
  1147. let key;
  1148. for (i = 0; i < len; i++) {
  1149. key = keys[i];
  1150. obj[key] = arr[key];
  1151. }
  1152. return obj;
  1153. }
  1154. /**
  1155. * It takes a FormData object and returns a JavaScript object
  1156. *
  1157. * @param {string} formData The FormData object to convert to JSON.
  1158. *
  1159. * @returns {Object<string, any> | null} The converted object.
  1160. */
  1161. function formDataToJSON(formData) {
  1162. function buildPath(path, value, target, index) {
  1163. let name = path[index++];
  1164. const isNumericKey = Number.isFinite(+name);
  1165. const isLast = index >= path.length;
  1166. name = !name && utils.isArray(target) ? target.length : name;
  1167. if (isLast) {
  1168. if (utils.hasOwnProp(target, name)) {
  1169. target[name] = [target[name], value];
  1170. } else {
  1171. target[name] = value;
  1172. }
  1173. return !isNumericKey;
  1174. }
  1175. if (!target[name] || !utils.isObject(target[name])) {
  1176. target[name] = [];
  1177. }
  1178. const result = buildPath(path, value, target[name], index);
  1179. if (result && utils.isArray(target[name])) {
  1180. target[name] = arrayToObject(target[name]);
  1181. }
  1182. return !isNumericKey;
  1183. }
  1184. if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
  1185. const obj = {};
  1186. utils.forEachEntry(formData, (name, value) => {
  1187. buildPath(parsePropPath(name), value, obj, 0);
  1188. });
  1189. return obj;
  1190. }
  1191. return null;
  1192. }
  1193. const DEFAULT_CONTENT_TYPE = {
  1194. 'Content-Type': undefined
  1195. };
  1196. /**
  1197. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1198. * of the input
  1199. *
  1200. * @param {any} rawValue - The value to be stringified.
  1201. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1202. * @param {Function} encoder - A function that takes a value and returns a string.
  1203. *
  1204. * @returns {string} A stringified version of the rawValue.
  1205. */
  1206. function stringifySafely(rawValue, parser, encoder) {
  1207. if (utils.isString(rawValue)) {
  1208. try {
  1209. (parser || JSON.parse)(rawValue);
  1210. return utils.trim(rawValue);
  1211. } catch (e) {
  1212. if (e.name !== 'SyntaxError') {
  1213. throw e;
  1214. }
  1215. }
  1216. }
  1217. return (encoder || JSON.stringify)(rawValue);
  1218. }
  1219. const defaults = {
  1220. transitional: transitionalDefaults,
  1221. adapter: ['xhr', 'http'],
  1222. transformRequest: [function transformRequest(data, headers) {
  1223. const contentType = headers.getContentType() || '';
  1224. const hasJSONContentType = contentType.indexOf('application/json') > -1;
  1225. const isObjectPayload = utils.isObject(data);
  1226. if (isObjectPayload && utils.isHTMLForm(data)) {
  1227. data = new FormData(data);
  1228. }
  1229. const isFormData = utils.isFormData(data);
  1230. if (isFormData) {
  1231. if (!hasJSONContentType) {
  1232. return data;
  1233. }
  1234. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1235. }
  1236. if (utils.isArrayBuffer(data) ||
  1237. utils.isBuffer(data) ||
  1238. utils.isStream(data) ||
  1239. utils.isFile(data) ||
  1240. utils.isBlob(data)
  1241. ) {
  1242. return data;
  1243. }
  1244. if (utils.isArrayBufferView(data)) {
  1245. return data.buffer;
  1246. }
  1247. if (utils.isURLSearchParams(data)) {
  1248. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1249. return data.toString();
  1250. }
  1251. let isFileList;
  1252. if (isObjectPayload) {
  1253. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1254. return toURLEncodedForm(data, this.formSerializer).toString();
  1255. }
  1256. if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  1257. const _FormData = this.env && this.env.FormData;
  1258. return toFormData$1(
  1259. isFileList ? {'files[]': data} : data,
  1260. _FormData && new _FormData(),
  1261. this.formSerializer
  1262. );
  1263. }
  1264. }
  1265. if (isObjectPayload || hasJSONContentType ) {
  1266. headers.setContentType('application/json', false);
  1267. return stringifySafely(data);
  1268. }
  1269. return data;
  1270. }],
  1271. transformResponse: [function transformResponse(data) {
  1272. const transitional = this.transitional || defaults.transitional;
  1273. const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1274. const JSONRequested = this.responseType === 'json';
  1275. if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
  1276. const silentJSONParsing = transitional && transitional.silentJSONParsing;
  1277. const strictJSONParsing = !silentJSONParsing && JSONRequested;
  1278. try {
  1279. return JSON.parse(data);
  1280. } catch (e) {
  1281. if (strictJSONParsing) {
  1282. if (e.name === 'SyntaxError') {
  1283. throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
  1284. }
  1285. throw e;
  1286. }
  1287. }
  1288. }
  1289. return data;
  1290. }],
  1291. /**
  1292. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1293. * timeout is not created.
  1294. */
  1295. timeout: 0,
  1296. xsrfCookieName: 'XSRF-TOKEN',
  1297. xsrfHeaderName: 'X-XSRF-TOKEN',
  1298. maxContentLength: -1,
  1299. maxBodyLength: -1,
  1300. env: {
  1301. FormData: platform.classes.FormData,
  1302. Blob: platform.classes.Blob
  1303. },
  1304. validateStatus: function validateStatus(status) {
  1305. return status >= 200 && status < 300;
  1306. },
  1307. headers: {
  1308. common: {
  1309. 'Accept': 'application/json, text/plain, */*'
  1310. }
  1311. }
  1312. };
  1313. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1314. defaults.headers[method] = {};
  1315. });
  1316. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1317. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1318. });
  1319. const defaults$1 = defaults;
  1320. // RawAxiosHeaders whose duplicates are ignored by node
  1321. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1322. const ignoreDuplicateOf = utils.toObjectSet([
  1323. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1324. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1325. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1326. 'referer', 'retry-after', 'user-agent'
  1327. ]);
  1328. /**
  1329. * Parse headers into an object
  1330. *
  1331. * ```
  1332. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1333. * Content-Type: application/json
  1334. * Connection: keep-alive
  1335. * Transfer-Encoding: chunked
  1336. * ```
  1337. *
  1338. * @param {String} rawHeaders Headers needing to be parsed
  1339. *
  1340. * @returns {Object} Headers parsed into an object
  1341. */
  1342. const parseHeaders = rawHeaders => {
  1343. const parsed = {};
  1344. let key;
  1345. let val;
  1346. let i;
  1347. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  1348. i = line.indexOf(':');
  1349. key = line.substring(0, i).trim().toLowerCase();
  1350. val = line.substring(i + 1).trim();
  1351. if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
  1352. return;
  1353. }
  1354. if (key === 'set-cookie') {
  1355. if (parsed[key]) {
  1356. parsed[key].push(val);
  1357. } else {
  1358. parsed[key] = [val];
  1359. }
  1360. } else {
  1361. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1362. }
  1363. });
  1364. return parsed;
  1365. };
  1366. const $internals = Symbol('internals');
  1367. function normalizeHeader(header) {
  1368. return header && String(header).trim().toLowerCase();
  1369. }
  1370. function normalizeValue(value) {
  1371. if (value === false || value == null) {
  1372. return value;
  1373. }
  1374. return utils.isArray(value) ? value.map(normalizeValue) : String(value);
  1375. }
  1376. function parseTokens(str) {
  1377. const tokens = Object.create(null);
  1378. const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1379. let match;
  1380. while ((match = tokensRE.exec(str))) {
  1381. tokens[match[1]] = match[2];
  1382. }
  1383. return tokens;
  1384. }
  1385. const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  1386. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  1387. if (utils.isFunction(filter)) {
  1388. return filter.call(this, value, header);
  1389. }
  1390. if (isHeaderNameFilter) {
  1391. value = header;
  1392. }
  1393. if (!utils.isString(value)) return;
  1394. if (utils.isString(filter)) {
  1395. return value.indexOf(filter) !== -1;
  1396. }
  1397. if (utils.isRegExp(filter)) {
  1398. return filter.test(value);
  1399. }
  1400. }
  1401. function formatHeader(header) {
  1402. return header.trim()
  1403. .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
  1404. return char.toUpperCase() + str;
  1405. });
  1406. }
  1407. function buildAccessors(obj, header) {
  1408. const accessorName = utils.toCamelCase(' ' + header);
  1409. ['get', 'set', 'has'].forEach(methodName => {
  1410. Object.defineProperty(obj, methodName + accessorName, {
  1411. value: function(arg1, arg2, arg3) {
  1412. return this[methodName].call(this, header, arg1, arg2, arg3);
  1413. },
  1414. configurable: true
  1415. });
  1416. });
  1417. }
  1418. class AxiosHeaders$1 {
  1419. constructor(headers) {
  1420. headers && this.set(headers);
  1421. }
  1422. set(header, valueOrRewrite, rewrite) {
  1423. const self = this;
  1424. function setHeader(_value, _header, _rewrite) {
  1425. const lHeader = normalizeHeader(_header);
  1426. if (!lHeader) {
  1427. throw new Error('header name must be a non-empty string');
  1428. }
  1429. const key = utils.findKey(self, lHeader);
  1430. if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
  1431. self[key || _header] = normalizeValue(_value);
  1432. }
  1433. }
  1434. const setHeaders = (headers, _rewrite) =>
  1435. utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
  1436. if (utils.isPlainObject(header) || header instanceof this.constructor) {
  1437. setHeaders(header, valueOrRewrite);
  1438. } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  1439. setHeaders(parseHeaders(header), valueOrRewrite);
  1440. } else {
  1441. header != null && setHeader(valueOrRewrite, header, rewrite);
  1442. }
  1443. return this;
  1444. }
  1445. get(header, parser) {
  1446. header = normalizeHeader(header);
  1447. if (header) {
  1448. const key = utils.findKey(this, header);
  1449. if (key) {
  1450. const value = this[key];
  1451. if (!parser) {
  1452. return value;
  1453. }
  1454. if (parser === true) {
  1455. return parseTokens(value);
  1456. }
  1457. if (utils.isFunction(parser)) {
  1458. return parser.call(this, value, key);
  1459. }
  1460. if (utils.isRegExp(parser)) {
  1461. return parser.exec(value);
  1462. }
  1463. throw new TypeError('parser must be boolean|regexp|function');
  1464. }
  1465. }
  1466. }
  1467. has(header, matcher) {
  1468. header = normalizeHeader(header);
  1469. if (header) {
  1470. const key = utils.findKey(this, header);
  1471. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  1472. }
  1473. return false;
  1474. }
  1475. delete(header, matcher) {
  1476. const self = this;
  1477. let deleted = false;
  1478. function deleteHeader(_header) {
  1479. _header = normalizeHeader(_header);
  1480. if (_header) {
  1481. const key = utils.findKey(self, _header);
  1482. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  1483. delete self[key];
  1484. deleted = true;
  1485. }
  1486. }
  1487. }
  1488. if (utils.isArray(header)) {
  1489. header.forEach(deleteHeader);
  1490. } else {
  1491. deleteHeader(header);
  1492. }
  1493. return deleted;
  1494. }
  1495. clear(matcher) {
  1496. const keys = Object.keys(this);
  1497. let i = keys.length;
  1498. let deleted = false;
  1499. while (i--) {
  1500. const key = keys[i];
  1501. if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  1502. delete this[key];
  1503. deleted = true;
  1504. }
  1505. }
  1506. return deleted;
  1507. }
  1508. normalize(format) {
  1509. const self = this;
  1510. const headers = {};
  1511. utils.forEach(this, (value, header) => {
  1512. const key = utils.findKey(headers, header);
  1513. if (key) {
  1514. self[key] = normalizeValue(value);
  1515. delete self[header];
  1516. return;
  1517. }
  1518. const normalized = format ? formatHeader(header) : String(header).trim();
  1519. if (normalized !== header) {
  1520. delete self[header];
  1521. }
  1522. self[normalized] = normalizeValue(value);
  1523. headers[normalized] = true;
  1524. });
  1525. return this;
  1526. }
  1527. concat(...targets) {
  1528. return this.constructor.concat(this, ...targets);
  1529. }
  1530. toJSON(asStrings) {
  1531. const obj = Object.create(null);
  1532. utils.forEach(this, (value, header) => {
  1533. value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
  1534. });
  1535. return obj;
  1536. }
  1537. [Symbol.iterator]() {
  1538. return Object.entries(this.toJSON())[Symbol.iterator]();
  1539. }
  1540. toString() {
  1541. return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
  1542. }
  1543. get [Symbol.toStringTag]() {
  1544. return 'AxiosHeaders';
  1545. }
  1546. static from(thing) {
  1547. return thing instanceof this ? thing : new this(thing);
  1548. }
  1549. static concat(first, ...targets) {
  1550. const computed = new this(first);
  1551. targets.forEach((target) => computed.set(target));
  1552. return computed;
  1553. }
  1554. static accessor(header) {
  1555. const internals = this[$internals] = (this[$internals] = {
  1556. accessors: {}
  1557. });
  1558. const accessors = internals.accessors;
  1559. const prototype = this.prototype;
  1560. function defineAccessor(_header) {
  1561. const lHeader = normalizeHeader(_header);
  1562. if (!accessors[lHeader]) {
  1563. buildAccessors(prototype, _header);
  1564. accessors[lHeader] = true;
  1565. }
  1566. }
  1567. utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  1568. return this;
  1569. }
  1570. }
  1571. AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  1572. utils.freezeMethods(AxiosHeaders$1.prototype);
  1573. utils.freezeMethods(AxiosHeaders$1);
  1574. const AxiosHeaders$2 = AxiosHeaders$1;
  1575. /**
  1576. * Transform the data for a request or a response
  1577. *
  1578. * @param {Array|Function} fns A single function or Array of functions
  1579. * @param {?Object} response The response object
  1580. *
  1581. * @returns {*} The resulting transformed data
  1582. */
  1583. function transformData(fns, response) {
  1584. const config = this || defaults$1;
  1585. const context = response || config;
  1586. const headers = AxiosHeaders$2.from(context.headers);
  1587. let data = context.data;
  1588. utils.forEach(fns, function transform(fn) {
  1589. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  1590. });
  1591. headers.normalize();
  1592. return data;
  1593. }
  1594. function isCancel$1(value) {
  1595. return !!(value && value.__CANCEL__);
  1596. }
  1597. /**
  1598. * A `CanceledError` is an object that is thrown when an operation is canceled.
  1599. *
  1600. * @param {string=} message The message.
  1601. * @param {Object=} config The config.
  1602. * @param {Object=} request The request.
  1603. *
  1604. * @returns {CanceledError} The created error.
  1605. */
  1606. function CanceledError$1(message, config, request) {
  1607. // eslint-disable-next-line no-eq-null,eqeqeq
  1608. AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
  1609. this.name = 'CanceledError';
  1610. }
  1611. utils.inherits(CanceledError$1, AxiosError$1, {
  1612. __CANCEL__: true
  1613. });
  1614. /**
  1615. * Resolve or reject a Promise based on response status.
  1616. *
  1617. * @param {Function} resolve A function that resolves the promise.
  1618. * @param {Function} reject A function that rejects the promise.
  1619. * @param {object} response The response.
  1620. *
  1621. * @returns {object} The response.
  1622. */
  1623. function settle(resolve, reject, response) {
  1624. const validateStatus = response.config.validateStatus;
  1625. if (!response.status || !validateStatus || validateStatus(response.status)) {
  1626. resolve(response);
  1627. } else {
  1628. reject(new AxiosError$1(
  1629. 'Request failed with status code ' + response.status,
  1630. [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
  1631. response.config,
  1632. response.request,
  1633. response
  1634. ));
  1635. }
  1636. }
  1637. const cookies = platform.isStandardBrowserEnv ?
  1638. // Standard browser envs support document.cookie
  1639. (function standardBrowserEnv() {
  1640. return {
  1641. write: function write(name, value, expires, path, domain, secure) {
  1642. const cookie = [];
  1643. cookie.push(name + '=' + encodeURIComponent(value));
  1644. if (utils.isNumber(expires)) {
  1645. cookie.push('expires=' + new Date(expires).toGMTString());
  1646. }
  1647. if (utils.isString(path)) {
  1648. cookie.push('path=' + path);
  1649. }
  1650. if (utils.isString(domain)) {
  1651. cookie.push('domain=' + domain);
  1652. }
  1653. if (secure === true) {
  1654. cookie.push('secure');
  1655. }
  1656. document.cookie = cookie.join('; ');
  1657. },
  1658. read: function read(name) {
  1659. const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1660. return (match ? decodeURIComponent(match[3]) : null);
  1661. },
  1662. remove: function remove(name) {
  1663. this.write(name, '', Date.now() - 86400000);
  1664. }
  1665. };
  1666. })() :
  1667. // Non standard browser env (web workers, react-native) lack needed support.
  1668. (function nonStandardBrowserEnv() {
  1669. return {
  1670. write: function write() {},
  1671. read: function read() { return null; },
  1672. remove: function remove() {}
  1673. };
  1674. })();
  1675. /**
  1676. * Determines whether the specified URL is absolute
  1677. *
  1678. * @param {string} url The URL to test
  1679. *
  1680. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1681. */
  1682. function isAbsoluteURL(url) {
  1683. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1684. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1685. // by any combination of letters, digits, plus, period, or hyphen.
  1686. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1687. }
  1688. /**
  1689. * Creates a new URL by combining the specified URLs
  1690. *
  1691. * @param {string} baseURL The base URL
  1692. * @param {string} relativeURL The relative URL
  1693. *
  1694. * @returns {string} The combined URL
  1695. */
  1696. function combineURLs(baseURL, relativeURL) {
  1697. return relativeURL
  1698. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1699. : baseURL;
  1700. }
  1701. /**
  1702. * Creates a new URL by combining the baseURL with the requestedURL,
  1703. * only when the requestedURL is not already an absolute URL.
  1704. * If the requestURL is absolute, this function returns the requestedURL untouched.
  1705. *
  1706. * @param {string} baseURL The base URL
  1707. * @param {string} requestedURL Absolute or relative URL to combine
  1708. *
  1709. * @returns {string} The combined full path
  1710. */
  1711. function buildFullPath(baseURL, requestedURL) {
  1712. if (baseURL && !isAbsoluteURL(requestedURL)) {
  1713. return combineURLs(baseURL, requestedURL);
  1714. }
  1715. return requestedURL;
  1716. }
  1717. const isURLSameOrigin = platform.isStandardBrowserEnv ?
  1718. // Standard browser envs have full support of the APIs needed to test
  1719. // whether the request URL is of the same origin as current location.
  1720. (function standardBrowserEnv() {
  1721. const msie = /(msie|trident)/i.test(navigator.userAgent);
  1722. const urlParsingNode = document.createElement('a');
  1723. let originURL;
  1724. /**
  1725. * Parse a URL to discover it's components
  1726. *
  1727. * @param {String} url The URL to be parsed
  1728. * @returns {Object}
  1729. */
  1730. function resolveURL(url) {
  1731. let href = url;
  1732. if (msie) {
  1733. // IE needs attribute set twice to normalize properties
  1734. urlParsingNode.setAttribute('href', href);
  1735. href = urlParsingNode.href;
  1736. }
  1737. urlParsingNode.setAttribute('href', href);
  1738. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1739. return {
  1740. href: urlParsingNode.href,
  1741. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1742. host: urlParsingNode.host,
  1743. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1744. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1745. hostname: urlParsingNode.hostname,
  1746. port: urlParsingNode.port,
  1747. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1748. urlParsingNode.pathname :
  1749. '/' + urlParsingNode.pathname
  1750. };
  1751. }
  1752. originURL = resolveURL(window.location.href);
  1753. /**
  1754. * Determine if a URL shares the same origin as the current location
  1755. *
  1756. * @param {String} requestURL The URL to test
  1757. * @returns {boolean} True if URL shares the same origin, otherwise false
  1758. */
  1759. return function isURLSameOrigin(requestURL) {
  1760. const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1761. return (parsed.protocol === originURL.protocol &&
  1762. parsed.host === originURL.host);
  1763. };
  1764. })() :
  1765. // Non standard browser envs (web workers, react-native) lack needed support.
  1766. (function nonStandardBrowserEnv() {
  1767. return function isURLSameOrigin() {
  1768. return true;
  1769. };
  1770. })();
  1771. function parseProtocol(url) {
  1772. const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1773. return match && match[1] || '';
  1774. }
  1775. /**
  1776. * Calculate data maxRate
  1777. * @param {Number} [samplesCount= 10]
  1778. * @param {Number} [min= 1000]
  1779. * @returns {Function}
  1780. */
  1781. function speedometer(samplesCount, min) {
  1782. samplesCount = samplesCount || 10;
  1783. const bytes = new Array(samplesCount);
  1784. const timestamps = new Array(samplesCount);
  1785. let head = 0;
  1786. let tail = 0;
  1787. let firstSampleTS;
  1788. min = min !== undefined ? min : 1000;
  1789. return function push(chunkLength) {
  1790. const now = Date.now();
  1791. const startedAt = timestamps[tail];
  1792. if (!firstSampleTS) {
  1793. firstSampleTS = now;
  1794. }
  1795. bytes[head] = chunkLength;
  1796. timestamps[head] = now;
  1797. let i = tail;
  1798. let bytesCount = 0;
  1799. while (i !== head) {
  1800. bytesCount += bytes[i++];
  1801. i = i % samplesCount;
  1802. }
  1803. head = (head + 1) % samplesCount;
  1804. if (head === tail) {
  1805. tail = (tail + 1) % samplesCount;
  1806. }
  1807. if (now - firstSampleTS < min) {
  1808. return;
  1809. }
  1810. const passed = startedAt && now - startedAt;
  1811. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  1812. };
  1813. }
  1814. function progressEventReducer(listener, isDownloadStream) {
  1815. let bytesNotified = 0;
  1816. const _speedometer = speedometer(50, 250);
  1817. return e => {
  1818. const loaded = e.loaded;
  1819. const total = e.lengthComputable ? e.total : undefined;
  1820. const progressBytes = loaded - bytesNotified;
  1821. const rate = _speedometer(progressBytes);
  1822. const inRange = loaded <= total;
  1823. bytesNotified = loaded;
  1824. const data = {
  1825. loaded,
  1826. total,
  1827. progress: total ? (loaded / total) : undefined,
  1828. bytes: progressBytes,
  1829. rate: rate ? rate : undefined,
  1830. estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
  1831. event: e
  1832. };
  1833. data[isDownloadStream ? 'download' : 'upload'] = true;
  1834. listener(data);
  1835. };
  1836. }
  1837. const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  1838. const xhrAdapter = isXHRAdapterSupported && function (config) {
  1839. return new Promise(function dispatchXhrRequest(resolve, reject) {
  1840. let requestData = config.data;
  1841. const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
  1842. const responseType = config.responseType;
  1843. let onCanceled;
  1844. function done() {
  1845. if (config.cancelToken) {
  1846. config.cancelToken.unsubscribe(onCanceled);
  1847. }
  1848. if (config.signal) {
  1849. config.signal.removeEventListener('abort', onCanceled);
  1850. }
  1851. }
  1852. if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
  1853. requestHeaders.setContentType(false); // Let the browser set it
  1854. }
  1855. let request = new XMLHttpRequest();
  1856. // HTTP basic authentication
  1857. if (config.auth) {
  1858. const username = config.auth.username || '';
  1859. const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  1860. requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
  1861. }
  1862. const fullPath = buildFullPath(config.baseURL, config.url);
  1863. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  1864. // Set the request timeout in MS
  1865. request.timeout = config.timeout;
  1866. function onloadend() {
  1867. if (!request) {
  1868. return;
  1869. }
  1870. // Prepare the response
  1871. const responseHeaders = AxiosHeaders$2.from(
  1872. 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
  1873. );
  1874. const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  1875. request.responseText : request.response;
  1876. const response = {
  1877. data: responseData,
  1878. status: request.status,
  1879. statusText: request.statusText,
  1880. headers: responseHeaders,
  1881. config,
  1882. request
  1883. };
  1884. settle(function _resolve(value) {
  1885. resolve(value);
  1886. done();
  1887. }, function _reject(err) {
  1888. reject(err);
  1889. done();
  1890. }, response);
  1891. // Clean up request
  1892. request = null;
  1893. }
  1894. if ('onloadend' in request) {
  1895. // Use onloadend if available
  1896. request.onloadend = onloadend;
  1897. } else {
  1898. // Listen for ready state to emulate onloadend
  1899. request.onreadystatechange = function handleLoad() {
  1900. if (!request || request.readyState !== 4) {
  1901. return;
  1902. }
  1903. // The request errored out and we didn't get a response, this will be
  1904. // handled by onerror instead
  1905. // With one exception: request that using file: protocol, most browsers
  1906. // will return status as 0 even though it's a successful request
  1907. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  1908. return;
  1909. }
  1910. // readystate handler is calling before onerror or ontimeout handlers,
  1911. // so we should call onloadend on the next 'tick'
  1912. setTimeout(onloadend);
  1913. };
  1914. }
  1915. // Handle browser request cancellation (as opposed to a manual cancellation)
  1916. request.onabort = function handleAbort() {
  1917. if (!request) {
  1918. return;
  1919. }
  1920. reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
  1921. // Clean up request
  1922. request = null;
  1923. };
  1924. // Handle low level network errors
  1925. request.onerror = function handleError() {
  1926. // Real errors are hidden from us by the browser
  1927. // onerror should only fire if it's a network error
  1928. reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
  1929. // Clean up request
  1930. request = null;
  1931. };
  1932. // Handle timeout
  1933. request.ontimeout = function handleTimeout() {
  1934. let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  1935. const transitional = config.transitional || transitionalDefaults;
  1936. if (config.timeoutErrorMessage) {
  1937. timeoutErrorMessage = config.timeoutErrorMessage;
  1938. }
  1939. reject(new AxiosError$1(
  1940. timeoutErrorMessage,
  1941. transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
  1942. config,
  1943. request));
  1944. // Clean up request
  1945. request = null;
  1946. };
  1947. // Add xsrf header
  1948. // This is only done if running in a standard browser environment.
  1949. // Specifically not if we're in a web worker, or react-native.
  1950. if (platform.isStandardBrowserEnv) {
  1951. // Add xsrf header
  1952. const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
  1953. && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
  1954. if (xsrfValue) {
  1955. requestHeaders.set(config.xsrfHeaderName, xsrfValue);
  1956. }
  1957. }
  1958. // Remove Content-Type if data is undefined
  1959. requestData === undefined && requestHeaders.setContentType(null);
  1960. // Add headers to the request
  1961. if ('setRequestHeader' in request) {
  1962. utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  1963. request.setRequestHeader(key, val);
  1964. });
  1965. }
  1966. // Add withCredentials to request if needed
  1967. if (!utils.isUndefined(config.withCredentials)) {
  1968. request.withCredentials = !!config.withCredentials;
  1969. }
  1970. // Add responseType to request if needed
  1971. if (responseType && responseType !== 'json') {
  1972. request.responseType = config.responseType;
  1973. }
  1974. // Handle progress if needed
  1975. if (typeof config.onDownloadProgress === 'function') {
  1976. request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
  1977. }
  1978. // Not all browsers support upload events
  1979. if (typeof config.onUploadProgress === 'function' && request.upload) {
  1980. request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
  1981. }
  1982. if (config.cancelToken || config.signal) {
  1983. // Handle cancellation
  1984. // eslint-disable-next-line func-names
  1985. onCanceled = cancel => {
  1986. if (!request) {
  1987. return;
  1988. }
  1989. reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
  1990. request.abort();
  1991. request = null;
  1992. };
  1993. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  1994. if (config.signal) {
  1995. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  1996. }
  1997. }
  1998. const protocol = parseProtocol(fullPath);
  1999. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  2000. reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
  2001. return;
  2002. }
  2003. // Send the request
  2004. request.send(requestData || null);
  2005. });
  2006. };
  2007. const knownAdapters = {
  2008. http: httpAdapter,
  2009. xhr: xhrAdapter
  2010. };
  2011. utils.forEach(knownAdapters, (fn, value) => {
  2012. if(fn) {
  2013. try {
  2014. Object.defineProperty(fn, 'name', {value});
  2015. } catch (e) {
  2016. // eslint-disable-next-line no-empty
  2017. }
  2018. Object.defineProperty(fn, 'adapterName', {value});
  2019. }
  2020. });
  2021. const adapters = {
  2022. getAdapter: (adapters) => {
  2023. adapters = utils.isArray(adapters) ? adapters : [adapters];
  2024. const {length} = adapters;
  2025. let nameOrAdapter;
  2026. let adapter;
  2027. for (let i = 0; i < length; i++) {
  2028. nameOrAdapter = adapters[i];
  2029. if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
  2030. break;
  2031. }
  2032. }
  2033. if (!adapter) {
  2034. if (adapter === false) {
  2035. throw new AxiosError$1(
  2036. `Adapter ${nameOrAdapter} is not supported by the environment`,
  2037. 'ERR_NOT_SUPPORT'
  2038. );
  2039. }
  2040. throw new Error(
  2041. utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
  2042. `Adapter '${nameOrAdapter}' is not available in the build` :
  2043. `Unknown adapter '${nameOrAdapter}'`
  2044. );
  2045. }
  2046. if (!utils.isFunction(adapter)) {
  2047. throw new TypeError('adapter is not a function');
  2048. }
  2049. return adapter;
  2050. },
  2051. adapters: knownAdapters
  2052. };
  2053. /**
  2054. * Throws a `CanceledError` if cancellation has been requested.
  2055. *
  2056. * @param {Object} config The config that is to be used for the request
  2057. *
  2058. * @returns {void}
  2059. */
  2060. function throwIfCancellationRequested(config) {
  2061. if (config.cancelToken) {
  2062. config.cancelToken.throwIfRequested();
  2063. }
  2064. if (config.signal && config.signal.aborted) {
  2065. throw new CanceledError$1(null, config);
  2066. }
  2067. }
  2068. /**
  2069. * Dispatch a request to the server using the configured adapter.
  2070. *
  2071. * @param {object} config The config that is to be used for the request
  2072. *
  2073. * @returns {Promise} The Promise to be fulfilled
  2074. */
  2075. function dispatchRequest(config) {
  2076. throwIfCancellationRequested(config);
  2077. config.headers = AxiosHeaders$2.from(config.headers);
  2078. // Transform request data
  2079. config.data = transformData.call(
  2080. config,
  2081. config.transformRequest
  2082. );
  2083. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  2084. config.headers.setContentType('application/x-www-form-urlencoded', false);
  2085. }
  2086. const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
  2087. return adapter(config).then(function onAdapterResolution(response) {
  2088. throwIfCancellationRequested(config);
  2089. // Transform response data
  2090. response.data = transformData.call(
  2091. config,
  2092. config.transformResponse,
  2093. response
  2094. );
  2095. response.headers = AxiosHeaders$2.from(response.headers);
  2096. return response;
  2097. }, function onAdapterRejection(reason) {
  2098. if (!isCancel$1(reason)) {
  2099. throwIfCancellationRequested(config);
  2100. // Transform response data
  2101. if (reason && reason.response) {
  2102. reason.response.data = transformData.call(
  2103. config,
  2104. config.transformResponse,
  2105. reason.response
  2106. );
  2107. reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
  2108. }
  2109. }
  2110. return Promise.reject(reason);
  2111. });
  2112. }
  2113. const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSON() : thing;
  2114. /**
  2115. * Config-specific merge-function which creates a new config-object
  2116. * by merging two configuration objects together.
  2117. *
  2118. * @param {Object} config1
  2119. * @param {Object} config2
  2120. *
  2121. * @returns {Object} New object resulting from merging config2 to config1
  2122. */
  2123. function mergeConfig$1(config1, config2) {
  2124. // eslint-disable-next-line no-param-reassign
  2125. config2 = config2 || {};
  2126. const config = {};
  2127. function getMergedValue(target, source, caseless) {
  2128. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  2129. return utils.merge.call({caseless}, target, source);
  2130. } else if (utils.isPlainObject(source)) {
  2131. return utils.merge({}, source);
  2132. } else if (utils.isArray(source)) {
  2133. return source.slice();
  2134. }
  2135. return source;
  2136. }
  2137. // eslint-disable-next-line consistent-return
  2138. function mergeDeepProperties(a, b, caseless) {
  2139. if (!utils.isUndefined(b)) {
  2140. return getMergedValue(a, b, caseless);
  2141. } else if (!utils.isUndefined(a)) {
  2142. return getMergedValue(undefined, a, caseless);
  2143. }
  2144. }
  2145. // eslint-disable-next-line consistent-return
  2146. function valueFromConfig2(a, b) {
  2147. if (!utils.isUndefined(b)) {
  2148. return getMergedValue(undefined, b);
  2149. }
  2150. }
  2151. // eslint-disable-next-line consistent-return
  2152. function defaultToConfig2(a, b) {
  2153. if (!utils.isUndefined(b)) {
  2154. return getMergedValue(undefined, b);
  2155. } else if (!utils.isUndefined(a)) {
  2156. return getMergedValue(undefined, a);
  2157. }
  2158. }
  2159. // eslint-disable-next-line consistent-return
  2160. function mergeDirectKeys(a, b, prop) {
  2161. if (prop in config2) {
  2162. return getMergedValue(a, b);
  2163. } else if (prop in config1) {
  2164. return getMergedValue(undefined, a);
  2165. }
  2166. }
  2167. const mergeMap = {
  2168. url: valueFromConfig2,
  2169. method: valueFromConfig2,
  2170. data: valueFromConfig2,
  2171. baseURL: defaultToConfig2,
  2172. transformRequest: defaultToConfig2,
  2173. transformResponse: defaultToConfig2,
  2174. paramsSerializer: defaultToConfig2,
  2175. timeout: defaultToConfig2,
  2176. timeoutMessage: defaultToConfig2,
  2177. withCredentials: defaultToConfig2,
  2178. adapter: defaultToConfig2,
  2179. responseType: defaultToConfig2,
  2180. xsrfCookieName: defaultToConfig2,
  2181. xsrfHeaderName: defaultToConfig2,
  2182. onUploadProgress: defaultToConfig2,
  2183. onDownloadProgress: defaultToConfig2,
  2184. decompress: defaultToConfig2,
  2185. maxContentLength: defaultToConfig2,
  2186. maxBodyLength: defaultToConfig2,
  2187. beforeRedirect: defaultToConfig2,
  2188. transport: defaultToConfig2,
  2189. httpAgent: defaultToConfig2,
  2190. httpsAgent: defaultToConfig2,
  2191. cancelToken: defaultToConfig2,
  2192. socketPath: defaultToConfig2,
  2193. responseEncoding: defaultToConfig2,
  2194. validateStatus: mergeDirectKeys,
  2195. headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
  2196. };
  2197. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  2198. const merge = mergeMap[prop] || mergeDeepProperties;
  2199. const configValue = merge(config1[prop], config2[prop], prop);
  2200. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  2201. });
  2202. return config;
  2203. }
  2204. const VERSION$1 = "1.3.5";
  2205. const validators$1 = {};
  2206. // eslint-disable-next-line func-names
  2207. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
  2208. validators$1[type] = function validator(thing) {
  2209. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  2210. };
  2211. });
  2212. const deprecatedWarnings = {};
  2213. /**
  2214. * Transitional option validator
  2215. *
  2216. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  2217. * @param {string?} version - deprecated version / removed since version
  2218. * @param {string?} message - some message with additional info
  2219. *
  2220. * @returns {function}
  2221. */
  2222. validators$1.transitional = function transitional(validator, version, message) {
  2223. function formatMessage(opt, desc) {
  2224. return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  2225. }
  2226. // eslint-disable-next-line func-names
  2227. return (value, opt, opts) => {
  2228. if (validator === false) {
  2229. throw new AxiosError$1(
  2230. formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
  2231. AxiosError$1.ERR_DEPRECATED
  2232. );
  2233. }
  2234. if (version && !deprecatedWarnings[opt]) {
  2235. deprecatedWarnings[opt] = true;
  2236. // eslint-disable-next-line no-console
  2237. console.warn(
  2238. formatMessage(
  2239. opt,
  2240. ' has been deprecated since v' + version + ' and will be removed in the near future'
  2241. )
  2242. );
  2243. }
  2244. return validator ? validator(value, opt, opts) : true;
  2245. };
  2246. };
  2247. /**
  2248. * Assert object's properties type
  2249. *
  2250. * @param {object} options
  2251. * @param {object} schema
  2252. * @param {boolean?} allowUnknown
  2253. *
  2254. * @returns {object}
  2255. */
  2256. function assertOptions(options, schema, allowUnknown) {
  2257. if (typeof options !== 'object') {
  2258. throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
  2259. }
  2260. const keys = Object.keys(options);
  2261. let i = keys.length;
  2262. while (i-- > 0) {
  2263. const opt = keys[i];
  2264. const validator = schema[opt];
  2265. if (validator) {
  2266. const value = options[opt];
  2267. const result = value === undefined || validator(value, opt, options);
  2268. if (result !== true) {
  2269. throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
  2270. }
  2271. continue;
  2272. }
  2273. if (allowUnknown !== true) {
  2274. throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
  2275. }
  2276. }
  2277. }
  2278. const validator = {
  2279. assertOptions,
  2280. validators: validators$1
  2281. };
  2282. const validators = validator.validators;
  2283. /**
  2284. * Create a new instance of Axios
  2285. *
  2286. * @param {Object} instanceConfig The default config for the instance
  2287. *
  2288. * @return {Axios} A new instance of Axios
  2289. */
  2290. class Axios$1 {
  2291. constructor(instanceConfig) {
  2292. this.defaults = instanceConfig;
  2293. this.interceptors = {
  2294. request: new InterceptorManager$1(),
  2295. response: new InterceptorManager$1()
  2296. };
  2297. }
  2298. /**
  2299. * Dispatch a request
  2300. *
  2301. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  2302. * @param {?Object} config
  2303. *
  2304. * @returns {Promise} The Promise to be fulfilled
  2305. */
  2306. request(configOrUrl, config) {
  2307. /*eslint no-param-reassign:0*/
  2308. // Allow for axios('example/url'[, config]) a la fetch API
  2309. if (typeof configOrUrl === 'string') {
  2310. config = config || {};
  2311. config.url = configOrUrl;
  2312. } else {
  2313. config = configOrUrl || {};
  2314. }
  2315. config = mergeConfig$1(this.defaults, config);
  2316. const {transitional, paramsSerializer, headers} = config;
  2317. if (transitional !== undefined) {
  2318. validator.assertOptions(transitional, {
  2319. silentJSONParsing: validators.transitional(validators.boolean),
  2320. forcedJSONParsing: validators.transitional(validators.boolean),
  2321. clarifyTimeoutError: validators.transitional(validators.boolean)
  2322. }, false);
  2323. }
  2324. if (paramsSerializer != null) {
  2325. if (utils.isFunction(paramsSerializer)) {
  2326. config.paramsSerializer = {
  2327. serialize: paramsSerializer
  2328. };
  2329. } else {
  2330. validator.assertOptions(paramsSerializer, {
  2331. encode: validators.function,
  2332. serialize: validators.function
  2333. }, true);
  2334. }
  2335. }
  2336. // Set config.method
  2337. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  2338. let contextHeaders;
  2339. // Flatten headers
  2340. contextHeaders = headers && utils.merge(
  2341. headers.common,
  2342. headers[config.method]
  2343. );
  2344. contextHeaders && utils.forEach(
  2345. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  2346. (method) => {
  2347. delete headers[method];
  2348. }
  2349. );
  2350. config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
  2351. // filter out skipped interceptors
  2352. const requestInterceptorChain = [];
  2353. let synchronousRequestInterceptors = true;
  2354. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  2355. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  2356. return;
  2357. }
  2358. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  2359. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  2360. });
  2361. const responseInterceptorChain = [];
  2362. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  2363. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  2364. });
  2365. let promise;
  2366. let i = 0;
  2367. let len;
  2368. if (!synchronousRequestInterceptors) {
  2369. const chain = [dispatchRequest.bind(this), undefined];
  2370. chain.unshift.apply(chain, requestInterceptorChain);
  2371. chain.push.apply(chain, responseInterceptorChain);
  2372. len = chain.length;
  2373. promise = Promise.resolve(config);
  2374. while (i < len) {
  2375. promise = promise.then(chain[i++], chain[i++]);
  2376. }
  2377. return promise;
  2378. }
  2379. len = requestInterceptorChain.length;
  2380. let newConfig = config;
  2381. i = 0;
  2382. while (i < len) {
  2383. const onFulfilled = requestInterceptorChain[i++];
  2384. const onRejected = requestInterceptorChain[i++];
  2385. try {
  2386. newConfig = onFulfilled(newConfig);
  2387. } catch (error) {
  2388. onRejected.call(this, error);
  2389. break;
  2390. }
  2391. }
  2392. try {
  2393. promise = dispatchRequest.call(this, newConfig);
  2394. } catch (error) {
  2395. return Promise.reject(error);
  2396. }
  2397. i = 0;
  2398. len = responseInterceptorChain.length;
  2399. while (i < len) {
  2400. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  2401. }
  2402. return promise;
  2403. }
  2404. getUri(config) {
  2405. config = mergeConfig$1(this.defaults, config);
  2406. const fullPath = buildFullPath(config.baseURL, config.url);
  2407. return buildURL(fullPath, config.params, config.paramsSerializer);
  2408. }
  2409. }
  2410. // Provide aliases for supported request methods
  2411. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  2412. /*eslint func-names:0*/
  2413. Axios$1.prototype[method] = function(url, config) {
  2414. return this.request(mergeConfig$1(config || {}, {
  2415. method,
  2416. url,
  2417. data: (config || {}).data
  2418. }));
  2419. };
  2420. });
  2421. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  2422. /*eslint func-names:0*/
  2423. function generateHTTPMethod(isForm) {
  2424. return function httpMethod(url, data, config) {
  2425. return this.request(mergeConfig$1(config || {}, {
  2426. method,
  2427. headers: isForm ? {
  2428. 'Content-Type': 'multipart/form-data'
  2429. } : {},
  2430. url,
  2431. data
  2432. }));
  2433. };
  2434. }
  2435. Axios$1.prototype[method] = generateHTTPMethod();
  2436. Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
  2437. });
  2438. const Axios$2 = Axios$1;
  2439. /**
  2440. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  2441. *
  2442. * @param {Function} executor The executor function.
  2443. *
  2444. * @returns {CancelToken}
  2445. */
  2446. class CancelToken$1 {
  2447. constructor(executor) {
  2448. if (typeof executor !== 'function') {
  2449. throw new TypeError('executor must be a function.');
  2450. }
  2451. let resolvePromise;
  2452. this.promise = new Promise(function promiseExecutor(resolve) {
  2453. resolvePromise = resolve;
  2454. });
  2455. const token = this;
  2456. // eslint-disable-next-line func-names
  2457. this.promise.then(cancel => {
  2458. if (!token._listeners) return;
  2459. let i = token._listeners.length;
  2460. while (i-- > 0) {
  2461. token._listeners[i](cancel);
  2462. }
  2463. token._listeners = null;
  2464. });
  2465. // eslint-disable-next-line func-names
  2466. this.promise.then = onfulfilled => {
  2467. let _resolve;
  2468. // eslint-disable-next-line func-names
  2469. const promise = new Promise(resolve => {
  2470. token.subscribe(resolve);
  2471. _resolve = resolve;
  2472. }).then(onfulfilled);
  2473. promise.cancel = function reject() {
  2474. token.unsubscribe(_resolve);
  2475. };
  2476. return promise;
  2477. };
  2478. executor(function cancel(message, config, request) {
  2479. if (token.reason) {
  2480. // Cancellation has already been requested
  2481. return;
  2482. }
  2483. token.reason = new CanceledError$1(message, config, request);
  2484. resolvePromise(token.reason);
  2485. });
  2486. }
  2487. /**
  2488. * Throws a `CanceledError` if cancellation has been requested.
  2489. */
  2490. throwIfRequested() {
  2491. if (this.reason) {
  2492. throw this.reason;
  2493. }
  2494. }
  2495. /**
  2496. * Subscribe to the cancel signal
  2497. */
  2498. subscribe(listener) {
  2499. if (this.reason) {
  2500. listener(this.reason);
  2501. return;
  2502. }
  2503. if (this._listeners) {
  2504. this._listeners.push(listener);
  2505. } else {
  2506. this._listeners = [listener];
  2507. }
  2508. }
  2509. /**
  2510. * Unsubscribe from the cancel signal
  2511. */
  2512. unsubscribe(listener) {
  2513. if (!this._listeners) {
  2514. return;
  2515. }
  2516. const index = this._listeners.indexOf(listener);
  2517. if (index !== -1) {
  2518. this._listeners.splice(index, 1);
  2519. }
  2520. }
  2521. /**
  2522. * Returns an object that contains a new `CancelToken` and a function that, when called,
  2523. * cancels the `CancelToken`.
  2524. */
  2525. static source() {
  2526. let cancel;
  2527. const token = new CancelToken$1(function executor(c) {
  2528. cancel = c;
  2529. });
  2530. return {
  2531. token,
  2532. cancel
  2533. };
  2534. }
  2535. }
  2536. const CancelToken$2 = CancelToken$1;
  2537. /**
  2538. * Syntactic sugar for invoking a function and expanding an array for arguments.
  2539. *
  2540. * Common use case would be to use `Function.prototype.apply`.
  2541. *
  2542. * ```js
  2543. * function f(x, y, z) {}
  2544. * var args = [1, 2, 3];
  2545. * f.apply(null, args);
  2546. * ```
  2547. *
  2548. * With `spread` this example can be re-written.
  2549. *
  2550. * ```js
  2551. * spread(function(x, y, z) {})([1, 2, 3]);
  2552. * ```
  2553. *
  2554. * @param {Function} callback
  2555. *
  2556. * @returns {Function}
  2557. */
  2558. function spread$1(callback) {
  2559. return function wrap(arr) {
  2560. return callback.apply(null, arr);
  2561. };
  2562. }
  2563. /**
  2564. * Determines whether the payload is an error thrown by Axios
  2565. *
  2566. * @param {*} payload The value to test
  2567. *
  2568. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  2569. */
  2570. function isAxiosError$1(payload) {
  2571. return utils.isObject(payload) && (payload.isAxiosError === true);
  2572. }
  2573. const HttpStatusCode$1 = {
  2574. Continue: 100,
  2575. SwitchingProtocols: 101,
  2576. Processing: 102,
  2577. EarlyHints: 103,
  2578. Ok: 200,
  2579. Created: 201,
  2580. Accepted: 202,
  2581. NonAuthoritativeInformation: 203,
  2582. NoContent: 204,
  2583. ResetContent: 205,
  2584. PartialContent: 206,
  2585. MultiStatus: 207,
  2586. AlreadyReported: 208,
  2587. ImUsed: 226,
  2588. MultipleChoices: 300,
  2589. MovedPermanently: 301,
  2590. Found: 302,
  2591. SeeOther: 303,
  2592. NotModified: 304,
  2593. UseProxy: 305,
  2594. Unused: 306,
  2595. TemporaryRedirect: 307,
  2596. PermanentRedirect: 308,
  2597. BadRequest: 400,
  2598. Unauthorized: 401,
  2599. PaymentRequired: 402,
  2600. Forbidden: 403,
  2601. NotFound: 404,
  2602. MethodNotAllowed: 405,
  2603. NotAcceptable: 406,
  2604. ProxyAuthenticationRequired: 407,
  2605. RequestTimeout: 408,
  2606. Conflict: 409,
  2607. Gone: 410,
  2608. LengthRequired: 411,
  2609. PreconditionFailed: 412,
  2610. PayloadTooLarge: 413,
  2611. UriTooLong: 414,
  2612. UnsupportedMediaType: 415,
  2613. RangeNotSatisfiable: 416,
  2614. ExpectationFailed: 417,
  2615. ImATeapot: 418,
  2616. MisdirectedRequest: 421,
  2617. UnprocessableEntity: 422,
  2618. Locked: 423,
  2619. FailedDependency: 424,
  2620. TooEarly: 425,
  2621. UpgradeRequired: 426,
  2622. PreconditionRequired: 428,
  2623. TooManyRequests: 429,
  2624. RequestHeaderFieldsTooLarge: 431,
  2625. UnavailableForLegalReasons: 451,
  2626. InternalServerError: 500,
  2627. NotImplemented: 501,
  2628. BadGateway: 502,
  2629. ServiceUnavailable: 503,
  2630. GatewayTimeout: 504,
  2631. HttpVersionNotSupported: 505,
  2632. VariantAlsoNegotiates: 506,
  2633. InsufficientStorage: 507,
  2634. LoopDetected: 508,
  2635. NotExtended: 510,
  2636. NetworkAuthenticationRequired: 511,
  2637. };
  2638. Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
  2639. HttpStatusCode$1[value] = key;
  2640. });
  2641. const HttpStatusCode$2 = HttpStatusCode$1;
  2642. /**
  2643. * Create an instance of Axios
  2644. *
  2645. * @param {Object} defaultConfig The default config for the instance
  2646. *
  2647. * @returns {Axios} A new instance of Axios
  2648. */
  2649. function createInstance(defaultConfig) {
  2650. const context = new Axios$2(defaultConfig);
  2651. const instance = bind(Axios$2.prototype.request, context);
  2652. // Copy axios.prototype to instance
  2653. utils.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
  2654. // Copy context to instance
  2655. utils.extend(instance, context, null, {allOwnKeys: true});
  2656. // Factory for creating new instances
  2657. instance.create = function create(instanceConfig) {
  2658. return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
  2659. };
  2660. return instance;
  2661. }
  2662. // Create the default instance to be exported
  2663. const axios = createInstance(defaults$1);
  2664. // Expose Axios class to allow class inheritance
  2665. axios.Axios = Axios$2;
  2666. // Expose Cancel & CancelToken
  2667. axios.CanceledError = CanceledError$1;
  2668. axios.CancelToken = CancelToken$2;
  2669. axios.isCancel = isCancel$1;
  2670. axios.VERSION = VERSION$1;
  2671. axios.toFormData = toFormData$1;
  2672. // Expose AxiosError class
  2673. axios.AxiosError = AxiosError$1;
  2674. // alias for CanceledError for backward compatibility
  2675. axios.Cancel = axios.CanceledError;
  2676. // Expose all/spread
  2677. axios.all = function all(promises) {
  2678. return Promise.all(promises);
  2679. };
  2680. axios.spread = spread$1;
  2681. // Expose isAxiosError
  2682. axios.isAxiosError = isAxiosError$1;
  2683. // Expose mergeConfig
  2684. axios.mergeConfig = mergeConfig$1;
  2685. axios.AxiosHeaders = AxiosHeaders$2;
  2686. axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
  2687. axios.HttpStatusCode = HttpStatusCode$2;
  2688. axios.default = axios;
  2689. // this module should only have a default export
  2690. const axios$1 = axios;
  2691. // This module is intended to unwrap Axios default export as named.
  2692. // Keep top-level export same with static properties
  2693. // so that it can keep same with es module or cjs
  2694. const {
  2695. Axios,
  2696. AxiosError,
  2697. CanceledError,
  2698. isCancel,
  2699. CancelToken,
  2700. VERSION,
  2701. all,
  2702. Cancel,
  2703. isAxiosError,
  2704. spread,
  2705. toFormData,
  2706. AxiosHeaders,
  2707. HttpStatusCode,
  2708. formToJSON,
  2709. mergeConfig
  2710. } = axios$1;
  2711. export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
  2712. //# sourceMappingURL=axios.js.map