axios.js 94 KB

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