axios.js 147 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463
  1. /*! Axios v1.13.6 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 = !1;
  28. function pump(e, r) {
  29. return n = !0, r = new Promise(function (n) {
  30. n(t[e](r));
  31. }), {
  32. done: !1,
  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 = !1, t) : pump("next", t);
  40. }, "function" == typeof t.throw && (e.throw = function (t) {
  41. if (n) throw n = !1, t;
  42. return pump("throw", t);
  43. }), "function" == typeof t.return && (e.return = function (t) {
  44. return n ? (n = !1, 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: !0
  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 || !1, o.configurable = !0, "value" in o && (o.writable = !0), 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: !1
  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 && r && "number" == typeof r.length) {
  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: !0
  155. } : {
  156. done: !1,
  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 = !0,
  170. u = !1;
  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 = !0, 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: !0,
  195. configurable: !0,
  196. writable: !0
  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: !0,
  210. configurable: !0
  211. }
  212. }), Object.defineProperty(t, "prototype", {
  213. writable: !1
  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 = !0,
  243. o = !1;
  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 = !0, 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), !0).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 = !1,
  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 = !0, 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), !0), 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 || "default");
  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: !0
  490. });
  491. break;
  492. case "throw":
  493. r.reject(n);
  494. break;
  495. default:
  496. r.resolve({
  497. value: n,
  498. done: !1
  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: !1,
  541. writable: !0,
  542. configurable: !0
  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. var AxiosError$1 = AxiosError;
  1458. // eslint-disable-next-line strict
  1459. var httpAdapter = null;
  1460. /**
  1461. * Determines if the given thing is a array or js object.
  1462. *
  1463. * @param {string} thing - The object or array to be visited.
  1464. *
  1465. * @returns {boolean}
  1466. */
  1467. function isVisitable(thing) {
  1468. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  1469. }
  1470. /**
  1471. * It removes the brackets from the end of a string
  1472. *
  1473. * @param {string} key - The key of the parameter.
  1474. *
  1475. * @returns {string} the key without the brackets.
  1476. */
  1477. function removeBrackets(key) {
  1478. return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
  1479. }
  1480. /**
  1481. * It takes a path, a key, and a boolean, and returns a string
  1482. *
  1483. * @param {string} path - The path to the current key.
  1484. * @param {string} key - The key of the current object being iterated over.
  1485. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  1486. *
  1487. * @returns {string} The path to the current key.
  1488. */
  1489. function renderKey(path, key, dots) {
  1490. if (!path) return key;
  1491. return path.concat(key).map(function each(token, i) {
  1492. // eslint-disable-next-line no-param-reassign
  1493. token = removeBrackets(token);
  1494. return !dots && i ? '[' + token + ']' : token;
  1495. }).join(dots ? '.' : '');
  1496. }
  1497. /**
  1498. * If the array is an array and none of its elements are visitable, then it's a flat array.
  1499. *
  1500. * @param {Array<any>} arr - The array to check
  1501. *
  1502. * @returns {boolean}
  1503. */
  1504. function isFlatArray(arr) {
  1505. return utils$1.isArray(arr) && !arr.some(isVisitable);
  1506. }
  1507. var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  1508. return /^is[A-Z]/.test(prop);
  1509. });
  1510. /**
  1511. * Convert a data object to FormData
  1512. *
  1513. * @param {Object} obj
  1514. * @param {?Object} [formData]
  1515. * @param {?Object} [options]
  1516. * @param {Function} [options.visitor]
  1517. * @param {Boolean} [options.metaTokens = true]
  1518. * @param {Boolean} [options.dots = false]
  1519. * @param {?Boolean} [options.indexes = false]
  1520. *
  1521. * @returns {Object}
  1522. **/
  1523. /**
  1524. * It converts an object into a FormData object
  1525. *
  1526. * @param {Object<any, any>} obj - The object to convert to form data.
  1527. * @param {string} formData - The FormData object to append to.
  1528. * @param {Object<string, any>} options
  1529. *
  1530. * @returns
  1531. */
  1532. function toFormData(obj, formData, options) {
  1533. if (!utils$1.isObject(obj)) {
  1534. throw new TypeError('target must be an object');
  1535. }
  1536. // eslint-disable-next-line no-param-reassign
  1537. formData = formData || new (FormData)();
  1538. // eslint-disable-next-line no-param-reassign
  1539. options = utils$1.toFlatObject(options, {
  1540. metaTokens: true,
  1541. dots: false,
  1542. indexes: false
  1543. }, false, function defined(option, source) {
  1544. // eslint-disable-next-line no-eq-null,eqeqeq
  1545. return !utils$1.isUndefined(source[option]);
  1546. });
  1547. var metaTokens = options.metaTokens;
  1548. // eslint-disable-next-line no-use-before-define
  1549. var visitor = options.visitor || defaultVisitor;
  1550. var dots = options.dots;
  1551. var indexes = options.indexes;
  1552. var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  1553. var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  1554. if (!utils$1.isFunction(visitor)) {
  1555. throw new TypeError('visitor must be a function');
  1556. }
  1557. function convertValue(value) {
  1558. if (value === null) return '';
  1559. if (utils$1.isDate(value)) {
  1560. return value.toISOString();
  1561. }
  1562. if (utils$1.isBoolean(value)) {
  1563. return value.toString();
  1564. }
  1565. if (!useBlob && utils$1.isBlob(value)) {
  1566. throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
  1567. }
  1568. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  1569. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  1570. }
  1571. return value;
  1572. }
  1573. /**
  1574. * Default visitor.
  1575. *
  1576. * @param {*} value
  1577. * @param {String|Number} key
  1578. * @param {Array<String|Number>} path
  1579. * @this {FormData}
  1580. *
  1581. * @returns {boolean} return true to visit the each prop of the value recursively
  1582. */
  1583. function defaultVisitor(value, key, path) {
  1584. var arr = value;
  1585. if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
  1586. formData.append(renderKey(path, key, dots), convertValue(value));
  1587. return false;
  1588. }
  1589. if (value && !path && _typeof(value) === 'object') {
  1590. if (utils$1.endsWith(key, '{}')) {
  1591. // eslint-disable-next-line no-param-reassign
  1592. key = metaTokens ? key : key.slice(0, -2);
  1593. // eslint-disable-next-line no-param-reassign
  1594. value = JSON.stringify(value);
  1595. } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
  1596. // eslint-disable-next-line no-param-reassign
  1597. key = removeBrackets(key);
  1598. arr.forEach(function each(el, index) {
  1599. !(utils$1.isUndefined(el) || el === null) && formData.append(
  1600. // eslint-disable-next-line no-nested-ternary
  1601. indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
  1602. });
  1603. return false;
  1604. }
  1605. }
  1606. if (isVisitable(value)) {
  1607. return true;
  1608. }
  1609. formData.append(renderKey(path, key, dots), convertValue(value));
  1610. return false;
  1611. }
  1612. var stack = [];
  1613. var exposedHelpers = Object.assign(predicates, {
  1614. defaultVisitor: defaultVisitor,
  1615. convertValue: convertValue,
  1616. isVisitable: isVisitable
  1617. });
  1618. function build(value, path) {
  1619. if (utils$1.isUndefined(value)) return;
  1620. if (stack.indexOf(value) !== -1) {
  1621. throw Error('Circular reference detected in ' + path.join('.'));
  1622. }
  1623. stack.push(value);
  1624. utils$1.forEach(value, function each(el, key) {
  1625. var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
  1626. if (result === true) {
  1627. build(el, path ? path.concat(key) : [key]);
  1628. }
  1629. });
  1630. stack.pop();
  1631. }
  1632. if (!utils$1.isObject(obj)) {
  1633. throw new TypeError('data must be an object');
  1634. }
  1635. build(obj);
  1636. return formData;
  1637. }
  1638. /**
  1639. * It encodes a string by replacing all characters that are not in the unreserved set with
  1640. * their percent-encoded equivalents
  1641. *
  1642. * @param {string} str - The string to encode.
  1643. *
  1644. * @returns {string} The encoded string.
  1645. */
  1646. function encode$1(str) {
  1647. var charMap = {
  1648. '!': '%21',
  1649. "'": '%27',
  1650. '(': '%28',
  1651. ')': '%29',
  1652. '~': '%7E',
  1653. '%20': '+',
  1654. '%00': '\x00'
  1655. };
  1656. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  1657. return charMap[match];
  1658. });
  1659. }
  1660. /**
  1661. * It takes a params object and converts it to a FormData object
  1662. *
  1663. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  1664. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  1665. *
  1666. * @returns {void}
  1667. */
  1668. function AxiosURLSearchParams(params, options) {
  1669. this._pairs = [];
  1670. params && toFormData(params, this, options);
  1671. }
  1672. var prototype = AxiosURLSearchParams.prototype;
  1673. prototype.append = function append(name, value) {
  1674. this._pairs.push([name, value]);
  1675. };
  1676. prototype.toString = function toString(encoder) {
  1677. var _encode = encoder ? function (value) {
  1678. return encoder.call(this, value, encode$1);
  1679. } : encode$1;
  1680. return this._pairs.map(function each(pair) {
  1681. return _encode(pair[0]) + '=' + _encode(pair[1]);
  1682. }, '').join('&');
  1683. };
  1684. /**
  1685. * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
  1686. * URI encoded counterparts
  1687. *
  1688. * @param {string} val The value to be encoded.
  1689. *
  1690. * @returns {string} The encoded value.
  1691. */
  1692. function encode(val) {
  1693. return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
  1694. }
  1695. /**
  1696. * Build a URL by appending params to the end
  1697. *
  1698. * @param {string} url The base of the url (e.g., http://www.google.com)
  1699. * @param {object} [params] The params to be appended
  1700. * @param {?(object|Function)} options
  1701. *
  1702. * @returns {string} The formatted url
  1703. */
  1704. function buildURL(url, params, options) {
  1705. if (!params) {
  1706. return url;
  1707. }
  1708. var _encode = options && options.encode || encode;
  1709. var _options = utils$1.isFunction(options) ? {
  1710. serialize: options
  1711. } : options;
  1712. var serializeFn = _options && _options.serialize;
  1713. var serializedParams;
  1714. if (serializeFn) {
  1715. serializedParams = serializeFn(params, _options);
  1716. } else {
  1717. serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
  1718. }
  1719. if (serializedParams) {
  1720. var hashmarkIndex = url.indexOf('#');
  1721. if (hashmarkIndex !== -1) {
  1722. url = url.slice(0, hashmarkIndex);
  1723. }
  1724. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1725. }
  1726. return url;
  1727. }
  1728. var InterceptorManager = /*#__PURE__*/function () {
  1729. function InterceptorManager() {
  1730. _classCallCheck(this, InterceptorManager);
  1731. this.handlers = [];
  1732. }
  1733. /**
  1734. * Add a new interceptor to the stack
  1735. *
  1736. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1737. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1738. * @param {Object} options The options for the interceptor, synchronous and runWhen
  1739. *
  1740. * @return {Number} An ID used to remove interceptor later
  1741. */
  1742. return _createClass(InterceptorManager, [{
  1743. key: "use",
  1744. value: function use(fulfilled, rejected, options) {
  1745. this.handlers.push({
  1746. fulfilled: fulfilled,
  1747. rejected: rejected,
  1748. synchronous: options ? options.synchronous : false,
  1749. runWhen: options ? options.runWhen : null
  1750. });
  1751. return this.handlers.length - 1;
  1752. }
  1753. /**
  1754. * Remove an interceptor from the stack
  1755. *
  1756. * @param {Number} id The ID that was returned by `use`
  1757. *
  1758. * @returns {void}
  1759. */
  1760. }, {
  1761. key: "eject",
  1762. value: function eject(id) {
  1763. if (this.handlers[id]) {
  1764. this.handlers[id] = null;
  1765. }
  1766. }
  1767. /**
  1768. * Clear all interceptors from the stack
  1769. *
  1770. * @returns {void}
  1771. */
  1772. }, {
  1773. key: "clear",
  1774. value: function clear() {
  1775. if (this.handlers) {
  1776. this.handlers = [];
  1777. }
  1778. }
  1779. /**
  1780. * Iterate over all the registered interceptors
  1781. *
  1782. * This method is particularly useful for skipping over any
  1783. * interceptors that may have become `null` calling `eject`.
  1784. *
  1785. * @param {Function} fn The function to call for each interceptor
  1786. *
  1787. * @returns {void}
  1788. */
  1789. }, {
  1790. key: "forEach",
  1791. value: function forEach(fn) {
  1792. utils$1.forEach(this.handlers, function forEachHandler(h) {
  1793. if (h !== null) {
  1794. fn(h);
  1795. }
  1796. });
  1797. }
  1798. }]);
  1799. }();
  1800. var InterceptorManager$1 = InterceptorManager;
  1801. var transitionalDefaults = {
  1802. silentJSONParsing: true,
  1803. forcedJSONParsing: true,
  1804. clarifyTimeoutError: false,
  1805. legacyInterceptorReqResOrdering: true
  1806. };
  1807. var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  1808. var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
  1809. var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
  1810. var platform$1 = {
  1811. isBrowser: true,
  1812. classes: {
  1813. URLSearchParams: URLSearchParams$1,
  1814. FormData: FormData$1,
  1815. Blob: Blob$1
  1816. },
  1817. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  1818. };
  1819. var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
  1820. var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
  1821. /**
  1822. * Determine if we're running in a standard browser environment
  1823. *
  1824. * This allows axios to run in a web worker, and react-native.
  1825. * Both environments support XMLHttpRequest, but not fully standard globals.
  1826. *
  1827. * web workers:
  1828. * typeof window -> undefined
  1829. * typeof document -> undefined
  1830. *
  1831. * react-native:
  1832. * navigator.product -> 'ReactNative'
  1833. * nativescript
  1834. * navigator.product -> 'NativeScript' or 'NS'
  1835. *
  1836. * @returns {boolean}
  1837. */
  1838. var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
  1839. /**
  1840. * Determine if we're running in a standard browser webWorker environment
  1841. *
  1842. * Although the `isStandardBrowserEnv` method indicates that
  1843. * `allows axios to run in a web worker`, the WebWorker will still be
  1844. * filtered out due to its judgment standard
  1845. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  1846. * This leads to a problem when axios post `FormData` in webWorker
  1847. */
  1848. var hasStandardBrowserWebWorkerEnv = function () {
  1849. return typeof WorkerGlobalScope !== 'undefined' &&
  1850. // eslint-disable-next-line no-undef
  1851. self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
  1852. }();
  1853. var origin = hasBrowserEnv && window.location.href || 'http://localhost';
  1854. var utils = /*#__PURE__*/Object.freeze({
  1855. __proto__: null,
  1856. hasBrowserEnv: hasBrowserEnv,
  1857. hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
  1858. hasStandardBrowserEnv: hasStandardBrowserEnv,
  1859. navigator: _navigator,
  1860. origin: origin
  1861. });
  1862. var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
  1863. function toURLEncodedForm(data, options) {
  1864. return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
  1865. visitor: function visitor(value, key, path, helpers) {
  1866. if (platform.isNode && utils$1.isBuffer(value)) {
  1867. this.append(key, value.toString('base64'));
  1868. return false;
  1869. }
  1870. return helpers.defaultVisitor.apply(this, arguments);
  1871. }
  1872. }, options));
  1873. }
  1874. /**
  1875. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1876. *
  1877. * @param {string} name - The name of the property to get.
  1878. *
  1879. * @returns An array of strings.
  1880. */
  1881. function parsePropPath(name) {
  1882. // foo[x][y][z]
  1883. // foo.x.y.z
  1884. // foo-x-y-z
  1885. // foo x y z
  1886. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
  1887. return match[0] === '[]' ? '' : match[1] || match[0];
  1888. });
  1889. }
  1890. /**
  1891. * Convert an array to an object.
  1892. *
  1893. * @param {Array<any>} arr - The array to convert to an object.
  1894. *
  1895. * @returns An object with the same keys and values as the array.
  1896. */
  1897. function arrayToObject(arr) {
  1898. var obj = {};
  1899. var keys = Object.keys(arr);
  1900. var i;
  1901. var len = keys.length;
  1902. var key;
  1903. for (i = 0; i < len; i++) {
  1904. key = keys[i];
  1905. obj[key] = arr[key];
  1906. }
  1907. return obj;
  1908. }
  1909. /**
  1910. * It takes a FormData object and returns a JavaScript object
  1911. *
  1912. * @param {string} formData The FormData object to convert to JSON.
  1913. *
  1914. * @returns {Object<string, any> | null} The converted object.
  1915. */
  1916. function formDataToJSON(formData) {
  1917. function buildPath(path, value, target, index) {
  1918. var name = path[index++];
  1919. if (name === '__proto__') return true;
  1920. var isNumericKey = Number.isFinite(+name);
  1921. var isLast = index >= path.length;
  1922. name = !name && utils$1.isArray(target) ? target.length : name;
  1923. if (isLast) {
  1924. if (utils$1.hasOwnProp(target, name)) {
  1925. target[name] = [target[name], value];
  1926. } else {
  1927. target[name] = value;
  1928. }
  1929. return !isNumericKey;
  1930. }
  1931. if (!target[name] || !utils$1.isObject(target[name])) {
  1932. target[name] = [];
  1933. }
  1934. var result = buildPath(path, value, target[name], index);
  1935. if (result && utils$1.isArray(target[name])) {
  1936. target[name] = arrayToObject(target[name]);
  1937. }
  1938. return !isNumericKey;
  1939. }
  1940. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  1941. var obj = {};
  1942. utils$1.forEachEntry(formData, function (name, value) {
  1943. buildPath(parsePropPath(name), value, obj, 0);
  1944. });
  1945. return obj;
  1946. }
  1947. return null;
  1948. }
  1949. /**
  1950. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1951. * of the input
  1952. *
  1953. * @param {any} rawValue - The value to be stringified.
  1954. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1955. * @param {Function} encoder - A function that takes a value and returns a string.
  1956. *
  1957. * @returns {string} A stringified version of the rawValue.
  1958. */
  1959. function stringifySafely(rawValue, parser, encoder) {
  1960. if (utils$1.isString(rawValue)) {
  1961. try {
  1962. (parser || JSON.parse)(rawValue);
  1963. return utils$1.trim(rawValue);
  1964. } catch (e) {
  1965. if (e.name !== 'SyntaxError') {
  1966. throw e;
  1967. }
  1968. }
  1969. }
  1970. return (encoder || JSON.stringify)(rawValue);
  1971. }
  1972. var defaults = {
  1973. transitional: transitionalDefaults,
  1974. adapter: ['xhr', 'http', 'fetch'],
  1975. transformRequest: [function transformRequest(data, headers) {
  1976. var contentType = headers.getContentType() || '';
  1977. var hasJSONContentType = contentType.indexOf('application/json') > -1;
  1978. var isObjectPayload = utils$1.isObject(data);
  1979. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  1980. data = new FormData(data);
  1981. }
  1982. var isFormData = utils$1.isFormData(data);
  1983. if (isFormData) {
  1984. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1985. }
  1986. 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)) {
  1987. return data;
  1988. }
  1989. if (utils$1.isArrayBufferView(data)) {
  1990. return data.buffer;
  1991. }
  1992. if (utils$1.isURLSearchParams(data)) {
  1993. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1994. return data.toString();
  1995. }
  1996. var isFileList;
  1997. if (isObjectPayload) {
  1998. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1999. return toURLEncodedForm(data, this.formSerializer).toString();
  2000. }
  2001. if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  2002. var _FormData = this.env && this.env.FormData;
  2003. return toFormData(isFileList ? {
  2004. 'files[]': data
  2005. } : data, _FormData && new _FormData(), this.formSerializer);
  2006. }
  2007. }
  2008. if (isObjectPayload || hasJSONContentType) {
  2009. headers.setContentType('application/json', false);
  2010. return stringifySafely(data);
  2011. }
  2012. return data;
  2013. }],
  2014. transformResponse: [function transformResponse(data) {
  2015. var transitional = this.transitional || defaults.transitional;
  2016. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  2017. var JSONRequested = this.responseType === 'json';
  2018. if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
  2019. return data;
  2020. }
  2021. if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
  2022. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  2023. var strictJSONParsing = !silentJSONParsing && JSONRequested;
  2024. try {
  2025. return JSON.parse(data, this.parseReviver);
  2026. } catch (e) {
  2027. if (strictJSONParsing) {
  2028. if (e.name === 'SyntaxError') {
  2029. throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
  2030. }
  2031. throw e;
  2032. }
  2033. }
  2034. }
  2035. return data;
  2036. }],
  2037. /**
  2038. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  2039. * timeout is not created.
  2040. */
  2041. timeout: 0,
  2042. xsrfCookieName: 'XSRF-TOKEN',
  2043. xsrfHeaderName: 'X-XSRF-TOKEN',
  2044. maxContentLength: -1,
  2045. maxBodyLength: -1,
  2046. env: {
  2047. FormData: platform.classes.FormData,
  2048. Blob: platform.classes.Blob
  2049. },
  2050. validateStatus: function validateStatus(status) {
  2051. return status >= 200 && status < 300;
  2052. },
  2053. headers: {
  2054. common: {
  2055. Accept: 'application/json, text/plain, */*',
  2056. 'Content-Type': undefined
  2057. }
  2058. }
  2059. };
  2060. utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], function (method) {
  2061. defaults.headers[method] = {};
  2062. });
  2063. var defaults$1 = defaults;
  2064. // RawAxiosHeaders whose duplicates are ignored by node
  2065. // c.f. https://nodejs.org/api/http.html#http_message_headers
  2066. 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']);
  2067. /**
  2068. * Parse headers into an object
  2069. *
  2070. * ```
  2071. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  2072. * Content-Type: application/json
  2073. * Connection: keep-alive
  2074. * Transfer-Encoding: chunked
  2075. * ```
  2076. *
  2077. * @param {String} rawHeaders Headers needing to be parsed
  2078. *
  2079. * @returns {Object} Headers parsed into an object
  2080. */
  2081. var parseHeaders = (function (rawHeaders) {
  2082. var parsed = {};
  2083. var key;
  2084. var val;
  2085. var i;
  2086. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  2087. i = line.indexOf(':');
  2088. key = line.substring(0, i).trim().toLowerCase();
  2089. val = line.substring(i + 1).trim();
  2090. if (!key || parsed[key] && ignoreDuplicateOf[key]) {
  2091. return;
  2092. }
  2093. if (key === 'set-cookie') {
  2094. if (parsed[key]) {
  2095. parsed[key].push(val);
  2096. } else {
  2097. parsed[key] = [val];
  2098. }
  2099. } else {
  2100. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  2101. }
  2102. });
  2103. return parsed;
  2104. });
  2105. var $internals = Symbol('internals');
  2106. function normalizeHeader(header) {
  2107. return header && String(header).trim().toLowerCase();
  2108. }
  2109. function normalizeValue(value) {
  2110. if (value === false || value == null) {
  2111. return value;
  2112. }
  2113. return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
  2114. }
  2115. function parseTokens(str) {
  2116. var tokens = Object.create(null);
  2117. var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  2118. var match;
  2119. while (match = tokensRE.exec(str)) {
  2120. tokens[match[1]] = match[2];
  2121. }
  2122. return tokens;
  2123. }
  2124. var isValidHeaderName = function isValidHeaderName(str) {
  2125. return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  2126. };
  2127. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  2128. if (utils$1.isFunction(filter)) {
  2129. return filter.call(this, value, header);
  2130. }
  2131. if (isHeaderNameFilter) {
  2132. value = header;
  2133. }
  2134. if (!utils$1.isString(value)) return;
  2135. if (utils$1.isString(filter)) {
  2136. return value.indexOf(filter) !== -1;
  2137. }
  2138. if (utils$1.isRegExp(filter)) {
  2139. return filter.test(value);
  2140. }
  2141. }
  2142. function formatHeader(header) {
  2143. return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
  2144. return _char.toUpperCase() + str;
  2145. });
  2146. }
  2147. function buildAccessors(obj, header) {
  2148. var accessorName = utils$1.toCamelCase(' ' + header);
  2149. ['get', 'set', 'has'].forEach(function (methodName) {
  2150. Object.defineProperty(obj, methodName + accessorName, {
  2151. value: function value(arg1, arg2, arg3) {
  2152. return this[methodName].call(this, header, arg1, arg2, arg3);
  2153. },
  2154. configurable: true
  2155. });
  2156. });
  2157. }
  2158. var AxiosHeaders = /*#__PURE__*/function () {
  2159. function AxiosHeaders(headers) {
  2160. _classCallCheck(this, AxiosHeaders);
  2161. headers && this.set(headers);
  2162. }
  2163. return _createClass(AxiosHeaders, [{
  2164. key: "set",
  2165. value: function set(header, valueOrRewrite, rewrite) {
  2166. var self = this;
  2167. function setHeader(_value, _header, _rewrite) {
  2168. var lHeader = normalizeHeader(_header);
  2169. if (!lHeader) {
  2170. throw new Error('header name must be a non-empty string');
  2171. }
  2172. var key = utils$1.findKey(self, lHeader);
  2173. if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
  2174. self[key || _header] = normalizeValue(_value);
  2175. }
  2176. }
  2177. var setHeaders = function setHeaders(headers, _rewrite) {
  2178. return utils$1.forEach(headers, function (_value, _header) {
  2179. return setHeader(_value, _header, _rewrite);
  2180. });
  2181. };
  2182. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  2183. setHeaders(header, valueOrRewrite);
  2184. } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  2185. setHeaders(parseHeaders(header), valueOrRewrite);
  2186. } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
  2187. var obj = {},
  2188. dest,
  2189. key;
  2190. var _iterator = _createForOfIteratorHelper(header),
  2191. _step;
  2192. try {
  2193. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2194. var entry = _step.value;
  2195. if (!utils$1.isArray(entry)) {
  2196. throw TypeError('Object iterator must return a key-value pair');
  2197. }
  2198. obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
  2199. }
  2200. } catch (err) {
  2201. _iterator.e(err);
  2202. } finally {
  2203. _iterator.f();
  2204. }
  2205. setHeaders(obj, valueOrRewrite);
  2206. } else {
  2207. header != null && setHeader(valueOrRewrite, header, rewrite);
  2208. }
  2209. return this;
  2210. }
  2211. }, {
  2212. key: "get",
  2213. value: function get(header, parser) {
  2214. header = normalizeHeader(header);
  2215. if (header) {
  2216. var key = utils$1.findKey(this, header);
  2217. if (key) {
  2218. var value = this[key];
  2219. if (!parser) {
  2220. return value;
  2221. }
  2222. if (parser === true) {
  2223. return parseTokens(value);
  2224. }
  2225. if (utils$1.isFunction(parser)) {
  2226. return parser.call(this, value, key);
  2227. }
  2228. if (utils$1.isRegExp(parser)) {
  2229. return parser.exec(value);
  2230. }
  2231. throw new TypeError('parser must be boolean|regexp|function');
  2232. }
  2233. }
  2234. }
  2235. }, {
  2236. key: "has",
  2237. value: function has(header, matcher) {
  2238. header = normalizeHeader(header);
  2239. if (header) {
  2240. var key = utils$1.findKey(this, header);
  2241. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  2242. }
  2243. return false;
  2244. }
  2245. }, {
  2246. key: "delete",
  2247. value: function _delete(header, matcher) {
  2248. var self = this;
  2249. var deleted = false;
  2250. function deleteHeader(_header) {
  2251. _header = normalizeHeader(_header);
  2252. if (_header) {
  2253. var key = utils$1.findKey(self, _header);
  2254. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  2255. delete self[key];
  2256. deleted = true;
  2257. }
  2258. }
  2259. }
  2260. if (utils$1.isArray(header)) {
  2261. header.forEach(deleteHeader);
  2262. } else {
  2263. deleteHeader(header);
  2264. }
  2265. return deleted;
  2266. }
  2267. }, {
  2268. key: "clear",
  2269. value: function clear(matcher) {
  2270. var keys = Object.keys(this);
  2271. var i = keys.length;
  2272. var deleted = false;
  2273. while (i--) {
  2274. var key = keys[i];
  2275. if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  2276. delete this[key];
  2277. deleted = true;
  2278. }
  2279. }
  2280. return deleted;
  2281. }
  2282. }, {
  2283. key: "normalize",
  2284. value: function normalize(format) {
  2285. var self = this;
  2286. var headers = {};
  2287. utils$1.forEach(this, function (value, header) {
  2288. var key = utils$1.findKey(headers, header);
  2289. if (key) {
  2290. self[key] = normalizeValue(value);
  2291. delete self[header];
  2292. return;
  2293. }
  2294. var normalized = format ? formatHeader(header) : String(header).trim();
  2295. if (normalized !== header) {
  2296. delete self[header];
  2297. }
  2298. self[normalized] = normalizeValue(value);
  2299. headers[normalized] = true;
  2300. });
  2301. return this;
  2302. }
  2303. }, {
  2304. key: "concat",
  2305. value: function concat() {
  2306. var _this$constructor;
  2307. for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
  2308. targets[_key] = arguments[_key];
  2309. }
  2310. return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
  2311. }
  2312. }, {
  2313. key: "toJSON",
  2314. value: function toJSON(asStrings) {
  2315. var obj = Object.create(null);
  2316. utils$1.forEach(this, function (value, header) {
  2317. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
  2318. });
  2319. return obj;
  2320. }
  2321. }, {
  2322. key: Symbol.iterator,
  2323. value: function value() {
  2324. return Object.entries(this.toJSON())[Symbol.iterator]();
  2325. }
  2326. }, {
  2327. key: "toString",
  2328. value: function toString() {
  2329. return Object.entries(this.toJSON()).map(function (_ref) {
  2330. var _ref2 = _slicedToArray(_ref, 2),
  2331. header = _ref2[0],
  2332. value = _ref2[1];
  2333. return header + ': ' + value;
  2334. }).join('\n');
  2335. }
  2336. }, {
  2337. key: "getSetCookie",
  2338. value: function getSetCookie() {
  2339. return this.get('set-cookie') || [];
  2340. }
  2341. }, {
  2342. key: Symbol.toStringTag,
  2343. get: function get() {
  2344. return 'AxiosHeaders';
  2345. }
  2346. }], [{
  2347. key: "from",
  2348. value: function from(thing) {
  2349. return thing instanceof this ? thing : new this(thing);
  2350. }
  2351. }, {
  2352. key: "concat",
  2353. value: function concat(first) {
  2354. var computed = new this(first);
  2355. for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  2356. targets[_key2 - 1] = arguments[_key2];
  2357. }
  2358. targets.forEach(function (target) {
  2359. return computed.set(target);
  2360. });
  2361. return computed;
  2362. }
  2363. }, {
  2364. key: "accessor",
  2365. value: function accessor(header) {
  2366. var internals = this[$internals] = this[$internals] = {
  2367. accessors: {}
  2368. };
  2369. var accessors = internals.accessors;
  2370. var prototype = this.prototype;
  2371. function defineAccessor(_header) {
  2372. var lHeader = normalizeHeader(_header);
  2373. if (!accessors[lHeader]) {
  2374. buildAccessors(prototype, _header);
  2375. accessors[lHeader] = true;
  2376. }
  2377. }
  2378. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  2379. return this;
  2380. }
  2381. }]);
  2382. }();
  2383. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  2384. // reserved names hotfix
  2385. utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
  2386. var value = _ref3.value;
  2387. var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
  2388. return {
  2389. get: function get() {
  2390. return value;
  2391. },
  2392. set: function set(headerValue) {
  2393. this[mapped] = headerValue;
  2394. }
  2395. };
  2396. });
  2397. utils$1.freezeMethods(AxiosHeaders);
  2398. var AxiosHeaders$1 = AxiosHeaders;
  2399. /**
  2400. * Transform the data for a request or a response
  2401. *
  2402. * @param {Array|Function} fns A single function or Array of functions
  2403. * @param {?Object} response The response object
  2404. *
  2405. * @returns {*} The resulting transformed data
  2406. */
  2407. function transformData(fns, response) {
  2408. var config = this || defaults$1;
  2409. var context = response || config;
  2410. var headers = AxiosHeaders$1.from(context.headers);
  2411. var data = context.data;
  2412. utils$1.forEach(fns, function transform(fn) {
  2413. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  2414. });
  2415. headers.normalize();
  2416. return data;
  2417. }
  2418. function isCancel(value) {
  2419. return !!(value && value.__CANCEL__);
  2420. }
  2421. var CanceledError = /*#__PURE__*/function (_AxiosError) {
  2422. /**
  2423. * A `CanceledError` is an object that is thrown when an operation is canceled.
  2424. *
  2425. * @param {string=} message The message.
  2426. * @param {Object=} config The config.
  2427. * @param {Object=} request The request.
  2428. *
  2429. * @returns {CanceledError} The created error.
  2430. */
  2431. function CanceledError(message, config, request) {
  2432. var _this;
  2433. _classCallCheck(this, CanceledError);
  2434. _this = _callSuper(this, CanceledError, [message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request]);
  2435. _this.name = 'CanceledError';
  2436. _this.__CANCEL__ = true;
  2437. return _this;
  2438. }
  2439. _inherits(CanceledError, _AxiosError);
  2440. return _createClass(CanceledError);
  2441. }(AxiosError$1);
  2442. var CanceledError$1 = CanceledError;
  2443. /**
  2444. * Resolve or reject a Promise based on response status.
  2445. *
  2446. * @param {Function} resolve A function that resolves the promise.
  2447. * @param {Function} reject A function that rejects the promise.
  2448. * @param {object} response The response.
  2449. *
  2450. * @returns {object} The response.
  2451. */
  2452. function settle(resolve, reject, response) {
  2453. var validateStatus = response.config.validateStatus;
  2454. if (!response.status || !validateStatus || validateStatus(response.status)) {
  2455. resolve(response);
  2456. } else {
  2457. reject(new AxiosError$1('Request failed with status code ' + response.status, [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
  2458. }
  2459. }
  2460. function parseProtocol(url) {
  2461. var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  2462. return match && match[1] || '';
  2463. }
  2464. /**
  2465. * Calculate data maxRate
  2466. * @param {Number} [samplesCount= 10]
  2467. * @param {Number} [min= 1000]
  2468. * @returns {Function}
  2469. */
  2470. function speedometer(samplesCount, min) {
  2471. samplesCount = samplesCount || 10;
  2472. var bytes = new Array(samplesCount);
  2473. var timestamps = new Array(samplesCount);
  2474. var head = 0;
  2475. var tail = 0;
  2476. var firstSampleTS;
  2477. min = min !== undefined ? min : 1000;
  2478. return function push(chunkLength) {
  2479. var now = Date.now();
  2480. var startedAt = timestamps[tail];
  2481. if (!firstSampleTS) {
  2482. firstSampleTS = now;
  2483. }
  2484. bytes[head] = chunkLength;
  2485. timestamps[head] = now;
  2486. var i = tail;
  2487. var bytesCount = 0;
  2488. while (i !== head) {
  2489. bytesCount += bytes[i++];
  2490. i = i % samplesCount;
  2491. }
  2492. head = (head + 1) % samplesCount;
  2493. if (head === tail) {
  2494. tail = (tail + 1) % samplesCount;
  2495. }
  2496. if (now - firstSampleTS < min) {
  2497. return;
  2498. }
  2499. var passed = startedAt && now - startedAt;
  2500. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  2501. };
  2502. }
  2503. /**
  2504. * Throttle decorator
  2505. * @param {Function} fn
  2506. * @param {Number} freq
  2507. * @return {Function}
  2508. */
  2509. function throttle(fn, freq) {
  2510. var timestamp = 0;
  2511. var threshold = 1000 / freq;
  2512. var lastArgs;
  2513. var timer;
  2514. var invoke = function invoke(args) {
  2515. var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
  2516. timestamp = now;
  2517. lastArgs = null;
  2518. if (timer) {
  2519. clearTimeout(timer);
  2520. timer = null;
  2521. }
  2522. fn.apply(void 0, _toConsumableArray(args));
  2523. };
  2524. var throttled = function throttled() {
  2525. var now = Date.now();
  2526. var passed = now - timestamp;
  2527. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2528. args[_key] = arguments[_key];
  2529. }
  2530. if (passed >= threshold) {
  2531. invoke(args, now);
  2532. } else {
  2533. lastArgs = args;
  2534. if (!timer) {
  2535. timer = setTimeout(function () {
  2536. timer = null;
  2537. invoke(lastArgs);
  2538. }, threshold - passed);
  2539. }
  2540. }
  2541. };
  2542. var flush = function flush() {
  2543. return lastArgs && invoke(lastArgs);
  2544. };
  2545. return [throttled, flush];
  2546. }
  2547. var progressEventReducer = function progressEventReducer(listener, isDownloadStream) {
  2548. var freq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
  2549. var bytesNotified = 0;
  2550. var _speedometer = speedometer(50, 250);
  2551. return throttle(function (e) {
  2552. var loaded = e.loaded;
  2553. var total = e.lengthComputable ? e.total : undefined;
  2554. var progressBytes = loaded - bytesNotified;
  2555. var rate = _speedometer(progressBytes);
  2556. var inRange = loaded <= total;
  2557. bytesNotified = loaded;
  2558. var data = _defineProperty({
  2559. loaded: loaded,
  2560. total: total,
  2561. progress: total ? loaded / total : undefined,
  2562. bytes: progressBytes,
  2563. rate: rate ? rate : undefined,
  2564. estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
  2565. event: e,
  2566. lengthComputable: total != null
  2567. }, isDownloadStream ? 'download' : 'upload', true);
  2568. listener(data);
  2569. }, freq);
  2570. };
  2571. var progressEventDecorator = function progressEventDecorator(total, throttled) {
  2572. var lengthComputable = total != null;
  2573. return [function (loaded) {
  2574. return throttled[0]({
  2575. lengthComputable: lengthComputable,
  2576. total: total,
  2577. loaded: loaded
  2578. });
  2579. }, throttled[1]];
  2580. };
  2581. var asyncDecorator = function asyncDecorator(fn) {
  2582. return function () {
  2583. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2584. args[_key] = arguments[_key];
  2585. }
  2586. return utils$1.asap(function () {
  2587. return fn.apply(void 0, args);
  2588. });
  2589. };
  2590. };
  2591. var isURLSameOrigin = platform.hasStandardBrowserEnv ? function (origin, isMSIE) {
  2592. return function (url) {
  2593. url = new URL(url, platform.origin);
  2594. return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
  2595. };
  2596. }(new URL(platform.origin), platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)) : function () {
  2597. return true;
  2598. };
  2599. var cookies = platform.hasStandardBrowserEnv ?
  2600. // Standard browser envs support document.cookie
  2601. {
  2602. write: function write(name, value, expires, path, domain, secure, sameSite) {
  2603. if (typeof document === 'undefined') return;
  2604. var cookie = ["".concat(name, "=").concat(encodeURIComponent(value))];
  2605. if (utils$1.isNumber(expires)) {
  2606. cookie.push("expires=".concat(new Date(expires).toUTCString()));
  2607. }
  2608. if (utils$1.isString(path)) {
  2609. cookie.push("path=".concat(path));
  2610. }
  2611. if (utils$1.isString(domain)) {
  2612. cookie.push("domain=".concat(domain));
  2613. }
  2614. if (secure === true) {
  2615. cookie.push('secure');
  2616. }
  2617. if (utils$1.isString(sameSite)) {
  2618. cookie.push("SameSite=".concat(sameSite));
  2619. }
  2620. document.cookie = cookie.join('; ');
  2621. },
  2622. read: function read(name) {
  2623. if (typeof document === 'undefined') return null;
  2624. var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
  2625. return match ? decodeURIComponent(match[1]) : null;
  2626. },
  2627. remove: function remove(name) {
  2628. this.write(name, '', Date.now() - 86400000, '/');
  2629. }
  2630. } :
  2631. // Non-standard browser env (web workers, react-native) lack needed support.
  2632. {
  2633. write: function write() {},
  2634. read: function read() {
  2635. return null;
  2636. },
  2637. remove: function remove() {}
  2638. };
  2639. /**
  2640. * Determines whether the specified URL is absolute
  2641. *
  2642. * @param {string} url The URL to test
  2643. *
  2644. * @returns {boolean} True if the specified URL is absolute, otherwise false
  2645. */
  2646. function isAbsoluteURL(url) {
  2647. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  2648. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  2649. // by any combination of letters, digits, plus, period, or hyphen.
  2650. if (typeof url !== 'string') {
  2651. return false;
  2652. }
  2653. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  2654. }
  2655. /**
  2656. * Creates a new URL by combining the specified URLs
  2657. *
  2658. * @param {string} baseURL The base URL
  2659. * @param {string} relativeURL The relative URL
  2660. *
  2661. * @returns {string} The combined URL
  2662. */
  2663. function combineURLs(baseURL, relativeURL) {
  2664. return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
  2665. }
  2666. /**
  2667. * Creates a new URL by combining the baseURL with the requestedURL,
  2668. * only when the requestedURL is not already an absolute URL.
  2669. * If the requestURL is absolute, this function returns the requestedURL untouched.
  2670. *
  2671. * @param {string} baseURL The base URL
  2672. * @param {string} requestedURL Absolute or relative URL to combine
  2673. *
  2674. * @returns {string} The combined full path
  2675. */
  2676. function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
  2677. var isRelativeUrl = !isAbsoluteURL(requestedURL);
  2678. if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
  2679. return combineURLs(baseURL, requestedURL);
  2680. }
  2681. return requestedURL;
  2682. }
  2683. var headersToObject = function headersToObject(thing) {
  2684. return thing instanceof AxiosHeaders$1 ? _objectSpread2({}, thing) : thing;
  2685. };
  2686. /**
  2687. * Config-specific merge-function which creates a new config-object
  2688. * by merging two configuration objects together.
  2689. *
  2690. * @param {Object} config1
  2691. * @param {Object} config2
  2692. *
  2693. * @returns {Object} New object resulting from merging config2 to config1
  2694. */
  2695. function mergeConfig(config1, config2) {
  2696. // eslint-disable-next-line no-param-reassign
  2697. config2 = config2 || {};
  2698. var config = {};
  2699. function getMergedValue(target, source, prop, caseless) {
  2700. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  2701. return utils$1.merge.call({
  2702. caseless: caseless
  2703. }, target, source);
  2704. } else if (utils$1.isPlainObject(source)) {
  2705. return utils$1.merge({}, source);
  2706. } else if (utils$1.isArray(source)) {
  2707. return source.slice();
  2708. }
  2709. return source;
  2710. }
  2711. function mergeDeepProperties(a, b, prop, caseless) {
  2712. if (!utils$1.isUndefined(b)) {
  2713. return getMergedValue(a, b, prop, caseless);
  2714. } else if (!utils$1.isUndefined(a)) {
  2715. return getMergedValue(undefined, a, prop, caseless);
  2716. }
  2717. }
  2718. // eslint-disable-next-line consistent-return
  2719. function valueFromConfig2(a, b) {
  2720. if (!utils$1.isUndefined(b)) {
  2721. return getMergedValue(undefined, b);
  2722. }
  2723. }
  2724. // eslint-disable-next-line consistent-return
  2725. function defaultToConfig2(a, b) {
  2726. if (!utils$1.isUndefined(b)) {
  2727. return getMergedValue(undefined, b);
  2728. } else if (!utils$1.isUndefined(a)) {
  2729. return getMergedValue(undefined, a);
  2730. }
  2731. }
  2732. // eslint-disable-next-line consistent-return
  2733. function mergeDirectKeys(a, b, prop) {
  2734. if (prop in config2) {
  2735. return getMergedValue(a, b);
  2736. } else if (prop in config1) {
  2737. return getMergedValue(undefined, a);
  2738. }
  2739. }
  2740. var mergeMap = {
  2741. url: valueFromConfig2,
  2742. method: valueFromConfig2,
  2743. data: valueFromConfig2,
  2744. baseURL: defaultToConfig2,
  2745. transformRequest: defaultToConfig2,
  2746. transformResponse: defaultToConfig2,
  2747. paramsSerializer: defaultToConfig2,
  2748. timeout: defaultToConfig2,
  2749. timeoutMessage: defaultToConfig2,
  2750. withCredentials: defaultToConfig2,
  2751. withXSRFToken: defaultToConfig2,
  2752. adapter: defaultToConfig2,
  2753. responseType: defaultToConfig2,
  2754. xsrfCookieName: defaultToConfig2,
  2755. xsrfHeaderName: defaultToConfig2,
  2756. onUploadProgress: defaultToConfig2,
  2757. onDownloadProgress: defaultToConfig2,
  2758. decompress: defaultToConfig2,
  2759. maxContentLength: defaultToConfig2,
  2760. maxBodyLength: defaultToConfig2,
  2761. beforeRedirect: defaultToConfig2,
  2762. transport: defaultToConfig2,
  2763. httpAgent: defaultToConfig2,
  2764. httpsAgent: defaultToConfig2,
  2765. cancelToken: defaultToConfig2,
  2766. socketPath: defaultToConfig2,
  2767. responseEncoding: defaultToConfig2,
  2768. validateStatus: mergeDirectKeys,
  2769. headers: function headers(a, b, prop) {
  2770. return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
  2771. }
  2772. };
  2773. utils$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
  2774. if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
  2775. var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
  2776. var configValue = merge(config1[prop], config2[prop], prop);
  2777. utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
  2778. });
  2779. return config;
  2780. }
  2781. var resolveConfig = (function (config) {
  2782. var newConfig = mergeConfig({}, config);
  2783. var data = newConfig.data,
  2784. withXSRFToken = newConfig.withXSRFToken,
  2785. xsrfHeaderName = newConfig.xsrfHeaderName,
  2786. xsrfCookieName = newConfig.xsrfCookieName,
  2787. headers = newConfig.headers,
  2788. auth = newConfig.auth;
  2789. newConfig.headers = headers = AxiosHeaders$1.from(headers);
  2790. newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
  2791. // HTTP basic authentication
  2792. if (auth) {
  2793. headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
  2794. }
  2795. if (utils$1.isFormData(data)) {
  2796. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
  2797. headers.setContentType(undefined); // browser handles it
  2798. } else if (utils$1.isFunction(data.getHeaders)) {
  2799. // Node.js FormData (like form-data package)
  2800. var formHeaders = data.getHeaders();
  2801. // Only set safe headers to avoid overwriting security headers
  2802. var allowedHeaders = ['content-type', 'content-length'];
  2803. Object.entries(formHeaders).forEach(function (_ref) {
  2804. var _ref2 = _slicedToArray(_ref, 2),
  2805. key = _ref2[0],
  2806. val = _ref2[1];
  2807. if (allowedHeaders.includes(key.toLowerCase())) {
  2808. headers.set(key, val);
  2809. }
  2810. });
  2811. }
  2812. }
  2813. // Add xsrf header
  2814. // This is only done if running in a standard browser environment.
  2815. // Specifically not if we're in a web worker, or react-native.
  2816. if (platform.hasStandardBrowserEnv) {
  2817. withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
  2818. if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
  2819. // Add xsrf header
  2820. var xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
  2821. if (xsrfValue) {
  2822. headers.set(xsrfHeaderName, xsrfValue);
  2823. }
  2824. }
  2825. }
  2826. return newConfig;
  2827. });
  2828. var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  2829. var xhrAdapter = isXHRAdapterSupported && function (config) {
  2830. return new Promise(function dispatchXhrRequest(resolve, reject) {
  2831. var _config = resolveConfig(config);
  2832. var requestData = _config.data;
  2833. var requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
  2834. var responseType = _config.responseType,
  2835. onUploadProgress = _config.onUploadProgress,
  2836. onDownloadProgress = _config.onDownloadProgress;
  2837. var onCanceled;
  2838. var uploadThrottled, downloadThrottled;
  2839. var flushUpload, flushDownload;
  2840. function done() {
  2841. flushUpload && flushUpload(); // flush events
  2842. flushDownload && flushDownload(); // flush events
  2843. _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
  2844. _config.signal && _config.signal.removeEventListener('abort', onCanceled);
  2845. }
  2846. var request = new XMLHttpRequest();
  2847. request.open(_config.method.toUpperCase(), _config.url, true);
  2848. // Set the request timeout in MS
  2849. request.timeout = _config.timeout;
  2850. function onloadend() {
  2851. if (!request) {
  2852. return;
  2853. }
  2854. // Prepare the response
  2855. var responseHeaders = AxiosHeaders$1.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
  2856. var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
  2857. var response = {
  2858. data: responseData,
  2859. status: request.status,
  2860. statusText: request.statusText,
  2861. headers: responseHeaders,
  2862. config: config,
  2863. request: request
  2864. };
  2865. settle(function _resolve(value) {
  2866. resolve(value);
  2867. done();
  2868. }, function _reject(err) {
  2869. reject(err);
  2870. done();
  2871. }, response);
  2872. // Clean up request
  2873. request = null;
  2874. }
  2875. if ('onloadend' in request) {
  2876. // Use onloadend if available
  2877. request.onloadend = onloadend;
  2878. } else {
  2879. // Listen for ready state to emulate onloadend
  2880. request.onreadystatechange = function handleLoad() {
  2881. if (!request || request.readyState !== 4) {
  2882. return;
  2883. }
  2884. // The request errored out and we didn't get a response, this will be
  2885. // handled by onerror instead
  2886. // With one exception: request that using file: protocol, most browsers
  2887. // will return status as 0 even though it's a successful request
  2888. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  2889. return;
  2890. }
  2891. // readystate handler is calling before onerror or ontimeout handlers,
  2892. // so we should call onloadend on the next 'tick'
  2893. setTimeout(onloadend);
  2894. };
  2895. }
  2896. // Handle browser request cancellation (as opposed to a manual cancellation)
  2897. request.onabort = function handleAbort() {
  2898. if (!request) {
  2899. return;
  2900. }
  2901. reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
  2902. // Clean up request
  2903. request = null;
  2904. };
  2905. // Handle low level network errors
  2906. request.onerror = function handleError(event) {
  2907. // Browsers deliver a ProgressEvent in XHR onerror
  2908. // (message may be empty; when present, surface it)
  2909. // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
  2910. var msg = event && event.message ? event.message : 'Network Error';
  2911. var err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
  2912. // attach the underlying event for consumers who want details
  2913. err.event = event || null;
  2914. reject(err);
  2915. request = null;
  2916. };
  2917. // Handle timeout
  2918. request.ontimeout = function handleTimeout() {
  2919. var timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
  2920. var transitional = _config.transitional || transitionalDefaults;
  2921. if (_config.timeoutErrorMessage) {
  2922. timeoutErrorMessage = _config.timeoutErrorMessage;
  2923. }
  2924. reject(new AxiosError$1(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED, config, request));
  2925. // Clean up request
  2926. request = null;
  2927. };
  2928. // Remove Content-Type if data is undefined
  2929. requestData === undefined && requestHeaders.setContentType(null);
  2930. // Add headers to the request
  2931. if ('setRequestHeader' in request) {
  2932. utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  2933. request.setRequestHeader(key, val);
  2934. });
  2935. }
  2936. // Add withCredentials to request if needed
  2937. if (!utils$1.isUndefined(_config.withCredentials)) {
  2938. request.withCredentials = !!_config.withCredentials;
  2939. }
  2940. // Add responseType to request if needed
  2941. if (responseType && responseType !== 'json') {
  2942. request.responseType = _config.responseType;
  2943. }
  2944. // Handle progress if needed
  2945. if (onDownloadProgress) {
  2946. var _progressEventReducer = progressEventReducer(onDownloadProgress, true);
  2947. var _progressEventReducer2 = _slicedToArray(_progressEventReducer, 2);
  2948. downloadThrottled = _progressEventReducer2[0];
  2949. flushDownload = _progressEventReducer2[1];
  2950. request.addEventListener('progress', downloadThrottled);
  2951. }
  2952. // Not all browsers support upload events
  2953. if (onUploadProgress && request.upload) {
  2954. var _progressEventReducer3 = progressEventReducer(onUploadProgress);
  2955. var _progressEventReducer4 = _slicedToArray(_progressEventReducer3, 2);
  2956. uploadThrottled = _progressEventReducer4[0];
  2957. flushUpload = _progressEventReducer4[1];
  2958. request.upload.addEventListener('progress', uploadThrottled);
  2959. request.upload.addEventListener('loadend', flushUpload);
  2960. }
  2961. if (_config.cancelToken || _config.signal) {
  2962. // Handle cancellation
  2963. // eslint-disable-next-line func-names
  2964. onCanceled = function onCanceled(cancel) {
  2965. if (!request) {
  2966. return;
  2967. }
  2968. reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
  2969. request.abort();
  2970. request = null;
  2971. };
  2972. _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
  2973. if (_config.signal) {
  2974. _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
  2975. }
  2976. }
  2977. var protocol = parseProtocol(_config.url);
  2978. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  2979. reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
  2980. return;
  2981. }
  2982. // Send the request
  2983. request.send(requestData || null);
  2984. });
  2985. };
  2986. var composeSignals = function composeSignals(signals, timeout) {
  2987. var _signals = signals = signals ? signals.filter(Boolean) : [],
  2988. length = _signals.length;
  2989. if (timeout || length) {
  2990. var controller = new AbortController();
  2991. var aborted;
  2992. var onabort = function onabort(reason) {
  2993. if (!aborted) {
  2994. aborted = true;
  2995. unsubscribe();
  2996. var err = reason instanceof Error ? reason : this.reason;
  2997. controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
  2998. }
  2999. };
  3000. var timer = timeout && setTimeout(function () {
  3001. timer = null;
  3002. onabort(new AxiosError$1("timeout of ".concat(timeout, "ms exceeded"), AxiosError$1.ETIMEDOUT));
  3003. }, timeout);
  3004. var unsubscribe = function unsubscribe() {
  3005. if (signals) {
  3006. timer && clearTimeout(timer);
  3007. timer = null;
  3008. signals.forEach(function (signal) {
  3009. signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
  3010. });
  3011. signals = null;
  3012. }
  3013. };
  3014. signals.forEach(function (signal) {
  3015. return signal.addEventListener('abort', onabort);
  3016. });
  3017. var signal = controller.signal;
  3018. signal.unsubscribe = function () {
  3019. return utils$1.asap(unsubscribe);
  3020. };
  3021. return signal;
  3022. }
  3023. };
  3024. var composeSignals$1 = composeSignals;
  3025. var streamChunk = /*#__PURE__*/_regenerator().m(function streamChunk(chunk, chunkSize) {
  3026. var len, pos, end;
  3027. return _regenerator().w(function (_context) {
  3028. while (1) switch (_context.n) {
  3029. case 0:
  3030. len = chunk.byteLength;
  3031. if (!(!chunkSize || len < chunkSize)) {
  3032. _context.n = 2;
  3033. break;
  3034. }
  3035. _context.n = 1;
  3036. return chunk;
  3037. case 1:
  3038. return _context.a(2);
  3039. case 2:
  3040. pos = 0;
  3041. case 3:
  3042. if (!(pos < len)) {
  3043. _context.n = 5;
  3044. break;
  3045. }
  3046. end = pos + chunkSize;
  3047. _context.n = 4;
  3048. return chunk.slice(pos, end);
  3049. case 4:
  3050. pos = end;
  3051. _context.n = 3;
  3052. break;
  3053. case 5:
  3054. return _context.a(2);
  3055. }
  3056. }, streamChunk);
  3057. });
  3058. var readBytes = /*#__PURE__*/function () {
  3059. var _ref = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee(iterable, chunkSize) {
  3060. var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
  3061. return _regenerator().w(function (_context2) {
  3062. while (1) switch (_context2.p = _context2.n) {
  3063. case 0:
  3064. _iteratorAbruptCompletion = false;
  3065. _didIteratorError = false;
  3066. _context2.p = 1;
  3067. _iterator = _asyncIterator(readStream(iterable));
  3068. case 2:
  3069. _context2.n = 3;
  3070. return _awaitAsyncGenerator(_iterator.next());
  3071. case 3:
  3072. if (!(_iteratorAbruptCompletion = !(_step = _context2.v).done)) {
  3073. _context2.n = 5;
  3074. break;
  3075. }
  3076. chunk = _step.value;
  3077. return _context2.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(streamChunk(chunk, chunkSize)))), 4);
  3078. case 4:
  3079. _iteratorAbruptCompletion = false;
  3080. _context2.n = 2;
  3081. break;
  3082. case 5:
  3083. _context2.n = 7;
  3084. break;
  3085. case 6:
  3086. _context2.p = 6;
  3087. _t = _context2.v;
  3088. _didIteratorError = true;
  3089. _iteratorError = _t;
  3090. case 7:
  3091. _context2.p = 7;
  3092. _context2.p = 8;
  3093. if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
  3094. _context2.n = 9;
  3095. break;
  3096. }
  3097. _context2.n = 9;
  3098. return _awaitAsyncGenerator(_iterator["return"]());
  3099. case 9:
  3100. _context2.p = 9;
  3101. if (!_didIteratorError) {
  3102. _context2.n = 10;
  3103. break;
  3104. }
  3105. throw _iteratorError;
  3106. case 10:
  3107. return _context2.f(9);
  3108. case 11:
  3109. return _context2.f(7);
  3110. case 12:
  3111. return _context2.a(2);
  3112. }
  3113. }, _callee, null, [[8,, 9, 11], [1, 6, 7, 12]]);
  3114. }));
  3115. return function readBytes(_x, _x2) {
  3116. return _ref.apply(this, arguments);
  3117. };
  3118. }();
  3119. var readStream = /*#__PURE__*/function () {
  3120. var _ref2 = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee2(stream) {
  3121. var reader, _yield$_awaitAsyncGen, done, value;
  3122. return _regenerator().w(function (_context3) {
  3123. while (1) switch (_context3.p = _context3.n) {
  3124. case 0:
  3125. if (!stream[Symbol.asyncIterator]) {
  3126. _context3.n = 2;
  3127. break;
  3128. }
  3129. return _context3.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(stream))), 1);
  3130. case 1:
  3131. return _context3.a(2);
  3132. case 2:
  3133. reader = stream.getReader();
  3134. _context3.p = 3;
  3135. case 4:
  3136. _context3.n = 5;
  3137. return _awaitAsyncGenerator(reader.read());
  3138. case 5:
  3139. _yield$_awaitAsyncGen = _context3.v;
  3140. done = _yield$_awaitAsyncGen.done;
  3141. value = _yield$_awaitAsyncGen.value;
  3142. if (!done) {
  3143. _context3.n = 6;
  3144. break;
  3145. }
  3146. return _context3.a(3, 8);
  3147. case 6:
  3148. _context3.n = 7;
  3149. return value;
  3150. case 7:
  3151. _context3.n = 4;
  3152. break;
  3153. case 8:
  3154. _context3.p = 8;
  3155. _context3.n = 9;
  3156. return _awaitAsyncGenerator(reader.cancel());
  3157. case 9:
  3158. return _context3.f(8);
  3159. case 10:
  3160. return _context3.a(2);
  3161. }
  3162. }, _callee2, null, [[3,, 8, 10]]);
  3163. }));
  3164. return function readStream(_x3) {
  3165. return _ref2.apply(this, arguments);
  3166. };
  3167. }();
  3168. var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) {
  3169. var iterator = readBytes(stream, chunkSize);
  3170. var bytes = 0;
  3171. var done;
  3172. var _onFinish = function _onFinish(e) {
  3173. if (!done) {
  3174. done = true;
  3175. onFinish && onFinish(e);
  3176. }
  3177. };
  3178. return new ReadableStream({
  3179. pull: function pull(controller) {
  3180. return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
  3181. var _yield$iterator$next, _done, value, len, loadedBytes, _t2;
  3182. return _regenerator().w(function (_context4) {
  3183. while (1) switch (_context4.p = _context4.n) {
  3184. case 0:
  3185. _context4.p = 0;
  3186. _context4.n = 1;
  3187. return iterator.next();
  3188. case 1:
  3189. _yield$iterator$next = _context4.v;
  3190. _done = _yield$iterator$next.done;
  3191. value = _yield$iterator$next.value;
  3192. if (!_done) {
  3193. _context4.n = 2;
  3194. break;
  3195. }
  3196. _onFinish();
  3197. controller.close();
  3198. return _context4.a(2);
  3199. case 2:
  3200. len = value.byteLength;
  3201. if (onProgress) {
  3202. loadedBytes = bytes += len;
  3203. onProgress(loadedBytes);
  3204. }
  3205. controller.enqueue(new Uint8Array(value));
  3206. _context4.n = 4;
  3207. break;
  3208. case 3:
  3209. _context4.p = 3;
  3210. _t2 = _context4.v;
  3211. _onFinish(_t2);
  3212. throw _t2;
  3213. case 4:
  3214. return _context4.a(2);
  3215. }
  3216. }, _callee3, null, [[0, 3]]);
  3217. }))();
  3218. },
  3219. cancel: function cancel(reason) {
  3220. _onFinish(reason);
  3221. return iterator["return"]();
  3222. }
  3223. }, {
  3224. highWaterMark: 2
  3225. });
  3226. };
  3227. var DEFAULT_CHUNK_SIZE = 64 * 1024;
  3228. var isFunction = utils$1.isFunction;
  3229. var globalFetchAPI = function (_ref) {
  3230. var Request = _ref.Request,
  3231. Response = _ref.Response;
  3232. return {
  3233. Request: Request,
  3234. Response: Response
  3235. };
  3236. }(utils$1.global);
  3237. var _utils$global = utils$1.global,
  3238. ReadableStream$1 = _utils$global.ReadableStream,
  3239. TextEncoder = _utils$global.TextEncoder;
  3240. var test = function test(fn) {
  3241. try {
  3242. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3243. args[_key - 1] = arguments[_key];
  3244. }
  3245. return !!fn.apply(void 0, args);
  3246. } catch (e) {
  3247. return false;
  3248. }
  3249. };
  3250. var factory = function factory(env) {
  3251. env = utils$1.merge.call({
  3252. skipUndefined: true
  3253. }, globalFetchAPI, env);
  3254. var _env = env,
  3255. envFetch = _env.fetch,
  3256. Request = _env.Request,
  3257. Response = _env.Response;
  3258. var isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
  3259. var isRequestSupported = isFunction(Request);
  3260. var isResponseSupported = isFunction(Response);
  3261. if (!isFetchSupported) {
  3262. return false;
  3263. }
  3264. var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
  3265. var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
  3266. return function (str) {
  3267. return encoder.encode(str);
  3268. };
  3269. }(new TextEncoder()) : (/*#__PURE__*/function () {
  3270. var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
  3271. var _t, _t2;
  3272. return _regenerator().w(function (_context) {
  3273. while (1) switch (_context.n) {
  3274. case 0:
  3275. _t = Uint8Array;
  3276. _context.n = 1;
  3277. return new Request(str).arrayBuffer();
  3278. case 1:
  3279. _t2 = _context.v;
  3280. return _context.a(2, new _t(_t2));
  3281. }
  3282. }, _callee);
  3283. }));
  3284. return function (_x) {
  3285. return _ref2.apply(this, arguments);
  3286. };
  3287. }()));
  3288. var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
  3289. var duplexAccessed = false;
  3290. var hasContentType = new Request(platform.origin, {
  3291. body: new ReadableStream$1(),
  3292. method: 'POST',
  3293. get duplex() {
  3294. duplexAccessed = true;
  3295. return 'half';
  3296. }
  3297. }).headers.has('Content-Type');
  3298. return duplexAccessed && !hasContentType;
  3299. });
  3300. var supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(function () {
  3301. return utils$1.isReadableStream(new Response('').body);
  3302. });
  3303. var resolvers = {
  3304. stream: supportsResponseStream && function (res) {
  3305. return res.body;
  3306. }
  3307. };
  3308. isFetchSupported && function () {
  3309. ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
  3310. !resolvers[type] && (resolvers[type] = function (res, config) {
  3311. var method = res && res[type];
  3312. if (method) {
  3313. return method.call(res);
  3314. }
  3315. throw new AxiosError$1("Response type '".concat(type, "' is not supported"), AxiosError$1.ERR_NOT_SUPPORT, config);
  3316. });
  3317. });
  3318. }();
  3319. var getBodyLength = /*#__PURE__*/function () {
  3320. var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
  3321. var _request;
  3322. return _regenerator().w(function (_context2) {
  3323. while (1) switch (_context2.n) {
  3324. case 0:
  3325. if (!(body == null)) {
  3326. _context2.n = 1;
  3327. break;
  3328. }
  3329. return _context2.a(2, 0);
  3330. case 1:
  3331. if (!utils$1.isBlob(body)) {
  3332. _context2.n = 2;
  3333. break;
  3334. }
  3335. return _context2.a(2, body.size);
  3336. case 2:
  3337. if (!utils$1.isSpecCompliantForm(body)) {
  3338. _context2.n = 4;
  3339. break;
  3340. }
  3341. _request = new Request(platform.origin, {
  3342. method: 'POST',
  3343. body: body
  3344. });
  3345. _context2.n = 3;
  3346. return _request.arrayBuffer();
  3347. case 3:
  3348. return _context2.a(2, _context2.v.byteLength);
  3349. case 4:
  3350. if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
  3351. _context2.n = 5;
  3352. break;
  3353. }
  3354. return _context2.a(2, body.byteLength);
  3355. case 5:
  3356. if (utils$1.isURLSearchParams(body)) {
  3357. body = body + '';
  3358. }
  3359. if (!utils$1.isString(body)) {
  3360. _context2.n = 7;
  3361. break;
  3362. }
  3363. _context2.n = 6;
  3364. return encodeText(body);
  3365. case 6:
  3366. return _context2.a(2, _context2.v.byteLength);
  3367. case 7:
  3368. return _context2.a(2);
  3369. }
  3370. }, _callee2);
  3371. }));
  3372. return function getBodyLength(_x2) {
  3373. return _ref3.apply(this, arguments);
  3374. };
  3375. }();
  3376. var resolveBodyLength = /*#__PURE__*/function () {
  3377. var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
  3378. var length;
  3379. return _regenerator().w(function (_context3) {
  3380. while (1) switch (_context3.n) {
  3381. case 0:
  3382. length = utils$1.toFiniteNumber(headers.getContentLength());
  3383. return _context3.a(2, length == null ? getBodyLength(body) : length);
  3384. }
  3385. }, _callee3);
  3386. }));
  3387. return function resolveBodyLength(_x3, _x4) {
  3388. return _ref4.apply(this, arguments);
  3389. };
  3390. }();
  3391. return /*#__PURE__*/function () {
  3392. var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
  3393. 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;
  3394. return _regenerator().w(function (_context4) {
  3395. while (1) switch (_context4.p = _context4.n) {
  3396. case 0:
  3397. _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;
  3398. _fetch = envFetch || fetch;
  3399. responseType = responseType ? (responseType + '').toLowerCase() : 'text';
  3400. composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
  3401. request = null;
  3402. unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
  3403. composedSignal.unsubscribe();
  3404. };
  3405. _context4.p = 1;
  3406. _t3 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
  3407. if (!_t3) {
  3408. _context4.n = 3;
  3409. break;
  3410. }
  3411. _context4.n = 2;
  3412. return resolveBodyLength(headers, data);
  3413. case 2:
  3414. _t4 = requestContentLength = _context4.v;
  3415. _t3 = _t4 !== 0;
  3416. case 3:
  3417. if (!_t3) {
  3418. _context4.n = 4;
  3419. break;
  3420. }
  3421. _request = new Request(url, {
  3422. method: 'POST',
  3423. body: data,
  3424. duplex: 'half'
  3425. });
  3426. if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
  3427. headers.setContentType(contentTypeHeader);
  3428. }
  3429. if (_request.body) {
  3430. _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
  3431. data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
  3432. }
  3433. case 4:
  3434. if (!utils$1.isString(withCredentials)) {
  3435. withCredentials = withCredentials ? 'include' : 'omit';
  3436. }
  3437. // Cloudflare Workers throws when credentials are defined
  3438. // see https://github.com/cloudflare/workerd/issues/902
  3439. isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
  3440. resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
  3441. signal: composedSignal,
  3442. method: method.toUpperCase(),
  3443. headers: headers.normalize().toJSON(),
  3444. body: data,
  3445. duplex: 'half',
  3446. credentials: isCredentialsSupported ? withCredentials : undefined
  3447. });
  3448. request = isRequestSupported && new Request(url, resolvedOptions);
  3449. _context4.n = 5;
  3450. return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
  3451. case 5:
  3452. response = _context4.v;
  3453. isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
  3454. if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
  3455. options = {};
  3456. ['status', 'statusText', 'headers'].forEach(function (prop) {
  3457. options[prop] = response[prop];
  3458. });
  3459. responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
  3460. _ref6 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref7 = _slicedToArray(_ref6, 2), _onProgress = _ref7[0], _flush = _ref7[1];
  3461. response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
  3462. _flush && _flush();
  3463. unsubscribe && unsubscribe();
  3464. }), options);
  3465. }
  3466. responseType = responseType || 'text';
  3467. _context4.n = 6;
  3468. return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
  3469. case 6:
  3470. responseData = _context4.v;
  3471. !isStreamResponse && unsubscribe && unsubscribe();
  3472. _context4.n = 7;
  3473. return new Promise(function (resolve, reject) {
  3474. settle(resolve, reject, {
  3475. data: responseData,
  3476. headers: AxiosHeaders$1.from(response.headers),
  3477. status: response.status,
  3478. statusText: response.statusText,
  3479. config: config,
  3480. request: request
  3481. });
  3482. });
  3483. case 7:
  3484. return _context4.a(2, _context4.v);
  3485. case 8:
  3486. _context4.p = 8;
  3487. _t5 = _context4.v;
  3488. unsubscribe && unsubscribe();
  3489. if (!(_t5 && _t5.name === 'TypeError' && /Load failed|fetch/i.test(_t5.message))) {
  3490. _context4.n = 9;
  3491. break;
  3492. }
  3493. throw Object.assign(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, _t5 && _t5.response), {
  3494. cause: _t5.cause || _t5
  3495. });
  3496. case 9:
  3497. throw AxiosError$1.from(_t5, _t5 && _t5.code, config, request, _t5 && _t5.response);
  3498. case 10:
  3499. return _context4.a(2);
  3500. }
  3501. }, _callee4, null, [[1, 8]]);
  3502. }));
  3503. return function (_x5) {
  3504. return _ref5.apply(this, arguments);
  3505. };
  3506. }();
  3507. };
  3508. var seedCache = new Map();
  3509. var getFetch = function getFetch(config) {
  3510. var env = config && config.env || {};
  3511. var fetch = env.fetch,
  3512. Request = env.Request,
  3513. Response = env.Response;
  3514. var seeds = [Request, Response, fetch];
  3515. var len = seeds.length,
  3516. i = len,
  3517. seed,
  3518. target,
  3519. map = seedCache;
  3520. while (i--) {
  3521. seed = seeds[i];
  3522. target = map.get(seed);
  3523. target === undefined && map.set(seed, target = i ? new Map() : factory(env));
  3524. map = target;
  3525. }
  3526. return target;
  3527. };
  3528. getFetch();
  3529. /**
  3530. * Known adapters mapping.
  3531. * Provides environment-specific adapters for Axios:
  3532. * - `http` for Node.js
  3533. * - `xhr` for browsers
  3534. * - `fetch` for fetch API-based requests
  3535. *
  3536. * @type {Object<string, Function|Object>}
  3537. */
  3538. var knownAdapters = {
  3539. http: httpAdapter,
  3540. xhr: xhrAdapter,
  3541. fetch: {
  3542. get: getFetch
  3543. }
  3544. };
  3545. // Assign adapter names for easier debugging and identification
  3546. utils$1.forEach(knownAdapters, function (fn, value) {
  3547. if (fn) {
  3548. try {
  3549. Object.defineProperty(fn, 'name', {
  3550. value: value
  3551. });
  3552. } catch (e) {
  3553. // eslint-disable-next-line no-empty
  3554. }
  3555. Object.defineProperty(fn, 'adapterName', {
  3556. value: value
  3557. });
  3558. }
  3559. });
  3560. /**
  3561. * Render a rejection reason string for unknown or unsupported adapters
  3562. *
  3563. * @param {string} reason
  3564. * @returns {string}
  3565. */
  3566. var renderReason = function renderReason(reason) {
  3567. return "- ".concat(reason);
  3568. };
  3569. /**
  3570. * Check if the adapter is resolved (function, null, or false)
  3571. *
  3572. * @param {Function|null|false} adapter
  3573. * @returns {boolean}
  3574. */
  3575. var isResolvedHandle = function isResolvedHandle(adapter) {
  3576. return utils$1.isFunction(adapter) || adapter === null || adapter === false;
  3577. };
  3578. /**
  3579. * Get the first suitable adapter from the provided list.
  3580. * Tries each adapter in order until a supported one is found.
  3581. * Throws an AxiosError if no adapter is suitable.
  3582. *
  3583. * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
  3584. * @param {Object} config - Axios request configuration
  3585. * @throws {AxiosError} If no suitable adapter is available
  3586. * @returns {Function} The resolved adapter function
  3587. */
  3588. function getAdapter(adapters, config) {
  3589. adapters = utils$1.isArray(adapters) ? adapters : [adapters];
  3590. var _adapters = adapters,
  3591. length = _adapters.length;
  3592. var nameOrAdapter;
  3593. var adapter;
  3594. var rejectedReasons = {};
  3595. for (var i = 0; i < length; i++) {
  3596. nameOrAdapter = adapters[i];
  3597. var id = void 0;
  3598. adapter = nameOrAdapter;
  3599. if (!isResolvedHandle(nameOrAdapter)) {
  3600. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  3601. if (adapter === undefined) {
  3602. throw new AxiosError$1("Unknown adapter '".concat(id, "'"));
  3603. }
  3604. }
  3605. if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
  3606. break;
  3607. }
  3608. rejectedReasons[id || '#' + i] = adapter;
  3609. }
  3610. if (!adapter) {
  3611. var reasons = Object.entries(rejectedReasons).map(function (_ref) {
  3612. var _ref2 = _slicedToArray(_ref, 2),
  3613. id = _ref2[0],
  3614. state = _ref2[1];
  3615. return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
  3616. });
  3617. var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
  3618. throw new AxiosError$1("There is no suitable adapter to dispatch the request " + s, 'ERR_NOT_SUPPORT');
  3619. }
  3620. return adapter;
  3621. }
  3622. /**
  3623. * Exports Axios adapters and utility to resolve an adapter
  3624. */
  3625. var adapters = {
  3626. /**
  3627. * Resolve an adapter from a list of adapter names or functions.
  3628. * @type {Function}
  3629. */
  3630. getAdapter: getAdapter,
  3631. /**
  3632. * Exposes all known adapters
  3633. * @type {Object<string, Function|Object>}
  3634. */
  3635. adapters: knownAdapters
  3636. };
  3637. /**
  3638. * Throws a `CanceledError` if cancellation has been requested.
  3639. *
  3640. * @param {Object} config The config that is to be used for the request
  3641. *
  3642. * @returns {void}
  3643. */
  3644. function throwIfCancellationRequested(config) {
  3645. if (config.cancelToken) {
  3646. config.cancelToken.throwIfRequested();
  3647. }
  3648. if (config.signal && config.signal.aborted) {
  3649. throw new CanceledError$1(null, config);
  3650. }
  3651. }
  3652. /**
  3653. * Dispatch a request to the server using the configured adapter.
  3654. *
  3655. * @param {object} config The config that is to be used for the request
  3656. *
  3657. * @returns {Promise} The Promise to be fulfilled
  3658. */
  3659. function dispatchRequest(config) {
  3660. throwIfCancellationRequested(config);
  3661. config.headers = AxiosHeaders$1.from(config.headers);
  3662. // Transform request data
  3663. config.data = transformData.call(config, config.transformRequest);
  3664. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  3665. config.headers.setContentType('application/x-www-form-urlencoded', false);
  3666. }
  3667. var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
  3668. return adapter(config).then(function onAdapterResolution(response) {
  3669. throwIfCancellationRequested(config);
  3670. // Transform response data
  3671. response.data = transformData.call(config, config.transformResponse, response);
  3672. response.headers = AxiosHeaders$1.from(response.headers);
  3673. return response;
  3674. }, function onAdapterRejection(reason) {
  3675. if (!isCancel(reason)) {
  3676. throwIfCancellationRequested(config);
  3677. // Transform response data
  3678. if (reason && reason.response) {
  3679. reason.response.data = transformData.call(config, config.transformResponse, reason.response);
  3680. reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
  3681. }
  3682. }
  3683. return Promise.reject(reason);
  3684. });
  3685. }
  3686. var VERSION = "1.13.6";
  3687. var validators$1 = {};
  3688. // eslint-disable-next-line func-names
  3689. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
  3690. validators$1[type] = function validator(thing) {
  3691. return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  3692. };
  3693. });
  3694. var deprecatedWarnings = {};
  3695. /**
  3696. * Transitional option validator
  3697. *
  3698. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  3699. * @param {string?} version - deprecated version / removed since version
  3700. * @param {string?} message - some message with additional info
  3701. *
  3702. * @returns {function}
  3703. */
  3704. validators$1.transitional = function transitional(validator, version, message) {
  3705. function formatMessage(opt, desc) {
  3706. return '[Axios v' + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? '. ' + message : '');
  3707. }
  3708. // eslint-disable-next-line func-names
  3709. return function (value, opt, opts) {
  3710. if (validator === false) {
  3711. throw new AxiosError$1(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError$1.ERR_DEPRECATED);
  3712. }
  3713. if (version && !deprecatedWarnings[opt]) {
  3714. deprecatedWarnings[opt] = true;
  3715. // eslint-disable-next-line no-console
  3716. console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
  3717. }
  3718. return validator ? validator(value, opt, opts) : true;
  3719. };
  3720. };
  3721. validators$1.spelling = function spelling(correctSpelling) {
  3722. return function (value, opt) {
  3723. // eslint-disable-next-line no-console
  3724. console.warn("".concat(opt, " is likely a misspelling of ").concat(correctSpelling));
  3725. return true;
  3726. };
  3727. };
  3728. /**
  3729. * Assert object's properties type
  3730. *
  3731. * @param {object} options
  3732. * @param {object} schema
  3733. * @param {boolean?} allowUnknown
  3734. *
  3735. * @returns {object}
  3736. */
  3737. function assertOptions(options, schema, allowUnknown) {
  3738. if (_typeof(options) !== 'object') {
  3739. throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
  3740. }
  3741. var keys = Object.keys(options);
  3742. var i = keys.length;
  3743. while (i-- > 0) {
  3744. var opt = keys[i];
  3745. var validator = schema[opt];
  3746. if (validator) {
  3747. var value = options[opt];
  3748. var result = value === undefined || validator(value, opt, options);
  3749. if (result !== true) {
  3750. throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
  3751. }
  3752. continue;
  3753. }
  3754. if (allowUnknown !== true) {
  3755. throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
  3756. }
  3757. }
  3758. }
  3759. var validator = {
  3760. assertOptions: assertOptions,
  3761. validators: validators$1
  3762. };
  3763. var validators = validator.validators;
  3764. /**
  3765. * Create a new instance of Axios
  3766. *
  3767. * @param {Object} instanceConfig The default config for the instance
  3768. *
  3769. * @return {Axios} A new instance of Axios
  3770. */
  3771. var Axios = /*#__PURE__*/function () {
  3772. function Axios(instanceConfig) {
  3773. _classCallCheck(this, Axios);
  3774. this.defaults = instanceConfig || {};
  3775. this.interceptors = {
  3776. request: new InterceptorManager$1(),
  3777. response: new InterceptorManager$1()
  3778. };
  3779. }
  3780. /**
  3781. * Dispatch a request
  3782. *
  3783. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  3784. * @param {?Object} config
  3785. *
  3786. * @returns {Promise} The Promise to be fulfilled
  3787. */
  3788. return _createClass(Axios, [{
  3789. key: "request",
  3790. value: (function () {
  3791. var _request2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configOrUrl, config) {
  3792. var dummy, stack, _t;
  3793. return _regenerator().w(function (_context) {
  3794. while (1) switch (_context.p = _context.n) {
  3795. case 0:
  3796. _context.p = 0;
  3797. _context.n = 1;
  3798. return this._request(configOrUrl, config);
  3799. case 1:
  3800. return _context.a(2, _context.v);
  3801. case 2:
  3802. _context.p = 2;
  3803. _t = _context.v;
  3804. if (_t instanceof Error) {
  3805. dummy = {};
  3806. Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
  3807. // slice off the Error: ... line
  3808. stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
  3809. try {
  3810. if (!_t.stack) {
  3811. _t.stack = stack;
  3812. // match without the 2 top stack lines
  3813. } else if (stack && !String(_t.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
  3814. _t.stack += '\n' + stack;
  3815. }
  3816. } catch (e) {
  3817. // ignore the case where "stack" is an un-writable property
  3818. }
  3819. }
  3820. throw _t;
  3821. case 3:
  3822. return _context.a(2);
  3823. }
  3824. }, _callee, this, [[0, 2]]);
  3825. }));
  3826. function request(_x, _x2) {
  3827. return _request2.apply(this, arguments);
  3828. }
  3829. return request;
  3830. }())
  3831. }, {
  3832. key: "_request",
  3833. value: function _request(configOrUrl, config) {
  3834. /*eslint no-param-reassign:0*/
  3835. // Allow for axios('example/url'[, config]) a la fetch API
  3836. if (typeof configOrUrl === 'string') {
  3837. config = config || {};
  3838. config.url = configOrUrl;
  3839. } else {
  3840. config = configOrUrl || {};
  3841. }
  3842. config = mergeConfig(this.defaults, config);
  3843. var _config = config,
  3844. transitional = _config.transitional,
  3845. paramsSerializer = _config.paramsSerializer,
  3846. headers = _config.headers;
  3847. if (transitional !== undefined) {
  3848. validator.assertOptions(transitional, {
  3849. silentJSONParsing: validators.transitional(validators["boolean"]),
  3850. forcedJSONParsing: validators.transitional(validators["boolean"]),
  3851. clarifyTimeoutError: validators.transitional(validators["boolean"]),
  3852. legacyInterceptorReqResOrdering: validators.transitional(validators["boolean"])
  3853. }, false);
  3854. }
  3855. if (paramsSerializer != null) {
  3856. if (utils$1.isFunction(paramsSerializer)) {
  3857. config.paramsSerializer = {
  3858. serialize: paramsSerializer
  3859. };
  3860. } else {
  3861. validator.assertOptions(paramsSerializer, {
  3862. encode: validators["function"],
  3863. serialize: validators["function"]
  3864. }, true);
  3865. }
  3866. }
  3867. // Set config.allowAbsoluteUrls
  3868. if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
  3869. config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
  3870. } else {
  3871. config.allowAbsoluteUrls = true;
  3872. }
  3873. validator.assertOptions(config, {
  3874. baseUrl: validators.spelling('baseURL'),
  3875. withXsrfToken: validators.spelling('withXSRFToken')
  3876. }, true);
  3877. // Set config.method
  3878. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  3879. // Flatten headers
  3880. var contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
  3881. headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
  3882. delete headers[method];
  3883. });
  3884. config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
  3885. // filter out skipped interceptors
  3886. var requestInterceptorChain = [];
  3887. var synchronousRequestInterceptors = true;
  3888. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  3889. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  3890. return;
  3891. }
  3892. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  3893. var transitional = config.transitional || transitionalDefaults;
  3894. var legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
  3895. if (legacyInterceptorReqResOrdering) {
  3896. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  3897. } else {
  3898. requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  3899. }
  3900. });
  3901. var responseInterceptorChain = [];
  3902. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  3903. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  3904. });
  3905. var promise;
  3906. var i = 0;
  3907. var len;
  3908. if (!synchronousRequestInterceptors) {
  3909. var chain = [dispatchRequest.bind(this), undefined];
  3910. chain.unshift.apply(chain, requestInterceptorChain);
  3911. chain.push.apply(chain, responseInterceptorChain);
  3912. len = chain.length;
  3913. promise = Promise.resolve(config);
  3914. while (i < len) {
  3915. promise = promise.then(chain[i++], chain[i++]);
  3916. }
  3917. return promise;
  3918. }
  3919. len = requestInterceptorChain.length;
  3920. var newConfig = config;
  3921. while (i < len) {
  3922. var onFulfilled = requestInterceptorChain[i++];
  3923. var onRejected = requestInterceptorChain[i++];
  3924. try {
  3925. newConfig = onFulfilled(newConfig);
  3926. } catch (error) {
  3927. onRejected.call(this, error);
  3928. break;
  3929. }
  3930. }
  3931. try {
  3932. promise = dispatchRequest.call(this, newConfig);
  3933. } catch (error) {
  3934. return Promise.reject(error);
  3935. }
  3936. i = 0;
  3937. len = responseInterceptorChain.length;
  3938. while (i < len) {
  3939. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  3940. }
  3941. return promise;
  3942. }
  3943. }, {
  3944. key: "getUri",
  3945. value: function getUri(config) {
  3946. config = mergeConfig(this.defaults, config);
  3947. var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
  3948. return buildURL(fullPath, config.params, config.paramsSerializer);
  3949. }
  3950. }]);
  3951. }(); // Provide aliases for supported request methods
  3952. utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  3953. /*eslint func-names:0*/
  3954. Axios.prototype[method] = function (url, config) {
  3955. return this.request(mergeConfig(config || {}, {
  3956. method: method,
  3957. url: url,
  3958. data: (config || {}).data
  3959. }));
  3960. };
  3961. });
  3962. utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  3963. /*eslint func-names:0*/
  3964. function generateHTTPMethod(isForm) {
  3965. return function httpMethod(url, data, config) {
  3966. return this.request(mergeConfig(config || {}, {
  3967. method: method,
  3968. headers: isForm ? {
  3969. 'Content-Type': 'multipart/form-data'
  3970. } : {},
  3971. url: url,
  3972. data: data
  3973. }));
  3974. };
  3975. }
  3976. Axios.prototype[method] = generateHTTPMethod();
  3977. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  3978. });
  3979. var Axios$1 = Axios;
  3980. /**
  3981. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  3982. *
  3983. * @param {Function} executor The executor function.
  3984. *
  3985. * @returns {CancelToken}
  3986. */
  3987. var CancelToken = /*#__PURE__*/function () {
  3988. function CancelToken(executor) {
  3989. _classCallCheck(this, CancelToken);
  3990. if (typeof executor !== 'function') {
  3991. throw new TypeError('executor must be a function.');
  3992. }
  3993. var resolvePromise;
  3994. this.promise = new Promise(function promiseExecutor(resolve) {
  3995. resolvePromise = resolve;
  3996. });
  3997. var token = this;
  3998. // eslint-disable-next-line func-names
  3999. this.promise.then(function (cancel) {
  4000. if (!token._listeners) return;
  4001. var i = token._listeners.length;
  4002. while (i-- > 0) {
  4003. token._listeners[i](cancel);
  4004. }
  4005. token._listeners = null;
  4006. });
  4007. // eslint-disable-next-line func-names
  4008. this.promise.then = function (onfulfilled) {
  4009. var _resolve;
  4010. // eslint-disable-next-line func-names
  4011. var promise = new Promise(function (resolve) {
  4012. token.subscribe(resolve);
  4013. _resolve = resolve;
  4014. }).then(onfulfilled);
  4015. promise.cancel = function reject() {
  4016. token.unsubscribe(_resolve);
  4017. };
  4018. return promise;
  4019. };
  4020. executor(function cancel(message, config, request) {
  4021. if (token.reason) {
  4022. // Cancellation has already been requested
  4023. return;
  4024. }
  4025. token.reason = new CanceledError$1(message, config, request);
  4026. resolvePromise(token.reason);
  4027. });
  4028. }
  4029. /**
  4030. * Throws a `CanceledError` if cancellation has been requested.
  4031. */
  4032. return _createClass(CancelToken, [{
  4033. key: "throwIfRequested",
  4034. value: function throwIfRequested() {
  4035. if (this.reason) {
  4036. throw this.reason;
  4037. }
  4038. }
  4039. /**
  4040. * Subscribe to the cancel signal
  4041. */
  4042. }, {
  4043. key: "subscribe",
  4044. value: function subscribe(listener) {
  4045. if (this.reason) {
  4046. listener(this.reason);
  4047. return;
  4048. }
  4049. if (this._listeners) {
  4050. this._listeners.push(listener);
  4051. } else {
  4052. this._listeners = [listener];
  4053. }
  4054. }
  4055. /**
  4056. * Unsubscribe from the cancel signal
  4057. */
  4058. }, {
  4059. key: "unsubscribe",
  4060. value: function unsubscribe(listener) {
  4061. if (!this._listeners) {
  4062. return;
  4063. }
  4064. var index = this._listeners.indexOf(listener);
  4065. if (index !== -1) {
  4066. this._listeners.splice(index, 1);
  4067. }
  4068. }
  4069. }, {
  4070. key: "toAbortSignal",
  4071. value: function toAbortSignal() {
  4072. var _this = this;
  4073. var controller = new AbortController();
  4074. var abort = function abort(err) {
  4075. controller.abort(err);
  4076. };
  4077. this.subscribe(abort);
  4078. controller.signal.unsubscribe = function () {
  4079. return _this.unsubscribe(abort);
  4080. };
  4081. return controller.signal;
  4082. }
  4083. /**
  4084. * Returns an object that contains a new `CancelToken` and a function that, when called,
  4085. * cancels the `CancelToken`.
  4086. */
  4087. }], [{
  4088. key: "source",
  4089. value: function source() {
  4090. var cancel;
  4091. var token = new CancelToken(function executor(c) {
  4092. cancel = c;
  4093. });
  4094. return {
  4095. token: token,
  4096. cancel: cancel
  4097. };
  4098. }
  4099. }]);
  4100. }();
  4101. var CancelToken$1 = CancelToken;
  4102. /**
  4103. * Syntactic sugar for invoking a function and expanding an array for arguments.
  4104. *
  4105. * Common use case would be to use `Function.prototype.apply`.
  4106. *
  4107. * ```js
  4108. * function f(x, y, z) {}
  4109. * const args = [1, 2, 3];
  4110. * f.apply(null, args);
  4111. * ```
  4112. *
  4113. * With `spread` this example can be re-written.
  4114. *
  4115. * ```js
  4116. * spread(function(x, y, z) {})([1, 2, 3]);
  4117. * ```
  4118. *
  4119. * @param {Function} callback
  4120. *
  4121. * @returns {Function}
  4122. */
  4123. function spread(callback) {
  4124. return function wrap(arr) {
  4125. return callback.apply(null, arr);
  4126. };
  4127. }
  4128. /**
  4129. * Determines whether the payload is an error thrown by Axios
  4130. *
  4131. * @param {*} payload The value to test
  4132. *
  4133. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  4134. */
  4135. function isAxiosError(payload) {
  4136. return utils$1.isObject(payload) && payload.isAxiosError === true;
  4137. }
  4138. var HttpStatusCode = {
  4139. Continue: 100,
  4140. SwitchingProtocols: 101,
  4141. Processing: 102,
  4142. EarlyHints: 103,
  4143. Ok: 200,
  4144. Created: 201,
  4145. Accepted: 202,
  4146. NonAuthoritativeInformation: 203,
  4147. NoContent: 204,
  4148. ResetContent: 205,
  4149. PartialContent: 206,
  4150. MultiStatus: 207,
  4151. AlreadyReported: 208,
  4152. ImUsed: 226,
  4153. MultipleChoices: 300,
  4154. MovedPermanently: 301,
  4155. Found: 302,
  4156. SeeOther: 303,
  4157. NotModified: 304,
  4158. UseProxy: 305,
  4159. Unused: 306,
  4160. TemporaryRedirect: 307,
  4161. PermanentRedirect: 308,
  4162. BadRequest: 400,
  4163. Unauthorized: 401,
  4164. PaymentRequired: 402,
  4165. Forbidden: 403,
  4166. NotFound: 404,
  4167. MethodNotAllowed: 405,
  4168. NotAcceptable: 406,
  4169. ProxyAuthenticationRequired: 407,
  4170. RequestTimeout: 408,
  4171. Conflict: 409,
  4172. Gone: 410,
  4173. LengthRequired: 411,
  4174. PreconditionFailed: 412,
  4175. PayloadTooLarge: 413,
  4176. UriTooLong: 414,
  4177. UnsupportedMediaType: 415,
  4178. RangeNotSatisfiable: 416,
  4179. ExpectationFailed: 417,
  4180. ImATeapot: 418,
  4181. MisdirectedRequest: 421,
  4182. UnprocessableEntity: 422,
  4183. Locked: 423,
  4184. FailedDependency: 424,
  4185. TooEarly: 425,
  4186. UpgradeRequired: 426,
  4187. PreconditionRequired: 428,
  4188. TooManyRequests: 429,
  4189. RequestHeaderFieldsTooLarge: 431,
  4190. UnavailableForLegalReasons: 451,
  4191. InternalServerError: 500,
  4192. NotImplemented: 501,
  4193. BadGateway: 502,
  4194. ServiceUnavailable: 503,
  4195. GatewayTimeout: 504,
  4196. HttpVersionNotSupported: 505,
  4197. VariantAlsoNegotiates: 506,
  4198. InsufficientStorage: 507,
  4199. LoopDetected: 508,
  4200. NotExtended: 510,
  4201. NetworkAuthenticationRequired: 511,
  4202. WebServerIsDown: 521,
  4203. ConnectionTimedOut: 522,
  4204. OriginIsUnreachable: 523,
  4205. TimeoutOccurred: 524,
  4206. SslHandshakeFailed: 525,
  4207. InvalidSslCertificate: 526
  4208. };
  4209. Object.entries(HttpStatusCode).forEach(function (_ref) {
  4210. var _ref2 = _slicedToArray(_ref, 2),
  4211. key = _ref2[0],
  4212. value = _ref2[1];
  4213. HttpStatusCode[value] = key;
  4214. });
  4215. var HttpStatusCode$1 = HttpStatusCode;
  4216. /**
  4217. * Create an instance of Axios
  4218. *
  4219. * @param {Object} defaultConfig The default config for the instance
  4220. *
  4221. * @returns {Axios} A new instance of Axios
  4222. */
  4223. function createInstance(defaultConfig) {
  4224. var context = new Axios$1(defaultConfig);
  4225. var instance = bind(Axios$1.prototype.request, context);
  4226. // Copy axios.prototype to instance
  4227. utils$1.extend(instance, Axios$1.prototype, context, {
  4228. allOwnKeys: true
  4229. });
  4230. // Copy context to instance
  4231. utils$1.extend(instance, context, null, {
  4232. allOwnKeys: true
  4233. });
  4234. // Factory for creating new instances
  4235. instance.create = function create(instanceConfig) {
  4236. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  4237. };
  4238. return instance;
  4239. }
  4240. // Create the default instance to be exported
  4241. var axios = createInstance(defaults$1);
  4242. // Expose Axios class to allow class inheritance
  4243. axios.Axios = Axios$1;
  4244. // Expose Cancel & CancelToken
  4245. axios.CanceledError = CanceledError$1;
  4246. axios.CancelToken = CancelToken$1;
  4247. axios.isCancel = isCancel;
  4248. axios.VERSION = VERSION;
  4249. axios.toFormData = toFormData;
  4250. // Expose AxiosError class
  4251. axios.AxiosError = AxiosError$1;
  4252. // alias for CanceledError for backward compatibility
  4253. axios.Cancel = axios.CanceledError;
  4254. // Expose all/spread
  4255. axios.all = function all(promises) {
  4256. return Promise.all(promises);
  4257. };
  4258. axios.spread = spread;
  4259. // Expose isAxiosError
  4260. axios.isAxiosError = isAxiosError;
  4261. // Expose mergeConfig
  4262. axios.mergeConfig = mergeConfig;
  4263. axios.AxiosHeaders = AxiosHeaders$1;
  4264. axios.formToJSON = function (thing) {
  4265. return formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  4266. };
  4267. axios.getAdapter = adapters.getAdapter;
  4268. axios.HttpStatusCode = HttpStatusCode$1;
  4269. axios["default"] = axios;
  4270. return axios;
  4271. }));
  4272. //# sourceMappingURL=axios.js.map