axios.js 148 KB

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