axios.js 113 KB

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