axios.js 148 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494
  1. /*! Axios v1.15.0 Copyright (c) 2026 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 _OverloadYield(e, d) {
  8. this.v = e, this.k = d;
  9. }
  10. function _arrayLikeToArray(r, a) {
  11. (null == a || a > r.length) && (a = r.length);
  12. for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  13. return n;
  14. }
  15. function _arrayWithHoles(r) {
  16. if (Array.isArray(r)) return r;
  17. }
  18. function _arrayWithoutHoles(r) {
  19. if (Array.isArray(r)) return _arrayLikeToArray(r);
  20. }
  21. function _assertThisInitialized(e) {
  22. if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  23. return e;
  24. }
  25. function _asyncGeneratorDelegate(t) {
  26. var e = {},
  27. n = false;
  28. function pump(e, r) {
  29. return n = true, r = new Promise(function (n) {
  30. n(t[e](r));
  31. }), {
  32. done: false,
  33. value: new _OverloadYield(r, 1)
  34. };
  35. }
  36. return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function () {
  37. return this;
  38. }, e.next = function (t) {
  39. return n ? (n = false, t) : pump("next", t);
  40. }, "function" == typeof t.throw && (e.throw = function (t) {
  41. if (n) throw n = false, t;
  42. return pump("throw", t);
  43. }), "function" == typeof t.return && (e.return = function (t) {
  44. return n ? (n = false, t) : pump("return", t);
  45. }), e;
  46. }
  47. function _asyncIterator(r) {
  48. var n,
  49. t,
  50. o,
  51. e = 2;
  52. for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
  53. if (t && null != (n = r[t])) return n.call(r);
  54. if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
  55. t = "@@asyncIterator", o = "@@iterator";
  56. }
  57. throw new TypeError("Object is not async iterable");
  58. }
  59. function AsyncFromSyncIterator(r) {
  60. function AsyncFromSyncIteratorContinuation(r) {
  61. if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
  62. var n = r.done;
  63. return Promise.resolve(r.value).then(function (r) {
  64. return {
  65. value: r,
  66. done: n
  67. };
  68. });
  69. }
  70. return AsyncFromSyncIterator = function (r) {
  71. this.s = r, this.n = r.next;
  72. }, AsyncFromSyncIterator.prototype = {
  73. s: null,
  74. n: null,
  75. next: function () {
  76. return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
  77. },
  78. return: function (r) {
  79. var n = this.s.return;
  80. return void 0 === n ? Promise.resolve({
  81. value: r,
  82. done: true
  83. }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
  84. },
  85. throw: function (r) {
  86. var n = this.s.return;
  87. return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
  88. }
  89. }, new AsyncFromSyncIterator(r);
  90. }
  91. function asyncGeneratorStep(n, t, e, r, o, a, c) {
  92. try {
  93. var i = n[a](c),
  94. u = i.value;
  95. } catch (n) {
  96. return void e(n);
  97. }
  98. i.done ? t(u) : Promise.resolve(u).then(r, o);
  99. }
  100. function _asyncToGenerator(n) {
  101. return function () {
  102. var t = this,
  103. e = arguments;
  104. return new Promise(function (r, o) {
  105. var a = n.apply(t, e);
  106. function _next(n) {
  107. asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
  108. }
  109. function _throw(n) {
  110. asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
  111. }
  112. _next(void 0);
  113. });
  114. };
  115. }
  116. function _awaitAsyncGenerator(e) {
  117. return new _OverloadYield(e, 0);
  118. }
  119. function _callSuper(t, o, e) {
  120. return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
  121. }
  122. function _classCallCheck(a, n) {
  123. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  124. }
  125. function _construct(t, e, r) {
  126. if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
  127. var o = [null];
  128. o.push.apply(o, e);
  129. var p = new (t.bind.apply(t, o))();
  130. return r && _setPrototypeOf(p, r.prototype), p;
  131. }
  132. function _defineProperties(e, r) {
  133. for (var t = 0; t < r.length; t++) {
  134. var o = r[t];
  135. o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
  136. }
  137. }
  138. function _createClass(e, r, t) {
  139. return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
  140. writable: false
  141. }), e;
  142. }
  143. function _createForOfIteratorHelper(r, e) {
  144. var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  145. if (!t) {
  146. if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
  147. t && (r = t);
  148. var n = 0,
  149. F = function () {};
  150. return {
  151. s: F,
  152. n: function () {
  153. return n >= r.length ? {
  154. done: true
  155. } : {
  156. done: false,
  157. value: r[n++]
  158. };
  159. },
  160. e: function (r) {
  161. throw r;
  162. },
  163. f: F
  164. };
  165. }
  166. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  167. }
  168. var o,
  169. a = true,
  170. u = false;
  171. return {
  172. s: function () {
  173. t = t.call(r);
  174. },
  175. n: function () {
  176. var r = t.next();
  177. return a = r.done, r;
  178. },
  179. e: function (r) {
  180. u = true, o = r;
  181. },
  182. f: function () {
  183. try {
  184. a || null == t.return || t.return();
  185. } finally {
  186. if (u) throw o;
  187. }
  188. }
  189. };
  190. }
  191. function _defineProperty(e, r, t) {
  192. return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
  193. value: t,
  194. enumerable: true,
  195. configurable: true,
  196. writable: true
  197. }) : e[r] = t, e;
  198. }
  199. function _getPrototypeOf(t) {
  200. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
  201. return t.__proto__ || Object.getPrototypeOf(t);
  202. }, _getPrototypeOf(t);
  203. }
  204. function _inherits(t, e) {
  205. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  206. t.prototype = Object.create(e && e.prototype, {
  207. constructor: {
  208. value: t,
  209. writable: true,
  210. configurable: true
  211. }
  212. }), Object.defineProperty(t, "prototype", {
  213. writable: false
  214. }), e && _setPrototypeOf(t, e);
  215. }
  216. function _isNativeFunction(t) {
  217. try {
  218. return -1 !== Function.toString.call(t).indexOf("[native code]");
  219. } catch (n) {
  220. return "function" == typeof t;
  221. }
  222. }
  223. function _isNativeReflectConstruct() {
  224. try {
  225. var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  226. } catch (t) {}
  227. return (_isNativeReflectConstruct = function () {
  228. return !!t;
  229. })();
  230. }
  231. function _iterableToArray(r) {
  232. if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
  233. }
  234. function _iterableToArrayLimit(r, l) {
  235. var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  236. if (null != t) {
  237. var e,
  238. n,
  239. i,
  240. u,
  241. a = [],
  242. f = true,
  243. o = false;
  244. try {
  245. if (i = (t = t.call(r)).next, 0 === l) {
  246. if (Object(t) !== t) return;
  247. f = !1;
  248. } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
  249. } catch (r) {
  250. o = true, n = r;
  251. } finally {
  252. try {
  253. if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
  254. } finally {
  255. if (o) throw n;
  256. }
  257. }
  258. return a;
  259. }
  260. }
  261. function _nonIterableRest() {
  262. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  263. }
  264. function _nonIterableSpread() {
  265. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  266. }
  267. function ownKeys(e, r) {
  268. var t = Object.keys(e);
  269. if (Object.getOwnPropertySymbols) {
  270. var o = Object.getOwnPropertySymbols(e);
  271. r && (o = o.filter(function (r) {
  272. return Object.getOwnPropertyDescriptor(e, r).enumerable;
  273. })), t.push.apply(t, o);
  274. }
  275. return t;
  276. }
  277. function _objectSpread2(e) {
  278. for (var r = 1; r < arguments.length; r++) {
  279. var t = null != arguments[r] ? arguments[r] : {};
  280. r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
  281. _defineProperty(e, r, t[r]);
  282. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
  283. Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
  284. });
  285. }
  286. return e;
  287. }
  288. function _possibleConstructorReturn(t, e) {
  289. if (e && ("object" == typeof e || "function" == typeof e)) return e;
  290. if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
  291. return _assertThisInitialized(t);
  292. }
  293. function _regenerator() {
  294. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
  295. var e,
  296. t,
  297. r = "function" == typeof Symbol ? Symbol : {},
  298. n = r.iterator || "@@iterator",
  299. o = r.toStringTag || "@@toStringTag";
  300. function i(r, n, o, i) {
  301. var c = n && n.prototype instanceof Generator ? n : Generator,
  302. u = Object.create(c.prototype);
  303. return _regeneratorDefine(u, "_invoke", function (r, n, o) {
  304. var i,
  305. c,
  306. u,
  307. f = 0,
  308. p = o || [],
  309. y = false,
  310. G = {
  311. p: 0,
  312. n: 0,
  313. v: e,
  314. a: d,
  315. f: d.bind(e, 4),
  316. d: function (t, r) {
  317. return i = t, c = 0, u = e, G.n = r, a;
  318. }
  319. };
  320. function d(r, n) {
  321. for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
  322. var o,
  323. i = p[t],
  324. d = G.p,
  325. l = i[2];
  326. r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
  327. }
  328. if (o || r > 1) return a;
  329. throw y = true, n;
  330. }
  331. return function (o, p, l) {
  332. if (f > 1) throw TypeError("Generator is already running");
  333. for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
  334. i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
  335. try {
  336. if (f = 2, i) {
  337. if (c || (o = "next"), t = i[o]) {
  338. if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
  339. if (!t.done) return t;
  340. u = t.value, c < 2 && (c = 0);
  341. } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
  342. i = e;
  343. } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
  344. } catch (t) {
  345. i = e, c = 1, u = t;
  346. } finally {
  347. f = 1;
  348. }
  349. }
  350. return {
  351. value: t,
  352. done: y
  353. };
  354. };
  355. }(r, o, i), true), u;
  356. }
  357. var a = {};
  358. function Generator() {}
  359. function GeneratorFunction() {}
  360. function GeneratorFunctionPrototype() {}
  361. t = Object.getPrototypeOf;
  362. var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
  363. return this;
  364. }), t),
  365. u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
  366. function f(e) {
  367. return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
  368. }
  369. return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
  370. return this;
  371. }), _regeneratorDefine(u, "toString", function () {
  372. return "[object Generator]";
  373. }), (_regenerator = function () {
  374. return {
  375. w: i,
  376. m: f
  377. };
  378. })();
  379. }
  380. function _regeneratorDefine(e, r, n, t) {
  381. var i = Object.defineProperty;
  382. try {
  383. i({}, "", {});
  384. } catch (e) {
  385. i = 0;
  386. }
  387. _regeneratorDefine = function (e, r, n, t) {
  388. function o(r, n) {
  389. _regeneratorDefine(e, r, function (e) {
  390. return this._invoke(r, n, e);
  391. });
  392. }
  393. r ? i ? i(e, r, {
  394. value: n,
  395. enumerable: !t,
  396. configurable: !t,
  397. writable: !t
  398. }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
  399. }, _regeneratorDefine(e, r, n, t);
  400. }
  401. function _regeneratorValues(e) {
  402. if (null != e) {
  403. var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
  404. r = 0;
  405. if (t) return t.call(e);
  406. if ("function" == typeof e.next) return e;
  407. if (!isNaN(e.length)) return {
  408. next: function () {
  409. return e && r >= e.length && (e = void 0), {
  410. value: e && e[r++],
  411. done: !e
  412. };
  413. }
  414. };
  415. }
  416. throw new TypeError(typeof e + " is not iterable");
  417. }
  418. function _setPrototypeOf(t, e) {
  419. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
  420. return t.__proto__ = e, t;
  421. }, _setPrototypeOf(t, e);
  422. }
  423. function _slicedToArray(r, e) {
  424. return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
  425. }
  426. function _toConsumableArray(r) {
  427. return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
  428. }
  429. function _toPrimitive(t, r) {
  430. if ("object" != typeof t || !t) return t;
  431. var e = t[Symbol.toPrimitive];
  432. if (void 0 !== e) {
  433. var i = e.call(t, r);
  434. if ("object" != typeof i) return i;
  435. throw new TypeError("@@toPrimitive must return a primitive value.");
  436. }
  437. return ("string" === r ? String : Number)(t);
  438. }
  439. function _toPropertyKey(t) {
  440. var i = _toPrimitive(t, "string");
  441. return "symbol" == typeof i ? i : i + "";
  442. }
  443. function _typeof(o) {
  444. "@babel/helpers - typeof";
  445. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  446. return typeof o;
  447. } : function (o) {
  448. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  449. }, _typeof(o);
  450. }
  451. function _unsupportedIterableToArray(r, a) {
  452. if (r) {
  453. if ("string" == typeof r) return _arrayLikeToArray(r, a);
  454. var t = {}.toString.call(r).slice(8, -1);
  455. return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  456. }
  457. }
  458. function _wrapAsyncGenerator(e) {
  459. return function () {
  460. return new AsyncGenerator(e.apply(this, arguments));
  461. };
  462. }
  463. function AsyncGenerator(e) {
  464. var r, t;
  465. function resume(r, t) {
  466. try {
  467. var n = e[r](t),
  468. o = n.value,
  469. u = o instanceof _OverloadYield;
  470. Promise.resolve(u ? o.v : o).then(function (t) {
  471. if (u) {
  472. var i = "return" === r ? "return" : "next";
  473. if (!o.k || t.done) return resume(i, t);
  474. t = e[i](t).value;
  475. }
  476. settle(n.done ? "return" : "normal", t);
  477. }, function (e) {
  478. resume("throw", e);
  479. });
  480. } catch (e) {
  481. settle("throw", e);
  482. }
  483. }
  484. function settle(e, n) {
  485. switch (e) {
  486. case "return":
  487. r.resolve({
  488. value: n,
  489. done: true
  490. });
  491. break;
  492. case "throw":
  493. r.reject(n);
  494. break;
  495. default:
  496. r.resolve({
  497. value: n,
  498. done: false
  499. });
  500. }
  501. (r = r.next) ? resume(r.key, r.arg) : t = null;
  502. }
  503. this._invoke = function (e, n) {
  504. return new Promise(function (o, u) {
  505. var i = {
  506. key: e,
  507. arg: n,
  508. resolve: o,
  509. reject: u,
  510. next: null
  511. };
  512. t ? t = t.next = i : (r = t = i, resume(e, n));
  513. });
  514. }, "function" != typeof e.return && (this.return = void 0);
  515. }
  516. AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function () {
  517. return this;
  518. }, AsyncGenerator.prototype.next = function (e) {
  519. return this._invoke("next", e);
  520. }, AsyncGenerator.prototype.throw = function (e) {
  521. return this._invoke("throw", e);
  522. }, AsyncGenerator.prototype.return = function (e) {
  523. return this._invoke("return", e);
  524. };
  525. function _wrapNativeSuper(t) {
  526. var r = "function" == typeof Map ? new Map() : void 0;
  527. return _wrapNativeSuper = function (t) {
  528. if (null === t || !_isNativeFunction(t)) return t;
  529. if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
  530. if (void 0 !== r) {
  531. if (r.has(t)) return r.get(t);
  532. r.set(t, Wrapper);
  533. }
  534. function Wrapper() {
  535. return _construct(t, arguments, _getPrototypeOf(this).constructor);
  536. }
  537. return Wrapper.prototype = Object.create(t.prototype, {
  538. constructor: {
  539. value: Wrapper,
  540. enumerable: false,
  541. writable: true,
  542. configurable: true
  543. }
  544. }), _setPrototypeOf(Wrapper, t);
  545. }, _wrapNativeSuper(t);
  546. }
  547. /**
  548. * Create a bound version of a function with a specified `this` context
  549. *
  550. * @param {Function} fn - The function to bind
  551. * @param {*} thisArg - The value to be passed as the `this` parameter
  552. * @returns {Function} A new function that will call the original function with the specified `this` context
  553. */
  554. function bind(fn, thisArg) {
  555. return function wrap() {
  556. return fn.apply(thisArg, arguments);
  557. };
  558. }
  559. // utils is a library of generic helper functions non-specific to axios
  560. var toString = Object.prototype.toString;
  561. var getPrototypeOf = Object.getPrototypeOf;
  562. var iterator = Symbol.iterator,
  563. toStringTag = Symbol.toStringTag;
  564. var kindOf = function (cache) {
  565. return function (thing) {
  566. var str = toString.call(thing);
  567. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  568. };
  569. }(Object.create(null));
  570. var kindOfTest = function kindOfTest(type) {
  571. type = type.toLowerCase();
  572. return function (thing) {
  573. return kindOf(thing) === type;
  574. };
  575. };
  576. var typeOfTest = function typeOfTest(type) {
  577. return function (thing) {
  578. return _typeof(thing) === type;
  579. };
  580. };
  581. /**
  582. * Determine if a value is a non-null object
  583. *
  584. * @param {Object} val The value to test
  585. *
  586. * @returns {boolean} True if value is an Array, otherwise false
  587. */
  588. var isArray = Array.isArray;
  589. /**
  590. * Determine if a value is undefined
  591. *
  592. * @param {*} val The value to test
  593. *
  594. * @returns {boolean} True if the value is undefined, otherwise false
  595. */
  596. var isUndefined = typeOfTest('undefined');
  597. /**
  598. * Determine if a value is a Buffer
  599. *
  600. * @param {*} val The value to test
  601. *
  602. * @returns {boolean} True if value is a Buffer, otherwise false
  603. */
  604. function isBuffer(val) {
  605. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  606. }
  607. /**
  608. * Determine if a value is an ArrayBuffer
  609. *
  610. * @param {*} val The value to test
  611. *
  612. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  613. */
  614. var isArrayBuffer = kindOfTest('ArrayBuffer');
  615. /**
  616. * Determine if a value is a view on an ArrayBuffer
  617. *
  618. * @param {*} val The value to test
  619. *
  620. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  621. */
  622. function isArrayBufferView(val) {
  623. var result;
  624. if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
  625. result = ArrayBuffer.isView(val);
  626. } else {
  627. result = val && val.buffer && isArrayBuffer(val.buffer);
  628. }
  629. return result;
  630. }
  631. /**
  632. * Determine if a value is a String
  633. *
  634. * @param {*} val The value to test
  635. *
  636. * @returns {boolean} True if value is a String, otherwise false
  637. */
  638. var isString = typeOfTest('string');
  639. /**
  640. * Determine if a value is a Function
  641. *
  642. * @param {*} val The value to test
  643. * @returns {boolean} True if value is a Function, otherwise false
  644. */
  645. var isFunction$1 = typeOfTest('function');
  646. /**
  647. * Determine if a value is a Number
  648. *
  649. * @param {*} val The value to test
  650. *
  651. * @returns {boolean} True if value is a Number, otherwise false
  652. */
  653. var isNumber = typeOfTest('number');
  654. /**
  655. * Determine if a value is an Object
  656. *
  657. * @param {*} thing The value to test
  658. *
  659. * @returns {boolean} True if value is an Object, otherwise false
  660. */
  661. var isObject = function isObject(thing) {
  662. return thing !== null && _typeof(thing) === 'object';
  663. };
  664. /**
  665. * Determine if a value is a Boolean
  666. *
  667. * @param {*} thing The value to test
  668. * @returns {boolean} True if value is a Boolean, otherwise false
  669. */
  670. var isBoolean = function isBoolean(thing) {
  671. return thing === true || thing === false;
  672. };
  673. /**
  674. * Determine if a value is a plain Object
  675. *
  676. * @param {*} val The value to test
  677. *
  678. * @returns {boolean} True if value is a plain Object, otherwise false
  679. */
  680. var isPlainObject = function isPlainObject(val) {
  681. if (kindOf(val) !== 'object') {
  682. return false;
  683. }
  684. var prototype = getPrototypeOf(val);
  685. return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
  686. };
  687. /**
  688. * Determine if a value is an empty object (safely handles Buffers)
  689. *
  690. * @param {*} val The value to test
  691. *
  692. * @returns {boolean} True if value is an empty object, otherwise false
  693. */
  694. var isEmptyObject = function isEmptyObject(val) {
  695. // Early return for non-objects or Buffers to prevent RangeError
  696. if (!isObject(val) || isBuffer(val)) {
  697. return false;
  698. }
  699. try {
  700. return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
  701. } catch (e) {
  702. // Fallback for any other objects that might cause RangeError with Object.keys()
  703. return false;
  704. }
  705. };
  706. /**
  707. * Determine if a value is a Date
  708. *
  709. * @param {*} val The value to test
  710. *
  711. * @returns {boolean} True if value is a Date, otherwise false
  712. */
  713. var isDate = kindOfTest('Date');
  714. /**
  715. * Determine if a value is a File
  716. *
  717. * @param {*} val The value to test
  718. *
  719. * @returns {boolean} True if value is a File, otherwise false
  720. */
  721. var isFile = kindOfTest('File');
  722. /**
  723. * Determine if a value is a React Native Blob
  724. * React Native "blob": an object with a `uri` attribute. Optionally, it can
  725. * also have a `name` and `type` attribute to specify filename and content type
  726. *
  727. * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
  728. *
  729. * @param {*} value The value to test
  730. *
  731. * @returns {boolean} True if value is a React Native Blob, otherwise false
  732. */
  733. var isReactNativeBlob = function isReactNativeBlob(value) {
  734. return !!(value && typeof value.uri !== 'undefined');
  735. };
  736. /**
  737. * Determine if environment is React Native
  738. * ReactNative `FormData` has a non-standard `getParts()` method
  739. *
  740. * @param {*} formData The formData to test
  741. *
  742. * @returns {boolean} True if environment is React Native, otherwise false
  743. */
  744. var isReactNative = function isReactNative(formData) {
  745. return formData && typeof formData.getParts !== 'undefined';
  746. };
  747. /**
  748. * Determine if a value is a Blob
  749. *
  750. * @param {*} val The value to test
  751. *
  752. * @returns {boolean} True if value is a Blob, otherwise false
  753. */
  754. var isBlob = kindOfTest('Blob');
  755. /**
  756. * Determine if a value is a FileList
  757. *
  758. * @param {*} val The value to test
  759. *
  760. * @returns {boolean} True if value is a File, otherwise false
  761. */
  762. var isFileList = kindOfTest('FileList');
  763. /**
  764. * Determine if a value is a Stream
  765. *
  766. * @param {*} val The value to test
  767. *
  768. * @returns {boolean} True if value is a Stream, otherwise false
  769. */
  770. var isStream = function isStream(val) {
  771. return isObject(val) && isFunction$1(val.pipe);
  772. };
  773. /**
  774. * Determine if a value is a FormData
  775. *
  776. * @param {*} thing The value to test
  777. *
  778. * @returns {boolean} True if value is an FormData, otherwise false
  779. */
  780. function getGlobal() {
  781. if (typeof globalThis !== 'undefined') return globalThis;
  782. if (typeof self !== 'undefined') return self;
  783. if (typeof window !== 'undefined') return window;
  784. if (typeof global !== 'undefined') return global;
  785. return {};
  786. }
  787. var G = getGlobal();
  788. var FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
  789. var isFormData = function isFormData(thing) {
  790. var kind;
  791. return thing && (FormDataCtor && thing instanceof FormDataCtor || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
  792. // detect form-data instance
  793. kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'));
  794. };
  795. /**
  796. * Determine if a value is a URLSearchParams object
  797. *
  798. * @param {*} val The value to test
  799. *
  800. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  801. */
  802. var isURLSearchParams = kindOfTest('URLSearchParams');
  803. var _map = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest),
  804. _map2 = _slicedToArray(_map, 4),
  805. isReadableStream = _map2[0],
  806. isRequest = _map2[1],
  807. isResponse = _map2[2],
  808. isHeaders = _map2[3];
  809. /**
  810. * Trim excess whitespace off the beginning and end of a string
  811. *
  812. * @param {String} str The String to trim
  813. *
  814. * @returns {String} The String freed of excess whitespace
  815. */
  816. var trim = function trim(str) {
  817. return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  818. };
  819. /**
  820. * Iterate over an Array or an Object invoking a function for each item.
  821. *
  822. * If `obj` is an Array callback will be called passing
  823. * the value, index, and complete array for each item.
  824. *
  825. * If 'obj' is an Object callback will be called passing
  826. * the value, key, and complete object for each property.
  827. *
  828. * @param {Object|Array<unknown>} obj The object to iterate
  829. * @param {Function} fn The callback to invoke for each item
  830. *
  831. * @param {Object} [options]
  832. * @param {Boolean} [options.allOwnKeys = false]
  833. * @returns {any}
  834. */
  835. function forEach(obj, fn) {
  836. var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  837. _ref$allOwnKeys = _ref.allOwnKeys,
  838. allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
  839. // Don't bother if no value provided
  840. if (obj === null || typeof obj === 'undefined') {
  841. return;
  842. }
  843. var i;
  844. var l;
  845. // Force an array if not already something iterable
  846. if (_typeof(obj) !== 'object') {
  847. /*eslint no-param-reassign:0*/
  848. obj = [obj];
  849. }
  850. if (isArray(obj)) {
  851. // Iterate over array values
  852. for (i = 0, l = obj.length; i < l; i++) {
  853. fn.call(null, obj[i], i, obj);
  854. }
  855. } else {
  856. // Buffer check
  857. if (isBuffer(obj)) {
  858. return;
  859. }
  860. // Iterate over object keys
  861. var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  862. var len = keys.length;
  863. var key;
  864. for (i = 0; i < len; i++) {
  865. key = keys[i];
  866. fn.call(null, obj[key], key, obj);
  867. }
  868. }
  869. }
  870. /**
  871. * Finds a key in an object, case-insensitive, returning the actual key name.
  872. * Returns null if the object is a Buffer or if no match is found.
  873. *
  874. * @param {Object} obj - The object to search.
  875. * @param {string} key - The key to find (case-insensitive).
  876. * @returns {?string} The actual key name if found, otherwise null.
  877. */
  878. function findKey(obj, key) {
  879. if (isBuffer(obj)) {
  880. return null;
  881. }
  882. key = key.toLowerCase();
  883. var keys = Object.keys(obj);
  884. var i = keys.length;
  885. var _key;
  886. while (i-- > 0) {
  887. _key = keys[i];
  888. if (key === _key.toLowerCase()) {
  889. return _key;
  890. }
  891. }
  892. return null;
  893. }
  894. var _global = function () {
  895. /*eslint no-undef:0*/
  896. if (typeof globalThis !== 'undefined') return globalThis;
  897. return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
  898. }();
  899. var isContextDefined = function isContextDefined(context) {
  900. return !isUndefined(context) && context !== _global;
  901. };
  902. /**
  903. * Accepts varargs expecting each argument to be an object, then
  904. * immutably merges the properties of each object and returns result.
  905. *
  906. * When multiple objects contain the same key the later object in
  907. * the arguments list will take precedence.
  908. *
  909. * Example:
  910. *
  911. * ```js
  912. * const result = merge({foo: 123}, {foo: 456});
  913. * console.log(result.foo); // outputs 456
  914. * ```
  915. *
  916. * @param {Object} obj1 Object to merge
  917. *
  918. * @returns {Object} Result of all merge properties
  919. */
  920. function merge(/* obj1, obj2, obj3, ... */
  921. ) {
  922. var _ref2 = isContextDefined(this) && this || {},
  923. caseless = _ref2.caseless,
  924. skipUndefined = _ref2.skipUndefined;
  925. var result = {};
  926. var assignValue = function assignValue(val, key) {
  927. // Skip dangerous property names to prevent prototype pollution
  928. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  929. return;
  930. }
  931. var targetKey = caseless && findKey(result, key) || key;
  932. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  933. result[targetKey] = merge(result[targetKey], val);
  934. } else if (isPlainObject(val)) {
  935. result[targetKey] = merge({}, val);
  936. } else if (isArray(val)) {
  937. result[targetKey] = val.slice();
  938. } else if (!skipUndefined || !isUndefined(val)) {
  939. result[targetKey] = val;
  940. }
  941. };
  942. for (var i = 0, l = arguments.length; i < l; i++) {
  943. arguments[i] && forEach(arguments[i], assignValue);
  944. }
  945. return result;
  946. }
  947. /**
  948. * Extends object a by mutably adding to it the properties of object b.
  949. *
  950. * @param {Object} a The object to be extended
  951. * @param {Object} b The object to copy properties from
  952. * @param {Object} thisArg The object to bind function to
  953. *
  954. * @param {Object} [options]
  955. * @param {Boolean} [options.allOwnKeys]
  956. * @returns {Object} The resulting value of object a
  957. */
  958. var extend = function extend(a, b, thisArg) {
  959. var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
  960. allOwnKeys = _ref3.allOwnKeys;
  961. forEach(b, function (val, key) {
  962. if (thisArg && isFunction$1(val)) {
  963. Object.defineProperty(a, key, {
  964. value: bind(val, thisArg),
  965. writable: true,
  966. enumerable: true,
  967. configurable: true
  968. });
  969. } else {
  970. Object.defineProperty(a, key, {
  971. value: val,
  972. writable: true,
  973. enumerable: true,
  974. configurable: true
  975. });
  976. }
  977. }, {
  978. allOwnKeys: allOwnKeys
  979. });
  980. return a;
  981. };
  982. /**
  983. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  984. *
  985. * @param {string} content with BOM
  986. *
  987. * @returns {string} content value without BOM
  988. */
  989. var stripBOM = function stripBOM(content) {
  990. if (content.charCodeAt(0) === 0xfeff) {
  991. content = content.slice(1);
  992. }
  993. return content;
  994. };
  995. /**
  996. * Inherit the prototype methods from one constructor into another
  997. * @param {function} constructor
  998. * @param {function} superConstructor
  999. * @param {object} [props]
  1000. * @param {object} [descriptors]
  1001. *
  1002. * @returns {void}
  1003. */
  1004. var inherits = function inherits(constructor, superConstructor, props, descriptors) {
  1005. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  1006. Object.defineProperty(constructor.prototype, 'constructor', {
  1007. value: constructor,
  1008. writable: true,
  1009. enumerable: false,
  1010. configurable: true
  1011. });
  1012. Object.defineProperty(constructor, 'super', {
  1013. value: superConstructor.prototype
  1014. });
  1015. props && Object.assign(constructor.prototype, props);
  1016. };
  1017. /**
  1018. * Resolve object with deep prototype chain to a flat object
  1019. * @param {Object} sourceObj source object
  1020. * @param {Object} [destObj]
  1021. * @param {Function|Boolean} [filter]
  1022. * @param {Function} [propFilter]
  1023. *
  1024. * @returns {Object}
  1025. */
  1026. var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
  1027. var props;
  1028. var i;
  1029. var prop;
  1030. var merged = {};
  1031. destObj = destObj || {};
  1032. // eslint-disable-next-line no-eq-null,eqeqeq
  1033. if (sourceObj == null) return destObj;
  1034. do {
  1035. props = Object.getOwnPropertyNames(sourceObj);
  1036. i = props.length;
  1037. while (i-- > 0) {
  1038. prop = props[i];
  1039. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  1040. destObj[prop] = sourceObj[prop];
  1041. merged[prop] = true;
  1042. }
  1043. }
  1044. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  1045. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  1046. return destObj;
  1047. };
  1048. /**
  1049. * Determines whether a string ends with the characters of a specified string
  1050. *
  1051. * @param {String} str
  1052. * @param {String} searchString
  1053. * @param {Number} [position= 0]
  1054. *
  1055. * @returns {boolean}
  1056. */
  1057. var endsWith = function endsWith(str, searchString, position) {
  1058. str = String(str);
  1059. if (position === undefined || position > str.length) {
  1060. position = str.length;
  1061. }
  1062. position -= searchString.length;
  1063. var lastIndex = str.indexOf(searchString, position);
  1064. return lastIndex !== -1 && lastIndex === position;
  1065. };
  1066. /**
  1067. * Returns new array from array like object or null if failed
  1068. *
  1069. * @param {*} [thing]
  1070. *
  1071. * @returns {?Array}
  1072. */
  1073. var toArray = function toArray(thing) {
  1074. if (!thing) return null;
  1075. if (isArray(thing)) return thing;
  1076. var i = thing.length;
  1077. if (!isNumber(i)) return null;
  1078. var arr = new Array(i);
  1079. while (i-- > 0) {
  1080. arr[i] = thing[i];
  1081. }
  1082. return arr;
  1083. };
  1084. /**
  1085. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  1086. * thing passed in is an instance of Uint8Array
  1087. *
  1088. * @param {TypedArray}
  1089. *
  1090. * @returns {Array}
  1091. */
  1092. // eslint-disable-next-line func-names
  1093. var isTypedArray = function (TypedArray) {
  1094. // eslint-disable-next-line func-names
  1095. return function (thing) {
  1096. return TypedArray && thing instanceof TypedArray;
  1097. };
  1098. }(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  1099. /**
  1100. * For each entry in the object, call the function with the key and value.
  1101. *
  1102. * @param {Object<any, any>} obj - The object to iterate over.
  1103. * @param {Function} fn - The function to call for each entry.
  1104. *
  1105. * @returns {void}
  1106. */
  1107. var forEachEntry = function forEachEntry(obj, fn) {
  1108. var generator = obj && obj[iterator];
  1109. var _iterator = generator.call(obj);
  1110. var result;
  1111. while ((result = _iterator.next()) && !result.done) {
  1112. var pair = result.value;
  1113. fn.call(obj, pair[0], pair[1]);
  1114. }
  1115. };
  1116. /**
  1117. * It takes a regular expression and a string, and returns an array of all the matches
  1118. *
  1119. * @param {string} regExp - The regular expression to match against.
  1120. * @param {string} str - The string to search.
  1121. *
  1122. * @returns {Array<boolean>}
  1123. */
  1124. var matchAll = function matchAll(regExp, str) {
  1125. var matches;
  1126. var arr = [];
  1127. while ((matches = regExp.exec(str)) !== null) {
  1128. arr.push(matches);
  1129. }
  1130. return arr;
  1131. };
  1132. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  1133. var isHTMLForm = kindOfTest('HTMLFormElement');
  1134. var toCamelCase = function toCamelCase(str) {
  1135. return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
  1136. return p1.toUpperCase() + p2;
  1137. });
  1138. };
  1139. /* Creating a function that will check if an object has a property. */
  1140. var hasOwnProperty = function (_ref4) {
  1141. var hasOwnProperty = _ref4.hasOwnProperty;
  1142. return function (obj, prop) {
  1143. return hasOwnProperty.call(obj, prop);
  1144. };
  1145. }(Object.prototype);
  1146. /**
  1147. * Determine if a value is a RegExp object
  1148. *
  1149. * @param {*} val The value to test
  1150. *
  1151. * @returns {boolean} True if value is a RegExp object, otherwise false
  1152. */
  1153. var isRegExp = kindOfTest('RegExp');
  1154. var reduceDescriptors = function reduceDescriptors(obj, reducer) {
  1155. var descriptors = Object.getOwnPropertyDescriptors(obj);
  1156. var reducedDescriptors = {};
  1157. forEach(descriptors, function (descriptor, name) {
  1158. var ret;
  1159. if ((ret = reducer(descriptor, name, obj)) !== false) {
  1160. reducedDescriptors[name] = ret || descriptor;
  1161. }
  1162. });
  1163. Object.defineProperties(obj, reducedDescriptors);
  1164. };
  1165. /**
  1166. * Makes all methods read-only
  1167. * @param {Object} obj
  1168. */
  1169. var freezeMethods = function freezeMethods(obj) {
  1170. reduceDescriptors(obj, function (descriptor, name) {
  1171. // skip restricted props in strict mode
  1172. if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
  1173. return false;
  1174. }
  1175. var value = obj[name];
  1176. if (!isFunction$1(value)) return;
  1177. descriptor.enumerable = false;
  1178. if ('writable' in descriptor) {
  1179. descriptor.writable = false;
  1180. return;
  1181. }
  1182. if (!descriptor.set) {
  1183. descriptor.set = function () {
  1184. throw Error("Can not rewrite read-only method '" + name + "'");
  1185. };
  1186. }
  1187. });
  1188. };
  1189. /**
  1190. * Converts an array or a delimited string into an object set with values as keys and true as values.
  1191. * Useful for fast membership checks.
  1192. *
  1193. * @param {Array|string} arrayOrString - The array or string to convert.
  1194. * @param {string} delimiter - The delimiter to use if input is a string.
  1195. * @returns {Object} An object with keys from the array or string, values set to true.
  1196. */
  1197. var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
  1198. var obj = {};
  1199. var define = function define(arr) {
  1200. arr.forEach(function (value) {
  1201. obj[value] = true;
  1202. });
  1203. };
  1204. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  1205. return obj;
  1206. };
  1207. var noop = function noop() {};
  1208. var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
  1209. return value != null && Number.isFinite(value = +value) ? value : defaultValue;
  1210. };
  1211. /**
  1212. * If the thing is a FormData object, return true, otherwise return false.
  1213. *
  1214. * @param {unknown} thing - The thing to check.
  1215. *
  1216. * @returns {boolean}
  1217. */
  1218. function isSpecCompliantForm(thing) {
  1219. return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
  1220. }
  1221. /**
  1222. * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
  1223. *
  1224. * @param {Object} obj - The object to convert.
  1225. * @returns {Object} The JSON-compatible object.
  1226. */
  1227. var toJSONObject = function toJSONObject(obj) {
  1228. var stack = new Array(10);
  1229. var _visit = function visit(source, i) {
  1230. if (isObject(source)) {
  1231. if (stack.indexOf(source) >= 0) {
  1232. return;
  1233. }
  1234. //Buffer check
  1235. if (isBuffer(source)) {
  1236. return source;
  1237. }
  1238. if (!('toJSON' in source)) {
  1239. stack[i] = source;
  1240. var target = isArray(source) ? [] : {};
  1241. forEach(source, function (value, key) {
  1242. var reducedValue = _visit(value, i + 1);
  1243. !isUndefined(reducedValue) && (target[key] = reducedValue);
  1244. });
  1245. stack[i] = undefined;
  1246. return target;
  1247. }
  1248. }
  1249. return source;
  1250. };
  1251. return _visit(obj, 0);
  1252. };
  1253. /**
  1254. * Determines if a value is an async function.
  1255. *
  1256. * @param {*} thing - The value to test.
  1257. * @returns {boolean} True if value is an async function, otherwise false.
  1258. */
  1259. var isAsyncFn = kindOfTest('AsyncFunction');
  1260. /**
  1261. * Determines if a value is thenable (has then and catch methods).
  1262. *
  1263. * @param {*} thing - The value to test.
  1264. * @returns {boolean} True if value is thenable, otherwise false.
  1265. */
  1266. var isThenable = function isThenable(thing) {
  1267. return thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing["catch"]);
  1268. };
  1269. // original code
  1270. // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
  1271. /**
  1272. * Provides a cross-platform setImmediate implementation.
  1273. * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
  1274. *
  1275. * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
  1276. * @param {boolean} postMessageSupported - Whether postMessage is supported.
  1277. * @returns {Function} A function to schedule a callback asynchronously.
  1278. */
  1279. var _setImmediate = function (setImmediateSupported, postMessageSupported) {
  1280. if (setImmediateSupported) {
  1281. return setImmediate;
  1282. }
  1283. return postMessageSupported ? function (token, callbacks) {
  1284. _global.addEventListener('message', function (_ref5) {
  1285. var source = _ref5.source,
  1286. data = _ref5.data;
  1287. if (source === _global && data === token) {
  1288. callbacks.length && callbacks.shift()();
  1289. }
  1290. }, false);
  1291. return function (cb) {
  1292. callbacks.push(cb);
  1293. _global.postMessage(token, '*');
  1294. };
  1295. }("axios@".concat(Math.random()), []) : function (cb) {
  1296. return setTimeout(cb);
  1297. };
  1298. }(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
  1299. /**
  1300. * Schedules a microtask or asynchronous callback as soon as possible.
  1301. * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
  1302. *
  1303. * @type {Function}
  1304. */
  1305. var asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
  1306. // *********************
  1307. var isIterable = function isIterable(thing) {
  1308. return thing != null && isFunction$1(thing[iterator]);
  1309. };
  1310. var utils$1 = {
  1311. isArray: isArray,
  1312. isArrayBuffer: isArrayBuffer,
  1313. isBuffer: isBuffer,
  1314. isFormData: isFormData,
  1315. isArrayBufferView: isArrayBufferView,
  1316. isString: isString,
  1317. isNumber: isNumber,
  1318. isBoolean: isBoolean,
  1319. isObject: isObject,
  1320. isPlainObject: isPlainObject,
  1321. isEmptyObject: isEmptyObject,
  1322. isReadableStream: isReadableStream,
  1323. isRequest: isRequest,
  1324. isResponse: isResponse,
  1325. isHeaders: isHeaders,
  1326. isUndefined: isUndefined,
  1327. isDate: isDate,
  1328. isFile: isFile,
  1329. isReactNativeBlob: isReactNativeBlob,
  1330. isReactNative: isReactNative,
  1331. isBlob: isBlob,
  1332. isRegExp: isRegExp,
  1333. isFunction: isFunction$1,
  1334. isStream: isStream,
  1335. isURLSearchParams: isURLSearchParams,
  1336. isTypedArray: isTypedArray,
  1337. isFileList: isFileList,
  1338. forEach: forEach,
  1339. merge: merge,
  1340. extend: extend,
  1341. trim: trim,
  1342. stripBOM: stripBOM,
  1343. inherits: inherits,
  1344. toFlatObject: toFlatObject,
  1345. kindOf: kindOf,
  1346. kindOfTest: kindOfTest,
  1347. endsWith: endsWith,
  1348. toArray: toArray,
  1349. forEachEntry: forEachEntry,
  1350. matchAll: matchAll,
  1351. isHTMLForm: isHTMLForm,
  1352. hasOwnProperty: hasOwnProperty,
  1353. hasOwnProp: hasOwnProperty,
  1354. // an alias to avoid ESLint no-prototype-builtins detection
  1355. reduceDescriptors: reduceDescriptors,
  1356. freezeMethods: freezeMethods,
  1357. toObjectSet: toObjectSet,
  1358. toCamelCase: toCamelCase,
  1359. noop: noop,
  1360. toFiniteNumber: toFiniteNumber,
  1361. findKey: findKey,
  1362. global: _global,
  1363. isContextDefined: isContextDefined,
  1364. isSpecCompliantForm: isSpecCompliantForm,
  1365. toJSONObject: toJSONObject,
  1366. isAsyncFn: isAsyncFn,
  1367. isThenable: isThenable,
  1368. setImmediate: _setImmediate,
  1369. asap: asap,
  1370. isIterable: isIterable
  1371. };
  1372. var AxiosError = /*#__PURE__*/function (_Error) {
  1373. /**
  1374. * Create an Error with the specified message, config, error code, request and response.
  1375. *
  1376. * @param {string} message The error message.
  1377. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  1378. * @param {Object} [config] The config.
  1379. * @param {Object} [request] The request.
  1380. * @param {Object} [response] The response.
  1381. *
  1382. * @returns {Error} The created error.
  1383. */
  1384. function AxiosError(message, code, config, request, response) {
  1385. var _this;
  1386. _classCallCheck(this, AxiosError);
  1387. _this = _callSuper(this, AxiosError, [message]);
  1388. // Make message enumerable to maintain backward compatibility
  1389. // The native Error constructor sets message as non-enumerable,
  1390. // but axios < v1.13.3 had it as enumerable
  1391. Object.defineProperty(_this, 'message', {
  1392. value: message,
  1393. enumerable: true,
  1394. writable: true,
  1395. configurable: true
  1396. });
  1397. _this.name = 'AxiosError';
  1398. _this.isAxiosError = true;
  1399. code && (_this.code = code);
  1400. config && (_this.config = config);
  1401. request && (_this.request = request);
  1402. if (response) {
  1403. _this.response = response;
  1404. _this.status = response.status;
  1405. }
  1406. return _this;
  1407. }
  1408. _inherits(AxiosError, _Error);
  1409. return _createClass(AxiosError, [{
  1410. key: "toJSON",
  1411. value: function toJSON() {
  1412. return {
  1413. // Standard
  1414. message: this.message,
  1415. name: this.name,
  1416. // Microsoft
  1417. description: this.description,
  1418. number: this.number,
  1419. // Mozilla
  1420. fileName: this.fileName,
  1421. lineNumber: this.lineNumber,
  1422. columnNumber: this.columnNumber,
  1423. stack: this.stack,
  1424. // Axios
  1425. config: utils$1.toJSONObject(this.config),
  1426. code: this.code,
  1427. status: this.status
  1428. };
  1429. }
  1430. }], [{
  1431. key: "from",
  1432. value: function from(error, code, config, request, response, customProps) {
  1433. var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
  1434. axiosError.cause = error;
  1435. axiosError.name = error.name;
  1436. // Preserve status from the original error if not already set from response
  1437. if (error.status != null && axiosError.status == null) {
  1438. axiosError.status = error.status;
  1439. }
  1440. customProps && Object.assign(axiosError, customProps);
  1441. return axiosError;
  1442. }
  1443. }]);
  1444. }(/*#__PURE__*/_wrapNativeSuper(Error)); // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
  1445. AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
  1446. AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
  1447. AxiosError.ECONNABORTED = 'ECONNABORTED';
  1448. AxiosError.ETIMEDOUT = 'ETIMEDOUT';
  1449. AxiosError.ERR_NETWORK = 'ERR_NETWORK';
  1450. AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
  1451. AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
  1452. AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
  1453. AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
  1454. AxiosError.ERR_CANCELED = 'ERR_CANCELED';
  1455. AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
  1456. AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
  1457. // eslint-disable-next-line strict
  1458. var httpAdapter = null;
  1459. /**
  1460. * Determines if the given thing is a array or js object.
  1461. *
  1462. * @param {string} thing - The object or array to be visited.
  1463. *
  1464. * @returns {boolean}
  1465. */
  1466. function isVisitable(thing) {
  1467. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  1468. }
  1469. /**
  1470. * It removes the brackets from the end of a string
  1471. *
  1472. * @param {string} key - The key of the parameter.
  1473. *
  1474. * @returns {string} the key without the brackets.
  1475. */
  1476. function removeBrackets(key) {
  1477. return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
  1478. }
  1479. /**
  1480. * It takes a path, a key, and a boolean, and returns a string
  1481. *
  1482. * @param {string} path - The path to the current key.
  1483. * @param {string} key - The key of the current object being iterated over.
  1484. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  1485. *
  1486. * @returns {string} The path to the current key.
  1487. */
  1488. function renderKey(path, key, dots) {
  1489. if (!path) return key;
  1490. return path.concat(key).map(function each(token, i) {
  1491. // eslint-disable-next-line no-param-reassign
  1492. token = removeBrackets(token);
  1493. return !dots && i ? '[' + token + ']' : token;
  1494. }).join(dots ? '.' : '');
  1495. }
  1496. /**
  1497. * If the array is an array and none of its elements are visitable, then it's a flat array.
  1498. *
  1499. * @param {Array<any>} arr - The array to check
  1500. *
  1501. * @returns {boolean}
  1502. */
  1503. function isFlatArray(arr) {
  1504. return utils$1.isArray(arr) && !arr.some(isVisitable);
  1505. }
  1506. var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  1507. return /^is[A-Z]/.test(prop);
  1508. });
  1509. /**
  1510. * Convert a data object to FormData
  1511. *
  1512. * @param {Object} obj
  1513. * @param {?Object} [formData]
  1514. * @param {?Object} [options]
  1515. * @param {Function} [options.visitor]
  1516. * @param {Boolean} [options.metaTokens = true]
  1517. * @param {Boolean} [options.dots = false]
  1518. * @param {?Boolean} [options.indexes = false]
  1519. *
  1520. * @returns {Object}
  1521. **/
  1522. /**
  1523. * It converts an object into a FormData object
  1524. *
  1525. * @param {Object<any, any>} obj - The object to convert to form data.
  1526. * @param {string} formData - The FormData object to append to.
  1527. * @param {Object<string, any>} options
  1528. *
  1529. * @returns
  1530. */
  1531. function toFormData(obj, formData, options) {
  1532. if (!utils$1.isObject(obj)) {
  1533. throw new TypeError('target must be an object');
  1534. }
  1535. // eslint-disable-next-line no-param-reassign
  1536. formData = formData || new (FormData)();
  1537. // eslint-disable-next-line no-param-reassign
  1538. options = utils$1.toFlatObject(options, {
  1539. metaTokens: true,
  1540. dots: false,
  1541. indexes: false
  1542. }, false, function defined(option, source) {
  1543. // eslint-disable-next-line no-eq-null,eqeqeq
  1544. return !utils$1.isUndefined(source[option]);
  1545. });
  1546. var metaTokens = options.metaTokens;
  1547. // eslint-disable-next-line no-use-before-define
  1548. var visitor = options.visitor || defaultVisitor;
  1549. var dots = options.dots;
  1550. var indexes = options.indexes;
  1551. var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  1552. var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  1553. if (!utils$1.isFunction(visitor)) {
  1554. throw new TypeError('visitor must be a function');
  1555. }
  1556. function convertValue(value) {
  1557. if (value === null) return '';
  1558. if (utils$1.isDate(value)) {
  1559. return value.toISOString();
  1560. }
  1561. if (utils$1.isBoolean(value)) {
  1562. return value.toString();
  1563. }
  1564. if (!useBlob && utils$1.isBlob(value)) {
  1565. throw new AxiosError('Blob is not supported. Use a Buffer instead.');
  1566. }
  1567. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  1568. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  1569. }
  1570. return value;
  1571. }
  1572. /**
  1573. * Default visitor.
  1574. *
  1575. * @param {*} value
  1576. * @param {String|Number} key
  1577. * @param {Array<String|Number>} path
  1578. * @this {FormData}
  1579. *
  1580. * @returns {boolean} return true to visit the each prop of the value recursively
  1581. */
  1582. function defaultVisitor(value, key, path) {
  1583. var arr = value;
  1584. if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
  1585. formData.append(renderKey(path, key, dots), convertValue(value));
  1586. return false;
  1587. }
  1588. if (value && !path && _typeof(value) === 'object') {
  1589. if (utils$1.endsWith(key, '{}')) {
  1590. // eslint-disable-next-line no-param-reassign
  1591. key = metaTokens ? key : key.slice(0, -2);
  1592. // eslint-disable-next-line no-param-reassign
  1593. value = JSON.stringify(value);
  1594. } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
  1595. // eslint-disable-next-line no-param-reassign
  1596. key = removeBrackets(key);
  1597. arr.forEach(function each(el, index) {
  1598. !(utils$1.isUndefined(el) || el === null) && formData.append(
  1599. // eslint-disable-next-line no-nested-ternary
  1600. indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
  1601. });
  1602. return false;
  1603. }
  1604. }
  1605. if (isVisitable(value)) {
  1606. return true;
  1607. }
  1608. formData.append(renderKey(path, key, dots), convertValue(value));
  1609. return false;
  1610. }
  1611. var stack = [];
  1612. var exposedHelpers = Object.assign(predicates, {
  1613. defaultVisitor: defaultVisitor,
  1614. convertValue: convertValue,
  1615. isVisitable: isVisitable
  1616. });
  1617. function build(value, path) {
  1618. if (utils$1.isUndefined(value)) return;
  1619. if (stack.indexOf(value) !== -1) {
  1620. throw Error('Circular reference detected in ' + path.join('.'));
  1621. }
  1622. stack.push(value);
  1623. utils$1.forEach(value, function each(el, key) {
  1624. var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
  1625. if (result === true) {
  1626. build(el, path ? path.concat(key) : [key]);
  1627. }
  1628. });
  1629. stack.pop();
  1630. }
  1631. if (!utils$1.isObject(obj)) {
  1632. throw new TypeError('data must be an object');
  1633. }
  1634. build(obj);
  1635. return formData;
  1636. }
  1637. /**
  1638. * It encodes a string by replacing all characters that are not in the unreserved set with
  1639. * their percent-encoded equivalents
  1640. *
  1641. * @param {string} str - The string to encode.
  1642. *
  1643. * @returns {string} The encoded string.
  1644. */
  1645. function encode$1(str) {
  1646. var charMap = {
  1647. '!': '%21',
  1648. "'": '%27',
  1649. '(': '%28',
  1650. ')': '%29',
  1651. '~': '%7E',
  1652. '%20': '+',
  1653. '%00': '\x00'
  1654. };
  1655. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  1656. return charMap[match];
  1657. });
  1658. }
  1659. /**
  1660. * It takes a params object and converts it to a FormData object
  1661. *
  1662. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  1663. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  1664. *
  1665. * @returns {void}
  1666. */
  1667. function AxiosURLSearchParams(params, options) {
  1668. this._pairs = [];
  1669. params && toFormData(params, this, options);
  1670. }
  1671. var prototype = AxiosURLSearchParams.prototype;
  1672. prototype.append = function append(name, value) {
  1673. this._pairs.push([name, value]);
  1674. };
  1675. prototype.toString = function toString(encoder) {
  1676. var _encode = encoder ? function (value) {
  1677. return encoder.call(this, value, encode$1);
  1678. } : encode$1;
  1679. return this._pairs.map(function each(pair) {
  1680. return _encode(pair[0]) + '=' + _encode(pair[1]);
  1681. }, '').join('&');
  1682. };
  1683. /**
  1684. * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
  1685. * their plain counterparts (`:`, `$`, `,`, `+`).
  1686. *
  1687. * @param {string} val The value to be encoded.
  1688. *
  1689. * @returns {string} The encoded value.
  1690. */
  1691. function encode(val) {
  1692. return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
  1693. }
  1694. /**
  1695. * Build a URL by appending params to the end
  1696. *
  1697. * @param {string} url The base of the url (e.g., http://www.google.com)
  1698. * @param {object} [params] The params to be appended
  1699. * @param {?(object|Function)} options
  1700. *
  1701. * @returns {string} The formatted url
  1702. */
  1703. function buildURL(url, params, options) {
  1704. if (!params) {
  1705. return url;
  1706. }
  1707. var _encode = options && options.encode || encode;
  1708. var _options = utils$1.isFunction(options) ? {
  1709. serialize: options
  1710. } : options;
  1711. var serializeFn = _options && _options.serialize;
  1712. var serializedParams;
  1713. if (serializeFn) {
  1714. serializedParams = serializeFn(params, _options);
  1715. } else {
  1716. serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
  1717. }
  1718. if (serializedParams) {
  1719. var hashmarkIndex = url.indexOf('#');
  1720. if (hashmarkIndex !== -1) {
  1721. url = url.slice(0, hashmarkIndex);
  1722. }
  1723. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1724. }
  1725. return url;
  1726. }
  1727. var InterceptorManager = /*#__PURE__*/function () {
  1728. function InterceptorManager() {
  1729. _classCallCheck(this, InterceptorManager);
  1730. this.handlers = [];
  1731. }
  1732. /**
  1733. * Add a new interceptor to the stack
  1734. *
  1735. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1736. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1737. * @param {Object} options The options for the interceptor, synchronous and runWhen
  1738. *
  1739. * @return {Number} An ID used to remove interceptor later
  1740. */
  1741. return _createClass(InterceptorManager, [{
  1742. key: "use",
  1743. value: function use(fulfilled, rejected, options) {
  1744. this.handlers.push({
  1745. fulfilled: fulfilled,
  1746. rejected: rejected,
  1747. synchronous: options ? options.synchronous : false,
  1748. runWhen: options ? options.runWhen : null
  1749. });
  1750. return this.handlers.length - 1;
  1751. }
  1752. /**
  1753. * Remove an interceptor from the stack
  1754. *
  1755. * @param {Number} id The ID that was returned by `use`
  1756. *
  1757. * @returns {void}
  1758. */
  1759. }, {
  1760. key: "eject",
  1761. value: function eject(id) {
  1762. if (this.handlers[id]) {
  1763. this.handlers[id] = null;
  1764. }
  1765. }
  1766. /**
  1767. * Clear all interceptors from the stack
  1768. *
  1769. * @returns {void}
  1770. */
  1771. }, {
  1772. key: "clear",
  1773. value: function clear() {
  1774. if (this.handlers) {
  1775. this.handlers = [];
  1776. }
  1777. }
  1778. /**
  1779. * Iterate over all the registered interceptors
  1780. *
  1781. * This method is particularly useful for skipping over any
  1782. * interceptors that may have become `null` calling `eject`.
  1783. *
  1784. * @param {Function} fn The function to call for each interceptor
  1785. *
  1786. * @returns {void}
  1787. */
  1788. }, {
  1789. key: "forEach",
  1790. value: function forEach(fn) {
  1791. utils$1.forEach(this.handlers, function forEachHandler(h) {
  1792. if (h !== null) {
  1793. fn(h);
  1794. }
  1795. });
  1796. }
  1797. }]);
  1798. }();
  1799. var transitionalDefaults = {
  1800. silentJSONParsing: true,
  1801. forcedJSONParsing: true,
  1802. clarifyTimeoutError: false,
  1803. legacyInterceptorReqResOrdering: true
  1804. };
  1805. var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  1806. var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
  1807. var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
  1808. var platform$1 = {
  1809. isBrowser: true,
  1810. classes: {
  1811. URLSearchParams: URLSearchParams$1,
  1812. FormData: FormData$1,
  1813. Blob: Blob$1
  1814. },
  1815. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  1816. };
  1817. var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
  1818. var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
  1819. /**
  1820. * Determine if we're running in a standard browser environment
  1821. *
  1822. * This allows axios to run in a web worker, and react-native.
  1823. * Both environments support XMLHttpRequest, but not fully standard globals.
  1824. *
  1825. * web workers:
  1826. * typeof window -> undefined
  1827. * typeof document -> undefined
  1828. *
  1829. * react-native:
  1830. * navigator.product -> 'ReactNative'
  1831. * nativescript
  1832. * navigator.product -> 'NativeScript' or 'NS'
  1833. *
  1834. * @returns {boolean}
  1835. */
  1836. var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
  1837. /**
  1838. * Determine if we're running in a standard browser webWorker environment
  1839. *
  1840. * Although the `isStandardBrowserEnv` method indicates that
  1841. * `allows axios to run in a web worker`, the WebWorker will still be
  1842. * filtered out due to its judgment standard
  1843. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  1844. * This leads to a problem when axios post `FormData` in webWorker
  1845. */
  1846. var hasStandardBrowserWebWorkerEnv = function () {
  1847. return typeof WorkerGlobalScope !== 'undefined' &&
  1848. // eslint-disable-next-line no-undef
  1849. self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
  1850. }();
  1851. var origin = hasBrowserEnv && window.location.href || 'http://localhost';
  1852. var utils = /*#__PURE__*/Object.freeze({
  1853. __proto__: null,
  1854. hasBrowserEnv: hasBrowserEnv,
  1855. hasStandardBrowserEnv: hasStandardBrowserEnv,
  1856. hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
  1857. navigator: _navigator,
  1858. origin: origin
  1859. });
  1860. var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
  1861. function toURLEncodedForm(data, options) {
  1862. return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
  1863. visitor: function visitor(value, key, path, helpers) {
  1864. if (platform.isNode && utils$1.isBuffer(value)) {
  1865. this.append(key, value.toString('base64'));
  1866. return false;
  1867. }
  1868. return helpers.defaultVisitor.apply(this, arguments);
  1869. }
  1870. }, options));
  1871. }
  1872. /**
  1873. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1874. *
  1875. * @param {string} name - The name of the property to get.
  1876. *
  1877. * @returns An array of strings.
  1878. */
  1879. function parsePropPath(name) {
  1880. // foo[x][y][z]
  1881. // foo.x.y.z
  1882. // foo-x-y-z
  1883. // foo x y z
  1884. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
  1885. return match[0] === '[]' ? '' : match[1] || match[0];
  1886. });
  1887. }
  1888. /**
  1889. * Convert an array to an object.
  1890. *
  1891. * @param {Array<any>} arr - The array to convert to an object.
  1892. *
  1893. * @returns An object with the same keys and values as the array.
  1894. */
  1895. function arrayToObject(arr) {
  1896. var obj = {};
  1897. var keys = Object.keys(arr);
  1898. var i;
  1899. var len = keys.length;
  1900. var key;
  1901. for (i = 0; i < len; i++) {
  1902. key = keys[i];
  1903. obj[key] = arr[key];
  1904. }
  1905. return obj;
  1906. }
  1907. /**
  1908. * It takes a FormData object and returns a JavaScript object
  1909. *
  1910. * @param {string} formData The FormData object to convert to JSON.
  1911. *
  1912. * @returns {Object<string, any> | null} The converted object.
  1913. */
  1914. function formDataToJSON(formData) {
  1915. function buildPath(path, value, target, index) {
  1916. var name = path[index++];
  1917. if (name === '__proto__') return true;
  1918. var isNumericKey = Number.isFinite(+name);
  1919. var isLast = index >= path.length;
  1920. name = !name && utils$1.isArray(target) ? target.length : name;
  1921. if (isLast) {
  1922. if (utils$1.hasOwnProp(target, name)) {
  1923. target[name] = [target[name], value];
  1924. } else {
  1925. target[name] = value;
  1926. }
  1927. return !isNumericKey;
  1928. }
  1929. if (!target[name] || !utils$1.isObject(target[name])) {
  1930. target[name] = [];
  1931. }
  1932. var result = buildPath(path, value, target[name], index);
  1933. if (result && utils$1.isArray(target[name])) {
  1934. target[name] = arrayToObject(target[name]);
  1935. }
  1936. return !isNumericKey;
  1937. }
  1938. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  1939. var obj = {};
  1940. utils$1.forEachEntry(formData, function (name, value) {
  1941. buildPath(parsePropPath(name), value, obj, 0);
  1942. });
  1943. return obj;
  1944. }
  1945. return null;
  1946. }
  1947. /**
  1948. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1949. * of the input
  1950. *
  1951. * @param {any} rawValue - The value to be stringified.
  1952. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1953. * @param {Function} encoder - A function that takes a value and returns a string.
  1954. *
  1955. * @returns {string} A stringified version of the rawValue.
  1956. */
  1957. function stringifySafely(rawValue, parser, encoder) {
  1958. if (utils$1.isString(rawValue)) {
  1959. try {
  1960. (parser || JSON.parse)(rawValue);
  1961. return utils$1.trim(rawValue);
  1962. } catch (e) {
  1963. if (e.name !== 'SyntaxError') {
  1964. throw e;
  1965. }
  1966. }
  1967. }
  1968. return (encoder || JSON.stringify)(rawValue);
  1969. }
  1970. var defaults = {
  1971. transitional: transitionalDefaults,
  1972. adapter: ['xhr', 'http', 'fetch'],
  1973. transformRequest: [function transformRequest(data, headers) {
  1974. var contentType = headers.getContentType() || '';
  1975. var hasJSONContentType = contentType.indexOf('application/json') > -1;
  1976. var isObjectPayload = utils$1.isObject(data);
  1977. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  1978. data = new FormData(data);
  1979. }
  1980. var isFormData = utils$1.isFormData(data);
  1981. if (isFormData) {
  1982. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1983. }
  1984. if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
  1985. return data;
  1986. }
  1987. if (utils$1.isArrayBufferView(data)) {
  1988. return data.buffer;
  1989. }
  1990. if (utils$1.isURLSearchParams(data)) {
  1991. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1992. return data.toString();
  1993. }
  1994. var isFileList;
  1995. if (isObjectPayload) {
  1996. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1997. return toURLEncodedForm(data, this.formSerializer).toString();
  1998. }
  1999. if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  2000. var _FormData = this.env && this.env.FormData;
  2001. return toFormData(isFileList ? {
  2002. 'files[]': data
  2003. } : data, _FormData && new _FormData(), this.formSerializer);
  2004. }
  2005. }
  2006. if (isObjectPayload || hasJSONContentType) {
  2007. headers.setContentType('application/json', false);
  2008. return stringifySafely(data);
  2009. }
  2010. return data;
  2011. }],
  2012. transformResponse: [function transformResponse(data) {
  2013. var transitional = this.transitional || defaults.transitional;
  2014. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  2015. var JSONRequested = this.responseType === 'json';
  2016. if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
  2017. return data;
  2018. }
  2019. if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
  2020. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  2021. var strictJSONParsing = !silentJSONParsing && JSONRequested;
  2022. try {
  2023. return JSON.parse(data, this.parseReviver);
  2024. } catch (e) {
  2025. if (strictJSONParsing) {
  2026. if (e.name === 'SyntaxError') {
  2027. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  2028. }
  2029. throw e;
  2030. }
  2031. }
  2032. }
  2033. return data;
  2034. }],
  2035. /**
  2036. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  2037. * timeout is not created.
  2038. */
  2039. timeout: 0,
  2040. xsrfCookieName: 'XSRF-TOKEN',
  2041. xsrfHeaderName: 'X-XSRF-TOKEN',
  2042. maxContentLength: -1,
  2043. maxBodyLength: -1,
  2044. env: {
  2045. FormData: platform.classes.FormData,
  2046. Blob: platform.classes.Blob
  2047. },
  2048. validateStatus: function validateStatus(status) {
  2049. return status >= 200 && status < 300;
  2050. },
  2051. headers: {
  2052. common: {
  2053. Accept: 'application/json, text/plain, */*',
  2054. 'Content-Type': undefined
  2055. }
  2056. }
  2057. };
  2058. utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], function (method) {
  2059. defaults.headers[method] = {};
  2060. });
  2061. // RawAxiosHeaders whose duplicates are ignored by node
  2062. // c.f. https://nodejs.org/api/http.html#http_message_headers
  2063. 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']);
  2064. /**
  2065. * Parse headers into an object
  2066. *
  2067. * ```
  2068. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  2069. * Content-Type: application/json
  2070. * Connection: keep-alive
  2071. * Transfer-Encoding: chunked
  2072. * ```
  2073. *
  2074. * @param {String} rawHeaders Headers needing to be parsed
  2075. *
  2076. * @returns {Object} Headers parsed into an object
  2077. */
  2078. var parseHeaders = (function (rawHeaders) {
  2079. var parsed = {};
  2080. var key;
  2081. var val;
  2082. var i;
  2083. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  2084. i = line.indexOf(':');
  2085. key = line.substring(0, i).trim().toLowerCase();
  2086. val = line.substring(i + 1).trim();
  2087. if (!key || parsed[key] && ignoreDuplicateOf[key]) {
  2088. return;
  2089. }
  2090. if (key === 'set-cookie') {
  2091. if (parsed[key]) {
  2092. parsed[key].push(val);
  2093. } else {
  2094. parsed[key] = [val];
  2095. }
  2096. } else {
  2097. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  2098. }
  2099. });
  2100. return parsed;
  2101. });
  2102. var $internals = Symbol('internals');
  2103. var isValidHeaderValue = function isValidHeaderValue(value) {
  2104. return !/[\r\n]/.test(value);
  2105. };
  2106. function assertValidHeaderValue(value, header) {
  2107. if (value === false || value == null) {
  2108. return;
  2109. }
  2110. if (utils$1.isArray(value)) {
  2111. value.forEach(function (v) {
  2112. return assertValidHeaderValue(v, header);
  2113. });
  2114. return;
  2115. }
  2116. if (!isValidHeaderValue(String(value))) {
  2117. throw new Error("Invalid character in header content [\"".concat(header, "\"]"));
  2118. }
  2119. }
  2120. function normalizeHeader(header) {
  2121. return header && String(header).trim().toLowerCase();
  2122. }
  2123. function stripTrailingCRLF(str) {
  2124. var end = str.length;
  2125. while (end > 0) {
  2126. var charCode = str.charCodeAt(end - 1);
  2127. if (charCode !== 10 && charCode !== 13) {
  2128. break;
  2129. }
  2130. end -= 1;
  2131. }
  2132. return end === str.length ? str : str.slice(0, end);
  2133. }
  2134. function normalizeValue(value) {
  2135. if (value === false || value == null) {
  2136. return value;
  2137. }
  2138. return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value));
  2139. }
  2140. function parseTokens(str) {
  2141. var tokens = Object.create(null);
  2142. var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  2143. var match;
  2144. while (match = tokensRE.exec(str)) {
  2145. tokens[match[1]] = match[2];
  2146. }
  2147. return tokens;
  2148. }
  2149. var isValidHeaderName = function isValidHeaderName(str) {
  2150. return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  2151. };
  2152. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  2153. if (utils$1.isFunction(filter)) {
  2154. return filter.call(this, value, header);
  2155. }
  2156. if (isHeaderNameFilter) {
  2157. value = header;
  2158. }
  2159. if (!utils$1.isString(value)) return;
  2160. if (utils$1.isString(filter)) {
  2161. return value.indexOf(filter) !== -1;
  2162. }
  2163. if (utils$1.isRegExp(filter)) {
  2164. return filter.test(value);
  2165. }
  2166. }
  2167. function formatHeader(header) {
  2168. return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
  2169. return _char.toUpperCase() + str;
  2170. });
  2171. }
  2172. function buildAccessors(obj, header) {
  2173. var accessorName = utils$1.toCamelCase(' ' + header);
  2174. ['get', 'set', 'has'].forEach(function (methodName) {
  2175. Object.defineProperty(obj, methodName + accessorName, {
  2176. value: function value(arg1, arg2, arg3) {
  2177. return this[methodName].call(this, header, arg1, arg2, arg3);
  2178. },
  2179. configurable: true
  2180. });
  2181. });
  2182. }
  2183. var AxiosHeaders = /*#__PURE__*/function () {
  2184. function AxiosHeaders(headers) {
  2185. _classCallCheck(this, AxiosHeaders);
  2186. headers && this.set(headers);
  2187. }
  2188. return _createClass(AxiosHeaders, [{
  2189. key: "set",
  2190. value: function set(header, valueOrRewrite, rewrite) {
  2191. var self = this;
  2192. function setHeader(_value, _header, _rewrite) {
  2193. var lHeader = normalizeHeader(_header);
  2194. if (!lHeader) {
  2195. throw new Error('header name must be a non-empty string');
  2196. }
  2197. var key = utils$1.findKey(self, lHeader);
  2198. if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
  2199. assertValidHeaderValue(_value, _header);
  2200. self[key || _header] = normalizeValue(_value);
  2201. }
  2202. }
  2203. var setHeaders = function setHeaders(headers, _rewrite) {
  2204. return utils$1.forEach(headers, function (_value, _header) {
  2205. return setHeader(_value, _header, _rewrite);
  2206. });
  2207. };
  2208. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  2209. setHeaders(header, valueOrRewrite);
  2210. } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  2211. setHeaders(parseHeaders(header), valueOrRewrite);
  2212. } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
  2213. var obj = {},
  2214. dest,
  2215. key;
  2216. var _iterator = _createForOfIteratorHelper(header),
  2217. _step;
  2218. try {
  2219. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2220. var entry = _step.value;
  2221. if (!utils$1.isArray(entry)) {
  2222. throw TypeError('Object iterator must return a key-value pair');
  2223. }
  2224. obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
  2225. }
  2226. } catch (err) {
  2227. _iterator.e(err);
  2228. } finally {
  2229. _iterator.f();
  2230. }
  2231. setHeaders(obj, valueOrRewrite);
  2232. } else {
  2233. header != null && setHeader(valueOrRewrite, header, rewrite);
  2234. }
  2235. return this;
  2236. }
  2237. }, {
  2238. key: "get",
  2239. value: function get(header, parser) {
  2240. header = normalizeHeader(header);
  2241. if (header) {
  2242. var key = utils$1.findKey(this, header);
  2243. if (key) {
  2244. var value = this[key];
  2245. if (!parser) {
  2246. return value;
  2247. }
  2248. if (parser === true) {
  2249. return parseTokens(value);
  2250. }
  2251. if (utils$1.isFunction(parser)) {
  2252. return parser.call(this, value, key);
  2253. }
  2254. if (utils$1.isRegExp(parser)) {
  2255. return parser.exec(value);
  2256. }
  2257. throw new TypeError('parser must be boolean|regexp|function');
  2258. }
  2259. }
  2260. }
  2261. }, {
  2262. key: "has",
  2263. value: function has(header, matcher) {
  2264. header = normalizeHeader(header);
  2265. if (header) {
  2266. var key = utils$1.findKey(this, header);
  2267. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  2268. }
  2269. return false;
  2270. }
  2271. }, {
  2272. key: "delete",
  2273. value: function _delete(header, matcher) {
  2274. var self = this;
  2275. var deleted = false;
  2276. function deleteHeader(_header) {
  2277. _header = normalizeHeader(_header);
  2278. if (_header) {
  2279. var key = utils$1.findKey(self, _header);
  2280. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  2281. delete self[key];
  2282. deleted = true;
  2283. }
  2284. }
  2285. }
  2286. if (utils$1.isArray(header)) {
  2287. header.forEach(deleteHeader);
  2288. } else {
  2289. deleteHeader(header);
  2290. }
  2291. return deleted;
  2292. }
  2293. }, {
  2294. key: "clear",
  2295. value: function clear(matcher) {
  2296. var keys = Object.keys(this);
  2297. var i = keys.length;
  2298. var deleted = false;
  2299. while (i--) {
  2300. var key = keys[i];
  2301. if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  2302. delete this[key];
  2303. deleted = true;
  2304. }
  2305. }
  2306. return deleted;
  2307. }
  2308. }, {
  2309. key: "normalize",
  2310. value: function normalize(format) {
  2311. var self = this;
  2312. var headers = {};
  2313. utils$1.forEach(this, function (value, header) {
  2314. var key = utils$1.findKey(headers, header);
  2315. if (key) {
  2316. self[key] = normalizeValue(value);
  2317. delete self[header];
  2318. return;
  2319. }
  2320. var normalized = format ? formatHeader(header) : String(header).trim();
  2321. if (normalized !== header) {
  2322. delete self[header];
  2323. }
  2324. self[normalized] = normalizeValue(value);
  2325. headers[normalized] = true;
  2326. });
  2327. return this;
  2328. }
  2329. }, {
  2330. key: "concat",
  2331. value: function concat() {
  2332. var _this$constructor;
  2333. for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
  2334. targets[_key] = arguments[_key];
  2335. }
  2336. return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
  2337. }
  2338. }, {
  2339. key: "toJSON",
  2340. value: function toJSON(asStrings) {
  2341. var obj = Object.create(null);
  2342. utils$1.forEach(this, function (value, header) {
  2343. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
  2344. });
  2345. return obj;
  2346. }
  2347. }, {
  2348. key: Symbol.iterator,
  2349. value: function value() {
  2350. return Object.entries(this.toJSON())[Symbol.iterator]();
  2351. }
  2352. }, {
  2353. key: "toString",
  2354. value: function toString() {
  2355. return Object.entries(this.toJSON()).map(function (_ref) {
  2356. var _ref2 = _slicedToArray(_ref, 2),
  2357. header = _ref2[0],
  2358. value = _ref2[1];
  2359. return header + ': ' + value;
  2360. }).join('\n');
  2361. }
  2362. }, {
  2363. key: "getSetCookie",
  2364. value: function getSetCookie() {
  2365. return this.get('set-cookie') || [];
  2366. }
  2367. }, {
  2368. key: Symbol.toStringTag,
  2369. get: function get() {
  2370. return 'AxiosHeaders';
  2371. }
  2372. }], [{
  2373. key: "from",
  2374. value: function from(thing) {
  2375. return thing instanceof this ? thing : new this(thing);
  2376. }
  2377. }, {
  2378. key: "concat",
  2379. value: function concat(first) {
  2380. var computed = new this(first);
  2381. for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  2382. targets[_key2 - 1] = arguments[_key2];
  2383. }
  2384. targets.forEach(function (target) {
  2385. return computed.set(target);
  2386. });
  2387. return computed;
  2388. }
  2389. }, {
  2390. key: "accessor",
  2391. value: function accessor(header) {
  2392. var internals = this[$internals] = this[$internals] = {
  2393. accessors: {}
  2394. };
  2395. var accessors = internals.accessors;
  2396. var prototype = this.prototype;
  2397. function defineAccessor(_header) {
  2398. var lHeader = normalizeHeader(_header);
  2399. if (!accessors[lHeader]) {
  2400. buildAccessors(prototype, _header);
  2401. accessors[lHeader] = true;
  2402. }
  2403. }
  2404. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  2405. return this;
  2406. }
  2407. }]);
  2408. }();
  2409. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  2410. // reserved names hotfix
  2411. utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
  2412. var value = _ref3.value;
  2413. var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
  2414. return {
  2415. get: function get() {
  2416. return value;
  2417. },
  2418. set: function set(headerValue) {
  2419. this[mapped] = headerValue;
  2420. }
  2421. };
  2422. });
  2423. utils$1.freezeMethods(AxiosHeaders);
  2424. /**
  2425. * Transform the data for a request or a response
  2426. *
  2427. * @param {Array|Function} fns A single function or Array of functions
  2428. * @param {?Object} response The response object
  2429. *
  2430. * @returns {*} The resulting transformed data
  2431. */
  2432. function transformData(fns, response) {
  2433. var config = this || defaults;
  2434. var context = response || config;
  2435. var headers = AxiosHeaders.from(context.headers);
  2436. var data = context.data;
  2437. utils$1.forEach(fns, function transform(fn) {
  2438. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  2439. });
  2440. headers.normalize();
  2441. return data;
  2442. }
  2443. function isCancel(value) {
  2444. return !!(value && value.__CANCEL__);
  2445. }
  2446. var CanceledError = /*#__PURE__*/function (_AxiosError) {
  2447. /**
  2448. * A `CanceledError` is an object that is thrown when an operation is canceled.
  2449. *
  2450. * @param {string=} message The message.
  2451. * @param {Object=} config The config.
  2452. * @param {Object=} request The request.
  2453. *
  2454. * @returns {CanceledError} The created error.
  2455. */
  2456. function CanceledError(message, config, request) {
  2457. var _this;
  2458. _classCallCheck(this, CanceledError);
  2459. _this = _callSuper(this, CanceledError, [message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request]);
  2460. _this.name = 'CanceledError';
  2461. _this.__CANCEL__ = true;
  2462. return _this;
  2463. }
  2464. _inherits(CanceledError, _AxiosError);
  2465. return _createClass(CanceledError);
  2466. }(AxiosError);
  2467. /**
  2468. * Resolve or reject a Promise based on response status.
  2469. *
  2470. * @param {Function} resolve A function that resolves the promise.
  2471. * @param {Function} reject A function that rejects the promise.
  2472. * @param {object} response The response.
  2473. *
  2474. * @returns {object} The response.
  2475. */
  2476. function settle(resolve, reject, response) {
  2477. var validateStatus = response.config.validateStatus;
  2478. if (!response.status || !validateStatus || validateStatus(response.status)) {
  2479. resolve(response);
  2480. } else {
  2481. 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));
  2482. }
  2483. }
  2484. function parseProtocol(url) {
  2485. var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  2486. return match && match[1] || '';
  2487. }
  2488. /**
  2489. * Calculate data maxRate
  2490. * @param {Number} [samplesCount= 10]
  2491. * @param {Number} [min= 1000]
  2492. * @returns {Function}
  2493. */
  2494. function speedometer(samplesCount, min) {
  2495. samplesCount = samplesCount || 10;
  2496. var bytes = new Array(samplesCount);
  2497. var timestamps = new Array(samplesCount);
  2498. var head = 0;
  2499. var tail = 0;
  2500. var firstSampleTS;
  2501. min = min !== undefined ? min : 1000;
  2502. return function push(chunkLength) {
  2503. var now = Date.now();
  2504. var startedAt = timestamps[tail];
  2505. if (!firstSampleTS) {
  2506. firstSampleTS = now;
  2507. }
  2508. bytes[head] = chunkLength;
  2509. timestamps[head] = now;
  2510. var i = tail;
  2511. var bytesCount = 0;
  2512. while (i !== head) {
  2513. bytesCount += bytes[i++];
  2514. i = i % samplesCount;
  2515. }
  2516. head = (head + 1) % samplesCount;
  2517. if (head === tail) {
  2518. tail = (tail + 1) % samplesCount;
  2519. }
  2520. if (now - firstSampleTS < min) {
  2521. return;
  2522. }
  2523. var passed = startedAt && now - startedAt;
  2524. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  2525. };
  2526. }
  2527. /**
  2528. * Throttle decorator
  2529. * @param {Function} fn
  2530. * @param {Number} freq
  2531. * @return {Function}
  2532. */
  2533. function throttle(fn, freq) {
  2534. var timestamp = 0;
  2535. var threshold = 1000 / freq;
  2536. var lastArgs;
  2537. var timer;
  2538. var invoke = function invoke(args) {
  2539. var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
  2540. timestamp = now;
  2541. lastArgs = null;
  2542. if (timer) {
  2543. clearTimeout(timer);
  2544. timer = null;
  2545. }
  2546. fn.apply(void 0, _toConsumableArray(args));
  2547. };
  2548. var throttled = function throttled() {
  2549. var now = Date.now();
  2550. var passed = now - timestamp;
  2551. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2552. args[_key] = arguments[_key];
  2553. }
  2554. if (passed >= threshold) {
  2555. invoke(args, now);
  2556. } else {
  2557. lastArgs = args;
  2558. if (!timer) {
  2559. timer = setTimeout(function () {
  2560. timer = null;
  2561. invoke(lastArgs);
  2562. }, threshold - passed);
  2563. }
  2564. }
  2565. };
  2566. var flush = function flush() {
  2567. return lastArgs && invoke(lastArgs);
  2568. };
  2569. return [throttled, flush];
  2570. }
  2571. var progressEventReducer = function progressEventReducer(listener, isDownloadStream) {
  2572. var freq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
  2573. var bytesNotified = 0;
  2574. var _speedometer = speedometer(50, 250);
  2575. return throttle(function (e) {
  2576. var loaded = e.loaded;
  2577. var total = e.lengthComputable ? e.total : undefined;
  2578. var progressBytes = loaded - bytesNotified;
  2579. var rate = _speedometer(progressBytes);
  2580. var inRange = loaded <= total;
  2581. bytesNotified = loaded;
  2582. var data = _defineProperty({
  2583. loaded: loaded,
  2584. total: total,
  2585. progress: total ? loaded / total : undefined,
  2586. bytes: progressBytes,
  2587. rate: rate ? rate : undefined,
  2588. estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
  2589. event: e,
  2590. lengthComputable: total != null
  2591. }, isDownloadStream ? 'download' : 'upload', true);
  2592. listener(data);
  2593. }, freq);
  2594. };
  2595. var progressEventDecorator = function progressEventDecorator(total, throttled) {
  2596. var lengthComputable = total != null;
  2597. return [function (loaded) {
  2598. return throttled[0]({
  2599. lengthComputable: lengthComputable,
  2600. total: total,
  2601. loaded: loaded
  2602. });
  2603. }, throttled[1]];
  2604. };
  2605. var asyncDecorator = function asyncDecorator(fn) {
  2606. return function () {
  2607. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2608. args[_key] = arguments[_key];
  2609. }
  2610. return utils$1.asap(function () {
  2611. return fn.apply(void 0, args);
  2612. });
  2613. };
  2614. };
  2615. var isURLSameOrigin = platform.hasStandardBrowserEnv ? function (origin, isMSIE) {
  2616. return function (url) {
  2617. url = new URL(url, platform.origin);
  2618. return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
  2619. };
  2620. }(new URL(platform.origin), platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)) : function () {
  2621. return true;
  2622. };
  2623. var cookies = platform.hasStandardBrowserEnv ?
  2624. // Standard browser envs support document.cookie
  2625. {
  2626. write: function write(name, value, expires, path, domain, secure, sameSite) {
  2627. if (typeof document === 'undefined') return;
  2628. var cookie = ["".concat(name, "=").concat(encodeURIComponent(value))];
  2629. if (utils$1.isNumber(expires)) {
  2630. cookie.push("expires=".concat(new Date(expires).toUTCString()));
  2631. }
  2632. if (utils$1.isString(path)) {
  2633. cookie.push("path=".concat(path));
  2634. }
  2635. if (utils$1.isString(domain)) {
  2636. cookie.push("domain=".concat(domain));
  2637. }
  2638. if (secure === true) {
  2639. cookie.push('secure');
  2640. }
  2641. if (utils$1.isString(sameSite)) {
  2642. cookie.push("SameSite=".concat(sameSite));
  2643. }
  2644. document.cookie = cookie.join('; ');
  2645. },
  2646. read: function read(name) {
  2647. if (typeof document === 'undefined') return null;
  2648. var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
  2649. return match ? decodeURIComponent(match[1]) : null;
  2650. },
  2651. remove: function remove(name) {
  2652. this.write(name, '', Date.now() - 86400000, '/');
  2653. }
  2654. } :
  2655. // Non-standard browser env (web workers, react-native) lack needed support.
  2656. {
  2657. write: function write() {},
  2658. read: function read() {
  2659. return null;
  2660. },
  2661. remove: function remove() {}
  2662. };
  2663. /**
  2664. * Determines whether the specified URL is absolute
  2665. *
  2666. * @param {string} url The URL to test
  2667. *
  2668. * @returns {boolean} True if the specified URL is absolute, otherwise false
  2669. */
  2670. function isAbsoluteURL(url) {
  2671. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  2672. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  2673. // by any combination of letters, digits, plus, period, or hyphen.
  2674. if (typeof url !== 'string') {
  2675. return false;
  2676. }
  2677. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  2678. }
  2679. /**
  2680. * Creates a new URL by combining the specified URLs
  2681. *
  2682. * @param {string} baseURL The base URL
  2683. * @param {string} relativeURL The relative URL
  2684. *
  2685. * @returns {string} The combined URL
  2686. */
  2687. function combineURLs(baseURL, relativeURL) {
  2688. return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
  2689. }
  2690. /**
  2691. * Creates a new URL by combining the baseURL with the requestedURL,
  2692. * only when the requestedURL is not already an absolute URL.
  2693. * If the requestURL is absolute, this function returns the requestedURL untouched.
  2694. *
  2695. * @param {string} baseURL The base URL
  2696. * @param {string} requestedURL Absolute or relative URL to combine
  2697. *
  2698. * @returns {string} The combined full path
  2699. */
  2700. function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
  2701. var isRelativeUrl = !isAbsoluteURL(requestedURL);
  2702. if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
  2703. return combineURLs(baseURL, requestedURL);
  2704. }
  2705. return requestedURL;
  2706. }
  2707. var headersToObject = function headersToObject(thing) {
  2708. return thing instanceof AxiosHeaders ? _objectSpread2({}, thing) : thing;
  2709. };
  2710. /**
  2711. * Config-specific merge-function which creates a new config-object
  2712. * by merging two configuration objects together.
  2713. *
  2714. * @param {Object} config1
  2715. * @param {Object} config2
  2716. *
  2717. * @returns {Object} New object resulting from merging config2 to config1
  2718. */
  2719. function mergeConfig(config1, config2) {
  2720. // eslint-disable-next-line no-param-reassign
  2721. config2 = config2 || {};
  2722. var config = {};
  2723. function getMergedValue(target, source, prop, caseless) {
  2724. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  2725. return utils$1.merge.call({
  2726. caseless: caseless
  2727. }, target, source);
  2728. } else if (utils$1.isPlainObject(source)) {
  2729. return utils$1.merge({}, source);
  2730. } else if (utils$1.isArray(source)) {
  2731. return source.slice();
  2732. }
  2733. return source;
  2734. }
  2735. function mergeDeepProperties(a, b, prop, caseless) {
  2736. if (!utils$1.isUndefined(b)) {
  2737. return getMergedValue(a, b, prop, caseless);
  2738. } else if (!utils$1.isUndefined(a)) {
  2739. return getMergedValue(undefined, a, prop, caseless);
  2740. }
  2741. }
  2742. // eslint-disable-next-line consistent-return
  2743. function valueFromConfig2(a, b) {
  2744. if (!utils$1.isUndefined(b)) {
  2745. return getMergedValue(undefined, b);
  2746. }
  2747. }
  2748. // eslint-disable-next-line consistent-return
  2749. function defaultToConfig2(a, b) {
  2750. if (!utils$1.isUndefined(b)) {
  2751. return getMergedValue(undefined, b);
  2752. } else if (!utils$1.isUndefined(a)) {
  2753. return getMergedValue(undefined, a);
  2754. }
  2755. }
  2756. // eslint-disable-next-line consistent-return
  2757. function mergeDirectKeys(a, b, prop) {
  2758. if (prop in config2) {
  2759. return getMergedValue(a, b);
  2760. } else if (prop in config1) {
  2761. return getMergedValue(undefined, a);
  2762. }
  2763. }
  2764. var mergeMap = {
  2765. url: valueFromConfig2,
  2766. method: valueFromConfig2,
  2767. data: valueFromConfig2,
  2768. baseURL: defaultToConfig2,
  2769. transformRequest: defaultToConfig2,
  2770. transformResponse: defaultToConfig2,
  2771. paramsSerializer: defaultToConfig2,
  2772. timeout: defaultToConfig2,
  2773. timeoutMessage: defaultToConfig2,
  2774. withCredentials: defaultToConfig2,
  2775. withXSRFToken: defaultToConfig2,
  2776. adapter: defaultToConfig2,
  2777. responseType: defaultToConfig2,
  2778. xsrfCookieName: defaultToConfig2,
  2779. xsrfHeaderName: defaultToConfig2,
  2780. onUploadProgress: defaultToConfig2,
  2781. onDownloadProgress: defaultToConfig2,
  2782. decompress: defaultToConfig2,
  2783. maxContentLength: defaultToConfig2,
  2784. maxBodyLength: defaultToConfig2,
  2785. beforeRedirect: defaultToConfig2,
  2786. transport: defaultToConfig2,
  2787. httpAgent: defaultToConfig2,
  2788. httpsAgent: defaultToConfig2,
  2789. cancelToken: defaultToConfig2,
  2790. socketPath: defaultToConfig2,
  2791. responseEncoding: defaultToConfig2,
  2792. validateStatus: mergeDirectKeys,
  2793. headers: function headers(a, b, prop) {
  2794. return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
  2795. }
  2796. };
  2797. utils$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
  2798. if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
  2799. var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
  2800. var configValue = merge(config1[prop], config2[prop], prop);
  2801. utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
  2802. });
  2803. return config;
  2804. }
  2805. var resolveConfig = (function (config) {
  2806. var newConfig = mergeConfig({}, config);
  2807. var data = newConfig.data,
  2808. withXSRFToken = newConfig.withXSRFToken,
  2809. xsrfHeaderName = newConfig.xsrfHeaderName,
  2810. xsrfCookieName = newConfig.xsrfCookieName,
  2811. headers = newConfig.headers,
  2812. auth = newConfig.auth;
  2813. newConfig.headers = headers = AxiosHeaders.from(headers);
  2814. newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
  2815. // HTTP basic authentication
  2816. if (auth) {
  2817. headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
  2818. }
  2819. if (utils$1.isFormData(data)) {
  2820. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
  2821. headers.setContentType(undefined); // browser handles it
  2822. } else if (utils$1.isFunction(data.getHeaders)) {
  2823. // Node.js FormData (like form-data package)
  2824. var formHeaders = data.getHeaders();
  2825. // Only set safe headers to avoid overwriting security headers
  2826. var allowedHeaders = ['content-type', 'content-length'];
  2827. Object.entries(formHeaders).forEach(function (_ref) {
  2828. var _ref2 = _slicedToArray(_ref, 2),
  2829. key = _ref2[0],
  2830. val = _ref2[1];
  2831. if (allowedHeaders.includes(key.toLowerCase())) {
  2832. headers.set(key, val);
  2833. }
  2834. });
  2835. }
  2836. }
  2837. // Add xsrf header
  2838. // This is only done if running in a standard browser environment.
  2839. // Specifically not if we're in a web worker, or react-native.
  2840. if (platform.hasStandardBrowserEnv) {
  2841. withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
  2842. if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
  2843. // Add xsrf header
  2844. var xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
  2845. if (xsrfValue) {
  2846. headers.set(xsrfHeaderName, xsrfValue);
  2847. }
  2848. }
  2849. }
  2850. return newConfig;
  2851. });
  2852. var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  2853. var xhrAdapter = isXHRAdapterSupported && function (config) {
  2854. return new Promise(function dispatchXhrRequest(resolve, reject) {
  2855. var _config = resolveConfig(config);
  2856. var requestData = _config.data;
  2857. var requestHeaders = AxiosHeaders.from(_config.headers).normalize();
  2858. var responseType = _config.responseType,
  2859. onUploadProgress = _config.onUploadProgress,
  2860. onDownloadProgress = _config.onDownloadProgress;
  2861. var onCanceled;
  2862. var uploadThrottled, downloadThrottled;
  2863. var flushUpload, flushDownload;
  2864. function done() {
  2865. flushUpload && flushUpload(); // flush events
  2866. flushDownload && flushDownload(); // flush events
  2867. _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
  2868. _config.signal && _config.signal.removeEventListener('abort', onCanceled);
  2869. }
  2870. var request = new XMLHttpRequest();
  2871. request.open(_config.method.toUpperCase(), _config.url, true);
  2872. // Set the request timeout in MS
  2873. request.timeout = _config.timeout;
  2874. function onloadend() {
  2875. if (!request) {
  2876. return;
  2877. }
  2878. // Prepare the response
  2879. var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
  2880. var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
  2881. var response = {
  2882. data: responseData,
  2883. status: request.status,
  2884. statusText: request.statusText,
  2885. headers: responseHeaders,
  2886. config: config,
  2887. request: request
  2888. };
  2889. settle(function _resolve(value) {
  2890. resolve(value);
  2891. done();
  2892. }, function _reject(err) {
  2893. reject(err);
  2894. done();
  2895. }, response);
  2896. // Clean up request
  2897. request = null;
  2898. }
  2899. if ('onloadend' in request) {
  2900. // Use onloadend if available
  2901. request.onloadend = onloadend;
  2902. } else {
  2903. // Listen for ready state to emulate onloadend
  2904. request.onreadystatechange = function handleLoad() {
  2905. if (!request || request.readyState !== 4) {
  2906. return;
  2907. }
  2908. // The request errored out and we didn't get a response, this will be
  2909. // handled by onerror instead
  2910. // With one exception: request that using file: protocol, most browsers
  2911. // will return status as 0 even though it's a successful request
  2912. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  2913. return;
  2914. }
  2915. // readystate handler is calling before onerror or ontimeout handlers,
  2916. // so we should call onloadend on the next 'tick'
  2917. setTimeout(onloadend);
  2918. };
  2919. }
  2920. // Handle browser request cancellation (as opposed to a manual cancellation)
  2921. request.onabort = function handleAbort() {
  2922. if (!request) {
  2923. return;
  2924. }
  2925. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  2926. // Clean up request
  2927. request = null;
  2928. };
  2929. // Handle low level network errors
  2930. request.onerror = function handleError(event) {
  2931. // Browsers deliver a ProgressEvent in XHR onerror
  2932. // (message may be empty; when present, surface it)
  2933. // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
  2934. var msg = event && event.message ? event.message : 'Network Error';
  2935. var err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
  2936. // attach the underlying event for consumers who want details
  2937. err.event = event || null;
  2938. reject(err);
  2939. request = null;
  2940. };
  2941. // Handle timeout
  2942. request.ontimeout = function handleTimeout() {
  2943. var timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
  2944. var transitional = _config.transitional || transitionalDefaults;
  2945. if (_config.timeoutErrorMessage) {
  2946. timeoutErrorMessage = _config.timeoutErrorMessage;
  2947. }
  2948. reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
  2949. // Clean up request
  2950. request = null;
  2951. };
  2952. // Remove Content-Type if data is undefined
  2953. requestData === undefined && requestHeaders.setContentType(null);
  2954. // Add headers to the request
  2955. if ('setRequestHeader' in request) {
  2956. utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  2957. request.setRequestHeader(key, val);
  2958. });
  2959. }
  2960. // Add withCredentials to request if needed
  2961. if (!utils$1.isUndefined(_config.withCredentials)) {
  2962. request.withCredentials = !!_config.withCredentials;
  2963. }
  2964. // Add responseType to request if needed
  2965. if (responseType && responseType !== 'json') {
  2966. request.responseType = _config.responseType;
  2967. }
  2968. // Handle progress if needed
  2969. if (onDownloadProgress) {
  2970. var _progressEventReducer = progressEventReducer(onDownloadProgress, true);
  2971. var _progressEventReducer2 = _slicedToArray(_progressEventReducer, 2);
  2972. downloadThrottled = _progressEventReducer2[0];
  2973. flushDownload = _progressEventReducer2[1];
  2974. request.addEventListener('progress', downloadThrottled);
  2975. }
  2976. // Not all browsers support upload events
  2977. if (onUploadProgress && request.upload) {
  2978. var _progressEventReducer3 = progressEventReducer(onUploadProgress);
  2979. var _progressEventReducer4 = _slicedToArray(_progressEventReducer3, 2);
  2980. uploadThrottled = _progressEventReducer4[0];
  2981. flushUpload = _progressEventReducer4[1];
  2982. request.upload.addEventListener('progress', uploadThrottled);
  2983. request.upload.addEventListener('loadend', flushUpload);
  2984. }
  2985. if (_config.cancelToken || _config.signal) {
  2986. // Handle cancellation
  2987. // eslint-disable-next-line func-names
  2988. onCanceled = function onCanceled(cancel) {
  2989. if (!request) {
  2990. return;
  2991. }
  2992. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  2993. request.abort();
  2994. request = null;
  2995. };
  2996. _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
  2997. if (_config.signal) {
  2998. _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
  2999. }
  3000. }
  3001. var protocol = parseProtocol(_config.url);
  3002. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  3003. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  3004. return;
  3005. }
  3006. // Send the request
  3007. request.send(requestData || null);
  3008. });
  3009. };
  3010. var composeSignals = function composeSignals(signals, timeout) {
  3011. var _signals = signals = signals ? signals.filter(Boolean) : [],
  3012. length = _signals.length;
  3013. if (timeout || length) {
  3014. var controller = new AbortController();
  3015. var aborted;
  3016. var onabort = function onabort(reason) {
  3017. if (!aborted) {
  3018. aborted = true;
  3019. unsubscribe();
  3020. var err = reason instanceof Error ? reason : this.reason;
  3021. controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
  3022. }
  3023. };
  3024. var timer = timeout && setTimeout(function () {
  3025. timer = null;
  3026. onabort(new AxiosError("timeout of ".concat(timeout, "ms exceeded"), AxiosError.ETIMEDOUT));
  3027. }, timeout);
  3028. var unsubscribe = function unsubscribe() {
  3029. if (signals) {
  3030. timer && clearTimeout(timer);
  3031. timer = null;
  3032. signals.forEach(function (signal) {
  3033. signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
  3034. });
  3035. signals = null;
  3036. }
  3037. };
  3038. signals.forEach(function (signal) {
  3039. return signal.addEventListener('abort', onabort);
  3040. });
  3041. var signal = controller.signal;
  3042. signal.unsubscribe = function () {
  3043. return utils$1.asap(unsubscribe);
  3044. };
  3045. return signal;
  3046. }
  3047. };
  3048. var streamChunk = /*#__PURE__*/_regenerator().m(function streamChunk(chunk, chunkSize) {
  3049. var len, pos, end;
  3050. return _regenerator().w(function (_context) {
  3051. while (1) switch (_context.n) {
  3052. case 0:
  3053. len = chunk.byteLength;
  3054. if (!(!chunkSize || len < chunkSize)) {
  3055. _context.n = 2;
  3056. break;
  3057. }
  3058. _context.n = 1;
  3059. return chunk;
  3060. case 1:
  3061. return _context.a(2);
  3062. case 2:
  3063. pos = 0;
  3064. case 3:
  3065. if (!(pos < len)) {
  3066. _context.n = 5;
  3067. break;
  3068. }
  3069. end = pos + chunkSize;
  3070. _context.n = 4;
  3071. return chunk.slice(pos, end);
  3072. case 4:
  3073. pos = end;
  3074. _context.n = 3;
  3075. break;
  3076. case 5:
  3077. return _context.a(2);
  3078. }
  3079. }, streamChunk);
  3080. });
  3081. var readBytes = /*#__PURE__*/function () {
  3082. var _ref = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee(iterable, chunkSize) {
  3083. var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
  3084. return _regenerator().w(function (_context2) {
  3085. while (1) switch (_context2.p = _context2.n) {
  3086. case 0:
  3087. _iteratorAbruptCompletion = false;
  3088. _didIteratorError = false;
  3089. _context2.p = 1;
  3090. _iterator = _asyncIterator(readStream(iterable));
  3091. case 2:
  3092. _context2.n = 3;
  3093. return _awaitAsyncGenerator(_iterator.next());
  3094. case 3:
  3095. if (!(_iteratorAbruptCompletion = !(_step = _context2.v).done)) {
  3096. _context2.n = 5;
  3097. break;
  3098. }
  3099. chunk = _step.value;
  3100. return _context2.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(streamChunk(chunk, chunkSize)))), 4);
  3101. case 4:
  3102. _iteratorAbruptCompletion = false;
  3103. _context2.n = 2;
  3104. break;
  3105. case 5:
  3106. _context2.n = 7;
  3107. break;
  3108. case 6:
  3109. _context2.p = 6;
  3110. _t = _context2.v;
  3111. _didIteratorError = true;
  3112. _iteratorError = _t;
  3113. case 7:
  3114. _context2.p = 7;
  3115. _context2.p = 8;
  3116. if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
  3117. _context2.n = 9;
  3118. break;
  3119. }
  3120. _context2.n = 9;
  3121. return _awaitAsyncGenerator(_iterator["return"]());
  3122. case 9:
  3123. _context2.p = 9;
  3124. if (!_didIteratorError) {
  3125. _context2.n = 10;
  3126. break;
  3127. }
  3128. throw _iteratorError;
  3129. case 10:
  3130. return _context2.f(9);
  3131. case 11:
  3132. return _context2.f(7);
  3133. case 12:
  3134. return _context2.a(2);
  3135. }
  3136. }, _callee, null, [[8,, 9, 11], [1, 6, 7, 12]]);
  3137. }));
  3138. return function readBytes(_x, _x2) {
  3139. return _ref.apply(this, arguments);
  3140. };
  3141. }();
  3142. var readStream = /*#__PURE__*/function () {
  3143. var _ref2 = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee2(stream) {
  3144. var reader, _yield$_awaitAsyncGen, done, value;
  3145. return _regenerator().w(function (_context3) {
  3146. while (1) switch (_context3.p = _context3.n) {
  3147. case 0:
  3148. if (!stream[Symbol.asyncIterator]) {
  3149. _context3.n = 2;
  3150. break;
  3151. }
  3152. return _context3.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(stream))), 1);
  3153. case 1:
  3154. return _context3.a(2);
  3155. case 2:
  3156. reader = stream.getReader();
  3157. _context3.p = 3;
  3158. case 4:
  3159. _context3.n = 5;
  3160. return _awaitAsyncGenerator(reader.read());
  3161. case 5:
  3162. _yield$_awaitAsyncGen = _context3.v;
  3163. done = _yield$_awaitAsyncGen.done;
  3164. value = _yield$_awaitAsyncGen.value;
  3165. if (!done) {
  3166. _context3.n = 6;
  3167. break;
  3168. }
  3169. return _context3.a(3, 8);
  3170. case 6:
  3171. _context3.n = 7;
  3172. return value;
  3173. case 7:
  3174. _context3.n = 4;
  3175. break;
  3176. case 8:
  3177. _context3.p = 8;
  3178. _context3.n = 9;
  3179. return _awaitAsyncGenerator(reader.cancel());
  3180. case 9:
  3181. return _context3.f(8);
  3182. case 10:
  3183. return _context3.a(2);
  3184. }
  3185. }, _callee2, null, [[3,, 8, 10]]);
  3186. }));
  3187. return function readStream(_x3) {
  3188. return _ref2.apply(this, arguments);
  3189. };
  3190. }();
  3191. var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) {
  3192. var iterator = readBytes(stream, chunkSize);
  3193. var bytes = 0;
  3194. var done;
  3195. var _onFinish = function _onFinish(e) {
  3196. if (!done) {
  3197. done = true;
  3198. onFinish && onFinish(e);
  3199. }
  3200. };
  3201. return new ReadableStream({
  3202. pull: function pull(controller) {
  3203. return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
  3204. var _yield$iterator$next, _done, value, len, loadedBytes, _t2;
  3205. return _regenerator().w(function (_context4) {
  3206. while (1) switch (_context4.p = _context4.n) {
  3207. case 0:
  3208. _context4.p = 0;
  3209. _context4.n = 1;
  3210. return iterator.next();
  3211. case 1:
  3212. _yield$iterator$next = _context4.v;
  3213. _done = _yield$iterator$next.done;
  3214. value = _yield$iterator$next.value;
  3215. if (!_done) {
  3216. _context4.n = 2;
  3217. break;
  3218. }
  3219. _onFinish();
  3220. controller.close();
  3221. return _context4.a(2);
  3222. case 2:
  3223. len = value.byteLength;
  3224. if (onProgress) {
  3225. loadedBytes = bytes += len;
  3226. onProgress(loadedBytes);
  3227. }
  3228. controller.enqueue(new Uint8Array(value));
  3229. _context4.n = 4;
  3230. break;
  3231. case 3:
  3232. _context4.p = 3;
  3233. _t2 = _context4.v;
  3234. _onFinish(_t2);
  3235. throw _t2;
  3236. case 4:
  3237. return _context4.a(2);
  3238. }
  3239. }, _callee3, null, [[0, 3]]);
  3240. }))();
  3241. },
  3242. cancel: function cancel(reason) {
  3243. _onFinish(reason);
  3244. return iterator["return"]();
  3245. }
  3246. }, {
  3247. highWaterMark: 2
  3248. });
  3249. };
  3250. var DEFAULT_CHUNK_SIZE = 64 * 1024;
  3251. var isFunction = utils$1.isFunction;
  3252. var globalFetchAPI = function (_ref) {
  3253. var Request = _ref.Request,
  3254. Response = _ref.Response;
  3255. return {
  3256. Request: Request,
  3257. Response: Response
  3258. };
  3259. }(utils$1.global);
  3260. var _utils$global = utils$1.global,
  3261. ReadableStream$1 = _utils$global.ReadableStream,
  3262. TextEncoder = _utils$global.TextEncoder;
  3263. var test = function test(fn) {
  3264. try {
  3265. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3266. args[_key - 1] = arguments[_key];
  3267. }
  3268. return !!fn.apply(void 0, args);
  3269. } catch (e) {
  3270. return false;
  3271. }
  3272. };
  3273. var factory = function factory(env) {
  3274. env = utils$1.merge.call({
  3275. skipUndefined: true
  3276. }, globalFetchAPI, env);
  3277. var _env = env,
  3278. envFetch = _env.fetch,
  3279. Request = _env.Request,
  3280. Response = _env.Response;
  3281. var isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
  3282. var isRequestSupported = isFunction(Request);
  3283. var isResponseSupported = isFunction(Response);
  3284. if (!isFetchSupported) {
  3285. return false;
  3286. }
  3287. var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
  3288. var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
  3289. return function (str) {
  3290. return encoder.encode(str);
  3291. };
  3292. }(new TextEncoder()) : (/*#__PURE__*/function () {
  3293. var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
  3294. var _t, _t2;
  3295. return _regenerator().w(function (_context) {
  3296. while (1) switch (_context.n) {
  3297. case 0:
  3298. _t = Uint8Array;
  3299. _context.n = 1;
  3300. return new Request(str).arrayBuffer();
  3301. case 1:
  3302. _t2 = _context.v;
  3303. return _context.a(2, new _t(_t2));
  3304. }
  3305. }, _callee);
  3306. }));
  3307. return function (_x) {
  3308. return _ref2.apply(this, arguments);
  3309. };
  3310. }()));
  3311. var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
  3312. var duplexAccessed = false;
  3313. var body = new ReadableStream$1();
  3314. var hasContentType = new Request(platform.origin, {
  3315. body: body,
  3316. method: 'POST',
  3317. get duplex() {
  3318. duplexAccessed = true;
  3319. return 'half';
  3320. }
  3321. }).headers.has('Content-Type');
  3322. body.cancel();
  3323. return duplexAccessed && !hasContentType;
  3324. });
  3325. var supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(function () {
  3326. return utils$1.isReadableStream(new Response('').body);
  3327. });
  3328. var resolvers = {
  3329. stream: supportsResponseStream && function (res) {
  3330. return res.body;
  3331. }
  3332. };
  3333. isFetchSupported && function () {
  3334. ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
  3335. !resolvers[type] && (resolvers[type] = function (res, config) {
  3336. var method = res && res[type];
  3337. if (method) {
  3338. return method.call(res);
  3339. }
  3340. throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
  3341. });
  3342. });
  3343. }();
  3344. var getBodyLength = /*#__PURE__*/function () {
  3345. var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
  3346. var _request;
  3347. return _regenerator().w(function (_context2) {
  3348. while (1) switch (_context2.n) {
  3349. case 0:
  3350. if (!(body == null)) {
  3351. _context2.n = 1;
  3352. break;
  3353. }
  3354. return _context2.a(2, 0);
  3355. case 1:
  3356. if (!utils$1.isBlob(body)) {
  3357. _context2.n = 2;
  3358. break;
  3359. }
  3360. return _context2.a(2, body.size);
  3361. case 2:
  3362. if (!utils$1.isSpecCompliantForm(body)) {
  3363. _context2.n = 4;
  3364. break;
  3365. }
  3366. _request = new Request(platform.origin, {
  3367. method: 'POST',
  3368. body: body
  3369. });
  3370. _context2.n = 3;
  3371. return _request.arrayBuffer();
  3372. case 3:
  3373. return _context2.a(2, _context2.v.byteLength);
  3374. case 4:
  3375. if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
  3376. _context2.n = 5;
  3377. break;
  3378. }
  3379. return _context2.a(2, body.byteLength);
  3380. case 5:
  3381. if (utils$1.isURLSearchParams(body)) {
  3382. body = body + '';
  3383. }
  3384. if (!utils$1.isString(body)) {
  3385. _context2.n = 7;
  3386. break;
  3387. }
  3388. _context2.n = 6;
  3389. return encodeText(body);
  3390. case 6:
  3391. return _context2.a(2, _context2.v.byteLength);
  3392. case 7:
  3393. return _context2.a(2);
  3394. }
  3395. }, _callee2);
  3396. }));
  3397. return function getBodyLength(_x2) {
  3398. return _ref3.apply(this, arguments);
  3399. };
  3400. }();
  3401. var resolveBodyLength = /*#__PURE__*/function () {
  3402. var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
  3403. var length;
  3404. return _regenerator().w(function (_context3) {
  3405. while (1) switch (_context3.n) {
  3406. case 0:
  3407. length = utils$1.toFiniteNumber(headers.getContentLength());
  3408. return _context3.a(2, length == null ? getBodyLength(body) : length);
  3409. }
  3410. }, _callee3);
  3411. }));
  3412. return function resolveBodyLength(_x3, _x4) {
  3413. return _ref4.apply(this, arguments);
  3414. };
  3415. }();
  3416. return /*#__PURE__*/function () {
  3417. var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
  3418. var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _fetch, composedSignal, request, unsubscribe, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, resolvedOptions, response, isStreamResponse, options, responseContentLength, _ref6, _ref7, _onProgress, _flush, responseData, _t3, _t4, _t5;
  3419. return _regenerator().w(function (_context4) {
  3420. while (1) switch (_context4.p = _context4.n) {
  3421. case 0:
  3422. _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
  3423. _fetch = envFetch || fetch;
  3424. responseType = responseType ? (responseType + '').toLowerCase() : 'text';
  3425. composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
  3426. request = null;
  3427. unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
  3428. composedSignal.unsubscribe();
  3429. };
  3430. _context4.p = 1;
  3431. _t3 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
  3432. if (!_t3) {
  3433. _context4.n = 3;
  3434. break;
  3435. }
  3436. _context4.n = 2;
  3437. return resolveBodyLength(headers, data);
  3438. case 2:
  3439. _t4 = requestContentLength = _context4.v;
  3440. _t3 = _t4 !== 0;
  3441. case 3:
  3442. if (!_t3) {
  3443. _context4.n = 4;
  3444. break;
  3445. }
  3446. _request = new Request(url, {
  3447. method: 'POST',
  3448. body: data,
  3449. duplex: 'half'
  3450. });
  3451. if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
  3452. headers.setContentType(contentTypeHeader);
  3453. }
  3454. if (_request.body) {
  3455. _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
  3456. data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
  3457. }
  3458. case 4:
  3459. if (!utils$1.isString(withCredentials)) {
  3460. withCredentials = withCredentials ? 'include' : 'omit';
  3461. }
  3462. // Cloudflare Workers throws when credentials are defined
  3463. // see https://github.com/cloudflare/workerd/issues/902
  3464. isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
  3465. resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
  3466. signal: composedSignal,
  3467. method: method.toUpperCase(),
  3468. headers: headers.normalize().toJSON(),
  3469. body: data,
  3470. duplex: 'half',
  3471. credentials: isCredentialsSupported ? withCredentials : undefined
  3472. });
  3473. request = isRequestSupported && new Request(url, resolvedOptions);
  3474. _context4.n = 5;
  3475. return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
  3476. case 5:
  3477. response = _context4.v;
  3478. isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
  3479. if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
  3480. options = {};
  3481. ['status', 'statusText', 'headers'].forEach(function (prop) {
  3482. options[prop] = response[prop];
  3483. });
  3484. responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
  3485. _ref6 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref7 = _slicedToArray(_ref6, 2), _onProgress = _ref7[0], _flush = _ref7[1];
  3486. response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
  3487. _flush && _flush();
  3488. unsubscribe && unsubscribe();
  3489. }), options);
  3490. }
  3491. responseType = responseType || 'text';
  3492. _context4.n = 6;
  3493. return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
  3494. case 6:
  3495. responseData = _context4.v;
  3496. !isStreamResponse && unsubscribe && unsubscribe();
  3497. _context4.n = 7;
  3498. return new Promise(function (resolve, reject) {
  3499. settle(resolve, reject, {
  3500. data: responseData,
  3501. headers: AxiosHeaders.from(response.headers),
  3502. status: response.status,
  3503. statusText: response.statusText,
  3504. config: config,
  3505. request: request
  3506. });
  3507. });
  3508. case 7:
  3509. return _context4.a(2, _context4.v);
  3510. case 8:
  3511. _context4.p = 8;
  3512. _t5 = _context4.v;
  3513. unsubscribe && unsubscribe();
  3514. if (!(_t5 && _t5.name === 'TypeError' && /Load failed|fetch/i.test(_t5.message))) {
  3515. _context4.n = 9;
  3516. break;
  3517. }
  3518. throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t5 && _t5.response), {
  3519. cause: _t5.cause || _t5
  3520. });
  3521. case 9:
  3522. throw AxiosError.from(_t5, _t5 && _t5.code, config, request, _t5 && _t5.response);
  3523. case 10:
  3524. return _context4.a(2);
  3525. }
  3526. }, _callee4, null, [[1, 8]]);
  3527. }));
  3528. return function (_x5) {
  3529. return _ref5.apply(this, arguments);
  3530. };
  3531. }();
  3532. };
  3533. var seedCache = new Map();
  3534. var getFetch = function getFetch(config) {
  3535. var env = config && config.env || {};
  3536. var fetch = env.fetch,
  3537. Request = env.Request,
  3538. Response = env.Response;
  3539. var seeds = [Request, Response, fetch];
  3540. var len = seeds.length,
  3541. i = len,
  3542. seed,
  3543. target,
  3544. map = seedCache;
  3545. while (i--) {
  3546. seed = seeds[i];
  3547. target = map.get(seed);
  3548. target === undefined && map.set(seed, target = i ? new Map() : factory(env));
  3549. map = target;
  3550. }
  3551. return target;
  3552. };
  3553. getFetch();
  3554. /**
  3555. * Known adapters mapping.
  3556. * Provides environment-specific adapters for Axios:
  3557. * - `http` for Node.js
  3558. * - `xhr` for browsers
  3559. * - `fetch` for fetch API-based requests
  3560. *
  3561. * @type {Object<string, Function|Object>}
  3562. */
  3563. var knownAdapters = {
  3564. http: httpAdapter,
  3565. xhr: xhrAdapter,
  3566. fetch: {
  3567. get: getFetch
  3568. }
  3569. };
  3570. // Assign adapter names for easier debugging and identification
  3571. utils$1.forEach(knownAdapters, function (fn, value) {
  3572. if (fn) {
  3573. try {
  3574. Object.defineProperty(fn, 'name', {
  3575. value: value
  3576. });
  3577. } catch (e) {
  3578. // eslint-disable-next-line no-empty
  3579. }
  3580. Object.defineProperty(fn, 'adapterName', {
  3581. value: value
  3582. });
  3583. }
  3584. });
  3585. /**
  3586. * Render a rejection reason string for unknown or unsupported adapters
  3587. *
  3588. * @param {string} reason
  3589. * @returns {string}
  3590. */
  3591. var renderReason = function renderReason(reason) {
  3592. return "- ".concat(reason);
  3593. };
  3594. /**
  3595. * Check if the adapter is resolved (function, null, or false)
  3596. *
  3597. * @param {Function|null|false} adapter
  3598. * @returns {boolean}
  3599. */
  3600. var isResolvedHandle = function isResolvedHandle(adapter) {
  3601. return utils$1.isFunction(adapter) || adapter === null || adapter === false;
  3602. };
  3603. /**
  3604. * Get the first suitable adapter from the provided list.
  3605. * Tries each adapter in order until a supported one is found.
  3606. * Throws an AxiosError if no adapter is suitable.
  3607. *
  3608. * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
  3609. * @param {Object} config - Axios request configuration
  3610. * @throws {AxiosError} If no suitable adapter is available
  3611. * @returns {Function} The resolved adapter function
  3612. */
  3613. function getAdapter(adapters, config) {
  3614. adapters = utils$1.isArray(adapters) ? adapters : [adapters];
  3615. var _adapters = adapters,
  3616. length = _adapters.length;
  3617. var nameOrAdapter;
  3618. var adapter;
  3619. var rejectedReasons = {};
  3620. for (var i = 0; i < length; i++) {
  3621. nameOrAdapter = adapters[i];
  3622. var id = void 0;
  3623. adapter = nameOrAdapter;
  3624. if (!isResolvedHandle(nameOrAdapter)) {
  3625. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  3626. if (adapter === undefined) {
  3627. throw new AxiosError("Unknown adapter '".concat(id, "'"));
  3628. }
  3629. }
  3630. if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
  3631. break;
  3632. }
  3633. rejectedReasons[id || '#' + i] = adapter;
  3634. }
  3635. if (!adapter) {
  3636. var reasons = Object.entries(rejectedReasons).map(function (_ref) {
  3637. var _ref2 = _slicedToArray(_ref, 2),
  3638. id = _ref2[0],
  3639. state = _ref2[1];
  3640. return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
  3641. });
  3642. var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
  3643. throw new AxiosError("There is no suitable adapter to dispatch the request " + s, 'ERR_NOT_SUPPORT');
  3644. }
  3645. return adapter;
  3646. }
  3647. /**
  3648. * Exports Axios adapters and utility to resolve an adapter
  3649. */
  3650. var adapters = {
  3651. /**
  3652. * Resolve an adapter from a list of adapter names or functions.
  3653. * @type {Function}
  3654. */
  3655. getAdapter: getAdapter,
  3656. /**
  3657. * Exposes all known adapters
  3658. * @type {Object<string, Function|Object>}
  3659. */
  3660. adapters: knownAdapters
  3661. };
  3662. /**
  3663. * Throws a `CanceledError` if cancellation has been requested.
  3664. *
  3665. * @param {Object} config The config that is to be used for the request
  3666. *
  3667. * @returns {void}
  3668. */
  3669. function throwIfCancellationRequested(config) {
  3670. if (config.cancelToken) {
  3671. config.cancelToken.throwIfRequested();
  3672. }
  3673. if (config.signal && config.signal.aborted) {
  3674. throw new CanceledError(null, config);
  3675. }
  3676. }
  3677. /**
  3678. * Dispatch a request to the server using the configured adapter.
  3679. *
  3680. * @param {object} config The config that is to be used for the request
  3681. *
  3682. * @returns {Promise} The Promise to be fulfilled
  3683. */
  3684. function dispatchRequest(config) {
  3685. throwIfCancellationRequested(config);
  3686. config.headers = AxiosHeaders.from(config.headers);
  3687. // Transform request data
  3688. config.data = transformData.call(config, config.transformRequest);
  3689. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  3690. config.headers.setContentType('application/x-www-form-urlencoded', false);
  3691. }
  3692. var adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
  3693. return adapter(config).then(function onAdapterResolution(response) {
  3694. throwIfCancellationRequested(config);
  3695. // Transform response data
  3696. response.data = transformData.call(config, config.transformResponse, response);
  3697. response.headers = AxiosHeaders.from(response.headers);
  3698. return response;
  3699. }, function onAdapterRejection(reason) {
  3700. if (!isCancel(reason)) {
  3701. throwIfCancellationRequested(config);
  3702. // Transform response data
  3703. if (reason && reason.response) {
  3704. reason.response.data = transformData.call(config, config.transformResponse, reason.response);
  3705. reason.response.headers = AxiosHeaders.from(reason.response.headers);
  3706. }
  3707. }
  3708. return Promise.reject(reason);
  3709. });
  3710. }
  3711. var VERSION = "1.15.0";
  3712. var validators$1 = {};
  3713. // eslint-disable-next-line func-names
  3714. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
  3715. validators$1[type] = function validator(thing) {
  3716. return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  3717. };
  3718. });
  3719. var deprecatedWarnings = {};
  3720. /**
  3721. * Transitional option validator
  3722. *
  3723. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  3724. * @param {string?} version - deprecated version / removed since version
  3725. * @param {string?} message - some message with additional info
  3726. *
  3727. * @returns {function}
  3728. */
  3729. validators$1.transitional = function transitional(validator, version, message) {
  3730. function formatMessage(opt, desc) {
  3731. return '[Axios v' + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? '. ' + message : '');
  3732. }
  3733. // eslint-disable-next-line func-names
  3734. return function (value, opt, opts) {
  3735. if (validator === false) {
  3736. throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
  3737. }
  3738. if (version && !deprecatedWarnings[opt]) {
  3739. deprecatedWarnings[opt] = true;
  3740. // eslint-disable-next-line no-console
  3741. console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
  3742. }
  3743. return validator ? validator(value, opt, opts) : true;
  3744. };
  3745. };
  3746. validators$1.spelling = function spelling(correctSpelling) {
  3747. return function (value, opt) {
  3748. // eslint-disable-next-line no-console
  3749. console.warn("".concat(opt, " is likely a misspelling of ").concat(correctSpelling));
  3750. return true;
  3751. };
  3752. };
  3753. /**
  3754. * Assert object's properties type
  3755. *
  3756. * @param {object} options
  3757. * @param {object} schema
  3758. * @param {boolean?} allowUnknown
  3759. *
  3760. * @returns {object}
  3761. */
  3762. function assertOptions(options, schema, allowUnknown) {
  3763. if (_typeof(options) !== 'object') {
  3764. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  3765. }
  3766. var keys = Object.keys(options);
  3767. var i = keys.length;
  3768. while (i-- > 0) {
  3769. var opt = keys[i];
  3770. var validator = schema[opt];
  3771. if (validator) {
  3772. var value = options[opt];
  3773. var result = value === undefined || validator(value, opt, options);
  3774. if (result !== true) {
  3775. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  3776. }
  3777. continue;
  3778. }
  3779. if (allowUnknown !== true) {
  3780. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  3781. }
  3782. }
  3783. }
  3784. var validator = {
  3785. assertOptions: assertOptions,
  3786. validators: validators$1
  3787. };
  3788. var validators = validator.validators;
  3789. /**
  3790. * Create a new instance of Axios
  3791. *
  3792. * @param {Object} instanceConfig The default config for the instance
  3793. *
  3794. * @return {Axios} A new instance of Axios
  3795. */
  3796. var Axios = /*#__PURE__*/function () {
  3797. function Axios(instanceConfig) {
  3798. _classCallCheck(this, Axios);
  3799. this.defaults = instanceConfig || {};
  3800. this.interceptors = {
  3801. request: new InterceptorManager(),
  3802. response: new InterceptorManager()
  3803. };
  3804. }
  3805. /**
  3806. * Dispatch a request
  3807. *
  3808. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  3809. * @param {?Object} config
  3810. *
  3811. * @returns {Promise} The Promise to be fulfilled
  3812. */
  3813. return _createClass(Axios, [{
  3814. key: "request",
  3815. value: (function () {
  3816. var _request2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configOrUrl, config) {
  3817. var dummy, stack, firstNewlineIndex, secondNewlineIndex, stackWithoutTwoTopLines, _t;
  3818. return _regenerator().w(function (_context) {
  3819. while (1) switch (_context.p = _context.n) {
  3820. case 0:
  3821. _context.p = 0;
  3822. _context.n = 1;
  3823. return this._request(configOrUrl, config);
  3824. case 1:
  3825. return _context.a(2, _context.v);
  3826. case 2:
  3827. _context.p = 2;
  3828. _t = _context.v;
  3829. if (_t instanceof Error) {
  3830. dummy = {};
  3831. Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
  3832. // slice off the Error: ... line
  3833. stack = function () {
  3834. if (!dummy.stack) {
  3835. return '';
  3836. }
  3837. var firstNewlineIndex = dummy.stack.indexOf('\n');
  3838. return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
  3839. }();
  3840. try {
  3841. if (!_t.stack) {
  3842. _t.stack = stack;
  3843. // match without the 2 top stack lines
  3844. } else if (stack) {
  3845. firstNewlineIndex = stack.indexOf('\n');
  3846. secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
  3847. stackWithoutTwoTopLines = secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
  3848. if (!String(_t.stack).endsWith(stackWithoutTwoTopLines)) {
  3849. _t.stack += '\n' + stack;
  3850. }
  3851. }
  3852. } catch (e) {
  3853. // ignore the case where "stack" is an un-writable property
  3854. }
  3855. }
  3856. throw _t;
  3857. case 3:
  3858. return _context.a(2);
  3859. }
  3860. }, _callee, this, [[0, 2]]);
  3861. }));
  3862. function request(_x, _x2) {
  3863. return _request2.apply(this, arguments);
  3864. }
  3865. return request;
  3866. }())
  3867. }, {
  3868. key: "_request",
  3869. value: function _request(configOrUrl, config) {
  3870. /*eslint no-param-reassign:0*/
  3871. // Allow for axios('example/url'[, config]) a la fetch API
  3872. if (typeof configOrUrl === 'string') {
  3873. config = config || {};
  3874. config.url = configOrUrl;
  3875. } else {
  3876. config = configOrUrl || {};
  3877. }
  3878. config = mergeConfig(this.defaults, config);
  3879. var _config = config,
  3880. transitional = _config.transitional,
  3881. paramsSerializer = _config.paramsSerializer,
  3882. headers = _config.headers;
  3883. if (transitional !== undefined) {
  3884. validator.assertOptions(transitional, {
  3885. silentJSONParsing: validators.transitional(validators["boolean"]),
  3886. forcedJSONParsing: validators.transitional(validators["boolean"]),
  3887. clarifyTimeoutError: validators.transitional(validators["boolean"]),
  3888. legacyInterceptorReqResOrdering: validators.transitional(validators["boolean"])
  3889. }, false);
  3890. }
  3891. if (paramsSerializer != null) {
  3892. if (utils$1.isFunction(paramsSerializer)) {
  3893. config.paramsSerializer = {
  3894. serialize: paramsSerializer
  3895. };
  3896. } else {
  3897. validator.assertOptions(paramsSerializer, {
  3898. encode: validators["function"],
  3899. serialize: validators["function"]
  3900. }, true);
  3901. }
  3902. }
  3903. // Set config.allowAbsoluteUrls
  3904. if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
  3905. config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
  3906. } else {
  3907. config.allowAbsoluteUrls = true;
  3908. }
  3909. validator.assertOptions(config, {
  3910. baseUrl: validators.spelling('baseURL'),
  3911. withXsrfToken: validators.spelling('withXSRFToken')
  3912. }, true);
  3913. // Set config.method
  3914. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  3915. // Flatten headers
  3916. var contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
  3917. headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
  3918. delete headers[method];
  3919. });
  3920. config.headers = AxiosHeaders.concat(contextHeaders, headers);
  3921. // filter out skipped interceptors
  3922. var requestInterceptorChain = [];
  3923. var synchronousRequestInterceptors = true;
  3924. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  3925. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  3926. return;
  3927. }
  3928. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  3929. var transitional = config.transitional || transitionalDefaults;
  3930. var legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
  3931. if (legacyInterceptorReqResOrdering) {
  3932. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  3933. } else {
  3934. requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  3935. }
  3936. });
  3937. var responseInterceptorChain = [];
  3938. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  3939. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  3940. });
  3941. var promise;
  3942. var i = 0;
  3943. var len;
  3944. if (!synchronousRequestInterceptors) {
  3945. var chain = [dispatchRequest.bind(this), undefined];
  3946. chain.unshift.apply(chain, requestInterceptorChain);
  3947. chain.push.apply(chain, responseInterceptorChain);
  3948. len = chain.length;
  3949. promise = Promise.resolve(config);
  3950. while (i < len) {
  3951. promise = promise.then(chain[i++], chain[i++]);
  3952. }
  3953. return promise;
  3954. }
  3955. len = requestInterceptorChain.length;
  3956. var newConfig = config;
  3957. while (i < len) {
  3958. var onFulfilled = requestInterceptorChain[i++];
  3959. var onRejected = requestInterceptorChain[i++];
  3960. try {
  3961. newConfig = onFulfilled(newConfig);
  3962. } catch (error) {
  3963. onRejected.call(this, error);
  3964. break;
  3965. }
  3966. }
  3967. try {
  3968. promise = dispatchRequest.call(this, newConfig);
  3969. } catch (error) {
  3970. return Promise.reject(error);
  3971. }
  3972. i = 0;
  3973. len = responseInterceptorChain.length;
  3974. while (i < len) {
  3975. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  3976. }
  3977. return promise;
  3978. }
  3979. }, {
  3980. key: "getUri",
  3981. value: function getUri(config) {
  3982. config = mergeConfig(this.defaults, config);
  3983. var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
  3984. return buildURL(fullPath, config.params, config.paramsSerializer);
  3985. }
  3986. }]);
  3987. }(); // Provide aliases for supported request methods
  3988. utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  3989. /*eslint func-names:0*/
  3990. Axios.prototype[method] = function (url, config) {
  3991. return this.request(mergeConfig(config || {}, {
  3992. method: method,
  3993. url: url,
  3994. data: (config || {}).data
  3995. }));
  3996. };
  3997. });
  3998. utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  3999. function generateHTTPMethod(isForm) {
  4000. return function httpMethod(url, data, config) {
  4001. return this.request(mergeConfig(config || {}, {
  4002. method: method,
  4003. headers: isForm ? {
  4004. 'Content-Type': 'multipart/form-data'
  4005. } : {},
  4006. url: url,
  4007. data: data
  4008. }));
  4009. };
  4010. }
  4011. Axios.prototype[method] = generateHTTPMethod();
  4012. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  4013. });
  4014. /**
  4015. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  4016. *
  4017. * @param {Function} executor The executor function.
  4018. *
  4019. * @returns {CancelToken}
  4020. */
  4021. var CancelToken = /*#__PURE__*/function () {
  4022. function CancelToken(executor) {
  4023. _classCallCheck(this, CancelToken);
  4024. if (typeof executor !== 'function') {
  4025. throw new TypeError('executor must be a function.');
  4026. }
  4027. var resolvePromise;
  4028. this.promise = new Promise(function promiseExecutor(resolve) {
  4029. resolvePromise = resolve;
  4030. });
  4031. var token = this;
  4032. // eslint-disable-next-line func-names
  4033. this.promise.then(function (cancel) {
  4034. if (!token._listeners) return;
  4035. var i = token._listeners.length;
  4036. while (i-- > 0) {
  4037. token._listeners[i](cancel);
  4038. }
  4039. token._listeners = null;
  4040. });
  4041. // eslint-disable-next-line func-names
  4042. this.promise.then = function (onfulfilled) {
  4043. var _resolve;
  4044. // eslint-disable-next-line func-names
  4045. var promise = new Promise(function (resolve) {
  4046. token.subscribe(resolve);
  4047. _resolve = resolve;
  4048. }).then(onfulfilled);
  4049. promise.cancel = function reject() {
  4050. token.unsubscribe(_resolve);
  4051. };
  4052. return promise;
  4053. };
  4054. executor(function cancel(message, config, request) {
  4055. if (token.reason) {
  4056. // Cancellation has already been requested
  4057. return;
  4058. }
  4059. token.reason = new CanceledError(message, config, request);
  4060. resolvePromise(token.reason);
  4061. });
  4062. }
  4063. /**
  4064. * Throws a `CanceledError` if cancellation has been requested.
  4065. */
  4066. return _createClass(CancelToken, [{
  4067. key: "throwIfRequested",
  4068. value: function throwIfRequested() {
  4069. if (this.reason) {
  4070. throw this.reason;
  4071. }
  4072. }
  4073. /**
  4074. * Subscribe to the cancel signal
  4075. */
  4076. }, {
  4077. key: "subscribe",
  4078. value: function subscribe(listener) {
  4079. if (this.reason) {
  4080. listener(this.reason);
  4081. return;
  4082. }
  4083. if (this._listeners) {
  4084. this._listeners.push(listener);
  4085. } else {
  4086. this._listeners = [listener];
  4087. }
  4088. }
  4089. /**
  4090. * Unsubscribe from the cancel signal
  4091. */
  4092. }, {
  4093. key: "unsubscribe",
  4094. value: function unsubscribe(listener) {
  4095. if (!this._listeners) {
  4096. return;
  4097. }
  4098. var index = this._listeners.indexOf(listener);
  4099. if (index !== -1) {
  4100. this._listeners.splice(index, 1);
  4101. }
  4102. }
  4103. }, {
  4104. key: "toAbortSignal",
  4105. value: function toAbortSignal() {
  4106. var _this = this;
  4107. var controller = new AbortController();
  4108. var abort = function abort(err) {
  4109. controller.abort(err);
  4110. };
  4111. this.subscribe(abort);
  4112. controller.signal.unsubscribe = function () {
  4113. return _this.unsubscribe(abort);
  4114. };
  4115. return controller.signal;
  4116. }
  4117. /**
  4118. * Returns an object that contains a new `CancelToken` and a function that, when called,
  4119. * cancels the `CancelToken`.
  4120. */
  4121. }], [{
  4122. key: "source",
  4123. value: function source() {
  4124. var cancel;
  4125. var token = new CancelToken(function executor(c) {
  4126. cancel = c;
  4127. });
  4128. return {
  4129. token: token,
  4130. cancel: cancel
  4131. };
  4132. }
  4133. }]);
  4134. }();
  4135. /**
  4136. * Syntactic sugar for invoking a function and expanding an array for arguments.
  4137. *
  4138. * Common use case would be to use `Function.prototype.apply`.
  4139. *
  4140. * ```js
  4141. * function f(x, y, z) {}
  4142. * const args = [1, 2, 3];
  4143. * f.apply(null, args);
  4144. * ```
  4145. *
  4146. * With `spread` this example can be re-written.
  4147. *
  4148. * ```js
  4149. * spread(function(x, y, z) {})([1, 2, 3]);
  4150. * ```
  4151. *
  4152. * @param {Function} callback
  4153. *
  4154. * @returns {Function}
  4155. */
  4156. function spread(callback) {
  4157. return function wrap(arr) {
  4158. return callback.apply(null, arr);
  4159. };
  4160. }
  4161. /**
  4162. * Determines whether the payload is an error thrown by Axios
  4163. *
  4164. * @param {*} payload The value to test
  4165. *
  4166. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  4167. */
  4168. function isAxiosError(payload) {
  4169. return utils$1.isObject(payload) && payload.isAxiosError === true;
  4170. }
  4171. var HttpStatusCode = {
  4172. Continue: 100,
  4173. SwitchingProtocols: 101,
  4174. Processing: 102,
  4175. EarlyHints: 103,
  4176. Ok: 200,
  4177. Created: 201,
  4178. Accepted: 202,
  4179. NonAuthoritativeInformation: 203,
  4180. NoContent: 204,
  4181. ResetContent: 205,
  4182. PartialContent: 206,
  4183. MultiStatus: 207,
  4184. AlreadyReported: 208,
  4185. ImUsed: 226,
  4186. MultipleChoices: 300,
  4187. MovedPermanently: 301,
  4188. Found: 302,
  4189. SeeOther: 303,
  4190. NotModified: 304,
  4191. UseProxy: 305,
  4192. Unused: 306,
  4193. TemporaryRedirect: 307,
  4194. PermanentRedirect: 308,
  4195. BadRequest: 400,
  4196. Unauthorized: 401,
  4197. PaymentRequired: 402,
  4198. Forbidden: 403,
  4199. NotFound: 404,
  4200. MethodNotAllowed: 405,
  4201. NotAcceptable: 406,
  4202. ProxyAuthenticationRequired: 407,
  4203. RequestTimeout: 408,
  4204. Conflict: 409,
  4205. Gone: 410,
  4206. LengthRequired: 411,
  4207. PreconditionFailed: 412,
  4208. PayloadTooLarge: 413,
  4209. UriTooLong: 414,
  4210. UnsupportedMediaType: 415,
  4211. RangeNotSatisfiable: 416,
  4212. ExpectationFailed: 417,
  4213. ImATeapot: 418,
  4214. MisdirectedRequest: 421,
  4215. UnprocessableEntity: 422,
  4216. Locked: 423,
  4217. FailedDependency: 424,
  4218. TooEarly: 425,
  4219. UpgradeRequired: 426,
  4220. PreconditionRequired: 428,
  4221. TooManyRequests: 429,
  4222. RequestHeaderFieldsTooLarge: 431,
  4223. UnavailableForLegalReasons: 451,
  4224. InternalServerError: 500,
  4225. NotImplemented: 501,
  4226. BadGateway: 502,
  4227. ServiceUnavailable: 503,
  4228. GatewayTimeout: 504,
  4229. HttpVersionNotSupported: 505,
  4230. VariantAlsoNegotiates: 506,
  4231. InsufficientStorage: 507,
  4232. LoopDetected: 508,
  4233. NotExtended: 510,
  4234. NetworkAuthenticationRequired: 511,
  4235. WebServerIsDown: 521,
  4236. ConnectionTimedOut: 522,
  4237. OriginIsUnreachable: 523,
  4238. TimeoutOccurred: 524,
  4239. SslHandshakeFailed: 525,
  4240. InvalidSslCertificate: 526
  4241. };
  4242. Object.entries(HttpStatusCode).forEach(function (_ref) {
  4243. var _ref2 = _slicedToArray(_ref, 2),
  4244. key = _ref2[0],
  4245. value = _ref2[1];
  4246. HttpStatusCode[value] = key;
  4247. });
  4248. /**
  4249. * Create an instance of Axios
  4250. *
  4251. * @param {Object} defaultConfig The default config for the instance
  4252. *
  4253. * @returns {Axios} A new instance of Axios
  4254. */
  4255. function createInstance(defaultConfig) {
  4256. var context = new Axios(defaultConfig);
  4257. var instance = bind(Axios.prototype.request, context);
  4258. // Copy axios.prototype to instance
  4259. utils$1.extend(instance, Axios.prototype, context, {
  4260. allOwnKeys: true
  4261. });
  4262. // Copy context to instance
  4263. utils$1.extend(instance, context, null, {
  4264. allOwnKeys: true
  4265. });
  4266. // Factory for creating new instances
  4267. instance.create = function create(instanceConfig) {
  4268. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  4269. };
  4270. return instance;
  4271. }
  4272. // Create the default instance to be exported
  4273. var axios = createInstance(defaults);
  4274. // Expose Axios class to allow class inheritance
  4275. axios.Axios = Axios;
  4276. // Expose Cancel & CancelToken
  4277. axios.CanceledError = CanceledError;
  4278. axios.CancelToken = CancelToken;
  4279. axios.isCancel = isCancel;
  4280. axios.VERSION = VERSION;
  4281. axios.toFormData = toFormData;
  4282. // Expose AxiosError class
  4283. axios.AxiosError = AxiosError;
  4284. // alias for CanceledError for backward compatibility
  4285. axios.Cancel = axios.CanceledError;
  4286. // Expose all/spread
  4287. axios.all = function all(promises) {
  4288. return Promise.all(promises);
  4289. };
  4290. axios.spread = spread;
  4291. // Expose isAxiosError
  4292. axios.isAxiosError = isAxiosError;
  4293. // Expose mergeConfig
  4294. axios.mergeConfig = mergeConfig;
  4295. axios.AxiosHeaders = AxiosHeaders;
  4296. axios.formToJSON = function (thing) {
  4297. return formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  4298. };
  4299. axios.getAdapter = adapters.getAdapter;
  4300. axios.HttpStatusCode = HttpStatusCode;
  4301. axios["default"] = axios;
  4302. return axios;
  4303. }));
  4304. //# sourceMappingURL=axios.js.map