axios.js 231 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477
  1. /*! Axios v1.21.1 Copyright (c) 2026 Matt Zabriskie and contributors */
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  4. typeof define === 'function' && define.amd ? define(factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.axios = factory());
  6. })(this, (function () { 'use strict';
  7. function _OverloadYield(e, d) {
  8. this.v = e, this.k = d;
  9. }
  10. function _arrayLikeToArray(r, a) {
  11. (null == a || a > r.length) && (a = r.length);
  12. for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  13. return n;
  14. }
  15. function _arrayWithHoles(r) {
  16. if (Array.isArray(r)) return r;
  17. }
  18. function _arrayWithoutHoles(r) {
  19. if (Array.isArray(r)) return _arrayLikeToArray(r);
  20. }
  21. function _assertThisInitialized(e) {
  22. if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  23. return e;
  24. }
  25. function _asyncGeneratorDelegate(t) {
  26. var e = {},
  27. n = false;
  28. function pump(e, r) {
  29. return n = true, r = new Promise(function (n) {
  30. n(t[e](r));
  31. }), {
  32. done: false,
  33. value: new _OverloadYield(r, 1)
  34. };
  35. }
  36. return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function () {
  37. return this;
  38. }, e.next = function (t) {
  39. return n ? (n = false, t) : pump("next", t);
  40. }, "function" == typeof t.throw && (e.throw = function (t) {
  41. if (n) throw n = false, t;
  42. return pump("throw", t);
  43. }), "function" == typeof t.return && (e.return = function (t) {
  44. return n ? (n = false, t) : pump("return", t);
  45. }), e;
  46. }
  47. function _asyncIterator(r) {
  48. var n,
  49. t,
  50. o,
  51. e = 2;
  52. for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
  53. if (t && null != (n = r[t])) return n.call(r);
  54. if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
  55. t = "@@asyncIterator", o = "@@iterator";
  56. }
  57. throw new TypeError("Object is not async iterable");
  58. }
  59. function AsyncFromSyncIterator(r) {
  60. function AsyncFromSyncIteratorContinuation(r) {
  61. if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
  62. var n = r.done;
  63. return Promise.resolve(r.value).then(function (r) {
  64. return {
  65. value: r,
  66. done: n
  67. };
  68. });
  69. }
  70. return AsyncFromSyncIterator = function (r) {
  71. this.s = r, this.n = r.next;
  72. }, AsyncFromSyncIterator.prototype = {
  73. s: null,
  74. n: null,
  75. next: function () {
  76. return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
  77. },
  78. return: function (r) {
  79. var n = this.s.return;
  80. return void 0 === n ? Promise.resolve({
  81. value: r,
  82. done: true
  83. }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
  84. },
  85. throw: function (r) {
  86. var n = this.s.return;
  87. return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
  88. }
  89. }, new AsyncFromSyncIterator(r);
  90. }
  91. function asyncGeneratorStep(n, t, e, r, o, a, c) {
  92. try {
  93. var i = n[a](c),
  94. u = i.value;
  95. } catch (n) {
  96. return void e(n);
  97. }
  98. i.done ? t(u) : Promise.resolve(u).then(r, o);
  99. }
  100. function _asyncToGenerator(n) {
  101. return function () {
  102. var t = this,
  103. e = arguments;
  104. return new Promise(function (r, o) {
  105. var a = n.apply(t, e);
  106. function _next(n) {
  107. asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
  108. }
  109. function _throw(n) {
  110. asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
  111. }
  112. _next(void 0);
  113. });
  114. };
  115. }
  116. function _awaitAsyncGenerator(e) {
  117. return new _OverloadYield(e, 0);
  118. }
  119. function _callSuper(t, o, e) {
  120. return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
  121. }
  122. function _classCallCheck(a, n) {
  123. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  124. }
  125. function _construct(t, e, r) {
  126. if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
  127. var o = [null];
  128. o.push.apply(o, e);
  129. var p = new (t.bind.apply(t, o))();
  130. return r && _setPrototypeOf(p, r.prototype), p;
  131. }
  132. function _defineProperties(e, r) {
  133. for (var t = 0; t < r.length; t++) {
  134. var o = r[t];
  135. o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
  136. }
  137. }
  138. function _createClass(e, r, t) {
  139. return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
  140. writable: false
  141. }), e;
  142. }
  143. function _createForOfIteratorHelper(r, e) {
  144. var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  145. if (!t) {
  146. if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
  147. t && (r = t);
  148. var n = 0,
  149. F = function () {};
  150. return {
  151. s: F,
  152. n: function () {
  153. return n >= r.length ? {
  154. done: true
  155. } : {
  156. done: false,
  157. value: r[n++]
  158. };
  159. },
  160. e: function (r) {
  161. throw r;
  162. },
  163. f: F
  164. };
  165. }
  166. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  167. }
  168. var o,
  169. a = true,
  170. u = false;
  171. return {
  172. s: function () {
  173. t = t.call(r);
  174. },
  175. n: function () {
  176. var r = t.next();
  177. return a = r.done, r;
  178. },
  179. e: function (r) {
  180. u = true, o = r;
  181. },
  182. f: function () {
  183. try {
  184. a || null == t.return || t.return();
  185. } finally {
  186. if (u) throw o;
  187. }
  188. }
  189. };
  190. }
  191. function _defineProperty(e, r, t) {
  192. return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
  193. value: t,
  194. enumerable: true,
  195. configurable: true,
  196. writable: true
  197. }) : e[r] = t, e;
  198. }
  199. function _getPrototypeOf(t) {
  200. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
  201. return t.__proto__ || Object.getPrototypeOf(t);
  202. }, _getPrototypeOf(t);
  203. }
  204. function _inherits(t, e) {
  205. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  206. t.prototype = Object.create(e && e.prototype, {
  207. constructor: {
  208. value: t,
  209. writable: true,
  210. configurable: true
  211. }
  212. }), Object.defineProperty(t, "prototype", {
  213. writable: false
  214. }), e && _setPrototypeOf(t, e);
  215. }
  216. function _isNativeFunction(t) {
  217. try {
  218. return -1 !== Function.toString.call(t).indexOf("[native code]");
  219. } catch (n) {
  220. return "function" == typeof t;
  221. }
  222. }
  223. function _isNativeReflectConstruct() {
  224. try {
  225. var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  226. } catch (t) {}
  227. return (_isNativeReflectConstruct = function () {
  228. return !!t;
  229. })();
  230. }
  231. function _iterableToArray(r) {
  232. if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
  233. }
  234. function _iterableToArrayLimit(r, l) {
  235. var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  236. if (null != t) {
  237. var e,
  238. n,
  239. i,
  240. u,
  241. a = [],
  242. f = true,
  243. o = false;
  244. try {
  245. if (i = (t = t.call(r)).next, 0 === l) {
  246. if (Object(t) !== t) return;
  247. f = !1;
  248. } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
  249. } catch (r) {
  250. o = true, n = r;
  251. } finally {
  252. try {
  253. if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
  254. } finally {
  255. if (o) throw n;
  256. }
  257. }
  258. return a;
  259. }
  260. }
  261. function _nonIterableRest() {
  262. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  263. }
  264. function _nonIterableSpread() {
  265. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  266. }
  267. function ownKeys(e, r) {
  268. var t = Object.keys(e);
  269. if (Object.getOwnPropertySymbols) {
  270. var o = Object.getOwnPropertySymbols(e);
  271. r && (o = o.filter(function (r) {
  272. return Object.getOwnPropertyDescriptor(e, r).enumerable;
  273. })), t.push.apply(t, o);
  274. }
  275. return t;
  276. }
  277. function _objectSpread2(e) {
  278. for (var r = 1; r < arguments.length; r++) {
  279. var t = null != arguments[r] ? arguments[r] : {};
  280. r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
  281. _defineProperty(e, r, t[r]);
  282. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
  283. Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
  284. });
  285. }
  286. return e;
  287. }
  288. function _possibleConstructorReturn(t, e) {
  289. if (e && ("object" == typeof e || "function" == typeof e)) return e;
  290. if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
  291. return _assertThisInitialized(t);
  292. }
  293. function _regenerator() {
  294. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
  295. var e,
  296. t,
  297. r = "function" == typeof Symbol ? Symbol : {},
  298. n = r.iterator || "@@iterator",
  299. o = r.toStringTag || "@@toStringTag";
  300. function i(r, n, o, i) {
  301. var c = n && n.prototype instanceof Generator ? n : Generator,
  302. u = Object.create(c.prototype);
  303. return _regeneratorDefine(u, "_invoke", function (r, n, o) {
  304. var i,
  305. c,
  306. u,
  307. f = 0,
  308. p = o || [],
  309. y = false,
  310. G = {
  311. p: 0,
  312. n: 0,
  313. v: e,
  314. a: d,
  315. f: d.bind(e, 4),
  316. d: function (t, r) {
  317. return i = t, c = 0, u = e, G.n = r, a;
  318. }
  319. };
  320. function d(r, n) {
  321. for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
  322. var o,
  323. i = p[t],
  324. d = G.p,
  325. l = i[2];
  326. r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
  327. }
  328. if (o || r > 1) return a;
  329. throw y = true, n;
  330. }
  331. return function (o, p, l) {
  332. if (f > 1) throw TypeError("Generator is already running");
  333. for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
  334. i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
  335. try {
  336. if (f = 2, i) {
  337. if (c || (o = "next"), t = i[o]) {
  338. if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
  339. if (!t.done) return t;
  340. u = t.value, c < 2 && (c = 0);
  341. } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
  342. i = e;
  343. } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
  344. } catch (t) {
  345. i = e, c = 1, u = t;
  346. } finally {
  347. f = 1;
  348. }
  349. }
  350. return {
  351. value: t,
  352. done: y
  353. };
  354. };
  355. }(r, o, i), true), u;
  356. }
  357. var a = {};
  358. function Generator() {}
  359. function GeneratorFunction() {}
  360. function GeneratorFunctionPrototype() {}
  361. t = Object.getPrototypeOf;
  362. var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
  363. return this;
  364. }), t),
  365. u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
  366. function f(e) {
  367. return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
  368. }
  369. return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
  370. return this;
  371. }), _regeneratorDefine(u, "toString", function () {
  372. return "[object Generator]";
  373. }), (_regenerator = function () {
  374. return {
  375. w: i,
  376. m: f
  377. };
  378. })();
  379. }
  380. function _regeneratorDefine(e, r, n, t) {
  381. var i = Object.defineProperty;
  382. try {
  383. i({}, "", {});
  384. } catch (e) {
  385. i = 0;
  386. }
  387. _regeneratorDefine = function (e, r, n, t) {
  388. function o(r, n) {
  389. _regeneratorDefine(e, r, function (e) {
  390. return this._invoke(r, n, e);
  391. });
  392. }
  393. r ? i ? i(e, r, {
  394. value: n,
  395. enumerable: !t,
  396. configurable: !t,
  397. writable: !t
  398. }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
  399. }, _regeneratorDefine(e, r, n, t);
  400. }
  401. function _regeneratorValues(e) {
  402. if (null != e) {
  403. var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
  404. r = 0;
  405. if (t) return t.call(e);
  406. if ("function" == typeof e.next) return e;
  407. if (!isNaN(e.length)) return {
  408. next: function () {
  409. return e && r >= e.length && (e = void 0), {
  410. value: e && e[r++],
  411. done: !e
  412. };
  413. }
  414. };
  415. }
  416. throw new TypeError(typeof e + " is not iterable");
  417. }
  418. function _setPrototypeOf(t, e) {
  419. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
  420. return t.__proto__ = e, t;
  421. }, _setPrototypeOf(t, e);
  422. }
  423. function _slicedToArray(r, e) {
  424. return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
  425. }
  426. function _toConsumableArray(r) {
  427. return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
  428. }
  429. function _toPrimitive(t, e) {
  430. if ("object" != typeof t || !t) return t;
  431. var r;
  432. if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
  433. var i = r.call(t, e);
  434. if ("object" != typeof i) return i;
  435. throw new TypeError("@@toPrimitive must return a primitive value.");
  436. }
  437. return ("string" === e ? String : Number)(t);
  438. }
  439. function _toPropertyKey(t) {
  440. var i = _toPrimitive(t, "string");
  441. return "symbol" == typeof i ? i : i + "";
  442. }
  443. function _typeof(o) {
  444. "@babel/helpers - typeof";
  445. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  446. return typeof o;
  447. } : function (o) {
  448. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  449. }, _typeof(o);
  450. }
  451. function _unsupportedIterableToArray(r, a) {
  452. if (r) {
  453. if ("string" == typeof r) return _arrayLikeToArray(r, a);
  454. var t = {}.toString.call(r).slice(8, -1);
  455. return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  456. }
  457. }
  458. function _wrapAsyncGenerator(e) {
  459. return function () {
  460. return new AsyncGenerator(e.apply(this, arguments));
  461. };
  462. }
  463. function AsyncGenerator(e) {
  464. var t, n;
  465. function resume(t, n) {
  466. try {
  467. var r = e[t](n),
  468. o = r.value,
  469. u = o instanceof _OverloadYield;
  470. Promise.resolve(u ? o.v : o).then(function (n) {
  471. if (u) {
  472. var i = "return" === t && o.k ? t : "next";
  473. if (!o.k || n.done) return resume(i, n);
  474. n = e[i](n).value;
  475. }
  476. settle(!!r.done, n);
  477. }, function (e) {
  478. resume("throw", e);
  479. });
  480. } catch (e) {
  481. settle(2, e);
  482. }
  483. }
  484. function settle(e, r) {
  485. 2 === e ? t.reject(r) : t.resolve({
  486. value: r,
  487. done: e
  488. }), (t = t.next) ? resume(t.key, t.arg) : n = null;
  489. }
  490. this._invoke = function (e, r) {
  491. return new Promise(function (o, u) {
  492. var i = {
  493. key: e,
  494. arg: r,
  495. resolve: o,
  496. reject: u,
  497. next: null
  498. };
  499. n ? n = n.next = i : (t = n = i, resume(e, r));
  500. });
  501. }, "function" != typeof e.return && (this.return = void 0);
  502. }
  503. AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function () {
  504. return this;
  505. }, AsyncGenerator.prototype.next = function (e) {
  506. return this._invoke("next", e);
  507. }, AsyncGenerator.prototype.throw = function (e) {
  508. return this._invoke("throw", e);
  509. }, AsyncGenerator.prototype.return = function (e) {
  510. return this._invoke("return", e);
  511. };
  512. function _wrapNativeSuper(t) {
  513. var r = "function" == typeof Map ? new Map() : void 0;
  514. return _wrapNativeSuper = function (t) {
  515. if (null === t || !_isNativeFunction(t)) return t;
  516. if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
  517. if (void 0 !== r) {
  518. if (r.has(t)) return r.get(t);
  519. r.set(t, Wrapper);
  520. }
  521. function Wrapper() {
  522. return _construct(t, arguments, _getPrototypeOf(this).constructor);
  523. }
  524. return Wrapper.prototype = Object.create(t.prototype, {
  525. constructor: {
  526. value: Wrapper,
  527. enumerable: false,
  528. writable: true,
  529. configurable: true
  530. }
  531. }), _setPrototypeOf(Wrapper, t);
  532. }, _wrapNativeSuper(t);
  533. }
  534. /**
  535. * Create a bound version of a function with a specified `this` context
  536. *
  537. * @param {Function} fn - The function to bind
  538. * @param {*} thisArg - The value to be passed as the `this` parameter
  539. * @returns {Function} A new function that will call the original function with the specified `this` context
  540. */
  541. function bind(fn, thisArg) {
  542. return function wrap() {
  543. return fn.apply(thisArg, arguments);
  544. };
  545. }
  546. // utils is a library of generic helper functions non-specific to axios
  547. var toString = Object.prototype.toString;
  548. var getPrototypeOf = Object.getPrototypeOf;
  549. var iterator = Symbol.iterator,
  550. toStringTag = Symbol.toStringTag;
  551. /* Creating a function that will check if an object has a property. */
  552. var hasOwnProperty = function (_ref) {
  553. var hasOwnProperty = _ref.hasOwnProperty;
  554. return function (obj, prop) {
  555. return hasOwnProperty.call(obj, prop);
  556. };
  557. }(Object.prototype);
  558. var isUnsafeObjectKey = function isUnsafeObjectKey(prop) {
  559. return typeof prop === 'string' && (prop === '__proto__' || prop === 'constructor' || prop === 'prototype');
  560. };
  561. /**
  562. * Determine whether an inherited object must be treated as a shared-prototype
  563. * boundary. Cross-realm Object.prototype objects cannot be distinguished
  564. * reliably from application-created null-prototype objects because their
  565. * properties are mutable, so all inherited terminal prototypes are excluded
  566. * as a fail-closed boundary. A null-prototype source still keeps its own
  567. * properties, as produced by mergeConfig and other safe materialization paths.
  568. *
  569. * @param {*} obj The object to inspect
  570. * @param {*} prototype The object's prototype
  571. * @param {boolean} source Whether obj is the original traversal source
  572. *
  573. * @returns {boolean} True when obj is a safe prototype traversal boundary
  574. */
  575. var isPrototypeBoundary = function isPrototypeBoundary(obj, prototype, source) {
  576. return obj === Object.prototype || !source && prototype === null;
  577. };
  578. /**
  579. * Determine whether an object can retain its identity through code paths that
  580. * add, replace, and remove config properties without bypassing unsafe-key
  581. * filtering. Immutable objects, unsafe-key-bearing objects, and objects with
  582. * accessor or restricted data properties must be materialized instead.
  583. *
  584. * @param {*} obj The object to inspect
  585. *
  586. * @returns {boolean} True when every own property is safe and fully mutable
  587. */
  588. var isSafeAndFullyMutable = function isSafeAndFullyMutable(obj) {
  589. if (!Object.isExtensible(obj)) {
  590. return false;
  591. }
  592. var props = Object.getOwnPropertyNames(obj);
  593. if (Object.getOwnPropertySymbols) {
  594. props.push.apply(props, _toConsumableArray(Object.getOwnPropertySymbols(obj)));
  595. }
  596. return props.every(function (prop) {
  597. if (isUnsafeObjectKey(prop)) {
  598. return false;
  599. }
  600. var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
  601. return !!descriptor && descriptor.configurable && descriptor.writable === true;
  602. });
  603. };
  604. /**
  605. * Walk the prototype chain (excluding the source realm's Object.prototype)
  606. * looking for an own `prop`. This distinguishes genuine own/inherited members
  607. * — including class accessors and template prototypes — from members injected
  608. * via Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
  609. * which live on Object.prototype itself and are therefore never matched.
  610. *
  611. * @param {*} thing The value whose chain to inspect
  612. * @param {string|symbol} prop The property key to look for
  613. *
  614. * @returns {boolean} True when `prop` is owned below Object.prototype
  615. */
  616. var hasOwnInPrototypeChain = function hasOwnInPrototypeChain(thing, prop) {
  617. var obj = thing;
  618. var seen = [];
  619. while (obj != null) {
  620. if (seen.indexOf(obj) !== -1) {
  621. return false;
  622. }
  623. seen.push(obj);
  624. var prototype = getPrototypeOf(obj);
  625. if (isPrototypeBoundary(obj, prototype, obj === thing)) {
  626. return false;
  627. }
  628. if (hasOwnProperty(obj, prop)) {
  629. return true;
  630. }
  631. obj = prototype;
  632. }
  633. return false;
  634. };
  635. /**
  636. * Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
  637. * properties and members inherited from a non-Object.prototype source (a class
  638. * instance or template object) are honored; a value reachable only through a
  639. * polluted Object.prototype is ignored and `undefined` is returned.
  640. *
  641. * @param {*} obj The source object
  642. * @param {string|symbol} prop The property key to read
  643. *
  644. * @returns {*} The resolved value, or undefined when unsafe/absent
  645. */
  646. var getSafeProp = function getSafeProp(obj, prop) {
  647. return obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
  648. };
  649. /**
  650. * Flatten an object and its application-defined prototype chain into a
  651. * null-prototype object. Members inherited only from the source realm's
  652. * Object.prototype are deliberately excluded, while class/template members
  653. * below that boundary are preserved.
  654. *
  655. * @param {*} thing The value to flatten
  656. *
  657. * @returns {*} A null-prototype copy, or the original value when it is already
  658. * structurally safe or is not an object
  659. */
  660. var toSafeFlatObject = function toSafeFlatObject(thing) {
  661. if (thing == null || _typeof(thing) !== 'object' && typeof thing !== 'function') {
  662. return thing;
  663. }
  664. var sourcePrototype = getPrototypeOf(thing);
  665. if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
  666. return thing;
  667. }
  668. var result = Object.create(null);
  669. var merged = Object.create(null);
  670. var seen = [];
  671. var current = thing;
  672. while (current != null) {
  673. if (seen.indexOf(current) !== -1) {
  674. break;
  675. }
  676. seen.push(current);
  677. var prototype = current === thing ? sourcePrototype : getPrototypeOf(current);
  678. if (isPrototypeBoundary(current, prototype, current === thing)) {
  679. break;
  680. }
  681. var props = Object.getOwnPropertyNames(current);
  682. if (Object.getOwnPropertySymbols) {
  683. props.push.apply(props, _toConsumableArray(Object.getOwnPropertySymbols(current)));
  684. }
  685. var _iterator2 = _createForOfIteratorHelper(props),
  686. _step;
  687. try {
  688. for (_iterator2.s(); !(_step = _iterator2.n()).done;) {
  689. var prop = _step.value;
  690. if (isUnsafeObjectKey(prop)) {
  691. continue;
  692. }
  693. if (!hasOwnProperty(merged, prop)) {
  694. result[prop] = thing[prop];
  695. merged[prop] = true;
  696. }
  697. }
  698. } catch (err) {
  699. _iterator2.e(err);
  700. } finally {
  701. _iterator2.f();
  702. }
  703. current = prototype;
  704. }
  705. return result;
  706. };
  707. var kindOf = function (cache) {
  708. return function (thing) {
  709. var str = toString.call(thing);
  710. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  711. };
  712. }(Object.create(null));
  713. var kindOfTest = function kindOfTest(type) {
  714. type = type.toLowerCase();
  715. return function (thing) {
  716. return kindOf(thing) === type;
  717. };
  718. };
  719. var typeOfTest = function typeOfTest(type) {
  720. return function (thing) {
  721. return _typeof(thing) === type;
  722. };
  723. };
  724. /**
  725. * Determine if a value is a non-null object
  726. *
  727. * @param {Object} val The value to test
  728. *
  729. * @returns {boolean} True if value is an Array, otherwise false
  730. */
  731. var isArray = Array.isArray;
  732. /**
  733. * Determine if a value is undefined
  734. *
  735. * @param {*} val The value to test
  736. *
  737. * @returns {boolean} True if the value is undefined, otherwise false
  738. */
  739. var isUndefined = typeOfTest('undefined');
  740. /**
  741. * Determine if a value is a Buffer
  742. *
  743. * @param {*} val The value to test
  744. *
  745. * @returns {boolean} True if value is a Buffer, otherwise false
  746. */
  747. function isBuffer(val) {
  748. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  749. }
  750. /**
  751. * Determine if a value is an ArrayBuffer
  752. *
  753. * @param {*} val The value to test
  754. *
  755. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  756. */
  757. var isArrayBuffer = kindOfTest('ArrayBuffer');
  758. /**
  759. * Determine if a value is a view on an ArrayBuffer
  760. *
  761. * @param {*} val The value to test
  762. *
  763. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  764. */
  765. function isArrayBufferView(val) {
  766. var result;
  767. if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
  768. result = ArrayBuffer.isView(val);
  769. } else {
  770. result = val && val.buffer && isArrayBuffer(val.buffer);
  771. }
  772. return result;
  773. }
  774. /**
  775. * Determine if a value is a String
  776. *
  777. * @param {*} val The value to test
  778. *
  779. * @returns {boolean} True if value is a String, otherwise false
  780. */
  781. var isString = typeOfTest('string');
  782. /**
  783. * Determine if a value is a Function
  784. *
  785. * @param {*} val The value to test
  786. * @returns {boolean} True if value is a Function, otherwise false
  787. */
  788. var isFunction$1 = typeOfTest('function');
  789. /**
  790. * Determine if a value is a Number
  791. *
  792. * @param {*} val The value to test
  793. *
  794. * @returns {boolean} True if value is a Number, otherwise false
  795. */
  796. var isNumber = typeOfTest('number');
  797. /**
  798. * Determine if a value is an Object
  799. *
  800. * @param {*} thing The value to test
  801. *
  802. * @returns {boolean} True if value is an Object, otherwise false
  803. */
  804. var isObject = function isObject(thing) {
  805. return thing !== null && _typeof(thing) === 'object';
  806. };
  807. /**
  808. * Determine if a value is a Boolean
  809. *
  810. * @param {*} thing The value to test
  811. * @returns {boolean} True if value is a Boolean, otherwise false
  812. */
  813. var isBoolean = function isBoolean(thing) {
  814. return thing === true || thing === false;
  815. };
  816. /**
  817. * Determine if a value is a plain Object
  818. *
  819. * @param {*} val The value to test
  820. *
  821. * @returns {boolean} True if value is a plain Object, otherwise false
  822. */
  823. var isPlainObject = function isPlainObject(val) {
  824. if (!isObject(val)) {
  825. return false;
  826. }
  827. var prototype = getPrototypeOf(val);
  828. return (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) && (
  829. // Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
  830. // value is tagged/iterable, ignoring members reachable only through shared
  831. // or terminal prototype boundaries. This is exactly what
  832. // hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
  833. // above (null, Object.prototype, or a terminal null-prototype template) is
  834. // a boundary, so the walk never inspects anything but `val`'s own members,
  835. // and stops before even those when `val` is itself the boundary
  836. // Object.prototype. Checking that inline avoids allocating the walker's
  837. // `seen` list twice per call on the mergeConfig / merge hot path.
  838. isPrototypeBoundary(val, prototype, true) || !hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator));
  839. };
  840. /**
  841. * Determine if a value is an empty object (safely handles Buffers)
  842. *
  843. * @param {*} val The value to test
  844. *
  845. * @returns {boolean} True if value is an empty object, otherwise false
  846. */
  847. var isEmptyObject = function isEmptyObject(val) {
  848. // Early return for non-objects or Buffers to prevent RangeError
  849. if (!isObject(val) || isBuffer(val)) {
  850. return false;
  851. }
  852. try {
  853. return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
  854. } catch (e) {
  855. // Fallback for any other objects that might cause RangeError with Object.keys()
  856. return false;
  857. }
  858. };
  859. /**
  860. * Determine if a value is a Date
  861. *
  862. * @param {*} val The value to test
  863. *
  864. * @returns {boolean} True if value is a Date, otherwise false
  865. */
  866. var isDate = kindOfTest('Date');
  867. /**
  868. * Determine if a value is a File
  869. *
  870. * @param {*} val The value to test
  871. *
  872. * @returns {boolean} True if value is a File, otherwise false
  873. */
  874. var isFile = kindOfTest('File');
  875. /**
  876. * Determine if a value is a React Native Blob
  877. * React Native "blob": an object with a `uri` attribute. Optionally, it can
  878. * also have a `name` and `type` attribute to specify filename and content type
  879. *
  880. * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
  881. *
  882. * @param {*} value The value to test
  883. *
  884. * @returns {boolean} True if value is a React Native Blob, otherwise false
  885. */
  886. var isReactNativeBlob = function isReactNativeBlob(value) {
  887. return !!(value && typeof value.uri !== 'undefined');
  888. };
  889. /**
  890. * Determine if environment is React Native
  891. * ReactNative `FormData` has a non-standard `getParts()` method
  892. *
  893. * @param {*} formData The formData to test
  894. *
  895. * @returns {boolean} True if environment is React Native, otherwise false
  896. */
  897. var isReactNative = function isReactNative(formData) {
  898. return formData && typeof formData.getParts !== 'undefined';
  899. };
  900. /**
  901. * Determine if a value is a Blob
  902. *
  903. * @param {*} val The value to test
  904. *
  905. * @returns {boolean} True if value is a Blob, otherwise false
  906. */
  907. var isBlob = kindOfTest('Blob');
  908. /**
  909. * Determine if a value is a FileList
  910. *
  911. * @param {*} val The value to test
  912. *
  913. * @returns {boolean} True if value is a FileList, otherwise false
  914. */
  915. var isFileList = kindOfTest('FileList');
  916. var isSet = kindOfTest('Set');
  917. /**
  918. * Determine if a value is a Stream
  919. *
  920. * @param {*} val The value to test
  921. *
  922. * @returns {boolean} True if value is a Stream, otherwise false
  923. */
  924. var isStream = function isStream(val) {
  925. return isObject(val) && isFunction$1(val.pipe);
  926. };
  927. /**
  928. * Determine if a value is a FormData
  929. *
  930. * @param {*} thing The value to test
  931. *
  932. * @returns {boolean} True if value is an FormData, otherwise false
  933. */
  934. function getGlobal() {
  935. if (typeof globalThis !== 'undefined') return globalThis;
  936. if (typeof self !== 'undefined') return self;
  937. if (typeof window !== 'undefined') return window;
  938. if (typeof global !== 'undefined') return global;
  939. return {};
  940. }
  941. var G = getGlobal();
  942. var FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
  943. var isFormData = function isFormData(thing) {
  944. if (!thing) return false;
  945. if (FormDataCtor && thing instanceof FormDataCtor) return true;
  946. // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
  947. var proto = getPrototypeOf(thing);
  948. if (!proto || proto === Object.prototype) return false;
  949. if (!isFunction$1(thing.append)) return false;
  950. var kind = kindOf(thing);
  951. return kind === 'formdata' ||
  952. // detect form-data instance
  953. kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]';
  954. };
  955. /**
  956. * Determine if a value is a URLSearchParams object
  957. *
  958. * @param {*} val The value to test
  959. *
  960. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  961. */
  962. var isURLSearchParams = kindOfTest('URLSearchParams');
  963. var _map = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest),
  964. _map2 = _slicedToArray(_map, 4),
  965. isReadableStream = _map2[0],
  966. isRequest = _map2[1],
  967. isResponse = _map2[2],
  968. isHeaders = _map2[3];
  969. /**
  970. * Trim excess whitespace off the beginning and end of a string
  971. *
  972. * @param {String} str The String to trim
  973. *
  974. * @returns {String} The String freed of excess whitespace
  975. */
  976. var trim = function trim(str) {
  977. return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  978. };
  979. /**
  980. * Iterate over an Array or an Object invoking a function for each item.
  981. *
  982. * If `obj` is an Array callback will be called passing
  983. * the value, index, and complete array for each item.
  984. *
  985. * If 'obj' is an Object callback will be called passing
  986. * the value, key, and complete object for each property.
  987. *
  988. * @param {Object|Array<unknown>} obj The object to iterate
  989. * @param {Function} fn The callback to invoke for each item
  990. *
  991. * @param {Object} [options]
  992. * @param {Boolean} [options.allOwnKeys = false]
  993. * @returns {any}
  994. */
  995. function forEach(obj, fn) {
  996. var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  997. _ref2$allOwnKeys = _ref2.allOwnKeys,
  998. allOwnKeys = _ref2$allOwnKeys === void 0 ? false : _ref2$allOwnKeys;
  999. // Don't bother if no value provided
  1000. if (obj === null || typeof obj === 'undefined') {
  1001. return;
  1002. }
  1003. var i;
  1004. var l;
  1005. // Force an array if not already something iterable
  1006. if (_typeof(obj) !== 'object') {
  1007. /*eslint no-param-reassign:0*/
  1008. obj = [obj];
  1009. }
  1010. if (isArray(obj)) {
  1011. // Iterate over array values
  1012. for (i = 0, l = obj.length; i < l; i++) {
  1013. fn.call(null, obj[i], i, obj);
  1014. }
  1015. } else {
  1016. // Buffer check
  1017. if (isBuffer(obj)) {
  1018. return;
  1019. }
  1020. // Iterate over object keys
  1021. var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  1022. var len = keys.length;
  1023. var key;
  1024. for (i = 0; i < len; i++) {
  1025. key = keys[i];
  1026. fn.call(null, obj[key], key, obj);
  1027. }
  1028. }
  1029. }
  1030. /**
  1031. * Finds a key in an object, case-insensitive, returning the actual key name.
  1032. * Returns null if the object is a Buffer or if no match is found.
  1033. *
  1034. * @param {Object} obj - The object to search.
  1035. * @param {string} key - The key to find (case-insensitive).
  1036. * @returns {?string} The actual key name if found, otherwise null.
  1037. */
  1038. function findKey(obj, key) {
  1039. if (isBuffer(obj)) {
  1040. return null;
  1041. }
  1042. key = key.toLowerCase();
  1043. var keys = Object.keys(obj);
  1044. var i = keys.length;
  1045. var _key;
  1046. while (i-- > 0) {
  1047. _key = keys[i];
  1048. if (key === _key.toLowerCase()) {
  1049. return _key;
  1050. }
  1051. }
  1052. return null;
  1053. }
  1054. var _global = function () {
  1055. /*eslint no-undef:0*/
  1056. if (typeof globalThis !== 'undefined') return globalThis;
  1057. return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
  1058. }();
  1059. var isContextDefined = function isContextDefined(context) {
  1060. return !isUndefined(context) && context !== _global;
  1061. };
  1062. /**
  1063. * Accepts varargs expecting each argument to be an object, then
  1064. * immutably merges the properties of each object and returns result.
  1065. *
  1066. * When multiple objects contain the same key the later object in
  1067. * the arguments list will take precedence.
  1068. *
  1069. * Example:
  1070. *
  1071. * ```js
  1072. * const result = merge({foo: 123}, {foo: 456});
  1073. * console.log(result.foo); // outputs 456
  1074. * ```
  1075. *
  1076. * @param {Object} obj1 Object to merge
  1077. *
  1078. * @returns {Object} Result of all merge properties
  1079. */
  1080. function merge() {
  1081. var _ref3 = isContextDefined(this) && this || {},
  1082. caseless = _ref3.caseless,
  1083. skipUndefined = _ref3.skipUndefined;
  1084. var result = {};
  1085. // Caseless lookup only applies to string keys — symbol keys are
  1086. // identity-matched. Every string key that reaches `result` passes through
  1087. // this index first, so it can never hold two case variants of one key and a
  1088. // lowercase -> key map is exactly what findKey(result, key) would rescan
  1089. // Object.keys(result) for on each assignment.
  1090. var lowerCaseKeys = caseless ? Object.create(null) : null;
  1091. var assignValue = function assignValue(val, key) {
  1092. // Skip dangerous property names to prevent prototype pollution
  1093. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  1094. return;
  1095. }
  1096. var targetKey = key;
  1097. if (lowerCaseKeys && typeof key === 'string') {
  1098. var lowerKey = key.toLowerCase();
  1099. var knownKey = lowerCaseKeys[lowerKey];
  1100. // A key recorded but absent from `result` was skipped by skipUndefined;
  1101. // the later spelling wins then, as it does for findKey.
  1102. if (knownKey !== undefined && hasOwnProperty(result, knownKey)) {
  1103. targetKey = knownKey;
  1104. } else {
  1105. lowerCaseKeys[lowerKey] = key;
  1106. }
  1107. }
  1108. // Read via own-prop only — a bare `result[targetKey]` walks the prototype
  1109. // chain, so a polluted Object.prototype value could surface here and get
  1110. // copied into the merged result.
  1111. var existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
  1112. if (isPlainObject(existing) && isPlainObject(val)) {
  1113. result[targetKey] = merge(existing, val);
  1114. } else if (isPlainObject(val)) {
  1115. result[targetKey] = merge({}, val);
  1116. } else if (isArray(val)) {
  1117. result[targetKey] = val.slice();
  1118. } else if (!skipUndefined || !isUndefined(val)) {
  1119. result[targetKey] = val;
  1120. }
  1121. };
  1122. for (var i = 0, l = arguments.length; i < l; i++) {
  1123. var source = i < 0 || arguments.length <= i ? undefined : arguments[i];
  1124. if (!source || isBuffer(source)) {
  1125. continue;
  1126. }
  1127. forEach(source, assignValue);
  1128. if (_typeof(source) !== 'object' || isArray(source) || !Object.getOwnPropertySymbols) {
  1129. continue;
  1130. }
  1131. var symbols = Object.getOwnPropertySymbols(source);
  1132. for (var j = 0; j < symbols.length; j++) {
  1133. var symbol = symbols[j];
  1134. if (propertyIsEnumerable.call(source, symbol)) {
  1135. assignValue(source[symbol], symbol);
  1136. }
  1137. }
  1138. }
  1139. return result;
  1140. }
  1141. /**
  1142. * Extends object a by mutably adding to it the properties of object b.
  1143. *
  1144. * @param {Object} a The object to be extended
  1145. * @param {Object} b The object to copy properties from
  1146. * @param {Object} thisArg The object to bind function to
  1147. *
  1148. * @param {Object} [options]
  1149. * @param {Boolean} [options.allOwnKeys]
  1150. * @returns {Object} The resulting value of object a
  1151. */
  1152. var extend = function extend(a, b, thisArg) {
  1153. var _ref4 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
  1154. allOwnKeys = _ref4.allOwnKeys;
  1155. forEach(b, function (val, key) {
  1156. if (thisArg && isFunction$1(val)) {
  1157. Object.defineProperty(a, key, {
  1158. // Null-proto descriptor so a polluted Object.prototype.get cannot
  1159. // hijack defineProperty's accessor-vs-data resolution.
  1160. __proto__: null,
  1161. value: bind(val, thisArg),
  1162. writable: true,
  1163. enumerable: true,
  1164. configurable: true
  1165. });
  1166. } else {
  1167. Object.defineProperty(a, key, {
  1168. __proto__: null,
  1169. value: val,
  1170. writable: true,
  1171. enumerable: true,
  1172. configurable: true
  1173. });
  1174. }
  1175. }, {
  1176. allOwnKeys: allOwnKeys
  1177. });
  1178. return a;
  1179. };
  1180. /**
  1181. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1182. *
  1183. * @param {string} content with BOM
  1184. *
  1185. * @returns {string} content value without BOM
  1186. */
  1187. var stripBOM = function stripBOM(content) {
  1188. if (content.charCodeAt(0) === 0xfeff) {
  1189. content = content.slice(1);
  1190. }
  1191. return content;
  1192. };
  1193. /**
  1194. * Inherit the prototype methods from one constructor into another
  1195. * @param {function} constructor
  1196. * @param {function} superConstructor
  1197. * @param {object} [props]
  1198. * @param {object} [descriptors]
  1199. *
  1200. * @returns {void}
  1201. */
  1202. var inherits = function inherits(constructor, superConstructor, props, descriptors) {
  1203. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  1204. Object.defineProperty(constructor.prototype, 'constructor', {
  1205. __proto__: null,
  1206. value: constructor,
  1207. writable: true,
  1208. enumerable: false,
  1209. configurable: true
  1210. });
  1211. Object.defineProperty(constructor, 'super', {
  1212. __proto__: null,
  1213. value: superConstructor.prototype
  1214. });
  1215. props && Object.assign(constructor.prototype, props);
  1216. };
  1217. /**
  1218. * Resolve object with deep prototype chain to a flat object
  1219. * @param {Object} sourceObj source object
  1220. * @param {Object} [destObj]
  1221. * @param {Function|Boolean} [filter]
  1222. * @param {Function} [propFilter]
  1223. *
  1224. * @returns {Object}
  1225. */
  1226. var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
  1227. var props;
  1228. var i;
  1229. var prop;
  1230. var merged = {};
  1231. destObj = destObj || {};
  1232. // eslint-disable-next-line no-eq-null,eqeqeq
  1233. if (sourceObj == null) return destObj;
  1234. do {
  1235. props = Object.getOwnPropertyNames(sourceObj);
  1236. i = props.length;
  1237. while (i-- > 0) {
  1238. prop = props[i];
  1239. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  1240. destObj[prop] = sourceObj[prop];
  1241. merged[prop] = true;
  1242. }
  1243. }
  1244. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  1245. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  1246. return destObj;
  1247. };
  1248. /**
  1249. * Determines whether a string ends with the characters of a specified string
  1250. *
  1251. * @param {String} str
  1252. * @param {String} searchString
  1253. * @param {Number} [position= 0]
  1254. *
  1255. * @returns {boolean}
  1256. */
  1257. var endsWith = function endsWith(str, searchString, position) {
  1258. str = String(str);
  1259. if (position === undefined || position > str.length) {
  1260. position = str.length;
  1261. }
  1262. position -= searchString.length;
  1263. var lastIndex = str.indexOf(searchString, position);
  1264. return lastIndex !== -1 && lastIndex === position;
  1265. };
  1266. /**
  1267. * Returns new array from array like object or null if failed
  1268. *
  1269. * @param {*} [thing]
  1270. *
  1271. * @returns {?Array}
  1272. */
  1273. var toArray = function toArray(thing) {
  1274. if (!thing) return null;
  1275. if (isArray(thing)) return thing;
  1276. var i = thing.length;
  1277. if (!Number.isSafeInteger(i) || i < 0 || i > 0xffffffff) return null;
  1278. // Bound the copy by actual indexed properties, including hidden and inherited
  1279. // members of array-like collections, rather than by the declared length alone.
  1280. var indexes = new Set();
  1281. var seen = new Set();
  1282. var source = thing;
  1283. while (source != null && indexes.size < i) {
  1284. if (seen.has(source)) return null;
  1285. seen.add(source);
  1286. var prototype = getPrototypeOf(source);
  1287. if (isPrototypeBoundary(source, prototype, source === thing)) break;
  1288. Object.getOwnPropertyNames(source).forEach(function (key) {
  1289. var index = +key;
  1290. if (Number.isInteger(index) && index >= 0 && index < i && String(index) === key && hasOwnProperty(source, key)) {
  1291. indexes.add(index);
  1292. }
  1293. });
  1294. source = prototype;
  1295. }
  1296. if (indexes.size !== i) return null;
  1297. var arr = new Array(i);
  1298. while (i-- > 0) {
  1299. arr[i] = thing[i];
  1300. }
  1301. return arr;
  1302. };
  1303. /**
  1304. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  1305. * thing passed in is an instance of Uint8Array
  1306. *
  1307. * @param {TypedArray}
  1308. *
  1309. * @returns {Array}
  1310. */
  1311. // eslint-disable-next-line func-names
  1312. var isTypedArray = function (TypedArray) {
  1313. // eslint-disable-next-line func-names
  1314. return function (thing) {
  1315. return TypedArray && thing instanceof TypedArray;
  1316. };
  1317. }(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  1318. /**
  1319. * For each entry in the object, call the function with the key and value.
  1320. *
  1321. * @param {Object<any, any>} obj - The object to iterate over.
  1322. * @param {Function} fn - The function to call for each entry.
  1323. *
  1324. * @returns {void}
  1325. */
  1326. var forEachEntry = function forEachEntry(obj, fn) {
  1327. var generator = obj && obj[iterator];
  1328. var _iterator = generator.call(obj);
  1329. var result;
  1330. while ((result = _iterator.next()) && !result.done) {
  1331. var pair = result.value;
  1332. fn.call(obj, pair[0], pair[1]);
  1333. }
  1334. };
  1335. /**
  1336. * It takes a regular expression and a string, and returns an array of all the matches
  1337. *
  1338. * @param {string} regExp - The regular expression to match against.
  1339. * @param {string} str - The string to search.
  1340. *
  1341. * @returns {Array<boolean>}
  1342. */
  1343. var matchAll = function matchAll(regExp, str) {
  1344. var matches;
  1345. var arr = [];
  1346. while ((matches = regExp.exec(str)) !== null) {
  1347. arr.push(matches);
  1348. }
  1349. return arr;
  1350. };
  1351. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  1352. var isHTMLForm = kindOfTest('HTMLFormElement');
  1353. var toCamelCase = function toCamelCase(str) {
  1354. return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
  1355. return p1.toUpperCase() + p2;
  1356. });
  1357. };
  1358. var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
  1359. /**
  1360. * Determine if a value is a RegExp object
  1361. *
  1362. * @param {*} val The value to test
  1363. *
  1364. * @returns {boolean} True if value is a RegExp object, otherwise false
  1365. */
  1366. var isRegExp = kindOfTest('RegExp');
  1367. var reduceDescriptors = function reduceDescriptors(obj, reducer) {
  1368. var descriptors = Object.getOwnPropertyDescriptors(obj);
  1369. var reducedDescriptors = {};
  1370. forEach(descriptors, function (descriptor, name) {
  1371. var ret;
  1372. if ((ret = reducer(descriptor, name, obj)) !== false) {
  1373. reducedDescriptors[name] = ret || descriptor;
  1374. }
  1375. });
  1376. Object.defineProperties(obj, reducedDescriptors);
  1377. };
  1378. /**
  1379. * Makes all methods read-only
  1380. * @param {Object} obj
  1381. */
  1382. var freezeMethods = function freezeMethods(obj) {
  1383. reduceDescriptors(obj, function (descriptor, name) {
  1384. // skip restricted props in strict mode
  1385. if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
  1386. return false;
  1387. }
  1388. var value = obj[name];
  1389. if (!isFunction$1(value)) return;
  1390. descriptor.enumerable = false;
  1391. if ('writable' in descriptor) {
  1392. descriptor.writable = false;
  1393. return;
  1394. }
  1395. if (!descriptor.set) {
  1396. descriptor.set = function () {
  1397. throw Error("Can not rewrite read-only method '" + name + "'");
  1398. };
  1399. }
  1400. });
  1401. };
  1402. /**
  1403. * Converts an array or a delimited string into an object set with values as keys and true as values.
  1404. * Useful for fast membership checks.
  1405. *
  1406. * @param {Array|string} arrayOrString - The array or string to convert.
  1407. * @param {string} delimiter - The delimiter to use if input is a string.
  1408. * @returns {Object} An object with keys from the array or string, values set to true.
  1409. */
  1410. var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
  1411. var obj = {};
  1412. var define = function define(arr) {
  1413. arr.forEach(function (value) {
  1414. obj[value] = true;
  1415. });
  1416. };
  1417. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  1418. return obj;
  1419. };
  1420. var noop = function noop() {};
  1421. var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
  1422. return value != null && Number.isFinite(value = +value) ? value : defaultValue;
  1423. };
  1424. /**
  1425. * If the thing is a FormData object, return true, otherwise return false.
  1426. *
  1427. * @param {unknown} thing - The thing to check.
  1428. *
  1429. * @returns {boolean}
  1430. */
  1431. function isSpecCompliantForm(thing) {
  1432. return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
  1433. }
  1434. /**
  1435. * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
  1436. *
  1437. * @param {Object} obj - The object to convert.
  1438. * @returns {Object} The JSON-compatible object.
  1439. */
  1440. var toJSONObject = function toJSONObject(obj) {
  1441. var visited = new WeakSet();
  1442. var _visit = function visit(source) {
  1443. if (isObject(source)) {
  1444. if (visited.has(source)) {
  1445. return;
  1446. }
  1447. //Buffer check
  1448. if (isBuffer(source)) {
  1449. return source;
  1450. }
  1451. if (!('toJSON' in source)) {
  1452. // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
  1453. visited.add(source);
  1454. var target;
  1455. if (isSet(source)) {
  1456. target = [];
  1457. var _iterator3 = _createForOfIteratorHelper(source),
  1458. _step2;
  1459. try {
  1460. for (_iterator3.s(); !(_step2 = _iterator3.n()).done;) {
  1461. var value = _step2.value;
  1462. var reducedValue = _visit(value);
  1463. !isUndefined(reducedValue) && target.push(reducedValue);
  1464. }
  1465. } catch (err) {
  1466. _iterator3.e(err);
  1467. } finally {
  1468. _iterator3.f();
  1469. }
  1470. } else {
  1471. target = isArray(source) ? [] : {};
  1472. forEach(source, function (value, key) {
  1473. var reducedValue = _visit(value);
  1474. !isUndefined(reducedValue) && (target[key] = reducedValue);
  1475. });
  1476. }
  1477. visited["delete"](source);
  1478. return target;
  1479. }
  1480. }
  1481. return source;
  1482. };
  1483. return _visit(obj);
  1484. };
  1485. /**
  1486. * Determines if a value is an async function.
  1487. *
  1488. * @param {*} thing - The value to test.
  1489. * @returns {boolean} True if value is an async function, otherwise false.
  1490. */
  1491. var isAsyncFn = kindOfTest('AsyncFunction');
  1492. /**
  1493. * Determines if a value is thenable (has then and catch methods).
  1494. *
  1495. * @param {*} thing - The value to test.
  1496. * @returns {boolean} True if value is thenable, otherwise false.
  1497. */
  1498. var isThenable = function isThenable(thing) {
  1499. return thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing["catch"]);
  1500. };
  1501. // original code
  1502. // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
  1503. /**
  1504. * Provides a cross-platform setImmediate implementation.
  1505. * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
  1506. *
  1507. * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
  1508. * @param {boolean} postMessageSupported - Whether postMessage is supported.
  1509. * @returns {Function} A function to schedule a callback asynchronously.
  1510. */
  1511. var _setImmediate = function (setImmediateSupported, postMessageSupported) {
  1512. if (setImmediateSupported) {
  1513. return setImmediate;
  1514. }
  1515. return postMessageSupported ? function (token, callbacks) {
  1516. _global.addEventListener('message', function (_ref5) {
  1517. var source = _ref5.source,
  1518. data = _ref5.data;
  1519. if (source === _global && data === token) {
  1520. callbacks.length && callbacks.shift()();
  1521. }
  1522. }, false);
  1523. return function (cb) {
  1524. callbacks.push(cb);
  1525. _global.postMessage(token, '*');
  1526. };
  1527. }("axios@".concat(Math.random()), []) : function (cb) {
  1528. return setTimeout(cb);
  1529. };
  1530. }(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
  1531. /**
  1532. * Schedules a microtask or asynchronous callback as soon as possible.
  1533. * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
  1534. *
  1535. * @type {Function}
  1536. */
  1537. var asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
  1538. // *********************
  1539. var isIterable = function isIterable(thing) {
  1540. return thing != null && isFunction$1(thing[iterator]);
  1541. };
  1542. /**
  1543. * Determine if a value is iterable via an iterator that is NOT sourced solely
  1544. * from a polluted Object.prototype. Use this instead of `isIterable` whenever
  1545. * the iterable comes from untrusted input (e.g. user-supplied header sources),
  1546. * so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
  1547. * into an attacker-controlled entries iterator.
  1548. *
  1549. * @param {*} thing The value to test
  1550. *
  1551. * @returns {boolean} True if value has a non-polluted iterator
  1552. */
  1553. var isSafeIterable = function isSafeIterable(thing) {
  1554. return thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
  1555. };
  1556. var utils$1 = {
  1557. isArray: isArray,
  1558. isArrayBuffer: isArrayBuffer,
  1559. isBuffer: isBuffer,
  1560. isFormData: isFormData,
  1561. isArrayBufferView: isArrayBufferView,
  1562. isString: isString,
  1563. isNumber: isNumber,
  1564. isBoolean: isBoolean,
  1565. isObject: isObject,
  1566. isPlainObject: isPlainObject,
  1567. isEmptyObject: isEmptyObject,
  1568. isReadableStream: isReadableStream,
  1569. isRequest: isRequest,
  1570. isResponse: isResponse,
  1571. isHeaders: isHeaders,
  1572. isUndefined: isUndefined,
  1573. isDate: isDate,
  1574. isFile: isFile,
  1575. isReactNativeBlob: isReactNativeBlob,
  1576. isReactNative: isReactNative,
  1577. isBlob: isBlob,
  1578. isRegExp: isRegExp,
  1579. isFunction: isFunction$1,
  1580. isStream: isStream,
  1581. isURLSearchParams: isURLSearchParams,
  1582. isTypedArray: isTypedArray,
  1583. isFileList: isFileList,
  1584. forEach: forEach,
  1585. merge: merge,
  1586. extend: extend,
  1587. trim: trim,
  1588. stripBOM: stripBOM,
  1589. inherits: inherits,
  1590. toFlatObject: toFlatObject,
  1591. kindOf: kindOf,
  1592. kindOfTest: kindOfTest,
  1593. endsWith: endsWith,
  1594. toArray: toArray,
  1595. forEachEntry: forEachEntry,
  1596. matchAll: matchAll,
  1597. isHTMLForm: isHTMLForm,
  1598. hasOwnProperty: hasOwnProperty,
  1599. hasOwnProp: hasOwnProperty,
  1600. // an alias to avoid ESLint no-prototype-builtins detection
  1601. hasOwnInPrototypeChain: hasOwnInPrototypeChain,
  1602. getSafeProp: getSafeProp,
  1603. toSafeFlatObject: toSafeFlatObject,
  1604. reduceDescriptors: reduceDescriptors,
  1605. freezeMethods: freezeMethods,
  1606. toObjectSet: toObjectSet,
  1607. toCamelCase: toCamelCase,
  1608. noop: noop,
  1609. toFiniteNumber: toFiniteNumber,
  1610. findKey: findKey,
  1611. global: _global,
  1612. isContextDefined: isContextDefined,
  1613. isSpecCompliantForm: isSpecCompliantForm,
  1614. toJSONObject: toJSONObject,
  1615. isAsyncFn: isAsyncFn,
  1616. isThenable: isThenable,
  1617. setImmediate: _setImmediate,
  1618. asap: asap,
  1619. isIterable: isIterable,
  1620. isSafeIterable: isSafeIterable
  1621. };
  1622. // RawAxiosHeaders whose duplicates are ignored by node
  1623. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1624. var ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
  1625. /**
  1626. * Parse headers into an object
  1627. *
  1628. * ```
  1629. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1630. * Content-Type: application/json
  1631. * Connection: keep-alive
  1632. * Transfer-Encoding: chunked
  1633. * ```
  1634. *
  1635. * @param {String} rawHeaders Headers needing to be parsed
  1636. *
  1637. * @returns {Object} Headers parsed into an object
  1638. */
  1639. var parseHeaders = (function (rawHeaders) {
  1640. // Header names are data, including __proto__; avoid inherited setters.
  1641. var parsed = Object.create(null);
  1642. var key;
  1643. var val;
  1644. var i;
  1645. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  1646. i = line.indexOf(':');
  1647. key = line.substring(0, i).trim().toLowerCase();
  1648. val = line.substring(i + 1).trim();
  1649. var hasKey = utils$1.hasOwnProp(parsed, key);
  1650. if (!key || hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key)) {
  1651. return;
  1652. }
  1653. if (key === 'set-cookie') {
  1654. if (hasKey) {
  1655. parsed[key].push(val);
  1656. } else {
  1657. parsed[key] = [val];
  1658. }
  1659. } else {
  1660. parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
  1661. }
  1662. });
  1663. return parsed;
  1664. });
  1665. function trimSPorHTAB(str) {
  1666. var start = 0;
  1667. var end = str.length;
  1668. while (start < end) {
  1669. var code = str.charCodeAt(start);
  1670. if (code !== 0x09 && code !== 0x20) {
  1671. break;
  1672. }
  1673. start += 1;
  1674. }
  1675. while (end > start) {
  1676. var _code = str.charCodeAt(end - 1);
  1677. if (_code !== 0x09 && _code !== 0x20) {
  1678. break;
  1679. }
  1680. end -= 1;
  1681. }
  1682. return start === 0 && end === str.length ? str : str.slice(start, end);
  1683. }
  1684. // The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
  1685. // eslint-disable-next-line no-control-regex
  1686. var INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+", 'g');
  1687. // eslint-disable-next-line no-control-regex
  1688. var INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+", 'g');
  1689. function sanitizeValue(value, invalidChars) {
  1690. if (utils$1.isArray(value)) {
  1691. return value.map(function (item) {
  1692. return sanitizeValue(item, invalidChars);
  1693. });
  1694. }
  1695. return trimSPorHTAB(String(value).replace(invalidChars, ''));
  1696. }
  1697. var sanitizeHeaderValue = function sanitizeHeaderValue(value) {
  1698. return sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
  1699. };
  1700. var sanitizeByteStringHeaderValue = function sanitizeByteStringHeaderValue(value) {
  1701. return sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
  1702. };
  1703. function toByteStringHeaderObject(headers) {
  1704. var byteStringHeaders = Object.create(null);
  1705. utils$1.forEach(headers.toJSON(), function (value, header) {
  1706. byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
  1707. });
  1708. return byteStringHeaders;
  1709. }
  1710. var $internals$1 = Symbol('internals');
  1711. function normalizeHeader(header) {
  1712. return header && String(header).trim().toLowerCase();
  1713. }
  1714. function normalizeValue(value) {
  1715. if (value === false || value == null) {
  1716. return value;
  1717. }
  1718. return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
  1719. }
  1720. function parseTokens(str) {
  1721. var tokens = Object.create(null);
  1722. var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1723. var match;
  1724. while (match = tokensRE.exec(str)) {
  1725. tokens[match[1]] = match[2];
  1726. }
  1727. return tokens;
  1728. }
  1729. var parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
  1730. function trimOWS(value) {
  1731. var start = 0;
  1732. var end = value.length;
  1733. while (start < end) {
  1734. var code = value.charCodeAt(start);
  1735. if (code !== 0x09 && code !== 0x20) {
  1736. break;
  1737. }
  1738. start += 1;
  1739. }
  1740. while (end > start) {
  1741. var _code = value.charCodeAt(end - 1);
  1742. if (_code !== 0x09 && _code !== 0x20) {
  1743. break;
  1744. }
  1745. end -= 1;
  1746. }
  1747. return start === 0 && end === value.length ? value : value.slice(start, end);
  1748. }
  1749. function decodeQuotedString(value) {
  1750. var last = value.length - 1;
  1751. if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
  1752. return value;
  1753. }
  1754. var decoded = '';
  1755. for (var i = 1; i < last; i++) {
  1756. var code = value.charCodeAt(i);
  1757. if (code === 0x22) {
  1758. return value;
  1759. }
  1760. if (code === 0x5c) {
  1761. i += 1;
  1762. if (i >= last) {
  1763. return value;
  1764. }
  1765. }
  1766. decoded += value[i];
  1767. }
  1768. return decoded;
  1769. }
  1770. function _parseParameters(value) {
  1771. var parameters = Object.create(null);
  1772. var str = String(value);
  1773. var start = 0;
  1774. var quoted = false;
  1775. var escaped = false;
  1776. function parseParameter(end) {
  1777. var part = trimOWS(str.slice(start, end));
  1778. var equals = part.indexOf('=');
  1779. if (equals < 1) {
  1780. return;
  1781. }
  1782. var name = trimOWS(part.slice(0, equals));
  1783. if (!parameterNameRE.test(name)) {
  1784. return;
  1785. }
  1786. var normalizedName = name.toLowerCase();
  1787. if (normalizedName === '__proto__' || normalizedName === 'constructor' || normalizedName === 'prototype') {
  1788. return;
  1789. }
  1790. var parameterValue = trimOWS(part.slice(equals + 1));
  1791. parameters[normalizedName] = decodeQuotedString(parameterValue);
  1792. }
  1793. for (var i = 0; i < str.length; i++) {
  1794. var code = str.charCodeAt(i);
  1795. if (quoted) {
  1796. if (escaped) {
  1797. escaped = false;
  1798. } else if (code === 0x5c) {
  1799. escaped = true;
  1800. } else if (code === 0x22) {
  1801. quoted = false;
  1802. }
  1803. } else if (code === 0x22) {
  1804. quoted = true;
  1805. } else if (code === 0x2c || code === 0x3b) {
  1806. parseParameter(i);
  1807. start = i + 1;
  1808. }
  1809. }
  1810. parseParameter(str.length);
  1811. return parameters;
  1812. }
  1813. var isValidHeaderName = function isValidHeaderName(str) {
  1814. return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  1815. };
  1816. // `__proto__` is a valid field name, and the one name the uppercase mapping at
  1817. // the bottom of this file cannot reach: it is inherited from Object.prototype
  1818. // instead of being declared on AxiosHeaders.prototype, so `self.__proto__ = v`
  1819. // runs the inherited setter. That silently discards the header, and an array
  1820. // value replaces the instance prototype, taking every method with it.
  1821. // Store it under the same kind of case variant that mapping uses for `set` and
  1822. // `constructor`. Header lookup is caseless, so it reads back under either
  1823. // spelling, and no own `__proto__` slot is ever created for a later
  1824. // `Object.assign` to copy onto a plain object through the same setter.
  1825. var PROTO_HEADER_SLOT = '__Proto__';
  1826. var headerSlot = function headerSlot(name) {
  1827. return name === '__proto__' ? PROTO_HEADER_SLOT : name;
  1828. };
  1829. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  1830. if (utils$1.isFunction(filter)) {
  1831. return filter.call(context, value, header);
  1832. }
  1833. if (isHeaderNameFilter) {
  1834. value = header;
  1835. }
  1836. if (!utils$1.isString(value)) return;
  1837. if (utils$1.isString(filter)) {
  1838. return value.indexOf(filter) !== -1;
  1839. }
  1840. if (utils$1.isRegExp(filter)) {
  1841. return filter.test(value);
  1842. }
  1843. }
  1844. function formatHeader(header) {
  1845. return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
  1846. return _char.toUpperCase() + str;
  1847. });
  1848. }
  1849. function buildAccessors(obj, header) {
  1850. var accessorName = utils$1.toCamelCase(' ' + header);
  1851. ['get', 'set', 'has'].forEach(function (methodName) {
  1852. Object.defineProperty(obj, methodName + accessorName, {
  1853. // Null-proto descriptor so a polluted Object.prototype.get cannot turn
  1854. // this data descriptor into an accessor descriptor on the way in.
  1855. __proto__: null,
  1856. value: function value(arg1, arg2, arg3) {
  1857. return this[methodName].call(this, header, arg1, arg2, arg3);
  1858. },
  1859. configurable: true
  1860. });
  1861. });
  1862. }
  1863. var AxiosHeaders = /*#__PURE__*/function () {
  1864. function AxiosHeaders(headers) {
  1865. _classCallCheck(this, AxiosHeaders);
  1866. headers && this.set(headers);
  1867. }
  1868. return _createClass(AxiosHeaders, [{
  1869. key: "set",
  1870. value: function set(header, valueOrRewrite, rewrite) {
  1871. var self = this;
  1872. function setHeader(_value, _header, _rewrite) {
  1873. var lHeader = normalizeHeader(_header);
  1874. if (!lHeader) {
  1875. return;
  1876. }
  1877. var key = utils$1.findKey(self, lHeader);
  1878. if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
  1879. self[headerSlot(key || _header)] = normalizeValue(_value);
  1880. }
  1881. }
  1882. var setHeaders = function setHeaders(headers, _rewrite) {
  1883. return utils$1.forEach(headers, function (_value, _header) {
  1884. return setHeader(_value, _header, _rewrite);
  1885. });
  1886. };
  1887. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  1888. setHeaders(header, valueOrRewrite);
  1889. } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  1890. setHeaders(parseHeaders(header), valueOrRewrite);
  1891. } else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
  1892. var obj = Object.create(null),
  1893. dest,
  1894. key;
  1895. var _iterator = _createForOfIteratorHelper(header),
  1896. _step;
  1897. try {
  1898. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1899. var entry = _step.value;
  1900. if (!utils$1.isArray(entry)) {
  1901. throw new TypeError('Object iterator must return a key-value pair');
  1902. }
  1903. key = entry[0];
  1904. if (utils$1.hasOwnProp(obj, key)) {
  1905. dest = obj[key];
  1906. obj[key] = utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]];
  1907. } else {
  1908. obj[key] = entry[1];
  1909. }
  1910. }
  1911. } catch (err) {
  1912. _iterator.e(err);
  1913. } finally {
  1914. _iterator.f();
  1915. }
  1916. setHeaders(obj, valueOrRewrite);
  1917. } else {
  1918. header != null && setHeader(valueOrRewrite, header, rewrite);
  1919. }
  1920. return this;
  1921. }
  1922. }, {
  1923. key: "get",
  1924. value: function get(header, parser) {
  1925. header = normalizeHeader(header);
  1926. if (header) {
  1927. var key = utils$1.findKey(this, header);
  1928. if (key) {
  1929. var value = this[key];
  1930. if (!parser) {
  1931. return value;
  1932. }
  1933. if (parser === true) {
  1934. return parseTokens(value);
  1935. }
  1936. if (utils$1.isFunction(parser)) {
  1937. return parser.call(this, value, key);
  1938. }
  1939. if (utils$1.isRegExp(parser)) {
  1940. return parser.exec(value);
  1941. }
  1942. throw new TypeError('parser must be boolean|regexp|function');
  1943. }
  1944. }
  1945. }
  1946. }, {
  1947. key: "has",
  1948. value: function has(header, matcher) {
  1949. header = normalizeHeader(header);
  1950. if (header) {
  1951. var key = utils$1.findKey(this, header);
  1952. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  1953. }
  1954. return false;
  1955. }
  1956. }, {
  1957. key: "delete",
  1958. value: function _delete(header, matcher) {
  1959. var self = this;
  1960. var deleted = false;
  1961. function deleteHeader(_header) {
  1962. _header = normalizeHeader(_header);
  1963. if (_header) {
  1964. var key = utils$1.findKey(self, _header);
  1965. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  1966. delete self[key];
  1967. deleted = true;
  1968. }
  1969. }
  1970. }
  1971. if (utils$1.isArray(header)) {
  1972. header.forEach(deleteHeader);
  1973. } else {
  1974. deleteHeader(header);
  1975. }
  1976. return deleted;
  1977. }
  1978. }, {
  1979. key: "clear",
  1980. value: function clear(matcher) {
  1981. var keys = Object.keys(this);
  1982. var i = keys.length;
  1983. var deleted = false;
  1984. while (i--) {
  1985. var key = keys[i];
  1986. if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  1987. delete this[key];
  1988. deleted = true;
  1989. }
  1990. }
  1991. return deleted;
  1992. }
  1993. }, {
  1994. key: "normalize",
  1995. value: function normalize(format) {
  1996. var self = this;
  1997. var headers = Object.create(null);
  1998. utils$1.forEach(this, function (value, header) {
  1999. var key = utils$1.findKey(headers, header);
  2000. if (key) {
  2001. self[key] = normalizeValue(value);
  2002. delete self[header];
  2003. return;
  2004. }
  2005. var normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
  2006. if (normalized !== header) {
  2007. delete self[header];
  2008. }
  2009. self[normalized] = normalizeValue(value);
  2010. headers[normalized] = true;
  2011. });
  2012. return this;
  2013. }
  2014. }, {
  2015. key: "concat",
  2016. value: function concat() {
  2017. var _this$constructor;
  2018. for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
  2019. targets[_key] = arguments[_key];
  2020. }
  2021. return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
  2022. }
  2023. }, {
  2024. key: "toJSON",
  2025. value: function toJSON(asStrings) {
  2026. var obj = Object.create(null);
  2027. utils$1.forEach(this, function (value, header) {
  2028. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
  2029. });
  2030. return obj;
  2031. }
  2032. }, {
  2033. key: Symbol.iterator,
  2034. value: function value() {
  2035. return Object.entries(this.toJSON())[Symbol.iterator]();
  2036. }
  2037. }, {
  2038. key: "toString",
  2039. value: function toString() {
  2040. return Object.entries(this.toJSON()).map(function (_ref) {
  2041. var _ref2 = _slicedToArray(_ref, 2),
  2042. header = _ref2[0],
  2043. value = _ref2[1];
  2044. return header + ': ' + value;
  2045. }).join('\n');
  2046. }
  2047. }, {
  2048. key: "getSetCookie",
  2049. value: function getSetCookie() {
  2050. var value = this.get('set-cookie');
  2051. return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
  2052. }
  2053. }, {
  2054. key: Symbol.toStringTag,
  2055. get: function get() {
  2056. return 'AxiosHeaders';
  2057. }
  2058. }], [{
  2059. key: "from",
  2060. value: function from(thing) {
  2061. return thing instanceof this ? thing : new this(thing);
  2062. }
  2063. }, {
  2064. key: "parseParameters",
  2065. value: function parseParameters(value) {
  2066. return _parseParameters(value);
  2067. }
  2068. }, {
  2069. key: "concat",
  2070. value: function concat(first) {
  2071. var computed = new this(first);
  2072. for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  2073. targets[_key2 - 1] = arguments[_key2];
  2074. }
  2075. targets.forEach(function (target) {
  2076. return computed.set(target);
  2077. });
  2078. return computed;
  2079. }
  2080. }, {
  2081. key: "accessor",
  2082. value: function accessor(header) {
  2083. var internals = this[$internals$1] = this[$internals$1] = {
  2084. accessors: {}
  2085. };
  2086. var accessors = internals.accessors;
  2087. var prototype = this.prototype;
  2088. function defineAccessor(_header) {
  2089. var lHeader = normalizeHeader(_header);
  2090. if (!accessors[lHeader]) {
  2091. buildAccessors(prototype, _header);
  2092. accessors[lHeader] = true;
  2093. }
  2094. }
  2095. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  2096. return this;
  2097. }
  2098. }]);
  2099. }();
  2100. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  2101. // reserved names hotfix
  2102. utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
  2103. var value = _ref3.value;
  2104. var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
  2105. return {
  2106. get: function get() {
  2107. return value;
  2108. },
  2109. set: function set(headerValue) {
  2110. this[mapped] = headerValue;
  2111. }
  2112. };
  2113. });
  2114. utils$1.freezeMethods(AxiosHeaders);
  2115. var REDACTED = '[REDACTED ****]';
  2116. function hasOwnOrPrototypeToJSON(source) {
  2117. if (utils$1.hasOwnProp(source, 'toJSON')) {
  2118. return true;
  2119. }
  2120. var prototype = Object.getPrototypeOf(source);
  2121. while (prototype && prototype !== Object.prototype) {
  2122. if (utils$1.hasOwnProp(prototype, 'toJSON')) {
  2123. return true;
  2124. }
  2125. prototype = Object.getPrototypeOf(prototype);
  2126. }
  2127. return false;
  2128. }
  2129. // Build a plain-object snapshot of `config` and replace the value of any key
  2130. // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
  2131. // and AxiosHeaders, and short-circuits on circular references.
  2132. function redactConfig(config, redactKeys) {
  2133. var lowerKeys = new Set(redactKeys.map(function (k) {
  2134. return String(k).toLowerCase();
  2135. }));
  2136. var seen = [];
  2137. var _visit = function visit(source) {
  2138. if (source === null || _typeof(source) !== 'object') return source;
  2139. if (utils$1.isBuffer(source)) return source;
  2140. if (seen.indexOf(source) !== -1) return undefined;
  2141. if (source instanceof AxiosHeaders) {
  2142. source = source.toJSON();
  2143. }
  2144. seen.push(source);
  2145. var result;
  2146. if (utils$1.isArray(source)) {
  2147. result = [];
  2148. source.forEach(function (v, i) {
  2149. var reducedValue = _visit(v);
  2150. if (!utils$1.isUndefined(reducedValue)) {
  2151. result[i] = reducedValue;
  2152. }
  2153. });
  2154. } else {
  2155. if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
  2156. seen.pop();
  2157. return source;
  2158. }
  2159. result = Object.create(null);
  2160. for (var _i = 0, _Object$entries = Object.entries(source); _i < _Object$entries.length; _i++) {
  2161. var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
  2162. key = _Object$entries$_i[0],
  2163. value = _Object$entries$_i[1];
  2164. var reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : _visit(value);
  2165. if (!utils$1.isUndefined(reducedValue)) {
  2166. result[key] = reducedValue;
  2167. }
  2168. }
  2169. }
  2170. seen.pop();
  2171. return result;
  2172. };
  2173. return _visit(config);
  2174. }
  2175. function stringifySafely$1(value) {
  2176. try {
  2177. return String(value);
  2178. } catch (err) {
  2179. return '';
  2180. }
  2181. }
  2182. function aggregateErrorMessage(error) {
  2183. var message = error.errors.map(function (entry) {
  2184. try {
  2185. return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
  2186. } catch (err) {
  2187. return '';
  2188. }
  2189. }).filter(Boolean).join('; ');
  2190. return message || error.name || 'AggregateError';
  2191. }
  2192. // Shared with `Axios.prototype.request`, which splices the reconstructed
  2193. // caller frames in ahead of this marker.
  2194. var CAUSED_BY_SEPARATOR = '\nCaused by: ';
  2195. var $causeStack = Symbol('causeStack');
  2196. // Match the section we appended, not marker-like text in an error message or
  2197. // a replacement stack supplied by the caller. Do not re-read the cause's stack.
  2198. function getCauseStackIndex(error, stack) {
  2199. var causeStack = utils$1.hasOwnProp(error, $causeStack) && error[$causeStack];
  2200. return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
  2201. }
  2202. /**
  2203. * Append the stack of a wrapped error to `target.stack`.
  2204. *
  2205. * `cause` already exposes the original error for tooling that walks the standard
  2206. * cause chain, but many error reporters read `stack` and nothing else. Inlining
  2207. * the wrapped stack there means those reporters surface the underlying failure
  2208. * instead of the axios frames that normalized it (see #6670).
  2209. *
  2210. * Every read is defensive: a custom `Error.prepareStackTrace` hook, a runtime
  2211. * without stack support, or a replaced `stack` property can leave the value
  2212. * missing, non-string, or read-only, and normalizing an error must not throw
  2213. * because of that.
  2214. *
  2215. * @param {Error} target The AxiosError being built.
  2216. * @param {Error} source The error being wrapped.
  2217. *
  2218. * @returns {void}
  2219. */
  2220. function appendCauseStack(target, source) {
  2221. try {
  2222. var sourceStack = source && source.stack;
  2223. if (typeof sourceStack !== 'string' || !sourceStack) {
  2224. return;
  2225. }
  2226. var targetStack = target.stack;
  2227. if (typeof targetStack !== 'string' || !targetStack) {
  2228. return;
  2229. }
  2230. // Each call to `from()` creates a fresh target. Re-wrapping includes the
  2231. // previous stack verbatim, adding one cause section per wrap.
  2232. var causeStack = CAUSED_BY_SEPARATOR + sourceStack;
  2233. target.stack = targetStack + causeStack;
  2234. Object.defineProperty(target, $causeStack, {
  2235. __proto__: null,
  2236. value: causeStack
  2237. });
  2238. } catch (e) {
  2239. // Ignore failures from custom stack hooks or un-writable stack properties.
  2240. }
  2241. }
  2242. var AxiosError = /*#__PURE__*/function (_Error) {
  2243. /**
  2244. * Create an Error with the specified message, config, error code, request and response.
  2245. *
  2246. * @param {string} message The error message.
  2247. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  2248. * @param {Object} [config] The config.
  2249. * @param {Object} [request] The request.
  2250. * @param {Object} [response] The response.
  2251. *
  2252. * @returns {Error} The created error.
  2253. */
  2254. function AxiosError(message, code, config, request, response) {
  2255. var _this;
  2256. _classCallCheck(this, AxiosError);
  2257. _this = _callSuper(this, AxiosError, [message]);
  2258. // Make message enumerable to maintain backward compatibility
  2259. // The native Error constructor sets message as non-enumerable,
  2260. // but axios < v1.13.3 had it as enumerable
  2261. Object.defineProperty(_this, 'message', {
  2262. // Null-proto descriptor so a polluted Object.prototype.get cannot turn
  2263. // this data descriptor into an accessor descriptor on the way in.
  2264. __proto__: null,
  2265. value: message,
  2266. enumerable: true,
  2267. writable: true,
  2268. configurable: true
  2269. });
  2270. _this.name = 'AxiosError';
  2271. _this.isAxiosError = true;
  2272. code && (_this.code = code);
  2273. config && (_this.config = config);
  2274. request && (_this.request = request);
  2275. if (response) {
  2276. _this.response = response;
  2277. _this.status = response.status;
  2278. }
  2279. return _this;
  2280. }
  2281. _inherits(AxiosError, _Error);
  2282. return _createClass(AxiosError, [{
  2283. key: "toJSON",
  2284. value: function toJSON() {
  2285. // Opt-in redaction: when the request config carries a `redact` array, the
  2286. // value of any matching key (case-insensitive, at any depth) is replaced
  2287. // with REDACTED in the serialized snapshot. Undefined or empty leaves the
  2288. // existing serialization behavior unchanged.
  2289. var config = this.config;
  2290. var redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
  2291. var serializedConfig = utils$1.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils$1.toJSONObject(config);
  2292. return {
  2293. // Standard
  2294. message: this.message,
  2295. name: this.name,
  2296. // Microsoft
  2297. description: this.description,
  2298. number: this.number,
  2299. // Mozilla
  2300. fileName: this.fileName,
  2301. lineNumber: this.lineNumber,
  2302. columnNumber: this.columnNumber,
  2303. stack: this.stack,
  2304. // Axios
  2305. config: serializedConfig,
  2306. code: this.code,
  2307. status: this.status
  2308. };
  2309. }
  2310. }], [{
  2311. key: "from",
  2312. value: function from(error, code, config, request, response, customProps) {
  2313. // `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
  2314. // failures) has an empty `message`; its detail lives in `errors[]`. Without
  2315. // this, the wrapped error surfaces with a blank message (see #6721).
  2316. var message = error.message;
  2317. if (!message && utils$1.isArray(error.errors) && error.errors.length) {
  2318. message = aggregateErrorMessage(error);
  2319. }
  2320. var axiosError = new AxiosError(message, code || error.code, config, request, response);
  2321. // Match native `Error` `cause` semantics: non-enumerable. The wrapped
  2322. // error often carries circular internals (sockets, requests, agents), so
  2323. // an enumerable `cause` makes structured loggers (pino/winston) and any
  2324. // own-property walk throw "Converting circular structure to JSON".
  2325. // Regression from #6982; see #7205. `__proto__: null` mirrors the
  2326. // `message` descriptor below (prototype-pollution-safe descriptor).
  2327. Object.defineProperty(axiosError, 'cause', {
  2328. __proto__: null,
  2329. value: error,
  2330. writable: true,
  2331. enumerable: false,
  2332. configurable: true
  2333. });
  2334. axiosError.name = error.name;
  2335. // Inline the wrapped stack for reporters that read only `stack`; the `cause`
  2336. // property above already covers cause-aware tooling.
  2337. appendCauseStack(axiosError, error);
  2338. // Preserve status from the original error if not already set from response
  2339. if (error.status != null && axiosError.status == null) {
  2340. axiosError.status = error.status;
  2341. }
  2342. customProps && Object.assign(axiosError, customProps);
  2343. return axiosError;
  2344. }
  2345. }]);
  2346. }(/*#__PURE__*/_wrapNativeSuper(Error)); // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
  2347. AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
  2348. AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
  2349. AxiosError.ECONNABORTED = 'ECONNABORTED';
  2350. AxiosError.ETIMEDOUT = 'ETIMEDOUT';
  2351. AxiosError.ECONNREFUSED = 'ECONNREFUSED';
  2352. AxiosError.ERR_NETWORK = 'ERR_NETWORK';
  2353. AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
  2354. AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
  2355. AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
  2356. AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
  2357. AxiosError.ERR_CANCELED = 'ERR_CANCELED';
  2358. AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
  2359. AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
  2360. AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
  2361. // eslint-disable-next-line strict
  2362. var httpAdapter = null;
  2363. // Default nesting limit shared with the inverse transform (formDataToJSON) so
  2364. // the FormData <-> JSON round-trip stays symmetric.
  2365. var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
  2366. /**
  2367. * Determines if the given thing is a array or js object.
  2368. *
  2369. * @param {string} thing - The object or array to be visited.
  2370. *
  2371. * @returns {boolean}
  2372. */
  2373. function isVisitable(thing) {
  2374. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  2375. }
  2376. /**
  2377. * It removes the brackets from the end of a string
  2378. *
  2379. * @param {string} key - The key of the parameter.
  2380. *
  2381. * @returns {string} the key without the brackets.
  2382. */
  2383. function removeBrackets(key) {
  2384. return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
  2385. }
  2386. /**
  2387. * It takes a path, a key, and a boolean, and returns a string
  2388. *
  2389. * @param {string} path - The path to the current key.
  2390. * @param {string} key - The key of the current object being iterated over.
  2391. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  2392. *
  2393. * @returns {string} The path to the current key.
  2394. */
  2395. function renderKey(path, key, dots) {
  2396. if (!path) return key;
  2397. return path.concat(key).map(function each(token, i) {
  2398. // eslint-disable-next-line no-param-reassign
  2399. token = removeBrackets(token);
  2400. return !dots && i ? '[' + token + ']' : token;
  2401. }).join(dots ? '.' : '');
  2402. }
  2403. /**
  2404. * If the array is an array and none of its elements are visitable, then it's a flat array.
  2405. *
  2406. * @param {Array<any>} arr - The array to check
  2407. *
  2408. * @returns {boolean}
  2409. */
  2410. function isFlatArray(arr) {
  2411. return utils$1.isArray(arr) && !arr.some(isVisitable);
  2412. }
  2413. var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  2414. return /^is[A-Z]/.test(prop);
  2415. });
  2416. /**
  2417. * Convert a data object to FormData
  2418. *
  2419. * @param {Object} obj
  2420. * @param {?Object} [formData]
  2421. * @param {?Object} [options]
  2422. * @param {Function} [options.visitor]
  2423. * @param {Boolean} [options.metaTokens = true]
  2424. * @param {Boolean} [options.dots = false]
  2425. * @param {?Boolean} [options.indexes = false]
  2426. *
  2427. * @returns {Object}
  2428. **/
  2429. /**
  2430. * It converts an object into a FormData object
  2431. *
  2432. * @param {Object<any, any>} obj - The object to convert to form data.
  2433. * @param {string} formData - The FormData object to append to.
  2434. * @param {Object<string, any>} options
  2435. *
  2436. * @returns
  2437. */
  2438. function toFormData(obj, formData, options) {
  2439. if (!utils$1.isObject(obj)) {
  2440. throw new TypeError('target must be an object');
  2441. }
  2442. // eslint-disable-next-line no-param-reassign
  2443. formData = formData || new (FormData)();
  2444. var option = function option(name, fallback) {
  2445. var value = utils$1.getSafeProp(options, name);
  2446. return utils$1.isUndefined(value) ? fallback : value;
  2447. };
  2448. var metaTokens = option('metaTokens', true);
  2449. // eslint-disable-next-line no-use-before-define
  2450. var visitor = option('visitor') || defaultVisitor;
  2451. var dots = option('dots', false);
  2452. var indexes = option('indexes', false);
  2453. var _Blob = option('Blob') || typeof Blob !== 'undefined' && Blob;
  2454. var maxDepth = option('maxDepth', DEFAULT_FORM_DATA_MAX_DEPTH);
  2455. var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  2456. var stack = [];
  2457. if (!utils$1.isFunction(visitor)) {
  2458. throw new TypeError('visitor must be a function');
  2459. }
  2460. function convertValue(value) {
  2461. if (value === null) return '';
  2462. if (utils$1.isDate(value)) {
  2463. return value.toISOString();
  2464. }
  2465. if (utils$1.isBoolean(value)) {
  2466. return value.toString();
  2467. }
  2468. if (!useBlob && utils$1.isBlob(value)) {
  2469. throw new AxiosError('Blob is not supported. Use a Buffer instead.');
  2470. }
  2471. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  2472. if (useBlob && typeof _Blob === 'function') {
  2473. return new _Blob([value]);
  2474. }
  2475. throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
  2476. }
  2477. return value;
  2478. }
  2479. function throwIfMaxDepthExceeded(depth) {
  2480. if (depth > maxDepth) {
  2481. throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
  2482. }
  2483. }
  2484. function stringifyWithDepthLimit(value, depth) {
  2485. if (maxDepth === Infinity) {
  2486. return JSON.stringify(value);
  2487. }
  2488. var ancestors = [];
  2489. return JSON.stringify(value, function limitDepth(_key, currentValue) {
  2490. if (!utils$1.isObject(currentValue)) {
  2491. return currentValue;
  2492. }
  2493. while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
  2494. ancestors.pop();
  2495. }
  2496. ancestors.push(currentValue);
  2497. throwIfMaxDepthExceeded(depth + ancestors.length - 1);
  2498. return currentValue;
  2499. });
  2500. }
  2501. /**
  2502. * Default visitor.
  2503. *
  2504. * @param {*} value
  2505. * @param {String|Number} key
  2506. * @param {Array<String|Number>} path
  2507. * @this {FormData}
  2508. *
  2509. * @returns {boolean} return true to visit the each prop of the value recursively
  2510. */
  2511. function defaultVisitor(value, key, path) {
  2512. var arr = value;
  2513. if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
  2514. formData.append(renderKey(path, key, dots), convertValue(value));
  2515. return false;
  2516. }
  2517. if (value && !path && _typeof(value) === 'object') {
  2518. if (utils$1.endsWith(key, '{}')) {
  2519. // eslint-disable-next-line no-param-reassign
  2520. key = metaTokens ? key : key.slice(0, -2);
  2521. // eslint-disable-next-line no-param-reassign
  2522. value = stringifyWithDepthLimit(value, 1);
  2523. } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
  2524. // eslint-disable-next-line no-param-reassign
  2525. key = removeBrackets(key);
  2526. arr.forEach(function each(el, index) {
  2527. !(utils$1.isUndefined(el) || el === null) && formData.append(
  2528. // eslint-disable-next-line no-nested-ternary
  2529. indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
  2530. });
  2531. return false;
  2532. }
  2533. }
  2534. if (isVisitable(value)) {
  2535. return true;
  2536. }
  2537. formData.append(renderKey(path, key, dots), convertValue(value));
  2538. return false;
  2539. }
  2540. var exposedHelpers = Object.assign(predicates, {
  2541. defaultVisitor: defaultVisitor,
  2542. convertValue: convertValue,
  2543. isVisitable: isVisitable
  2544. });
  2545. function build(value, path) {
  2546. var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  2547. if (utils$1.isUndefined(value)) return;
  2548. throwIfMaxDepthExceeded(depth);
  2549. if (stack.indexOf(value) !== -1) {
  2550. throw new Error('Circular reference detected in ' + path.join('.'));
  2551. }
  2552. stack.push(value);
  2553. utils$1.forEach(value, function each(el, key) {
  2554. var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
  2555. if (result === true) {
  2556. build(el, path ? path.concat(key) : [key], depth + 1);
  2557. }
  2558. });
  2559. stack.pop();
  2560. }
  2561. if (!utils$1.isObject(obj)) {
  2562. throw new TypeError('data must be an object');
  2563. }
  2564. build(obj);
  2565. return formData;
  2566. }
  2567. /**
  2568. * It encodes a string by replacing all characters that are not in the unreserved set with
  2569. * their percent-encoded equivalents
  2570. *
  2571. * @param {string} str - The string to encode.
  2572. *
  2573. * @returns {string} The encoded string.
  2574. */
  2575. function encode$1(str) {
  2576. var charMap = {
  2577. '!': '%21',
  2578. "'": '%27',
  2579. '(': '%28',
  2580. ')': '%29',
  2581. '~': '%7E',
  2582. '%20': '+'
  2583. };
  2584. return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
  2585. return charMap[match];
  2586. });
  2587. }
  2588. /**
  2589. * It takes a params object and converts it to a FormData object
  2590. *
  2591. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  2592. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  2593. *
  2594. * @returns {void}
  2595. */
  2596. function AxiosURLSearchParams(params, options) {
  2597. this._pairs = [];
  2598. params && toFormData(params, this, options);
  2599. }
  2600. var prototype = AxiosURLSearchParams.prototype;
  2601. prototype.append = function append(name, value) {
  2602. this._pairs.push([name, value]);
  2603. };
  2604. prototype.toString = function toString(encoder) {
  2605. var _this = this;
  2606. var _encode = encoder ? function (value) {
  2607. return encoder.call(_this, value, encode$1);
  2608. } : encode$1;
  2609. return this._pairs.map(function each(pair) {
  2610. return _encode(pair[0]) + '=' + _encode(pair[1]);
  2611. }, '').join('&');
  2612. };
  2613. /**
  2614. * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
  2615. * their plain counterparts (`:`, `$`, `,`, `+`).
  2616. *
  2617. * @param {string} val The value to be encoded.
  2618. *
  2619. * @returns {string} The encoded value.
  2620. */
  2621. function encode(val) {
  2622. return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
  2623. }
  2624. /**
  2625. * Build a URL by appending params to the end
  2626. *
  2627. * @param {string} url The base of the url (e.g., http://www.google.com)
  2628. * @param {object} [params] The params to be appended
  2629. * @param {?(object|Function)} options
  2630. *
  2631. * @returns {string} The formatted url
  2632. */
  2633. function buildURL(url, params, options) {
  2634. if (!params) {
  2635. return url;
  2636. }
  2637. url = url || '';
  2638. var _options = utils$1.isFunction(options) ? {
  2639. serialize: options
  2640. } : options;
  2641. // Read serializer options pollution-safely: own properties and methods on a
  2642. // class/template prototype are honored, but values injected onto a polluted
  2643. // Object.prototype are ignored.
  2644. var _encode = utils$1.getSafeProp(_options, 'encode') || encode;
  2645. var serializeFn = utils$1.getSafeProp(_options, 'serialize');
  2646. var serializedParams;
  2647. if (serializeFn) {
  2648. serializedParams = serializeFn(params, _options);
  2649. } else {
  2650. serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
  2651. }
  2652. if (serializedParams) {
  2653. var hashmarkIndex = url.indexOf('#');
  2654. if (hashmarkIndex !== -1) {
  2655. url = url.slice(0, hashmarkIndex);
  2656. }
  2657. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  2658. }
  2659. return url;
  2660. }
  2661. var $internals = Symbol('internals');
  2662. // `handlers` is public and may be replaced with a nullish value by user code;
  2663. // `clear()` has always tolerated that. Treat it as an empty stack rather than
  2664. // dereferencing it.
  2665. function countHandlers(handlers) {
  2666. return handlers ? handlers.length : 0;
  2667. }
  2668. function trimHandlers(handlers) {
  2669. if (!handlers) {
  2670. return;
  2671. }
  2672. while (handlers.length && handlers[handlers.length - 1] === null) {
  2673. handlers.pop();
  2674. }
  2675. }
  2676. // Preserve the array-key coercion used before IDs were stored in a Map, without
  2677. // treating null, empty strings, or noncanonical numeric strings as ID zero.
  2678. function normalizeHandlerId(id) {
  2679. if (typeof id === 'string' && id !== '' && String(Number(id)) === id) {
  2680. return Number(id);
  2681. }
  2682. return id;
  2683. }
  2684. function syncHandlerEntries(manager, internals) {
  2685. var handlers = manager.handlers;
  2686. var length = countHandlers(handlers);
  2687. if (handlers !== internals.handlersRef) {
  2688. internals.handlersRef = handlers;
  2689. internals.handlerEntries.clear();
  2690. } else if (length !== internals.handlersLength) {
  2691. if (!length) {
  2692. internals.handlerEntries.clear();
  2693. } else {
  2694. internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
  2695. if (handlers[entry.index] !== entry.handler) {
  2696. internals.handlerEntries["delete"](id);
  2697. }
  2698. });
  2699. }
  2700. }
  2701. internals.handlersLength = length;
  2702. }
  2703. var InterceptorManager = /*#__PURE__*/function () {
  2704. function InterceptorManager() {
  2705. _classCallCheck(this, InterceptorManager);
  2706. this.handlers = [];
  2707. this[$internals] = {
  2708. handlersRef: this.handlers,
  2709. handlersLength: this.handlers.length,
  2710. handlerEntries: new Map(),
  2711. iterationDepth: 0,
  2712. nextId: 0
  2713. };
  2714. }
  2715. /**
  2716. * Add a new interceptor to the stack
  2717. *
  2718. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  2719. * @param {Function} rejected The function to handle `reject` for a `Promise`
  2720. * @param {Object} options The options for the interceptor, synchronous and runWhen
  2721. *
  2722. * @return {Number} An ID used to remove interceptor later
  2723. */
  2724. return _createClass(InterceptorManager, [{
  2725. key: "use",
  2726. value: function use(fulfilled, rejected, options) {
  2727. var handler = {
  2728. fulfilled: fulfilled,
  2729. rejected: rejected,
  2730. synchronous: options ? options.synchronous : false,
  2731. runWhen: options ? options.runWhen : null
  2732. };
  2733. var internals = this[$internals];
  2734. if (this.handlers == null) {
  2735. this.handlers = [];
  2736. }
  2737. syncHandlerEntries(this, internals);
  2738. var id = internals.nextId++;
  2739. this.handlers.push(handler);
  2740. internals.handlerEntries.set(id, {
  2741. handler: handler,
  2742. index: this.handlers.length - 1
  2743. });
  2744. internals.handlersLength = this.handlers.length;
  2745. return id;
  2746. }
  2747. /**
  2748. * Remove an interceptor from the stack
  2749. *
  2750. * @param {Number} id The ID that was returned by `use`
  2751. *
  2752. * @returns {void}
  2753. */
  2754. }, {
  2755. key: "eject",
  2756. value: function eject(id) {
  2757. var internals = this[$internals];
  2758. syncHandlerEntries(this, internals);
  2759. var handlerId = normalizeHandlerId(id);
  2760. var entry = internals.handlerEntries.get(handlerId);
  2761. if (entry) {
  2762. internals.handlerEntries["delete"](handlerId);
  2763. // Ignore IDs invalidated by clear or direct replacement of handlers.
  2764. if (this.handlers[entry.index] !== entry.handler) {
  2765. return;
  2766. }
  2767. this.handlers[entry.index] = null;
  2768. // Do not reuse an index while forEach is walking its length snapshot.
  2769. if (!internals.iterationDepth) {
  2770. trimHandlers(this.handlers);
  2771. internals.handlersLength = this.handlers.length;
  2772. }
  2773. }
  2774. }
  2775. /**
  2776. * Clear all interceptors from the stack
  2777. *
  2778. * @returns {void}
  2779. */
  2780. }, {
  2781. key: "clear",
  2782. value: function clear() {
  2783. if (this.handlers) {
  2784. this.handlers = [];
  2785. syncHandlerEntries(this, this[$internals]);
  2786. }
  2787. }
  2788. /**
  2789. * Iterate over all the registered interceptors
  2790. *
  2791. * This method is particularly useful for skipping over any
  2792. * interceptors that may have become `null` calling `eject`.
  2793. *
  2794. * @param {Function} fn The function to call for each interceptor
  2795. *
  2796. * @returns {void}
  2797. */
  2798. }, {
  2799. key: "forEach",
  2800. value: function forEach(fn) {
  2801. var internals = this[$internals];
  2802. syncHandlerEntries(this, internals);
  2803. internals.iterationDepth++;
  2804. try {
  2805. utils$1.forEach(this.handlers, function forEachHandler(h) {
  2806. if (h !== null) {
  2807. fn(h);
  2808. }
  2809. });
  2810. } finally {
  2811. if (! --internals.iterationDepth) {
  2812. syncHandlerEntries(this, internals);
  2813. trimHandlers(this.handlers);
  2814. internals.handlersLength = countHandlers(this.handlers);
  2815. }
  2816. }
  2817. }
  2818. }]);
  2819. }();
  2820. var transitionalDefaults = {
  2821. silentJSONParsing: true,
  2822. forcedJSONParsing: true,
  2823. clarifyTimeoutError: false,
  2824. legacyInterceptorReqResOrdering: true,
  2825. advertiseZstdAcceptEncoding: false,
  2826. validateStatusUndefinedResolves: true,
  2827. encodeBasicAuthUsername: false
  2828. };
  2829. var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  2830. var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
  2831. var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
  2832. var platform$1 = {
  2833. isBrowser: true,
  2834. classes: {
  2835. URLSearchParams: URLSearchParams$1,
  2836. FormData: FormData$1,
  2837. Blob: Blob$1
  2838. },
  2839. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  2840. };
  2841. var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
  2842. var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
  2843. /**
  2844. * Determine if we're running in a standard browser environment
  2845. *
  2846. * This allows axios to run in a web worker, and react-native.
  2847. * Both environments support XMLHttpRequest, but not fully standard globals.
  2848. *
  2849. * web workers:
  2850. * typeof window -> undefined
  2851. * typeof document -> undefined
  2852. *
  2853. * react-native:
  2854. * navigator.product -> 'ReactNative'
  2855. * nativescript
  2856. * navigator.product -> 'NativeScript' or 'NS'
  2857. *
  2858. * @returns {boolean}
  2859. */
  2860. var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
  2861. /**
  2862. * Determine if we're running in a standard browser webWorker environment
  2863. *
  2864. * Although the `isStandardBrowserEnv` method indicates that
  2865. * `allows axios to run in a web worker`, the WebWorker will still be
  2866. * filtered out due to its judgment standard
  2867. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  2868. * This leads to a problem when axios post `FormData` in webWorker
  2869. */
  2870. var hasStandardBrowserWebWorkerEnv = function () {
  2871. return typeof WorkerGlobalScope !== 'undefined' &&
  2872. // eslint-disable-next-line no-undef
  2873. self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
  2874. }();
  2875. var origin = hasBrowserEnv && window.location.href || 'http://localhost';
  2876. var utils = /*#__PURE__*/Object.freeze({
  2877. __proto__: null,
  2878. hasBrowserEnv: hasBrowserEnv,
  2879. hasStandardBrowserEnv: hasStandardBrowserEnv,
  2880. hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
  2881. navigator: _navigator,
  2882. origin: origin
  2883. });
  2884. var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
  2885. function toURLEncodedForm(data, options) {
  2886. return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
  2887. visitor: function visitor(value, key, path, helpers) {
  2888. if (platform.isNode && utils$1.isBuffer(value)) {
  2889. this.append(key, value.toString('base64'));
  2890. return false;
  2891. }
  2892. return helpers.defaultVisitor.apply(this, arguments);
  2893. }
  2894. }, options));
  2895. }
  2896. var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
  2897. function throwIfDepthExceeded(index) {
  2898. if (index > MAX_DEPTH) {
  2899. throw new AxiosError('FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
  2900. }
  2901. }
  2902. /**
  2903. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  2904. *
  2905. * @param {string} name - The name of the property to get.
  2906. *
  2907. * @returns An array of strings.
  2908. */
  2909. function parsePropPath(name) {
  2910. // foo[x][y][z] -> ['foo', 'x', 'y', 'z']
  2911. // foo.x.y.z -> ['foo', 'x', 'y', 'z']
  2912. // A path is split on `.` and on `[...]` groups. A segment — whether written
  2913. // in dot notation or captured inside brackets — may contain any character
  2914. // except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
  2915. // literal instead of being split (#5402). `.`, `[` and `]` keep their existing
  2916. // meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
  2917. // Excluding `[` from the bracket group also makes the match fail fast at the
  2918. // next `[`, so a malformed name cannot rescan to the end of the string from
  2919. // every unmatched `[` — parsing stays linear in the length of the name.
  2920. var path = [];
  2921. var pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
  2922. var match;
  2923. while ((match = pattern.exec(name)) !== null) {
  2924. throwIfDepthExceeded(path.length);
  2925. path.push(match[0] === '[]' ? '' : match[1] || match[0]);
  2926. }
  2927. return path;
  2928. }
  2929. /**
  2930. * Convert an array to an object.
  2931. *
  2932. * @param {Array<any>} arr - The array to convert to an object.
  2933. *
  2934. * @returns An object with the same keys and values as the array.
  2935. */
  2936. function arrayToObject(arr) {
  2937. var obj = {};
  2938. var keys = Object.keys(arr);
  2939. var i;
  2940. var len = keys.length;
  2941. var key;
  2942. for (i = 0; i < len; i++) {
  2943. key = keys[i];
  2944. obj[key] = arr[key];
  2945. }
  2946. return obj;
  2947. }
  2948. function normalizeArray(value) {
  2949. if (!utils$1.isArray(value)) return value;
  2950. var keys = Object.keys(value);
  2951. return keys.length !== value.length || keys.some(function (key, index) {
  2952. return key !== String(index);
  2953. }) ? arrayToObject(value) : value;
  2954. }
  2955. function normalizeArrays(obj) {
  2956. var pending = [obj];
  2957. var _loop = function _loop() {
  2958. var target = pending.pop();
  2959. Object.keys(target).forEach(function (key) {
  2960. var value = target[key] = normalizeArray(target[key]);
  2961. if (utils$1.isArray(value) || utils$1.isPlainObject(value)) {
  2962. pending.push(value);
  2963. }
  2964. });
  2965. };
  2966. while (pending.length) {
  2967. _loop();
  2968. }
  2969. return obj;
  2970. }
  2971. /**
  2972. * It takes a FormData object and returns a JavaScript object
  2973. *
  2974. * @param {string} formData The FormData object to convert to JSON.
  2975. *
  2976. * @returns {Object<string, any> | null} The converted object.
  2977. */
  2978. function formDataToJSON(formData) {
  2979. function buildPath(path, value, target, index) {
  2980. throwIfDepthExceeded(index);
  2981. var name = path[index++];
  2982. if (name === '__proto__') return true;
  2983. var isNumericKey = Number.isFinite(+name);
  2984. var isLast = index >= path.length;
  2985. name = !name && utils$1.isArray(target) ? target.length : name;
  2986. if (isLast) {
  2987. if (utils$1.hasOwnProp(target, name)) {
  2988. target[name] = normalizeArray(target[name]);
  2989. target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
  2990. } else {
  2991. target[name] = value;
  2992. }
  2993. return !isNumericKey;
  2994. }
  2995. if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
  2996. target[name] = [];
  2997. }
  2998. var result = buildPath(path, value, target[name], index);
  2999. if (result && utils$1.isArray(target[name])) {
  3000. target[name] = arrayToObject(target[name]);
  3001. }
  3002. return !isNumericKey;
  3003. }
  3004. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  3005. var obj = {};
  3006. utils$1.forEachEntry(formData, function (name, value) {
  3007. buildPath(parsePropPath(name), value, obj, 0);
  3008. });
  3009. return normalizeArrays(obj);
  3010. }
  3011. return null;
  3012. }
  3013. var methodList = Object.freeze(['get', 'delete', 'head', 'options', 'post', 'put', 'patch', 'purge', 'link', 'unlink', 'query']);
  3014. var own = function own(obj, key) {
  3015. return obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
  3016. };
  3017. /**
  3018. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  3019. * of the input
  3020. *
  3021. * @param {any} rawValue - The value to be stringified.
  3022. * @param {Function} parser - A function that parses a string into a JavaScript object.
  3023. * @param {Function} encoder - A function that takes a value and returns a string.
  3024. *
  3025. * @returns {string} A stringified version of the rawValue.
  3026. */
  3027. function stringifySafely(rawValue, parser, encoder) {
  3028. if (utils$1.isString(rawValue)) {
  3029. try {
  3030. (parser || JSON.parse)(rawValue);
  3031. return utils$1.trim(rawValue);
  3032. } catch (e) {
  3033. if (e.name !== 'SyntaxError') {
  3034. throw e;
  3035. }
  3036. }
  3037. }
  3038. return (encoder || JSON.stringify)(rawValue);
  3039. }
  3040. var defaults = {
  3041. transitional: transitionalDefaults,
  3042. adapter: ['xhr', 'http', 'fetch'],
  3043. transformRequest: [function transformRequest(data, headers) {
  3044. var contentType = headers.getContentType() || '';
  3045. var hasJSONContentType = contentType.indexOf('application/json') > -1;
  3046. var isObjectPayload = utils$1.isObject(data);
  3047. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  3048. data = new FormData(data);
  3049. }
  3050. var isFormData = utils$1.isFormData(data);
  3051. if (isFormData) {
  3052. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  3053. }
  3054. if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
  3055. return data;
  3056. }
  3057. if (utils$1.isArrayBufferView(data)) {
  3058. return data.buffer;
  3059. }
  3060. if (utils$1.isURLSearchParams(data)) {
  3061. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  3062. return data.toString();
  3063. }
  3064. var isFileList;
  3065. if (isObjectPayload) {
  3066. var formSerializer = own(this, 'formSerializer');
  3067. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  3068. return toURLEncodedForm(data, formSerializer).toString();
  3069. }
  3070. if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  3071. var env = own(this, 'env');
  3072. var _FormData = env && env.FormData;
  3073. return toFormData(isFileList ? {
  3074. 'files[]': data
  3075. } : data, _FormData && new _FormData(), formSerializer);
  3076. }
  3077. }
  3078. if (isObjectPayload || hasJSONContentType) {
  3079. headers.setContentType('application/json', false);
  3080. return stringifySafely(data);
  3081. }
  3082. return data;
  3083. }],
  3084. transformResponse: [function transformResponse(data) {
  3085. var transitional = own(this, 'transitional') || defaults.transitional;
  3086. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  3087. var responseType = own(this, 'responseType');
  3088. var JSONRequested = responseType === 'json';
  3089. if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
  3090. return data;
  3091. }
  3092. if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
  3093. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  3094. var strictJSONParsing = !silentJSONParsing && JSONRequested;
  3095. try {
  3096. return JSON.parse(data, own(this, 'parseReviver'));
  3097. } catch (e) {
  3098. if (strictJSONParsing) {
  3099. if (e.name === 'SyntaxError') {
  3100. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
  3101. }
  3102. throw e;
  3103. }
  3104. }
  3105. }
  3106. return data;
  3107. }],
  3108. /**
  3109. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  3110. * timeout is not created.
  3111. */
  3112. timeout: 0,
  3113. xsrfCookieName: 'XSRF-TOKEN',
  3114. xsrfHeaderName: 'X-XSRF-TOKEN',
  3115. maxContentLength: -1,
  3116. maxBodyLength: -1,
  3117. env: {
  3118. FormData: platform.classes.FormData,
  3119. Blob: platform.classes.Blob
  3120. },
  3121. validateStatus: function validateStatus(status) {
  3122. return status >= 200 && status < 300;
  3123. },
  3124. headers: {
  3125. common: {
  3126. Accept: 'application/json, text/plain, */*',
  3127. 'Content-Type': undefined
  3128. }
  3129. }
  3130. };
  3131. utils$1.forEach(methodList, function (method) {
  3132. defaults.headers[method] = {};
  3133. });
  3134. /**
  3135. * Transform the data for a request or a response
  3136. *
  3137. * @param {Array|Function} fns A single function or Array of functions
  3138. * @param {?Object} response The response object
  3139. *
  3140. * @returns {*} The resulting transformed data
  3141. */
  3142. function transformData(fns, response) {
  3143. var config = this || defaults;
  3144. var context = response || config;
  3145. var headers = AxiosHeaders.from(context.headers);
  3146. var data = context.data;
  3147. utils$1.forEach(fns, function transform(fn) {
  3148. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  3149. });
  3150. headers.normalize();
  3151. return data;
  3152. }
  3153. function isCancel(value) {
  3154. return !!(value && value.__CANCEL__);
  3155. }
  3156. var CanceledError = /*#__PURE__*/function (_AxiosError) {
  3157. /**
  3158. * A `CanceledError` is an object that is thrown when an operation is canceled.
  3159. *
  3160. * @param {string=} message The message.
  3161. * @param {Object=} config The config.
  3162. * @param {Object=} request The request.
  3163. *
  3164. * @returns {CanceledError} The created error.
  3165. */
  3166. function CanceledError(message, config, request) {
  3167. var _this;
  3168. _classCallCheck(this, CanceledError);
  3169. _this = _callSuper(this, CanceledError, [message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request]);
  3170. _this.name = 'CanceledError';
  3171. _this.__CANCEL__ = true;
  3172. return _this;
  3173. }
  3174. _inherits(CanceledError, _AxiosError);
  3175. return _createClass(CanceledError);
  3176. }(AxiosError);
  3177. /**
  3178. * Resolve or reject a Promise based on response status.
  3179. *
  3180. * @param {Function} resolve A function that resolves the promise.
  3181. * @param {Function} reject A function that rejects the promise.
  3182. * @param {object} response The response.
  3183. *
  3184. * @returns {object} The response.
  3185. */
  3186. function settle(resolve, reject, response) {
  3187. var validateStatus = response.config.validateStatus;
  3188. if (!response.status || !validateStatus || validateStatus(response.status)) {
  3189. resolve(response);
  3190. } else {
  3191. reject(new AxiosError('Request failed with status code ' + response.status, response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE, response.config, response.request, response));
  3192. }
  3193. }
  3194. var urlParserControlCharacters = /[\t\n\r]/g;
  3195. /**
  3196. * Match WHATWG URL preprocessing before checking a URL's protocol.
  3197. *
  3198. * @param {string} url
  3199. *
  3200. * @returns {string}
  3201. */
  3202. function normalizeURLForProtocolCheck(url) {
  3203. if (typeof url !== 'string') {
  3204. return url;
  3205. }
  3206. var start = 0;
  3207. while (start < url.length && url.charCodeAt(start) <= 0x20) {
  3208. start++;
  3209. }
  3210. return url.slice(start).replace(urlParserControlCharacters, '');
  3211. }
  3212. function parseProtocol(url) {
  3213. var match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
  3214. return match && match[1].toLowerCase() || '';
  3215. }
  3216. var decodeCookieValue = function decodeCookieValue(value) {
  3217. try {
  3218. return decodeURIComponent(value);
  3219. } catch (e) {
  3220. return value;
  3221. }
  3222. };
  3223. var cookies = platform.hasStandardBrowserEnv ?
  3224. // Standard browser envs support document.cookie
  3225. {
  3226. write: function write(name, value, expires, path, domain, secure, sameSite) {
  3227. if (typeof document === 'undefined') return;
  3228. var cookie = ["".concat(name, "=").concat(encodeURIComponent(value))];
  3229. if (utils$1.isNumber(expires)) {
  3230. cookie.push("expires=".concat(new Date(expires).toUTCString()));
  3231. }
  3232. if (utils$1.isString(path)) {
  3233. cookie.push("path=".concat(path));
  3234. }
  3235. if (utils$1.isString(domain)) {
  3236. cookie.push("domain=".concat(domain));
  3237. }
  3238. if (secure === true) {
  3239. cookie.push('secure');
  3240. }
  3241. if (utils$1.isString(sameSite)) {
  3242. cookie.push("SameSite=".concat(sameSite));
  3243. }
  3244. document.cookie = cookie.join('; ');
  3245. },
  3246. read: function read(name) {
  3247. if (typeof document === 'undefined') return null;
  3248. var cookieString = document.cookie;
  3249. if (!cookieString) return null;
  3250. // Match name=value by splitting on the semicolon separator instead of building a
  3251. // RegExp from `name` — interpolating an unescaped string into a RegExp would let
  3252. // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
  3253. // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
  3254. // "; ", so ignore optional whitespace before each cookie name.
  3255. var cookies = cookieString.split(';');
  3256. for (var i = 0; i < cookies.length; i++) {
  3257. var cookie = cookies[i].replace(/^\s+/, '');
  3258. var eq = cookie.indexOf('=');
  3259. if (eq !== -1 && cookie.slice(0, eq) === name) {
  3260. return decodeCookieValue(cookie.slice(eq + 1));
  3261. }
  3262. }
  3263. return null;
  3264. },
  3265. readAsync: function readAsync(name) {
  3266. var _this = this;
  3267. return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
  3268. var store, cookie;
  3269. return _regenerator().w(function (_context) {
  3270. while (1) switch (_context.p = _context.n) {
  3271. case 0:
  3272. _context.p = 0;
  3273. store = typeof window !== 'undefined' && window.cookieStore;
  3274. if (!(store && utils$1.isFunction(store.get))) {
  3275. _context.n = 2;
  3276. break;
  3277. }
  3278. _context.n = 1;
  3279. return store.get(name);
  3280. case 1:
  3281. cookie = _context.v;
  3282. return _context.a(2, cookie ? decodeCookieValue(cookie.value) : null);
  3283. case 2:
  3284. _context.n = 4;
  3285. break;
  3286. case 3:
  3287. _context.p = 3;
  3288. _context.v;
  3289. case 4:
  3290. return _context.a(2, _this.read(name));
  3291. }
  3292. }, _callee, null, [[0, 3]]);
  3293. }))();
  3294. },
  3295. remove: function remove(name) {
  3296. this.write(name, '', Date.now() - 86400000, '/');
  3297. }
  3298. } :
  3299. // Non-standard browser env (web workers, react-native) lack needed support.
  3300. {
  3301. write: function write() {},
  3302. read: function read() {
  3303. return null;
  3304. },
  3305. readAsync: function readAsync() {
  3306. return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
  3307. return _regenerator().w(function (_context2) {
  3308. while (1) switch (_context2.n) {
  3309. case 0:
  3310. return _context2.a(2, null);
  3311. }
  3312. }, _callee2);
  3313. }))();
  3314. },
  3315. remove: function remove() {}
  3316. };
  3317. /**
  3318. * Calculate data maxRate
  3319. * @param {Number} [samplesCount= 10]
  3320. * @param {Number} [min= 1000]
  3321. * @returns {Function}
  3322. */
  3323. function speedometer(samplesCount, min) {
  3324. samplesCount = samplesCount || 10;
  3325. var bytes = new Array(samplesCount);
  3326. var timestamps = new Array(samplesCount);
  3327. var head = 0;
  3328. var tail = 0;
  3329. var firstSampleTS;
  3330. min = min !== undefined ? min : 1000;
  3331. return function push(chunkLength) {
  3332. var now = Date.now();
  3333. var startedAt = timestamps[tail];
  3334. if (!firstSampleTS) {
  3335. firstSampleTS = now;
  3336. }
  3337. bytes[head] = chunkLength;
  3338. timestamps[head] = now;
  3339. var i = tail;
  3340. var bytesCount = 0;
  3341. while (i !== head) {
  3342. bytesCount += bytes[i++];
  3343. i = i % samplesCount;
  3344. }
  3345. head = (head + 1) % samplesCount;
  3346. if (head === tail) {
  3347. tail = (tail + 1) % samplesCount;
  3348. }
  3349. if (now - firstSampleTS < min) {
  3350. return;
  3351. }
  3352. var passed = startedAt && now - startedAt;
  3353. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  3354. };
  3355. }
  3356. /**
  3357. * Throttle decorator
  3358. * @param {Function} fn
  3359. * @param {Number} freq
  3360. * @return {Array<Function>}
  3361. */
  3362. function throttle(fn, freq) {
  3363. var timestamp = 0;
  3364. var threshold = 1000 / freq;
  3365. var lastArgs;
  3366. var timer;
  3367. var invoke = function invoke(args) {
  3368. var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
  3369. timestamp = now;
  3370. lastArgs = null;
  3371. if (timer) {
  3372. clearTimeout(timer);
  3373. timer = null;
  3374. }
  3375. fn.apply(void 0, _toConsumableArray(args));
  3376. };
  3377. var throttled = function throttled() {
  3378. var now = Date.now();
  3379. var passed = now - timestamp;
  3380. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3381. args[_key] = arguments[_key];
  3382. }
  3383. if (passed >= threshold) {
  3384. invoke(args, now);
  3385. } else {
  3386. lastArgs = args;
  3387. if (!timer) {
  3388. timer = setTimeout(function () {
  3389. timer = null;
  3390. invoke(lastArgs);
  3391. }, threshold - passed);
  3392. }
  3393. }
  3394. };
  3395. var flush = function flush() {
  3396. return lastArgs && invoke(lastArgs);
  3397. };
  3398. var flushWith = function flushWith() {
  3399. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3400. args[_key2] = arguments[_key2];
  3401. }
  3402. return invoke(args);
  3403. };
  3404. return [throttled, flush, flushWith];
  3405. }
  3406. var progressEventReducer = function progressEventReducer(listener, isDownloadStream) {
  3407. var freq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
  3408. var bytesNotified = 0;
  3409. var _speedometer = speedometer(50, 250);
  3410. return throttle(function (e) {
  3411. if (!e || !utils$1.isNumber(e.loaded)) {
  3412. return;
  3413. }
  3414. var rawLoaded = e.loaded;
  3415. var total = e.lengthComputable ? e.total : undefined;
  3416. var loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
  3417. var progressBytes = Math.max(0, loaded - bytesNotified);
  3418. var rate = _speedometer(progressBytes);
  3419. bytesNotified = Math.max(bytesNotified, loaded);
  3420. var data = _defineProperty({
  3421. loaded: loaded,
  3422. total: total,
  3423. progress: total ? loaded / total : undefined,
  3424. bytes: progressBytes,
  3425. rate: rate ? rate : undefined,
  3426. estimated: rate && total ? (total - loaded) / rate : undefined,
  3427. event: e,
  3428. lengthComputable: total != null
  3429. }, isDownloadStream ? 'download' : 'upload', true);
  3430. listener(data);
  3431. }, freq);
  3432. };
  3433. var progressEventDecorator = function progressEventDecorator(total, throttled) {
  3434. var lengthComputable = total != null;
  3435. return [function (loaded) {
  3436. return throttled[0]({
  3437. lengthComputable: lengthComputable,
  3438. total: total,
  3439. loaded: loaded
  3440. });
  3441. }, throttled[1]];
  3442. };
  3443. var asyncDecorator = function asyncDecorator(fn) {
  3444. var scheduler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : utils$1.asap;
  3445. return function () {
  3446. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3447. args[_key] = arguments[_key];
  3448. }
  3449. return scheduler(function () {
  3450. return fn.apply(void 0, args);
  3451. });
  3452. };
  3453. };
  3454. var isURLSameOrigin = platform.hasStandardBrowserEnv ? function (origin) {
  3455. return function (url) {
  3456. url = new URL(url, document.baseURI || platform.origin);
  3457. return origin.protocol === url.protocol && origin.host === url.host && origin.port === url.port;
  3458. };
  3459. }(new URL(platform.origin)) : function () {
  3460. return true;
  3461. };
  3462. /**
  3463. * Determines whether the specified URL is absolute
  3464. *
  3465. * @param {string} url The URL to test
  3466. *
  3467. * @returns {boolean} True if the specified URL is absolute, otherwise false
  3468. */
  3469. function isAbsoluteURL(url) {
  3470. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  3471. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  3472. // by any combination of letters, digits, plus, period, or hyphen.
  3473. if (typeof url !== 'string') {
  3474. return false;
  3475. }
  3476. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  3477. }
  3478. /**
  3479. * Creates a new URL by combining the specified URLs
  3480. *
  3481. * @param {string} baseURL The base URL
  3482. * @param {string} relativeURL The relative URL
  3483. *
  3484. * @returns {string} The combined URL
  3485. */
  3486. function combineURLs(baseURL, relativeURL) {
  3487. if (!relativeURL) {
  3488. return baseURL;
  3489. }
  3490. var end = baseURL.length;
  3491. while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
  3492. end--;
  3493. }
  3494. return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
  3495. }
  3496. var malformedHttpProtocol = /^https?:(?!\/\/)/i;
  3497. // Redact the parts of a URL that can carry secrets before it is embedded in an
  3498. // error message. AxiosError.toJSON() serializes `message` verbatim and errors
  3499. // are commonly logged, while the opt-in `config.redact` model only cleans
  3500. // config keys — it cannot reach the message. Redact only the genuinely
  3501. // sensitive substrings — userinfo (credentials), query parameter values and
  3502. // fragment contents — with the same REDACTED marker the config redaction uses,
  3503. // while keeping the scheme, host, path and parameter names so the offending
  3504. // request stays accurately identifiable.
  3505. function redactFragment(fragment) {
  3506. if (!fragment) {
  3507. return fragment;
  3508. }
  3509. return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, function (match, separator) {
  3510. var parameterName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  3511. return "".concat(separator).concat(parameterName).concat(REDACTED);
  3512. });
  3513. }
  3514. function redactSensitiveURLParts(url) {
  3515. var redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, "$1".concat(REDACTED, "@"));
  3516. var fragmentIndex = redactedURL.indexOf('#');
  3517. var urlWithoutFragment = fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
  3518. var redactedURLWithoutFragment = urlWithoutFragment.replace(/([?&][^=&#]*=)[^&#]*/g, "$1".concat(REDACTED));
  3519. if (fragmentIndex === -1) {
  3520. return redactedURLWithoutFragment;
  3521. }
  3522. return "".concat(redactedURLWithoutFragment, "#").concat(redactFragment(redactedURL.slice(fragmentIndex + 1)));
  3523. }
  3524. function assertValidHttpProtocolURL(url, config) {
  3525. if (typeof url === 'string') {
  3526. var normalizedURL = normalizeURLForProtocolCheck(url);
  3527. if (malformedHttpProtocol.test(normalizedURL)) {
  3528. throw new AxiosError("Invalid URL ".concat(JSON.stringify(redactSensitiveURLParts(normalizedURL)), ": missing \"//\" after protocol"), AxiosError.ERR_INVALID_URL, config);
  3529. }
  3530. }
  3531. }
  3532. /**
  3533. * Creates a new URL by combining the baseURL with the requestedURL,
  3534. * only when the requestedURL is not already an absolute URL.
  3535. * If the requestURL is absolute, this function returns the requestedURL untouched.
  3536. *
  3537. * @param {string} baseURL The base URL
  3538. * @param {string} requestedURL Absolute or relative URL to combine
  3539. *
  3540. * @returns {string} The combined full path
  3541. */
  3542. function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
  3543. assertValidHttpProtocolURL(requestedURL, config);
  3544. var isRelativeUrl = !isAbsoluteURL(requestedURL);
  3545. if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
  3546. assertValidHttpProtocolURL(baseURL, config);
  3547. return combineURLs(baseURL, requestedURL);
  3548. }
  3549. return requestedURL;
  3550. }
  3551. function assertParamsAcyclic(params) {
  3552. var pending = [{
  3553. value: params
  3554. }];
  3555. var active = new WeakSet();
  3556. var visited = new WeakSet();
  3557. var _loop = function _loop() {
  3558. var _pending$pop = pending.pop(),
  3559. value = _pending$pop.value,
  3560. done = _pending$pop.done;
  3561. if (!utils$1.isPlainObject(value) && !utils$1.isArray(value)) return 0; // continue
  3562. if (done) {
  3563. active["delete"](value);
  3564. return 0; // continue
  3565. }
  3566. if (active.has(value)) {
  3567. throw new AxiosError('Circular reference detected in params', AxiosError.ERR_BAD_OPTION_VALUE);
  3568. }
  3569. if (visited.has(value)) return 0; // continue
  3570. visited.add(value);
  3571. active.add(value);
  3572. pending.push({
  3573. value: value,
  3574. done: true
  3575. });
  3576. var keys = Object.keys(value);
  3577. if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
  3578. Object.getOwnPropertySymbols(value).forEach(function (key) {
  3579. var descriptor = Object.getOwnPropertyDescriptor(value, key);
  3580. if (descriptor && descriptor.enumerable) keys.push(key);
  3581. });
  3582. }
  3583. // Shallow array elements retain fields filtered during plain-object merges.
  3584. // Inspect reserved data properties without evaluating their accessors.
  3585. keys.forEach(function (key) {
  3586. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  3587. var descriptor = Object.getOwnPropertyDescriptor(value, key);
  3588. if (descriptor && utils$1.hasOwnProp(descriptor, 'value')) {
  3589. pending.push({
  3590. value: descriptor.value
  3591. });
  3592. }
  3593. } else {
  3594. pending.push({
  3595. value: value[key]
  3596. });
  3597. }
  3598. });
  3599. },
  3600. _ret;
  3601. while (pending.length) {
  3602. _ret = _loop();
  3603. if (_ret === 0) continue;
  3604. }
  3605. }
  3606. var headersToObject = function headersToObject(thing) {
  3607. return thing instanceof AxiosHeaders ? _objectSpread2({}, thing) : thing;
  3608. };
  3609. var ownEnumerableKeys = function ownEnumerableKeys(thing) {
  3610. if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
  3611. return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(function (symbol) {
  3612. var descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
  3613. return descriptor && descriptor.enumerable;
  3614. }));
  3615. }
  3616. return Object.keys(thing);
  3617. };
  3618. // Copy params without recursive merges so the serializer remains responsible
  3619. // for its depth policy. Only visit defaults that contribute to the result.
  3620. function mergeParams(a, b) {
  3621. var pending = [];
  3622. var copies = new WeakMap();
  3623. var empty = {};
  3624. function copy(target, source) {
  3625. if (!utils$1.isPlainObject(source)) {
  3626. return utils$1.isArray(source) ? source.slice() : source;
  3627. }
  3628. var base = utils$1.isPlainObject(target) ? target : empty;
  3629. var bases = copies.get(source);
  3630. if (!bases) {
  3631. bases = new WeakMap();
  3632. copies.set(source, bases);
  3633. }
  3634. if (bases.has(base)) return bases.get(base);
  3635. var result = {};
  3636. bases.set(base, result);
  3637. pending.push({
  3638. base: base,
  3639. source: source,
  3640. result: result
  3641. });
  3642. return result;
  3643. }
  3644. var result = utils$1.isUndefined(b) ? copy(undefined, a) : copy(a, b);
  3645. var _loop = function _loop() {
  3646. var _pending$pop = pending.pop(),
  3647. base = _pending$pop.base,
  3648. source = _pending$pop.source,
  3649. target = _pending$pop.result;
  3650. var baseKeys = new Set(ownEnumerableKeys(base));
  3651. var sourceKeys = new Set(ownEnumerableKeys(source));
  3652. var keys = new Set([].concat(_toConsumableArray(baseKeys), _toConsumableArray(sourceKeys)));
  3653. keys.forEach(function (key) {
  3654. if (key === '__proto__' || key === 'constructor' || key === 'prototype') return;
  3655. var hasSource = sourceKeys.has(key);
  3656. var value = hasSource ? source[key] : undefined;
  3657. var previous = (!hasSource || utils$1.isPlainObject(value)) && baseKeys.has(key) ? base[key] : undefined;
  3658. target[key] = hasSource ? copy(previous, value) : copy(undefined, previous);
  3659. });
  3660. };
  3661. while (pending.length) {
  3662. _loop();
  3663. }
  3664. assertParamsAcyclic(result);
  3665. return result;
  3666. }
  3667. function getMergedValue(target, source, prop, caseless) {
  3668. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  3669. return utils$1.merge.call({
  3670. caseless: caseless
  3671. }, target, source);
  3672. } else if (utils$1.isPlainObject(source)) {
  3673. return utils$1.merge({}, source);
  3674. } else if (utils$1.isArray(source)) {
  3675. return source.slice();
  3676. }
  3677. return source;
  3678. }
  3679. function mergeDeepProperties(a, b, prop, caseless) {
  3680. if (!utils$1.isUndefined(b)) {
  3681. return getMergedValue(a, b, prop, caseless);
  3682. } else if (!utils$1.isUndefined(a)) {
  3683. return getMergedValue(undefined, a, prop, caseless);
  3684. }
  3685. }
  3686. // eslint-disable-next-line consistent-return
  3687. function valueFromConfig2(a, b) {
  3688. if (!utils$1.isUndefined(b)) {
  3689. return getMergedValue(undefined, b);
  3690. }
  3691. }
  3692. // eslint-disable-next-line consistent-return
  3693. function defaultToConfig2(a, b) {
  3694. if (!utils$1.isUndefined(b)) {
  3695. return getMergedValue(undefined, b);
  3696. } else if (!utils$1.isUndefined(a)) {
  3697. return getMergedValue(undefined, a);
  3698. }
  3699. }
  3700. function getMergedTransitionalOption(config1, config2, prop) {
  3701. var transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
  3702. if (!utils$1.isUndefined(transitional2)) {
  3703. if (utils$1.isPlainObject(transitional2)) {
  3704. if (utils$1.hasOwnProp(transitional2, prop)) {
  3705. return transitional2[prop];
  3706. }
  3707. } else {
  3708. return undefined;
  3709. }
  3710. }
  3711. var transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
  3712. if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
  3713. return transitional1[prop];
  3714. }
  3715. return undefined;
  3716. }
  3717. // eslint-disable-next-line consistent-return
  3718. function mergeDirectKeys(a, b, prop, config1, config2) {
  3719. if (utils$1.hasOwnProp(config2, prop)) {
  3720. return getMergedValue(a, b);
  3721. } else if (utils$1.hasOwnProp(config1, prop)) {
  3722. return getMergedValue(undefined, a);
  3723. }
  3724. }
  3725. function mergeHeaders(a, b, prop) {
  3726. return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
  3727. }
  3728. // Null-proto, frozen descriptor so a polluted Object.prototype.get cannot turn
  3729. // this data descriptor into an accessor descriptor on the way in.
  3730. // defineProperty only reads it, so one shared instance serves every call.
  3731. var hasOwnPropertyDescriptor = Object.freeze({
  3732. __proto__: null,
  3733. value: Object.prototype.hasOwnProperty,
  3734. enumerable: false,
  3735. writable: true,
  3736. configurable: true
  3737. });
  3738. // The strategy table and the strategies above are stateless, so they are
  3739. // built once at module load instead of on every call: mergeConfig runs at
  3740. // most twice per request (once from a method alias, once from `_request`).
  3741. var mergeMap = {
  3742. url: valueFromConfig2,
  3743. method: valueFromConfig2,
  3744. data: valueFromConfig2,
  3745. baseURL: defaultToConfig2,
  3746. transformRequest: defaultToConfig2,
  3747. transformResponse: defaultToConfig2,
  3748. params: mergeParams,
  3749. paramsSerializer: defaultToConfig2,
  3750. timeout: defaultToConfig2,
  3751. timeoutErrorMessage: defaultToConfig2,
  3752. withCredentials: defaultToConfig2,
  3753. withXSRFToken: defaultToConfig2,
  3754. adapter: defaultToConfig2,
  3755. responseType: defaultToConfig2,
  3756. xsrfCookieName: defaultToConfig2,
  3757. xsrfHeaderName: defaultToConfig2,
  3758. onUploadProgress: defaultToConfig2,
  3759. onDownloadProgress: defaultToConfig2,
  3760. decompress: defaultToConfig2,
  3761. maxContentLength: defaultToConfig2,
  3762. maxBodyLength: defaultToConfig2,
  3763. beforeRedirect: defaultToConfig2,
  3764. transport: defaultToConfig2,
  3765. httpAgent: defaultToConfig2,
  3766. httpsAgent: defaultToConfig2,
  3767. cancelToken: defaultToConfig2,
  3768. socketPath: defaultToConfig2,
  3769. allowedSocketPaths: defaultToConfig2,
  3770. responseEncoding: defaultToConfig2,
  3771. validateStatus: mergeDirectKeys,
  3772. headers: mergeHeaders
  3773. };
  3774. /**
  3775. * Config-specific merge-function which creates a new config-object
  3776. * by merging two configuration objects together.
  3777. *
  3778. * @param {Object} config1
  3779. * @param {Object} config2
  3780. *
  3781. * @returns {Object} New object resulting from merging config2 to config1
  3782. */
  3783. function mergeConfig(config1, config2) {
  3784. // eslint-disable-next-line no-param-reassign
  3785. config1 = config1 || {};
  3786. config2 = config2 || {};
  3787. // Use a null-prototype object so that downstream reads such as `config.auth`
  3788. // or `config.baseURL` cannot inherit polluted values from Object.prototype.
  3789. // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
  3790. // ergonomics for user code that relies on it.
  3791. var config = Object.create(null);
  3792. Object.defineProperty(config, 'hasOwnProperty', hasOwnPropertyDescriptor);
  3793. var keys = ownEnumerableKeys(_objectSpread2(_objectSpread2({}, config1), config2));
  3794. for (var i = 0, len = keys.length; i < len; i++) {
  3795. var prop = keys[i];
  3796. if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') continue;
  3797. var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
  3798. var a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
  3799. var b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
  3800. var configValue = merge === mergeDirectKeys ? merge(a, b, prop, config1, config2) : merge(a, b, prop);
  3801. utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
  3802. }
  3803. if (utils$1.hasOwnProp(config2, 'validateStatus') && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption(config1, config2, 'validateStatusUndefinedResolves') === false) {
  3804. if (utils$1.hasOwnProp(config1, 'validateStatus')) {
  3805. config.validateStatus = getMergedValue(undefined, config1.validateStatus);
  3806. } else {
  3807. delete config.validateStatus;
  3808. }
  3809. }
  3810. return config;
  3811. }
  3812. var FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
  3813. /**
  3814. * Apply the headers generated by a FormData implementation to the request headers,
  3815. * honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
  3816. * content-* headers; otherwise merge all of them.
  3817. *
  3818. * @param {AxiosHeaders} headers - the request headers to mutate
  3819. * @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
  3820. * @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
  3821. *
  3822. * @returns {void}
  3823. */
  3824. function setFormDataHeaders(headers, formHeaders, policy) {
  3825. if (policy !== 'content-only') {
  3826. headers.set(formHeaders);
  3827. return;
  3828. }
  3829. Object.entries(formHeaders || {}).forEach(function (_ref) {
  3830. var _ref2 = _slicedToArray(_ref, 2),
  3831. key = _ref2[0],
  3832. val = _ref2[1];
  3833. if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
  3834. headers.set(key, val);
  3835. }
  3836. });
  3837. }
  3838. /**
  3839. * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
  3840. * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
  3841. *
  3842. * @param {string} str The string to encode
  3843. *
  3844. * @returns {string} UTF-8 bytes as a Latin-1 string
  3845. */
  3846. var encodeUTF8$1 = function encodeUTF8(str) {
  3847. return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
  3848. return String.fromCharCode(parseInt(hex, 16));
  3849. });
  3850. };
  3851. var readCookie = function readCookie(name) {
  3852. return cookies.read(name);
  3853. };
  3854. function resolveConfig(config) {
  3855. var readXsrfCookie = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : readCookie;
  3856. var newConfig = mergeConfig({}, config);
  3857. // Read only own properties to prevent prototype pollution gadgets
  3858. // (e.g. Object.prototype.baseURL = 'https://evil.com').
  3859. var own = function own(key) {
  3860. return utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
  3861. };
  3862. var data = own('data');
  3863. var withXSRFToken = own('withXSRFToken');
  3864. var xsrfHeaderName = own('xsrfHeaderName');
  3865. var xsrfCookieName = own('xsrfCookieName');
  3866. var headers = own('headers');
  3867. var auth = own('auth');
  3868. var baseURL = own('baseURL');
  3869. var allowAbsoluteUrls = own('allowAbsoluteUrls');
  3870. var url = own('url');
  3871. newConfig.headers = headers = AxiosHeaders.from(headers);
  3872. newConfig.url = buildURL(buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig), own('params'), own('paramsSerializer'));
  3873. // HTTP basic authentication
  3874. if (auth) {
  3875. var username = utils$1.getSafeProp(auth, 'username') || '';
  3876. var password = utils$1.getSafeProp(auth, 'password') || '';
  3877. var transitional = own('transitional');
  3878. var encodeUsername = transitional && utils$1.hasOwnProp(transitional, 'encodeBasicAuthUsername') && transitional.encodeBasicAuthUsername === true;
  3879. try {
  3880. headers.set('Authorization',
  3881. // Preserve legacy username bytes unless the caller opts in to UTF-8.
  3882. 'Basic ' + btoa((encodeUsername ? encodeUTF8$1(username) : username) + ':' + (password ? encodeUTF8$1(password) : '')));
  3883. } catch (e) {
  3884. throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
  3885. }
  3886. }
  3887. if (utils$1.isFormData(data)) {
  3888. var getHeaders = utils$1.getSafeProp(data, 'getHeaders');
  3889. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
  3890. headers.setContentType(undefined); // browser/web worker/RN handles it
  3891. } else if (utils$1.isFunction(getHeaders)) {
  3892. // Node.js FormData (like form-data package)
  3893. setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
  3894. }
  3895. }
  3896. // Add xsrf header
  3897. // This is only done if running in a standard browser environment.
  3898. // Specifically not if we're in a web worker, or react-native.
  3899. if (platform.hasStandardBrowserEnv) {
  3900. if (utils$1.isFunction(withXSRFToken)) {
  3901. withXSRFToken = withXSRFToken(newConfig);
  3902. }
  3903. // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
  3904. // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
  3905. // the XSRF token cross-origin.
  3906. var shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
  3907. if (shouldSendXSRF) {
  3908. var xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
  3909. if (xsrfValue) {
  3910. headers.set(xsrfHeaderName, xsrfValue);
  3911. }
  3912. }
  3913. }
  3914. return newConfig;
  3915. }
  3916. var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  3917. var xhrAdapter = isXHRAdapterSupported && function (config) {
  3918. return new Promise(function dispatchXhrRequest(resolve, reject) {
  3919. var useAsyncXsrf;
  3920. try {
  3921. var store = platform.hasStandardBrowserEnv && typeof window !== 'undefined' && window.cookieStore;
  3922. useAsyncXsrf = store && utils$1.isFunction(store.get);
  3923. } catch (e) {
  3924. // A restricted Cookie Store getter must retain the synchronous fallback.
  3925. }
  3926. var xsrfCookieName;
  3927. var _config = resolveConfig(config, useAsyncXsrf ? function (name) {
  3928. xsrfCookieName = name;
  3929. return null;
  3930. } : undefined);
  3931. var requestData = _config.data;
  3932. var requestHeaders = AxiosHeaders.from(_config.headers).normalize();
  3933. var responseType = _config.responseType,
  3934. onUploadProgress = _config.onUploadProgress,
  3935. onDownloadProgress = _config.onDownloadProgress;
  3936. var onCanceled;
  3937. var timeoutId;
  3938. var uploadThrottled, downloadThrottled;
  3939. var flushUpload, flushDownload, flushDownloadWithEvent;
  3940. function done() {
  3941. clearTimeout(timeoutId);
  3942. // A final progress callback must not prevent the remaining cleanup.
  3943. // Report errors asynchronously, as onloadend and the throttle timer do.
  3944. try {
  3945. flushUpload && flushUpload(); // flush events
  3946. } catch (err) {
  3947. setTimeout(function () {
  3948. throw err;
  3949. });
  3950. }
  3951. try {
  3952. flushDownload && flushDownload(); // flush events
  3953. } catch (err) {
  3954. setTimeout(function () {
  3955. throw err;
  3956. });
  3957. }
  3958. // A flush can synchronously cancel the request and reenter done().
  3959. // In that case the inner call has already detached these listeners.
  3960. if (request) {
  3961. downloadThrottled && request.removeEventListener('progress', downloadThrottled);
  3962. if (request.upload) {
  3963. uploadThrottled && request.upload.removeEventListener('progress', uploadThrottled);
  3964. flushUpload && request.upload.removeEventListener('loadend', flushUpload);
  3965. }
  3966. }
  3967. _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
  3968. _config.signal && _config.signal.removeEventListener('abort', onCanceled);
  3969. }
  3970. var request = new XMLHttpRequest();
  3971. request.open(_config.method.toUpperCase(), _config.url, true);
  3972. // Set the request timeout in MS
  3973. request.timeout = _config.timeout;
  3974. function onloadend(event) {
  3975. if (!request) {
  3976. return;
  3977. }
  3978. // Status 0 means no response was received, which onerror and onabort normally
  3979. // reject before this runs. Firefox 152 fires only readystatechange and loadend for
  3980. // navigation-canceled requests (https://bugzilla.mozilla.org/show_bug.cgi?id=1505389),
  3981. // leaving settle() to resolve them as an empty success. ECONNABORTED is the error
  3982. // onabort raised on Firefox 151. Reads over file:, which some environments report as
  3983. // status 0 on success, are excluded by the request URL's scheme after browser-style
  3984. // preprocessing, by the page origin's scheme for relative URLs (which inherit it), or
  3985. // by responseURL where implemented.
  3986. if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform.origin)) !== 'file' && !(request.responseURL && request.responseURL.startsWith('file:'))) {
  3987. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  3988. done();
  3989. // Clean up request
  3990. request = null;
  3991. return;
  3992. }
  3993. // When loadend is still dispatching, flushing with it gives progress
  3994. // listeners a final delivery whose event has a live target. The legacy
  3995. // ready-state fallback has no event, so replay its pending progress.
  3996. // A throwing listener must not block settlement; rethrow asynchronously,
  3997. // matching how listener errors surface on the throttle timer path.
  3998. try {
  3999. if (event) {
  4000. flushDownloadWithEvent && flushDownloadWithEvent(event);
  4001. } else {
  4002. flushDownload && flushDownload();
  4003. }
  4004. } catch (err) {
  4005. setTimeout(function () {
  4006. throw err;
  4007. });
  4008. }
  4009. // A final progress callback can cancel the request synchronously.
  4010. if (!request) {
  4011. return;
  4012. }
  4013. // Prepare the response
  4014. var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
  4015. var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
  4016. var response = {
  4017. data: responseData,
  4018. status: request.status,
  4019. statusText: request.statusText,
  4020. headers: responseHeaders,
  4021. config: config,
  4022. request: request
  4023. };
  4024. settle(function _resolve(value) {
  4025. resolve(value);
  4026. done();
  4027. }, function _reject(err) {
  4028. reject(err);
  4029. done();
  4030. }, response);
  4031. // Clean up request
  4032. request = null;
  4033. }
  4034. if ('onloadend' in request) {
  4035. // Use onloadend if available
  4036. request.onloadend = onloadend;
  4037. } else {
  4038. // Listen for ready state to emulate onloadend
  4039. request.onreadystatechange = function handleLoad() {
  4040. if (!request || request.readyState !== 4) {
  4041. return;
  4042. }
  4043. // The request errored out and we didn't get a response, this will be
  4044. // handled by onerror instead
  4045. // With one exception: request that using file: protocol, most browsers
  4046. // will return status as 0 even though it's a successful request
  4047. if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith('file:'))) {
  4048. return;
  4049. }
  4050. // readystate handler is calling before onerror or ontimeout handlers,
  4051. // so we should call onloadend on the next 'tick'
  4052. setTimeout(onloadend);
  4053. };
  4054. }
  4055. // Handle browser request cancellation (as opposed to a manual cancellation)
  4056. request.onabort = function handleAbort() {
  4057. if (!request) {
  4058. return;
  4059. }
  4060. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  4061. done();
  4062. // Clean up request
  4063. request = null;
  4064. };
  4065. // Handle low level network errors
  4066. request.onerror = function handleError(event) {
  4067. // Browsers deliver a ProgressEvent in XHR onerror
  4068. // (message may be empty; when present, surface it)
  4069. // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
  4070. var msg = event && event.message ? event.message : 'Network Error';
  4071. var err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
  4072. // attach the underlying event for consumers who want details
  4073. err.event = event || null;
  4074. reject(err);
  4075. done();
  4076. request = null;
  4077. };
  4078. // Handle timeout
  4079. request.ontimeout = function handleTimeout() {
  4080. if (!request) return;
  4081. var timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
  4082. var transitional = _config.transitional || transitionalDefaults;
  4083. if (_config.timeoutErrorMessage) {
  4084. timeoutErrorMessage = _config.timeoutErrorMessage;
  4085. }
  4086. reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
  4087. done();
  4088. // Clean up request
  4089. request = null;
  4090. };
  4091. // Remove Content-Type if data is undefined
  4092. requestData === undefined && requestHeaders.setContentType(null);
  4093. // Add withCredentials to request if needed
  4094. if (!utils$1.isUndefined(_config.withCredentials)) {
  4095. request.withCredentials = !!_config.withCredentials;
  4096. }
  4097. // Add responseType to request if needed
  4098. if (responseType && responseType !== 'json') {
  4099. request.responseType = _config.responseType;
  4100. }
  4101. // Handle progress if needed
  4102. if (onDownloadProgress) {
  4103. var _progressEventReducer = progressEventReducer(onDownloadProgress, true);
  4104. var _progressEventReducer2 = _slicedToArray(_progressEventReducer, 3);
  4105. downloadThrottled = _progressEventReducer2[0];
  4106. flushDownload = _progressEventReducer2[1];
  4107. flushDownloadWithEvent = _progressEventReducer2[2];
  4108. request.addEventListener('progress', downloadThrottled);
  4109. }
  4110. // Not all browsers support upload events
  4111. if (onUploadProgress && request.upload) {
  4112. var _progressEventReducer3 = progressEventReducer(onUploadProgress);
  4113. var _progressEventReducer4 = _slicedToArray(_progressEventReducer3, 2);
  4114. uploadThrottled = _progressEventReducer4[0];
  4115. flushUpload = _progressEventReducer4[1];
  4116. request.upload.addEventListener('progress', uploadThrottled);
  4117. request.upload.addEventListener('loadend', flushUpload);
  4118. }
  4119. if (_config.cancelToken || _config.signal) {
  4120. // Handle cancellation
  4121. // eslint-disable-next-line func-names
  4122. onCanceled = function onCanceled(cancel) {
  4123. if (!request) {
  4124. return;
  4125. }
  4126. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  4127. var xhr = request;
  4128. done();
  4129. request = null;
  4130. xhr.abort();
  4131. };
  4132. _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
  4133. if (!request) return;
  4134. if (_config.signal) {
  4135. _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
  4136. }
  4137. }
  4138. if (!request) return;
  4139. var protocol = parseProtocol(_config.url);
  4140. if (protocol && !platform.protocols.includes(protocol)) {
  4141. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  4142. done();
  4143. return;
  4144. }
  4145. var sendRequest = function sendRequest() {
  4146. if (!request) return;
  4147. // Apply headers after an asynchronous XSRF read so existing headers are
  4148. // replaced through AxiosHeaders rather than appended by the native XHR.
  4149. if ('setRequestHeader' in request) {
  4150. utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
  4151. request.setRequestHeader(key, val);
  4152. });
  4153. }
  4154. request.send(requestData || null);
  4155. };
  4156. if (xsrfCookieName) {
  4157. // Native XHR timeout starts at send(). Cover cookie preparation and the
  4158. // subsequent request with the same budget and existing timeout handler.
  4159. var now = typeof performance !== 'undefined' && utils$1.isFunction(performance.now) ? function () {
  4160. return performance.now();
  4161. } : Date.now;
  4162. var deadline = request.timeout > 0 ? now() + Number(request.timeout) : undefined;
  4163. var abortOnTimeout = function abortOnTimeout() {
  4164. if (!request) return;
  4165. var xhr = request;
  4166. xhr.ontimeout();
  4167. xhr.abort();
  4168. };
  4169. if (deadline !== undefined) {
  4170. var _scheduleTimeout = function scheduleTimeout() {
  4171. var remaining = deadline - now();
  4172. if (remaining > 0) {
  4173. // Browser timers overflow above the signed 32-bit delay limit.
  4174. timeoutId = setTimeout(_scheduleTimeout, Math.min(remaining, 0x7fffffff));
  4175. } else {
  4176. abortOnTimeout();
  4177. }
  4178. };
  4179. _scheduleTimeout();
  4180. }
  4181. cookies.readAsync(xsrfCookieName).then(function (value) {
  4182. if (!request) return;
  4183. // Promise callbacks may run before an overdue timer after a busy task.
  4184. if (deadline !== undefined && now() >= deadline) {
  4185. abortOnTimeout();
  4186. return;
  4187. }
  4188. if (value) {
  4189. var headerName = utils$1.hasOwnProp(_config, 'xsrfHeaderName') && _config.xsrfHeaderName;
  4190. requestHeaders.set(headerName, value);
  4191. }
  4192. sendRequest();
  4193. })["catch"](function (error) {
  4194. if (!request) return;
  4195. reject(AxiosError.from(error, null, config, request));
  4196. done();
  4197. request = null;
  4198. });
  4199. } else {
  4200. sendRequest();
  4201. }
  4202. });
  4203. };
  4204. var composeSignals = function composeSignals(signals, timeout) {
  4205. signals = signals ? signals.filter(Boolean) : [];
  4206. if (!timeout && !signals.length) {
  4207. return;
  4208. }
  4209. var controller = new AbortController();
  4210. var aborted = false;
  4211. var onabort = function onabort(reason) {
  4212. if (!aborted) {
  4213. aborted = true;
  4214. unsubscribe();
  4215. var err = reason instanceof Error ? reason : this.reason;
  4216. controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
  4217. }
  4218. };
  4219. var timer = timeout && setTimeout(function () {
  4220. timer = null;
  4221. onabort(new AxiosError("timeout of ".concat(timeout, "ms exceeded"), AxiosError.ETIMEDOUT));
  4222. }, timeout);
  4223. var unsubscribe = function unsubscribe() {
  4224. if (!signals) {
  4225. return;
  4226. }
  4227. timer && clearTimeout(timer);
  4228. timer = null;
  4229. signals.forEach(function (signal) {
  4230. var unsubscribeSignal = utils$1.getSafeProp(signal, 'unsubscribe');
  4231. utils$1.isFunction(unsubscribeSignal) ? unsubscribeSignal.call(signal, onabort) : signal.removeEventListener('abort', onabort);
  4232. });
  4233. signals = null;
  4234. };
  4235. signals.forEach(function (signal) {
  4236. if (aborted) {
  4237. return;
  4238. }
  4239. if (signal.aborted) {
  4240. onabort.call(signal);
  4241. return;
  4242. }
  4243. signal.addEventListener('abort', onabort, {
  4244. once: true
  4245. });
  4246. });
  4247. var signal = controller.signal;
  4248. signal.unsubscribe = function () {
  4249. return utils$1.asap(unsubscribe);
  4250. };
  4251. return signal;
  4252. };
  4253. var streamChunk = /*#__PURE__*/_regenerator().m(function streamChunk(chunk, chunkSize) {
  4254. var len, pos, end;
  4255. return _regenerator().w(function (_context) {
  4256. while (1) switch (_context.n) {
  4257. case 0:
  4258. len = chunk.byteLength;
  4259. if (!(!chunkSize || len < chunkSize)) {
  4260. _context.n = 2;
  4261. break;
  4262. }
  4263. _context.n = 1;
  4264. return chunk;
  4265. case 1:
  4266. return _context.a(2);
  4267. case 2:
  4268. pos = 0;
  4269. case 3:
  4270. if (!(pos < len)) {
  4271. _context.n = 5;
  4272. break;
  4273. }
  4274. end = pos + chunkSize;
  4275. _context.n = 4;
  4276. return chunk.slice(pos, end);
  4277. case 4:
  4278. pos = end;
  4279. _context.n = 3;
  4280. break;
  4281. case 5:
  4282. return _context.a(2);
  4283. }
  4284. }, streamChunk);
  4285. });
  4286. var readBytes = /*#__PURE__*/function () {
  4287. var _ref = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee(iterable, chunkSize) {
  4288. var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
  4289. return _regenerator().w(function (_context2) {
  4290. while (1) switch (_context2.p = _context2.n) {
  4291. case 0:
  4292. _iteratorAbruptCompletion = false;
  4293. _didIteratorError = false;
  4294. _context2.p = 1;
  4295. _iterator = _asyncIterator(readStream(iterable));
  4296. case 2:
  4297. _context2.n = 3;
  4298. return _awaitAsyncGenerator(_iterator.next());
  4299. case 3:
  4300. if (!(_iteratorAbruptCompletion = !(_step = _context2.v).done)) {
  4301. _context2.n = 5;
  4302. break;
  4303. }
  4304. chunk = _step.value;
  4305. return _context2.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(streamChunk(chunk, chunkSize)))), 4);
  4306. case 4:
  4307. _iteratorAbruptCompletion = false;
  4308. _context2.n = 2;
  4309. break;
  4310. case 5:
  4311. _context2.n = 7;
  4312. break;
  4313. case 6:
  4314. _context2.p = 6;
  4315. _t = _context2.v;
  4316. _didIteratorError = true;
  4317. _iteratorError = _t;
  4318. case 7:
  4319. _context2.p = 7;
  4320. _context2.p = 8;
  4321. if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
  4322. _context2.n = 9;
  4323. break;
  4324. }
  4325. _context2.n = 9;
  4326. return _awaitAsyncGenerator(_iterator["return"]());
  4327. case 9:
  4328. _context2.p = 9;
  4329. if (!_didIteratorError) {
  4330. _context2.n = 10;
  4331. break;
  4332. }
  4333. throw _iteratorError;
  4334. case 10:
  4335. return _context2.f(9);
  4336. case 11:
  4337. return _context2.f(7);
  4338. case 12:
  4339. return _context2.a(2);
  4340. }
  4341. }, _callee, null, [[8,, 9, 11], [1, 6, 7, 12]]);
  4342. }));
  4343. return function readBytes(_x, _x2) {
  4344. return _ref.apply(this, arguments);
  4345. };
  4346. }();
  4347. var readStream = /*#__PURE__*/function () {
  4348. var _ref2 = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee2(stream) {
  4349. var reader, _yield$_awaitAsyncGen, done, value;
  4350. return _regenerator().w(function (_context3) {
  4351. while (1) switch (_context3.p = _context3.n) {
  4352. case 0:
  4353. if (!stream[Symbol.asyncIterator]) {
  4354. _context3.n = 2;
  4355. break;
  4356. }
  4357. return _context3.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(stream))), 1);
  4358. case 1:
  4359. return _context3.a(2);
  4360. case 2:
  4361. reader = stream.getReader();
  4362. _context3.p = 3;
  4363. case 4:
  4364. _context3.n = 5;
  4365. return _awaitAsyncGenerator(reader.read());
  4366. case 5:
  4367. _yield$_awaitAsyncGen = _context3.v;
  4368. done = _yield$_awaitAsyncGen.done;
  4369. value = _yield$_awaitAsyncGen.value;
  4370. if (!done) {
  4371. _context3.n = 6;
  4372. break;
  4373. }
  4374. return _context3.a(3, 8);
  4375. case 6:
  4376. _context3.n = 7;
  4377. return value;
  4378. case 7:
  4379. _context3.n = 4;
  4380. break;
  4381. case 8:
  4382. _context3.p = 8;
  4383. _context3.n = 9;
  4384. return _awaitAsyncGenerator(reader.cancel());
  4385. case 9:
  4386. return _context3.f(8);
  4387. case 10:
  4388. return _context3.a(2);
  4389. }
  4390. }, _callee2, null, [[3,, 8, 10]]);
  4391. }));
  4392. return function readStream(_x3) {
  4393. return _ref2.apply(this, arguments);
  4394. };
  4395. }();
  4396. var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) {
  4397. var iterator = readBytes(stream, chunkSize);
  4398. var bytes = 0;
  4399. var done;
  4400. var _onFinish = function _onFinish(e) {
  4401. if (!done) {
  4402. done = true;
  4403. onFinish && onFinish(e);
  4404. }
  4405. };
  4406. return new ReadableStream({
  4407. pull: function pull(controller) {
  4408. return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
  4409. var _yield$iterator$next, _done, value, len, loadedBytes, _t2;
  4410. return _regenerator().w(function (_context4) {
  4411. while (1) switch (_context4.p = _context4.n) {
  4412. case 0:
  4413. _context4.p = 0;
  4414. _context4.n = 1;
  4415. return iterator.next();
  4416. case 1:
  4417. _yield$iterator$next = _context4.v;
  4418. _done = _yield$iterator$next.done;
  4419. value = _yield$iterator$next.value;
  4420. if (!_done) {
  4421. _context4.n = 2;
  4422. break;
  4423. }
  4424. _onFinish();
  4425. controller.close();
  4426. return _context4.a(2);
  4427. case 2:
  4428. len = value.byteLength;
  4429. if (onProgress) {
  4430. loadedBytes = bytes += len;
  4431. onProgress(loadedBytes);
  4432. }
  4433. controller.enqueue(new Uint8Array(value));
  4434. _context4.n = 4;
  4435. break;
  4436. case 3:
  4437. _context4.p = 3;
  4438. _t2 = _context4.v;
  4439. _onFinish(_t2);
  4440. throw _t2;
  4441. case 4:
  4442. return _context4.a(2);
  4443. }
  4444. }, _callee3, null, [[0, 3]]);
  4445. }))();
  4446. },
  4447. cancel: function cancel(reason) {
  4448. _onFinish(reason);
  4449. return iterator["return"]();
  4450. }
  4451. }, {
  4452. highWaterMark: 2
  4453. });
  4454. };
  4455. var CRLF = '\r\n';
  4456. var normalizeLines = function normalizeLines(value) {
  4457. return String(value).replace(/\r\n|\r|\n/g, CRLF);
  4458. };
  4459. var escapeName = function escapeName(value) {
  4460. return String(value).replace(/[\r\n"]/g, function (_char) {
  4461. return _char === '\r' ? '%0D' : _char === '\n' ? '%0A' : '%22';
  4462. });
  4463. };
  4464. // Count UTF-8 bytes without allocating an encoded copy of a field. FormData
  4465. // string values normalize line endings; Blob/File contents remain unchanged.
  4466. var stringBytes = function stringBytes(value, normalize) {
  4467. var length = 0;
  4468. for (var i = 0; i < value.length; i++) {
  4469. var code = value.charCodeAt(i);
  4470. if (normalize && (code === 13 || code === 10)) {
  4471. if (code === 13 && value.charCodeAt(i + 1) === 10) i++;
  4472. length += 2;
  4473. } else if (code < 0x80) {
  4474. length++;
  4475. } else if (code < 0x800) {
  4476. length += 2;
  4477. } else if (code >= 0xd800 && code <= 0xdbff && value.charCodeAt(i + 1) >= 0xdc00 && value.charCodeAt(i + 1) <= 0xdfff) {
  4478. length += 4;
  4479. i++;
  4480. } else {
  4481. length += 3;
  4482. }
  4483. }
  4484. return length;
  4485. };
  4486. // Describe serialization failures independently of any request library.
  4487. var FormDataError = /*#__PURE__*/function (_TypeError) {
  4488. function FormDataError(message, reason) {
  4489. var _this;
  4490. _classCallCheck(this, FormDataError);
  4491. _this = _callSuper(this, FormDataError, [message]);
  4492. _this.name = 'FormDataError';
  4493. _this.reason = reason;
  4494. return _this;
  4495. }
  4496. _inherits(FormDataError, _TypeError);
  4497. return _createClass(FormDataError);
  4498. }(/*#__PURE__*/_wrapNativeSuper(TypeError));
  4499. // The caller supplies the boundary, Blob implementation, and limit error.
  4500. function formDataToBlob(form, Blob, limit, limitError, boundary) {
  4501. if (!utils$1.isFunction(Blob)) {
  4502. throw new FormDataError('Blob is not supported', 'blob');
  4503. }
  4504. if (!utils$1.isString(boundary) || !/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) || / $/.test(boundary)) {
  4505. throw new FormDataError('Invalid multipart boundary', 'boundary');
  4506. }
  4507. var footer = '--' + boundary + '--' + CRLF;
  4508. var length = footer.length;
  4509. var parts = [];
  4510. var checkLength = function checkLength(extra) {
  4511. if (length + extra > limit) throw limitError();
  4512. };
  4513. checkLength(0);
  4514. var _iterator = _createForOfIteratorHelper(form),
  4515. _step;
  4516. try {
  4517. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4518. var _step$value = _slicedToArray(_step.value, 2),
  4519. name = _step$value[0],
  4520. value = _step$value[1];
  4521. var isString = utils$1.isString(value);
  4522. var valueLength = isString ? stringBytes(value, true) : value.size;
  4523. if (!Number.isFinite(valueLength) || valueLength < 0) {
  4524. throw new FormDataError('Unsupported FormData part size', 'part');
  4525. }
  4526. // Reject large values and names before building normalized header strings.
  4527. checkLength(valueLength + stringBytes(name, true) + (!isString && value.name ? stringBytes(value.name, false) : 0) + (!isString && value.type ? stringBytes(value.type, false) : 0));
  4528. var header = '--' + boundary + CRLF + 'Content-Disposition: form-data; name="' + escapeName(normalizeLines(name)) + '"';
  4529. if (!isString) {
  4530. header += '; filename="' + escapeName(utils$1.isString(value.name) ? value.name : 'blob') + '"' + CRLF + 'Content-Type: ' + String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
  4531. }
  4532. header += CRLF + CRLF;
  4533. var partLength = stringBytes(header, false) + valueLength + CRLF.length;
  4534. checkLength(partLength);
  4535. length += partLength;
  4536. parts.push({
  4537. header: header,
  4538. value: value,
  4539. isString: isString
  4540. });
  4541. }
  4542. // Native Blob composition retains existing Blob/File data. No file is read
  4543. // and no complete multipart ArrayBuffer is created to determine its length.
  4544. } catch (err) {
  4545. _iterator.e(err);
  4546. } finally {
  4547. _iterator.f();
  4548. }
  4549. var blobParts = [];
  4550. for (var _i = 0, _parts = parts; _i < _parts.length; _i++) {
  4551. var part = _parts[_i];
  4552. blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF);
  4553. }
  4554. blobParts.push(footer);
  4555. return new Blob(blobParts, {
  4556. type: 'multipart/form-data; boundary=' + boundary
  4557. });
  4558. }
  4559. function createMultipartBody(form, Blob, limit, limitError, boundary) {
  4560. // Report missing Blob support before trying to select a random source.
  4561. if (!utils$1.isFunction(Blob)) {
  4562. throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
  4563. }
  4564. if (boundary === undefined) {
  4565. if (utils$1.isFunction(platform.generateString)) {
  4566. boundary = 'axios-' + platform.generateString(36, '0123456789abcdef');
  4567. } else {
  4568. var crypto = utils$1.global.crypto;
  4569. if (!crypto || !utils$1.isFunction(crypto.getRandomValues)) {
  4570. throw new AxiosError('Random byte generation is not supported', AxiosError.ERR_NOT_SUPPORT);
  4571. }
  4572. var random = new Uint8Array(18);
  4573. crypto.getRandomValues(random);
  4574. boundary = 'axios-' + Array.from(random, function (value) {
  4575. return ('0' + value.toString(16)).slice(-2);
  4576. }).join('');
  4577. }
  4578. }
  4579. try {
  4580. return formDataToBlob(form, Blob, limit, limitError, boundary);
  4581. } catch (error) {
  4582. if (error instanceof FormDataError) {
  4583. var code = error.reason === 'boundary' ? AxiosError.ERR_BAD_OPTION_VALUE : AxiosError.ERR_BAD_REQUEST;
  4584. throw new AxiosError(error.message, code);
  4585. }
  4586. throw error;
  4587. }
  4588. }
  4589. /**
  4590. * Estimate data: URL byte lengths *without* allocating large buffers.
  4591. * - Fetch percent-decodes a base64 body before decoding it.
  4592. * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
  4593. * percent-decoded body, including ignored characters and content after padding.
  4594. * - Non-base64 data is percent-decoded and then encoded as UTF-8.
  4595. */
  4596. var isHexDigit = function isHexDigit(charCode) {
  4597. return charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
  4598. };
  4599. var isPercentEncodedByte = function isPercentEncodedByte(str, i, len) {
  4600. return i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
  4601. };
  4602. var hexValue = function hexValue(charCode) {
  4603. return charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55;
  4604. };
  4605. var isBase64Char = function isBase64Char(charCode) {
  4606. return charCode >= 65 && charCode <= 90 ||
  4607. // A-Z
  4608. charCode >= 97 && charCode <= 122 ||
  4609. // a-z
  4610. charCode >= 48 && charCode <= 57 ||
  4611. // 0-9
  4612. charCode === 43 ||
  4613. // +
  4614. charCode === 47 ||
  4615. // /
  4616. charCode === 45 ||
  4617. // - (base64url)
  4618. charCode === 95;
  4619. }; // _ (base64url)
  4620. var isBase64Whitespace = function isBase64Whitespace(charCode) {
  4621. return charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
  4622. };
  4623. var base64Bytes = function base64Bytes(significant) {
  4624. var groups = Math.floor(significant / 4);
  4625. var remainder = significant % 4;
  4626. return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
  4627. };
  4628. // Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
  4629. // upper bound even when Buffer.from later ignores characters or stops at '='.
  4630. var estimateBase64BufferAllocation = function estimateBase64BufferAllocation(body) {
  4631. var len = body.length;
  4632. var padding = 0;
  4633. if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
  4634. padding++;
  4635. if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
  4636. padding++;
  4637. }
  4638. }
  4639. return Math.floor((len - padding) * 3 / 4);
  4640. };
  4641. var estimatePercentDecodedBase64Bytes = function estimatePercentDecodedBase64Bytes(body) {
  4642. var len = body.length;
  4643. var significant = 0;
  4644. var padding = 0;
  4645. var invalid = false;
  4646. for (var i = 0; i < len; i++) {
  4647. var code = body.charCodeAt(i);
  4648. if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
  4649. code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
  4650. i += 2;
  4651. }
  4652. if (isBase64Whitespace(code)) {
  4653. continue;
  4654. }
  4655. if (code === 61 /* '=' */) {
  4656. padding++;
  4657. continue;
  4658. }
  4659. if (!isBase64Char(code) || padding > 0) {
  4660. invalid = true;
  4661. continue;
  4662. }
  4663. significant++;
  4664. }
  4665. // Fetch rejects malformed forgiving-base64 input. Returning the raw-size
  4666. // allocation bound keeps that invalid input from becoming a pre-check bypass.
  4667. if (invalid || padding > 2 || padding > 0 && (significant + padding) % 4 !== 0 || significant % 4 === 1) {
  4668. return estimateBase64BufferAllocation(body);
  4669. }
  4670. return base64Bytes(significant);
  4671. };
  4672. var estimateDataURLBytes = function estimateDataURLBytes(url, estimateBase64, base64Pattern) {
  4673. if (!url || typeof url !== 'string') return 0;
  4674. if (!/^data:/i.test(url)) return 0;
  4675. var comma = url.indexOf(',');
  4676. if (comma < 0) return 0;
  4677. var meta = url.slice(5, comma);
  4678. var body = url.slice(comma + 1);
  4679. var isBase64 = base64Pattern.test(meta);
  4680. if (isBase64) {
  4681. return estimateBase64(body);
  4682. }
  4683. // Compute UTF-8 byte length directly from UTF-16 code units without allocating
  4684. // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
  4685. // Valid %XX triplets count as one decoded byte; this matches the bytes that
  4686. // decodeURIComponent(body) would produce before Buffer re-encodes the string.
  4687. var bytes = 0;
  4688. for (var i = 0, len = body.length; i < len; i++) {
  4689. var c = body.charCodeAt(i);
  4690. if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
  4691. bytes += 1;
  4692. i += 2;
  4693. } else if (c < 0x80) {
  4694. bytes += 1;
  4695. } else if (c < 0x800) {
  4696. bytes += 2;
  4697. } else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
  4698. var next = body.charCodeAt(i + 1);
  4699. if (next >= 0xdc00 && next <= 0xdfff) {
  4700. bytes += 4;
  4701. i++;
  4702. } else {
  4703. bytes += 3;
  4704. }
  4705. } else {
  4706. bytes += 3;
  4707. }
  4708. }
  4709. return bytes;
  4710. };
  4711. /**
  4712. * Estimate the percent-decoded payload size used by Fetch data: URLs.
  4713. *
  4714. * @param {string} url
  4715. * @returns {number}
  4716. */
  4717. function estimateDataURLDecodedBytes(url) {
  4718. // Fetch removes URL fragments before processing a data: URL.
  4719. var fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
  4720. return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes, /; *base64[\t\n\f\r ]*$/i);
  4721. }
  4722. var VERSION = "1.21.1";
  4723. var DEFAULT_CHUNK_SIZE = 64 * 1024;
  4724. var DEFAULT_REQUEST_OPTIONS = {
  4725. cache: 'default',
  4726. redirect: 'follow',
  4727. referrer: 'about:client',
  4728. referrerPolicy: '',
  4729. mode: 'cors',
  4730. integrity: '',
  4731. keepalive: false,
  4732. priority: 'auto',
  4733. window: null
  4734. };
  4735. var isFunction = utils$1.isFunction;
  4736. /**
  4737. * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
  4738. * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
  4739. *
  4740. * @param {string} str The string to encode
  4741. *
  4742. * @returns {string} UTF-8 bytes as a Latin-1 string
  4743. */
  4744. var encodeUTF8 = function encodeUTF8(str) {
  4745. return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
  4746. return String.fromCharCode(parseInt(hex, 16));
  4747. });
  4748. };
  4749. // Node's WHATWG URL parser returns `username` and `password` percent-encoded.
  4750. // Decode before composing the `auth` option so credentials such as
  4751. // `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
  4752. // original value for malformed input so a bad encoding never throws.
  4753. var decodeURIComponentSafe = function decodeURIComponentSafe(value) {
  4754. if (!utils$1.isString(value)) {
  4755. return value;
  4756. }
  4757. try {
  4758. return decodeURIComponent(value);
  4759. } catch (error) {
  4760. return value;
  4761. }
  4762. };
  4763. var test = function test(fn) {
  4764. try {
  4765. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  4766. args[_key - 1] = arguments[_key];
  4767. }
  4768. return !!fn.apply(void 0, args);
  4769. } catch (e) {
  4770. return false;
  4771. }
  4772. };
  4773. var maybeWithAuthCredentials = function maybeWithAuthCredentials(url) {
  4774. var protocolIndex = url.indexOf('://');
  4775. var urlToCheck = url;
  4776. if (protocolIndex !== -1) {
  4777. urlToCheck = urlToCheck.slice(protocolIndex + 3);
  4778. }
  4779. return urlToCheck.includes('@') || urlToCheck.includes(':');
  4780. };
  4781. var factory = function factory(env) {
  4782. var globalObject = utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
  4783. var ReadableStream = globalObject.ReadableStream,
  4784. TextEncoder = globalObject.TextEncoder;
  4785. env = utils$1.merge.call({
  4786. skipUndefined: true
  4787. }, {
  4788. Request: globalObject.Request,
  4789. Response: globalObject.Response,
  4790. Blob: globalObject.Blob
  4791. }, env);
  4792. var envFetch = utils$1.hasOwnProp(env, 'fetch') ? env.fetch : undefined;
  4793. var _env = env,
  4794. Request = _env.Request,
  4795. Response = _env.Response,
  4796. Blob = _env.Blob;
  4797. var isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
  4798. var isRequestSupported = isFunction(Request);
  4799. var isResponseSupported = isFunction(Response);
  4800. if (!isFetchSupported) {
  4801. return false;
  4802. }
  4803. var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
  4804. var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
  4805. return function (str) {
  4806. return encoder.encode(str);
  4807. };
  4808. }(new TextEncoder()) : (/*#__PURE__*/function () {
  4809. var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
  4810. var _t, _t2;
  4811. return _regenerator().w(function (_context) {
  4812. while (1) switch (_context.n) {
  4813. case 0:
  4814. _t = Uint8Array;
  4815. _context.n = 1;
  4816. return new Request(str).arrayBuffer();
  4817. case 1:
  4818. _t2 = _context.v;
  4819. return _context.a(2, new _t(_t2));
  4820. }
  4821. }, _callee);
  4822. }));
  4823. return function (_x) {
  4824. return _ref.apply(this, arguments);
  4825. };
  4826. }()));
  4827. var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
  4828. var duplexAccessed = false;
  4829. var request = new Request(platform.origin, {
  4830. body: new ReadableStream(),
  4831. method: 'POST',
  4832. get duplex() {
  4833. duplexAccessed = true;
  4834. return 'half';
  4835. }
  4836. });
  4837. var hasContentType = request.headers.has('Content-Type');
  4838. if (request.body != null) {
  4839. request.body.cancel();
  4840. }
  4841. return duplexAccessed && !hasContentType;
  4842. });
  4843. var supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(function () {
  4844. return utils$1.isReadableStream(new Response('').body);
  4845. });
  4846. // Some runtimes reject every explicit cache mode. Use own defaults for both
  4847. // probes so unrelated polluted options cannot affect cache-mode detection.
  4848. var requestDefaults = Object.assign(Object.create(null), DEFAULT_REQUEST_OPTIONS);
  4849. if (isRequestSupported && !test(function () {
  4850. return new Request(platform.origin, requestDefaults);
  4851. })) {
  4852. delete requestDefaults.cache;
  4853. // Only omit cache when that makes Request construction succeed. Otherwise
  4854. // retain the explicit default that protects supporting runtimes from pollution.
  4855. if (!test(function () {
  4856. return new Request(platform.origin, requestDefaults);
  4857. })) {
  4858. requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
  4859. }
  4860. }
  4861. var resolvers = {
  4862. stream: supportsResponseStream && function (res) {
  4863. return res.body;
  4864. }
  4865. };
  4866. isFetchSupported && function () {
  4867. ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
  4868. !resolvers[type] && (resolvers[type] = function (res, config) {
  4869. var method = res && res[type];
  4870. if (method) {
  4871. return method.call(res);
  4872. }
  4873. throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
  4874. });
  4875. });
  4876. }();
  4877. var getBodyLength = /*#__PURE__*/function () {
  4878. var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
  4879. return _regenerator().w(function (_context2) {
  4880. while (1) switch (_context2.n) {
  4881. case 0:
  4882. if (!(body == null)) {
  4883. _context2.n = 1;
  4884. break;
  4885. }
  4886. return _context2.a(2, 0);
  4887. case 1:
  4888. if (!utils$1.isBlob(body)) {
  4889. _context2.n = 2;
  4890. break;
  4891. }
  4892. return _context2.a(2, body.size);
  4893. case 2:
  4894. if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
  4895. _context2.n = 3;
  4896. break;
  4897. }
  4898. return _context2.a(2, body.byteLength);
  4899. case 3:
  4900. if (utils$1.isURLSearchParams(body)) {
  4901. body = body + '';
  4902. }
  4903. if (!utils$1.isString(body)) {
  4904. _context2.n = 5;
  4905. break;
  4906. }
  4907. _context2.n = 4;
  4908. return encodeText(body);
  4909. case 4:
  4910. return _context2.a(2, _context2.v.byteLength);
  4911. case 5:
  4912. return _context2.a(2);
  4913. }
  4914. }, _callee2);
  4915. }));
  4916. return function getBodyLength(_x2) {
  4917. return _ref2.apply(this, arguments);
  4918. };
  4919. }();
  4920. var resolveBodyLength = /*#__PURE__*/function () {
  4921. var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
  4922. var length;
  4923. return _regenerator().w(function (_context3) {
  4924. while (1) switch (_context3.n) {
  4925. case 0:
  4926. length = utils$1.toFiniteNumber(headers.getContentLength());
  4927. return _context3.a(2, length == null ? getBodyLength(body) : length);
  4928. }
  4929. }, _callee3);
  4930. }));
  4931. return function resolveBodyLength(_x3, _x4) {
  4932. return _ref3.apply(this, arguments);
  4933. };
  4934. }();
  4935. return /*#__PURE__*/function () {
  4936. var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
  4937. var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, maxRedirects, hasMaxContentLength, hasMaxBodyLength, own, _fetch, composedSignal, request, unsubscribe, requestContentLength, pendingBodyError, pendingResponseError, maxBodyLengthError, auth, configAuth, username, password, parsedURL, urlUsername, urlPassword, estimated, formContentType, formBoundary, parameters, outboundLength, mustEnforceStreamBody, trackRequestStream, _request, contentTypeHeader, _ref5, _ref6, onProgress, flush, isCredentialsSupported, contentType, safeFetchOptions, resolvedOptions, response, responseHeaders, declaredLength, isStreamResponse, options, responseContentLength, _ref7, _ref8, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, networkError, _t3, _t4;
  4938. return _regenerator().w(function (_context4) {
  4939. while (1) switch (_context4.p = _context4.n) {
  4940. case 0:
  4941. _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions, maxContentLength = _resolveConfig.maxContentLength, maxBodyLength = _resolveConfig.maxBodyLength, maxRedirects = _resolveConfig.maxRedirects;
  4942. hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
  4943. hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
  4944. own = function own(key) {
  4945. return utils$1.hasOwnProp(config, key) ? config[key] : undefined;
  4946. };
  4947. _fetch = envFetch || fetch;
  4948. responseType = responseType ? (responseType + '').toLowerCase() : 'text';
  4949. composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
  4950. request = null;
  4951. unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
  4952. composedSignal.unsubscribe();
  4953. };
  4954. // AxiosErrors we raise while request or response bodies are being streamed. Captured
  4955. // by identity so the catch block can surface it directly, regardless of
  4956. // how the runtime wraps the resulting fetch rejection (undici exposes it
  4957. // as `err.cause`; some browsers drop the original error entirely).
  4958. pendingBodyError = null;
  4959. pendingResponseError = null;
  4960. maxBodyLengthError = function maxBodyLengthError() {
  4961. return new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
  4962. };
  4963. _context4.p = 1;
  4964. // HTTP basic authentication
  4965. auth = undefined;
  4966. configAuth = own('auth');
  4967. if (configAuth) {
  4968. username = utils$1.getSafeProp(configAuth, 'username') || '';
  4969. password = utils$1.getSafeProp(configAuth, 'password') || '';
  4970. auth = {
  4971. username: username,
  4972. password: password
  4973. };
  4974. }
  4975. if (maybeWithAuthCredentials(url)) {
  4976. parsedURL = new URL(url, platform.origin);
  4977. if (!auth && (parsedURL.username || parsedURL.password)) {
  4978. urlUsername = decodeURIComponentSafe(parsedURL.username);
  4979. urlPassword = decodeURIComponentSafe(parsedURL.password);
  4980. auth = {
  4981. username: urlUsername,
  4982. password: urlPassword
  4983. };
  4984. }
  4985. if (parsedURL.username || parsedURL.password) {
  4986. parsedURL.username = '';
  4987. parsedURL.password = '';
  4988. url = parsedURL.href;
  4989. }
  4990. }
  4991. if (auth) {
  4992. headers["delete"]('authorization');
  4993. headers.set('Authorization', 'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || ''))));
  4994. }
  4995. // Enforce maxContentLength for data: URLs up-front so we never materialize
  4996. // an oversized payload. The HTTP adapter applies the same check (see http.js
  4997. // "if (protocol === 'data:')" branch).
  4998. if (!(hasMaxContentLength && parsedURL && parsedURL.protocol === 'data:')) {
  4999. _context4.n = 2;
  5000. break;
  5001. }
  5002. estimated = estimateDataURLDecodedBytes(parsedURL.href);
  5003. if (!(estimated > maxContentLength)) {
  5004. _context4.n = 2;
  5005. break;
  5006. }
  5007. throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
  5008. case 2:
  5009. formContentType = utils$1.isSpecCompliantForm(data) && AxiosHeaders.from(own('headers')).getContentType();
  5010. if (utils$1.isString(formContentType) && /^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())) {
  5011. parameters = AxiosHeaders.parseParameters(formContentType);
  5012. if (utils$1.hasOwnProp(parameters, 'boundary')) formBoundary = parameters.boundary;
  5013. }
  5014. if (utils$1.isSpecCompliantForm(data) && method !== 'get' && method !== 'head' && (hasMaxBodyLength || onUploadProgress && supportsRequestStream || formBoundary !== undefined)) {
  5015. data = createMultipartBody(data, Blob, hasMaxBodyLength ? maxBodyLength : Infinity, maxBodyLengthError, formBoundary);
  5016. // Blob.type lowercases its value, including a case-sensitive boundary.
  5017. // Retain the caller's header when an explicit boundary was serialized.
  5018. headers.setContentType(formBoundary === undefined ? data.type : formContentType);
  5019. requestContentLength = data.size;
  5020. }
  5021. // Enforce maxBodyLength against known-size bodies before dispatch using
  5022. // the body's *actual* size — never a caller-declared Content-Length,
  5023. // which could under-report to slip an oversized body past the check.
  5024. // Unknown-size streams return undefined here and are counted per-chunk
  5025. // below as fetch consumes them.
  5026. if (!(hasMaxBodyLength && method !== 'get' && method !== 'head')) {
  5027. _context4.n = 4;
  5028. break;
  5029. }
  5030. _context4.n = 3;
  5031. return getBodyLength(data);
  5032. case 3:
  5033. outboundLength = _context4.v;
  5034. if (!(typeof outboundLength === 'number' && isFinite(outboundLength))) {
  5035. _context4.n = 4;
  5036. break;
  5037. }
  5038. requestContentLength = outboundLength;
  5039. if (!(outboundLength > maxBodyLength)) {
  5040. _context4.n = 4;
  5041. break;
  5042. }
  5043. throw maxBodyLengthError();
  5044. case 4:
  5045. // A streamed body under maxBodyLength must be counted as fetch consumes
  5046. // it; its size is never trusted from a caller-declared Content-Length.
  5047. mustEnforceStreamBody = hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
  5048. trackRequestStream = function trackRequestStream(stream, onProgress, flush) {
  5049. return trackStream(stream, DEFAULT_CHUNK_SIZE, function (loadedBytes) {
  5050. if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
  5051. throw pendingBodyError = maxBodyLengthError();
  5052. }
  5053. onProgress && onProgress(loadedBytes);
  5054. }, flush);
  5055. };
  5056. if (!(supportsRequestStream && method !== 'get' && method !== 'head' && (onUploadProgress || mustEnforceStreamBody))) {
  5057. _context4.n = 8;
  5058. break;
  5059. }
  5060. if (!(requestContentLength == null)) {
  5061. _context4.n = 6;
  5062. break;
  5063. }
  5064. _context4.n = 5;
  5065. return resolveBodyLength(headers, data);
  5066. case 5:
  5067. _t3 = _context4.v;
  5068. _context4.n = 7;
  5069. break;
  5070. case 6:
  5071. _t3 = requestContentLength;
  5072. case 7:
  5073. requestContentLength = _t3;
  5074. // A declared length of 0 is only trusted to skip the wrap when we are
  5075. // not enforcing a stream limit (which must not rely on that header).
  5076. if (requestContentLength !== 0 || mustEnforceStreamBody) {
  5077. _request = new Request(url, {
  5078. method: 'POST',
  5079. body: data,
  5080. duplex: 'half'
  5081. });
  5082. if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
  5083. headers.setContentType(contentTypeHeader);
  5084. }
  5085. if (_request.body) {
  5086. _ref5 = onUploadProgress && progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))) || [], _ref6 = _slicedToArray(_ref5, 2), onProgress = _ref6[0], flush = _ref6[1];
  5087. data = trackRequestStream(_request.body, onProgress, flush);
  5088. }
  5089. }
  5090. _context4.n = 10;
  5091. break;
  5092. case 8:
  5093. if (!(mustEnforceStreamBody && !isRequestSupported && isReadableStreamSupported && method !== 'get' && method !== 'head')) {
  5094. _context4.n = 9;
  5095. break;
  5096. }
  5097. data = trackRequestStream(data);
  5098. _context4.n = 10;
  5099. break;
  5100. case 9:
  5101. if (!(mustEnforceStreamBody && isRequestSupported && !supportsRequestStream && method !== 'get' && method !== 'head')) {
  5102. _context4.n = 10;
  5103. break;
  5104. }
  5105. throw new AxiosError('Stream request bodies are not supported by the current fetch implementation', AxiosError.ERR_NOT_SUPPORT, config, request);
  5106. case 10:
  5107. if (!utils$1.isString(withCredentials)) {
  5108. withCredentials = withCredentials ? 'include' : 'omit';
  5109. }
  5110. // Cloudflare Workers throws when credentials are defined
  5111. // see https://github.com/cloudflare/workerd/issues/902
  5112. isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype; // If data is FormData and Content-Type is multipart/form-data without boundary,
  5113. // delete it so fetch can set it correctly with the boundary
  5114. if (utils$1.isFormData(data)) {
  5115. contentType = headers.getContentType();
  5116. if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
  5117. headers["delete"]('content-type');
  5118. }
  5119. }
  5120. // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
  5121. headers.set('User-Agent', 'axios/' + VERSION, false);
  5122. safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(Object.create(null), fetchOptions);
  5123. if (safeFetchOptions) {
  5124. // These options are owned by Axios and are already reflected in the
  5125. // resolved Request passed to fetch.
  5126. delete safeFetchOptions.body;
  5127. delete safeFetchOptions.headers;
  5128. delete safeFetchOptions.method;
  5129. delete safeFetchOptions.signal;
  5130. delete safeFetchOptions.duplex;
  5131. delete safeFetchOptions.credentials;
  5132. }
  5133. resolvedOptions = Object.assign(Object.create(null), safeFetchOptions, {
  5134. signal: composedSignal,
  5135. method: method.toUpperCase(),
  5136. headers: toByteStringHeaderObject(headers.normalize()),
  5137. body: data,
  5138. duplex: 'half',
  5139. credentials: isCredentialsSupported ? withCredentials : undefined
  5140. });
  5141. if (isRequestSupported) {
  5142. utils$1.forEach(requestDefaults, function (value, key) {
  5143. if (resolvedOptions[key] === undefined) {
  5144. resolvedOptions[key] = value;
  5145. }
  5146. });
  5147. if (resolvedOptions.signal === undefined) {
  5148. resolvedOptions.signal = null;
  5149. }
  5150. if (resolvedOptions.body === undefined) {
  5151. resolvedOptions.body = null;
  5152. }
  5153. }
  5154. if (maxRedirects === 0) {
  5155. resolvedOptions.redirect = 'manual';
  5156. if (safeFetchOptions) {
  5157. safeFetchOptions.redirect = 'manual';
  5158. }
  5159. }
  5160. request = isRequestSupported && new Request(url, resolvedOptions);
  5161. _context4.n = 11;
  5162. return isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url, resolvedOptions);
  5163. case 11:
  5164. response = _context4.v;
  5165. responseHeaders = AxiosHeaders.from(response.headers); // Cheap pre-check: if the server honestly declares a content-length that
  5166. // already exceeds the cap, reject before we start streaming.
  5167. if (!hasMaxContentLength) {
  5168. _context4.n = 12;
  5169. break;
  5170. }
  5171. declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
  5172. if (!(declaredLength != null && declaredLength > maxContentLength)) {
  5173. _context4.n = 12;
  5174. break;
  5175. }
  5176. throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
  5177. case 12:
  5178. isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
  5179. if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
  5180. options = {};
  5181. ['status', 'statusText', 'headers'].forEach(function (prop) {
  5182. options[prop] = response[prop];
  5183. });
  5184. responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
  5185. _ref7 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref8 = _slicedToArray(_ref7, 2), _onProgress = _ref8[0], _flush = _ref8[1];
  5186. bytesRead = 0;
  5187. onChunkProgress = function onChunkProgress(loadedBytes) {
  5188. if (hasMaxContentLength) {
  5189. bytesRead = loadedBytes;
  5190. if (bytesRead > maxContentLength) {
  5191. throw pendingResponseError = new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
  5192. }
  5193. }
  5194. _onProgress && _onProgress(loadedBytes);
  5195. };
  5196. response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, function () {
  5197. _flush && _flush();
  5198. unsubscribe && unsubscribe();
  5199. }), options);
  5200. }
  5201. responseType = responseType || 'text';
  5202. _context4.n = 13;
  5203. return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
  5204. case 13:
  5205. responseData = _context4.v;
  5206. if (!(hasMaxContentLength && !supportsResponseStream && !isStreamResponse)) {
  5207. _context4.n = 14;
  5208. break;
  5209. }
  5210. if (responseData != null) {
  5211. if (typeof responseData.byteLength === 'number') {
  5212. materializedSize = responseData.byteLength;
  5213. } else if (typeof responseData.size === 'number') {
  5214. materializedSize = responseData.size;
  5215. } else if (typeof responseData === 'string') {
  5216. materializedSize = typeof TextEncoder === 'function' ? new TextEncoder().encode(responseData).byteLength : responseData.length;
  5217. }
  5218. }
  5219. if (!(typeof materializedSize === 'number' && materializedSize > maxContentLength)) {
  5220. _context4.n = 14;
  5221. break;
  5222. }
  5223. throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
  5224. case 14:
  5225. !isStreamResponse && unsubscribe && unsubscribe();
  5226. _context4.n = 15;
  5227. return new Promise(function (resolve, reject) {
  5228. settle(resolve, reject, {
  5229. data: responseData,
  5230. headers: AxiosHeaders.from(response.headers),
  5231. status: response.status,
  5232. statusText: response.statusText,
  5233. config: config,
  5234. request: request
  5235. });
  5236. });
  5237. case 15:
  5238. return _context4.a(2, _context4.v);
  5239. case 16:
  5240. _context4.p = 16;
  5241. _t4 = _context4.v;
  5242. unsubscribe && unsubscribe();
  5243. // Safari can surface fetch aborts as a DOMException-like object whose
  5244. // branded getters throw. Prefer our composed signal reason before reading
  5245. // the caught error, preserving timeout vs cancellation semantics.
  5246. if (!(composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError)) {
  5247. _context4.n = 17;
  5248. break;
  5249. }
  5250. canceledError = composedSignal.reason;
  5251. canceledError.config = config;
  5252. request && (canceledError.request = request);
  5253. if (_t4 !== canceledError) {
  5254. // Non-enumerable to match native Error `cause` semantics so loggers
  5255. // don't recurse into circular fetch internals (see #7205).
  5256. Object.defineProperty(canceledError, 'cause', {
  5257. __proto__: null,
  5258. value: _t4,
  5259. writable: true,
  5260. enumerable: false,
  5261. configurable: true
  5262. });
  5263. }
  5264. throw canceledError;
  5265. case 17:
  5266. if (!pendingBodyError) {
  5267. _context4.n = 18;
  5268. break;
  5269. }
  5270. request && !pendingBodyError.request && (pendingBodyError.request = request);
  5271. throw pendingBodyError;
  5272. case 18:
  5273. if (!pendingResponseError) {
  5274. _context4.n = 19;
  5275. break;
  5276. }
  5277. throw pendingResponseError;
  5278. case 19:
  5279. if (!(_t4 instanceof AxiosError)) {
  5280. _context4.n = 20;
  5281. break;
  5282. }
  5283. request && !_t4.request && (_t4.request = request);
  5284. throw _t4;
  5285. case 20:
  5286. if (!(_t4 && _t4.name === 'TypeError' && /Load failed|fetch/i.test(_t4.message))) {
  5287. _context4.n = 21;
  5288. break;
  5289. }
  5290. networkError = new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t4 && _t4.response); // Non-enumerable to match native Error `cause` semantics so loggers
  5291. // don't recurse into circular fetch internals (see #7205).
  5292. Object.defineProperty(networkError, 'cause', {
  5293. __proto__: null,
  5294. value: _t4.cause || _t4,
  5295. writable: true,
  5296. enumerable: false,
  5297. configurable: true
  5298. });
  5299. throw networkError;
  5300. case 21:
  5301. throw AxiosError.from(_t4, _t4 && _t4.code, config, request, _t4 && _t4.response);
  5302. case 22:
  5303. return _context4.a(2);
  5304. }
  5305. }, _callee4, null, [[1, 16]]);
  5306. }));
  5307. return function (_x5) {
  5308. return _ref4.apply(this, arguments);
  5309. };
  5310. }();
  5311. };
  5312. var seedCache = new Map();
  5313. var getFetch = function getFetch(config) {
  5314. var env = Object.create(null);
  5315. var configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
  5316. ['fetch', 'Request', 'Response', 'Blob'].forEach(function (key) {
  5317. if (configuredEnv && utils$1.hasOwnProp(configuredEnv, key)) {
  5318. env[key] = configuredEnv[key];
  5319. }
  5320. });
  5321. var fetch = env.fetch,
  5322. Request = env.Request,
  5323. Response = env.Response,
  5324. Blob = env.Blob;
  5325. var seeds = [Request, Response, fetch, Blob];
  5326. var len = seeds.length,
  5327. i = len,
  5328. seed,
  5329. target,
  5330. map = seedCache;
  5331. while (i--) {
  5332. seed = seeds[i];
  5333. target = map.get(seed);
  5334. target === undefined && map.set(seed, target = i ? new Map() : factory(env));
  5335. map = target;
  5336. }
  5337. return target;
  5338. };
  5339. getFetch();
  5340. /**
  5341. * Known adapters mapping.
  5342. * Provides environment-specific adapters for Axios:
  5343. * - `http` for Node.js
  5344. * - `xhr` for browsers
  5345. * - `fetch` for fetch API-based requests
  5346. *
  5347. * @type {Object<string, Function|Object>}
  5348. */
  5349. var knownAdapters = {
  5350. http: httpAdapter,
  5351. xhr: xhrAdapter,
  5352. fetch: {
  5353. get: getFetch
  5354. }
  5355. };
  5356. // Assign adapter names for easier debugging and identification
  5357. utils$1.forEach(knownAdapters, function (fn, value) {
  5358. if (fn) {
  5359. try {
  5360. // Null-proto descriptors so a polluted Object.prototype.get cannot turn
  5361. // these data descriptors into accessor descriptors on the way in.
  5362. Object.defineProperty(fn, 'name', {
  5363. __proto__: null,
  5364. value: value
  5365. });
  5366. } catch (e) {
  5367. // eslint-disable-next-line no-empty
  5368. }
  5369. Object.defineProperty(fn, 'adapterName', {
  5370. __proto__: null,
  5371. value: value
  5372. });
  5373. }
  5374. });
  5375. /**
  5376. * Render a rejection reason string for unknown or unsupported adapters
  5377. *
  5378. * @param {string} reason
  5379. * @returns {string}
  5380. */
  5381. var renderReason = function renderReason(reason) {
  5382. return "- ".concat(reason);
  5383. };
  5384. /**
  5385. * Check if the adapter is resolved (function, null, or false)
  5386. *
  5387. * @param {Function|null|false} adapter
  5388. * @returns {boolean}
  5389. */
  5390. var isResolvedHandle = function isResolvedHandle(adapter) {
  5391. return utils$1.isFunction(adapter) || adapter === null || adapter === false;
  5392. };
  5393. /**
  5394. * Get the first suitable adapter from the provided list.
  5395. * Tries each adapter in order until a supported one is found.
  5396. * Throws an AxiosError if no adapter is suitable.
  5397. *
  5398. * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
  5399. * @param {Object} config - Axios request configuration
  5400. * @throws {AxiosError} If no suitable adapter is available
  5401. * @returns {Function} The resolved adapter function
  5402. */
  5403. function getAdapter(adapters, config) {
  5404. adapters = utils$1.isArray(adapters) ? adapters : [adapters];
  5405. var _adapters = adapters,
  5406. length = _adapters.length;
  5407. var nameOrAdapter;
  5408. var adapter;
  5409. var rejectedReasons = {};
  5410. for (var i = 0; i < length; i++) {
  5411. nameOrAdapter = adapters[i];
  5412. var id = void 0;
  5413. adapter = nameOrAdapter;
  5414. if (!isResolvedHandle(nameOrAdapter)) {
  5415. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  5416. if (adapter === undefined) {
  5417. throw new AxiosError("Unknown adapter '".concat(id, "'"));
  5418. }
  5419. }
  5420. if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
  5421. break;
  5422. }
  5423. rejectedReasons[id || '#' + i] = adapter;
  5424. }
  5425. if (!adapter) {
  5426. var reasons = Object.entries(rejectedReasons).map(function (_ref) {
  5427. var _ref2 = _slicedToArray(_ref, 2),
  5428. id = _ref2[0],
  5429. state = _ref2[1];
  5430. return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
  5431. });
  5432. var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
  5433. throw new AxiosError("There is no suitable adapter to dispatch the request " + s, AxiosError.ERR_NOT_SUPPORT);
  5434. }
  5435. return adapter;
  5436. }
  5437. /**
  5438. * Exports Axios adapters and utility to resolve an adapter
  5439. */
  5440. var adapters = {
  5441. /**
  5442. * Resolve an adapter from a list of adapter names or functions.
  5443. * @type {Function}
  5444. */
  5445. getAdapter: getAdapter,
  5446. /**
  5447. * Exposes all known adapters
  5448. * @type {Object<string, Function|Object>}
  5449. */
  5450. adapters: knownAdapters
  5451. };
  5452. /**
  5453. * Throws a `CanceledError` if cancellation has been requested.
  5454. *
  5455. * @param {Object} config The config that is to be used for the request
  5456. *
  5457. * @returns {void}
  5458. */
  5459. function throwIfCancellationRequested(config) {
  5460. if (config.cancelToken) {
  5461. config.cancelToken.throwIfRequested();
  5462. }
  5463. if (config.signal && config.signal.aborted) {
  5464. throw new CanceledError(null, config);
  5465. }
  5466. }
  5467. /**
  5468. * Resolve the clock used to time adapter execution.
  5469. *
  5470. * Prefers the monotonic `performance.now()` so wall-clock adjustments do not
  5471. * skew the measurement, and so frameworks that forbid reading the current
  5472. * time during prerendering (e.g. Next.js Cache Components) accept it. Falls
  5473. * back to `Date.now()` in runtimes without the High Resolution Time API.
  5474. *
  5475. * @returns {() => number} Millisecond clock
  5476. */
  5477. function resolveClock() {
  5478. return typeof performance !== 'undefined' && utils$1.isFunction(performance.now) ? function () {
  5479. return performance.now();
  5480. } : Date.now;
  5481. }
  5482. /**
  5483. * Whole milliseconds elapsed since `start`, floored at zero.
  5484. *
  5485. * Rounded so the value stays an integer as with `Date.now()`. The fallback
  5486. * wall clock can move backwards mid-request, so the result is clamped.
  5487. *
  5488. * @param {() => number} now Clock returned by `resolveClock()`
  5489. * @param {number} start Timestamp read from `now`
  5490. *
  5491. * @returns {number} Non-negative elapsed milliseconds
  5492. */
  5493. function elapsedSince(now, start) {
  5494. return Math.max(0, Math.round(now() - start));
  5495. }
  5496. /**
  5497. * Dispatch a request to the server using the configured adapter.
  5498. *
  5499. * @param {object} config The config that is to be used for the request
  5500. *
  5501. * @returns {Promise} The Promise to be fulfilled
  5502. */
  5503. function dispatchRequest(_config) {
  5504. // Interceptors may replace the merged config with an ordinary object. Flatten
  5505. // it at the dispatch boundary so shared prototype members cannot become
  5506. // request behavior, while preserving intentional template/class members.
  5507. var config = utils$1.toSafeFlatObject(_config);
  5508. throwIfCancellationRequested(config);
  5509. config.headers = AxiosHeaders.from(utils$1.getSafeProp(config, 'headers'));
  5510. // Transform request data
  5511. config.data = transformData.call(config, config.transformRequest);
  5512. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  5513. config.headers.setContentType('application/x-www-form-urlencoded', false);
  5514. }
  5515. var adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
  5516. var now = resolveClock();
  5517. var start = now();
  5518. return adapter(config).then(function onAdapterResolution(response) {
  5519. throwIfCancellationRequested(config);
  5520. response.duration = elapsedSince(now, start);
  5521. // Expose the current response on config so that transformResponse can
  5522. // attach it to any AxiosError it throws (e.g. on JSON parse failure).
  5523. // We clean it up afterwards to avoid polluting the config object.
  5524. config.response = response;
  5525. try {
  5526. response.data = transformData.call(config, config.transformResponse, response);
  5527. } finally {
  5528. delete config.response;
  5529. }
  5530. response.headers = AxiosHeaders.from(response.headers);
  5531. return response;
  5532. }, function onAdapterRejection(reason) {
  5533. if (!isCancel(reason)) {
  5534. throwIfCancellationRequested(config);
  5535. // Transform response data
  5536. if (reason && reason.response) {
  5537. reason.response.duration = elapsedSince(now, start);
  5538. config.response = reason.response;
  5539. try {
  5540. reason.response.data = transformData.call(config, config.transformResponse, reason.response);
  5541. } finally {
  5542. delete config.response;
  5543. }
  5544. reason.response.headers = AxiosHeaders.from(reason.response.headers);
  5545. }
  5546. }
  5547. return Promise.reject(reason);
  5548. });
  5549. }
  5550. var validators$1 = {};
  5551. // eslint-disable-next-line func-names
  5552. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
  5553. validators$1[type] = function validator(thing) {
  5554. return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  5555. };
  5556. });
  5557. var deprecatedWarnings = {};
  5558. /**
  5559. * Transitional option validator
  5560. *
  5561. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  5562. * @param {string?} version - deprecated version / removed since version
  5563. * @param {string?} message - some message with additional info
  5564. *
  5565. * @returns {function}
  5566. */
  5567. validators$1.transitional = function transitional(validator, version, message) {
  5568. function formatMessage(opt, desc) {
  5569. return '[Axios v' + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? '. ' + message : '');
  5570. }
  5571. // eslint-disable-next-line func-names
  5572. return function (value, opt, opts) {
  5573. if (validator === false) {
  5574. throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
  5575. }
  5576. if (version && !deprecatedWarnings[opt]) {
  5577. deprecatedWarnings[opt] = true;
  5578. // eslint-disable-next-line no-console
  5579. console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
  5580. }
  5581. return validator ? validator(value, opt, opts) : true;
  5582. };
  5583. };
  5584. validators$1.spelling = function spelling(correctSpelling) {
  5585. return function (value, opt) {
  5586. // eslint-disable-next-line no-console
  5587. console.warn("".concat(opt, " is likely a misspelling of ").concat(correctSpelling));
  5588. return true;
  5589. };
  5590. };
  5591. /**
  5592. * Assert object's properties type
  5593. *
  5594. * @param {object} options
  5595. * @param {object} schema
  5596. * @param {boolean?} allowUnknown
  5597. *
  5598. * @returns {object}
  5599. */
  5600. function assertOptions(options, schema, allowUnknown) {
  5601. if (_typeof(options) !== 'object' || options === null) {
  5602. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  5603. }
  5604. var keys = Object.keys(options);
  5605. var i = keys.length;
  5606. while (i-- > 0) {
  5607. var opt = keys[i];
  5608. // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
  5609. // a non-function validator and cause a TypeError.
  5610. var validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
  5611. if (validator) {
  5612. var value = options[opt];
  5613. var result = value === undefined || validator(value, opt, options);
  5614. if (result !== true) {
  5615. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  5616. }
  5617. continue;
  5618. }
  5619. if (allowUnknown !== true) {
  5620. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  5621. }
  5622. }
  5623. }
  5624. var validator = {
  5625. assertOptions: assertOptions,
  5626. validators: validators$1
  5627. };
  5628. var validators = validator.validators;
  5629. // Recognize header maps without consuming objects intended as literal values.
  5630. // AxiosHeaders from other builds share a brand and header-container interface,
  5631. // but not constructor identity. A tag and toJSON alone can describe a literal.
  5632. var isHeadersBucket = function isHeadersBucket(value) {
  5633. if (value == null || utils$1.isPlainObject(value) || value instanceof AxiosHeaders) {
  5634. return true;
  5635. }
  5636. try {
  5637. return utils$1.isObject(value) && utils$1.getSafeProp(value, Symbol.toStringTag) === 'AxiosHeaders' && ['toJSON', 'set', 'get', 'has', 'delete', 'clear', 'normalize', 'concat', 'toString', Symbol.iterator].every(function (method) {
  5638. return utils$1.isFunction(utils$1.getSafeProp(value, method));
  5639. });
  5640. } catch (e) {
  5641. // A failed optional brand probe must not prevent literal header serialization.
  5642. return false;
  5643. }
  5644. };
  5645. /**
  5646. * Create a new instance of Axios
  5647. *
  5648. * @param {Object} instanceConfig The default config for the instance
  5649. *
  5650. * @return {Axios} A new instance of Axios
  5651. */
  5652. var Axios = /*#__PURE__*/function () {
  5653. function Axios(instanceConfig) {
  5654. _classCallCheck(this, Axios);
  5655. this.defaults = instanceConfig || {};
  5656. this.interceptors = {
  5657. request: new InterceptorManager(),
  5658. response: new InterceptorManager()
  5659. };
  5660. }
  5661. /**
  5662. * Dispatch a request
  5663. *
  5664. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  5665. * @param {?Object} config
  5666. *
  5667. * @returns {Promise} The Promise to be fulfilled
  5668. */
  5669. return _createClass(Axios, [{
  5670. key: "request",
  5671. value: (function () {
  5672. var _request2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configOrUrl, config) {
  5673. var dummy, dummyStack, stack, firstNewlineIndex, _firstNewlineIndex, secondNewlineIndex, duplicateCheckSuffix, currentStack, causeIndex, stackHead, causeSection, _t;
  5674. return _regenerator().w(function (_context) {
  5675. while (1) switch (_context.p = _context.n) {
  5676. case 0:
  5677. _context.p = 0;
  5678. _context.n = 1;
  5679. return this._request(configOrUrl, config);
  5680. case 1:
  5681. return _context.a(2, _context.v);
  5682. case 2:
  5683. _context.p = 2;
  5684. _t = _context.v;
  5685. if (_t instanceof Error) {
  5686. try {
  5687. dummy = {};
  5688. Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
  5689. dummyStack = dummy.stack;
  5690. stack = ''; // slice off the Error: ... line
  5691. if (typeof dummyStack === 'string') {
  5692. firstNewlineIndex = dummyStack.indexOf('\n');
  5693. stack = firstNewlineIndex === -1 ? '' : dummyStack.slice(firstNewlineIndex + 1);
  5694. }
  5695. if (!_t.stack) {
  5696. _t.stack = stack;
  5697. } else if (stack) {
  5698. // Match a common suffix after the 2 top frames when available,
  5699. // otherwise compare the full reconstructed stack.
  5700. _firstNewlineIndex = stack.indexOf('\n');
  5701. secondNewlineIndex = _firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', _firstNewlineIndex + 1);
  5702. duplicateCheckSuffix = secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1); // `AxiosError.from()` may have already inlined the wrapped error's
  5703. // stack under a `Caused by:` marker. Keep the reconstructed caller
  5704. // frames ahead of that marker so stack-only reporters do not read
  5705. // them as part of the low-level cause.
  5706. currentStack = String(_t.stack);
  5707. causeIndex = getCauseStackIndex(_t, currentStack);
  5708. stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
  5709. causeSection = causeIndex === -1 ? '' : currentStack.slice(causeIndex);
  5710. if (!stackHead.endsWith(duplicateCheckSuffix)) {
  5711. _t.stack = stackHead + '\n' + stack + causeSection;
  5712. }
  5713. }
  5714. } catch (e) {
  5715. // Ignore failures from custom stack hooks or un-writable stack properties.
  5716. }
  5717. }
  5718. throw _t;
  5719. case 3:
  5720. return _context.a(2);
  5721. }
  5722. }, _callee, this, [[0, 2]]);
  5723. }));
  5724. function request(_x, _x2) {
  5725. return _request2.apply(this, arguments);
  5726. }
  5727. return request;
  5728. }())
  5729. }, {
  5730. key: "_request",
  5731. value: function _request(configOrUrl, config) {
  5732. var _this = this;
  5733. /*eslint no-param-reassign:0*/
  5734. // Allow for axios('example/url'[, config]) a la fetch API
  5735. if (typeof configOrUrl === 'string') {
  5736. config = config || {};
  5737. config.url = configOrUrl;
  5738. } else {
  5739. config = configOrUrl || {};
  5740. }
  5741. config = mergeConfig(this.defaults, config);
  5742. var _config = config,
  5743. transitional = _config.transitional,
  5744. paramsSerializer = _config.paramsSerializer,
  5745. headers = _config.headers;
  5746. if (transitional !== undefined) {
  5747. validator.assertOptions(transitional, {
  5748. silentJSONParsing: validators.transitional(validators["boolean"]),
  5749. forcedJSONParsing: validators.transitional(validators["boolean"]),
  5750. clarifyTimeoutError: validators.transitional(validators["boolean"]),
  5751. legacyInterceptorReqResOrdering: validators.transitional(validators["boolean"]),
  5752. advertiseZstdAcceptEncoding: validators.transitional(validators["boolean"]),
  5753. validateStatusUndefinedResolves: validators.transitional(validators["boolean"]),
  5754. encodeBasicAuthUsername: validators.transitional(validators["boolean"])
  5755. }, false);
  5756. }
  5757. if (paramsSerializer != null) {
  5758. if (utils$1.isFunction(paramsSerializer)) {
  5759. config.paramsSerializer = {
  5760. serialize: paramsSerializer
  5761. };
  5762. } else {
  5763. validator.assertOptions(paramsSerializer, {
  5764. encode: validators["function"],
  5765. serialize: validators["function"]
  5766. }, true);
  5767. }
  5768. }
  5769. // Set config.allowAbsoluteUrls
  5770. if (config.allowAbsoluteUrls !== undefined) ; else if (utils$1.hasOwnProp(this.defaults, 'allowAbsoluteUrls') && this.defaults.allowAbsoluteUrls !== undefined) {
  5771. config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
  5772. } else {
  5773. config.allowAbsoluteUrls = true;
  5774. }
  5775. validator.assertOptions(config, {
  5776. baseUrl: validators.spelling('baseURL'),
  5777. withXsrfToken: validators.spelling('withXSRFToken')
  5778. }, true);
  5779. // Set config.method
  5780. config.method = (utils$1.getSafeProp(config, 'method') || utils$1.getSafeProp(this.defaults, 'method') || 'get').toLowerCase();
  5781. // Flatten header defaults without consuming literal method-named headers.
  5782. var commonHeaders = utils$1.getSafeProp(headers, 'common');
  5783. var methodHeaders = utils$1.getSafeProp(headers, config.method);
  5784. var contextHeaders = headers && utils$1.merge(isHeadersBucket(commonHeaders) ? commonHeaders : undefined, isHeadersBucket(methodHeaders) ? methodHeaders : undefined);
  5785. headers && utils$1.forEach(methodList.concat('common'), function (method) {
  5786. if (isHeadersBucket(utils$1.getSafeProp(headers, method))) {
  5787. delete headers[method];
  5788. }
  5789. });
  5790. config.headers = AxiosHeaders.concat(contextHeaders, headers);
  5791. // filter out skipped interceptors
  5792. var requestInterceptorChain = [];
  5793. var synchronousRequestInterceptors = true;
  5794. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  5795. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  5796. return;
  5797. }
  5798. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  5799. var transitional = config.transitional || transitionalDefaults;
  5800. var legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
  5801. if (legacyInterceptorReqResOrdering) {
  5802. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  5803. } else {
  5804. requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  5805. }
  5806. });
  5807. var responseInterceptorChain = [];
  5808. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  5809. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  5810. });
  5811. var promise;
  5812. var i = 0;
  5813. var len;
  5814. if (!synchronousRequestInterceptors) {
  5815. var chain = [dispatchRequest.bind(this), undefined];
  5816. chain.unshift.apply(chain, requestInterceptorChain);
  5817. chain.push.apply(chain, responseInterceptorChain);
  5818. len = chain.length;
  5819. promise = Promise.resolve(config);
  5820. while (i < len) {
  5821. promise = promise.then(chain[i++], chain[i++]);
  5822. }
  5823. return promise;
  5824. }
  5825. len = requestInterceptorChain.length;
  5826. var newConfig = config;
  5827. while (i < len) {
  5828. var onFulfilled = requestInterceptorChain[i++];
  5829. var onRejected = requestInterceptorChain[i++];
  5830. try {
  5831. newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
  5832. } catch (error) {
  5833. if (!onRejected) {
  5834. promise = Promise.reject(error);
  5835. break;
  5836. }
  5837. try {
  5838. var rejectedResult = onRejected.call(this, error);
  5839. if (utils$1.isThenable(rejectedResult)) {
  5840. promise = Promise.resolve(rejectedResult).then(function () {
  5841. return dispatchRequest.call(_this, newConfig);
  5842. });
  5843. }
  5844. } catch (rejectedError) {
  5845. promise = Promise.reject(rejectedError);
  5846. }
  5847. break;
  5848. }
  5849. }
  5850. if (!promise) {
  5851. try {
  5852. promise = dispatchRequest.call(this, newConfig);
  5853. } catch (error) {
  5854. promise = Promise.reject(error);
  5855. }
  5856. }
  5857. i = 0;
  5858. len = responseInterceptorChain.length;
  5859. while (i < len) {
  5860. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  5861. }
  5862. return promise;
  5863. }
  5864. }, {
  5865. key: "getUri",
  5866. value: function getUri(config) {
  5867. config = mergeConfig(this.defaults, config);
  5868. var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
  5869. return buildURL(fullPath, config.params, config.paramsSerializer);
  5870. }
  5871. }]);
  5872. }(); // Provide aliases for supported request methods
  5873. utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  5874. /*eslint func-names:0*/
  5875. Axios.prototype[method] = /*#__PURE__*/function () {
  5876. var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(url, config) {
  5877. return _regenerator().w(function (_context2) {
  5878. while (1) switch (_context2.n) {
  5879. case 0:
  5880. return _context2.a(2, this.request(mergeConfig(config || {}, {
  5881. method: method,
  5882. url: url,
  5883. data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined
  5884. })));
  5885. }
  5886. }, _callee2, this);
  5887. }));
  5888. return function (_x3, _x4) {
  5889. return _ref.apply(this, arguments);
  5890. };
  5891. }();
  5892. });
  5893. utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
  5894. function generateHTTPMethod(isForm) {
  5895. return /*#__PURE__*/function () {
  5896. var _httpMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(url, data, config) {
  5897. return _regenerator().w(function (_context3) {
  5898. while (1) switch (_context3.n) {
  5899. case 0:
  5900. return _context3.a(2, this.request(mergeConfig(config || {}, {
  5901. method: method,
  5902. headers: isForm ? {
  5903. 'Content-Type': 'multipart/form-data'
  5904. } : {},
  5905. url: url,
  5906. data: data
  5907. })));
  5908. }
  5909. }, _callee3, this);
  5910. }));
  5911. function httpMethod(_x5, _x6, _x7) {
  5912. return _httpMethod.apply(this, arguments);
  5913. }
  5914. return httpMethod;
  5915. }();
  5916. }
  5917. Axios.prototype[method] = generateHTTPMethod();
  5918. // QUERY is a safe/idempotent read method; multipart form bodies don't fit
  5919. // its semantics, so no queryForm shorthand is generated.
  5920. if (method !== 'query') {
  5921. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  5922. }
  5923. });
  5924. /**
  5925. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  5926. *
  5927. * @param {Function} executor The executor function.
  5928. *
  5929. * @returns {CancelToken}
  5930. */
  5931. var CancelToken = /*#__PURE__*/function () {
  5932. function CancelToken(executor) {
  5933. _classCallCheck(this, CancelToken);
  5934. if (typeof executor !== 'function') {
  5935. throw new TypeError('executor must be a function.');
  5936. }
  5937. var resolvePromise;
  5938. this.promise = new Promise(function promiseExecutor(resolve) {
  5939. resolvePromise = resolve;
  5940. });
  5941. var token = this;
  5942. // eslint-disable-next-line func-names
  5943. this.promise.then(function (cancel) {
  5944. if (!token._listeners) return;
  5945. var i = token._listeners.length;
  5946. while (i-- > 0) {
  5947. token._listeners[i](cancel);
  5948. }
  5949. token._listeners = null;
  5950. });
  5951. // eslint-disable-next-line func-names
  5952. this.promise.then = function (onfulfilled) {
  5953. var _resolve;
  5954. // eslint-disable-next-line func-names
  5955. var promise = new Promise(function (resolve) {
  5956. token.subscribe(resolve);
  5957. _resolve = resolve;
  5958. }).then(onfulfilled);
  5959. promise.cancel = function reject() {
  5960. token.unsubscribe(_resolve);
  5961. };
  5962. return promise;
  5963. };
  5964. executor(function cancel(message, config, request) {
  5965. if (token.reason) {
  5966. // Cancellation has already been requested
  5967. return;
  5968. }
  5969. token.reason = new CanceledError(message, config, request);
  5970. resolvePromise(token.reason);
  5971. });
  5972. }
  5973. /**
  5974. * Throws a `CanceledError` if cancellation has been requested.
  5975. */
  5976. return _createClass(CancelToken, [{
  5977. key: "throwIfRequested",
  5978. value: function throwIfRequested() {
  5979. if (this.reason) {
  5980. throw this.reason;
  5981. }
  5982. }
  5983. /**
  5984. * Subscribe to the cancel signal
  5985. */
  5986. }, {
  5987. key: "subscribe",
  5988. value: function subscribe(listener) {
  5989. if (this.reason) {
  5990. listener(this.reason);
  5991. return;
  5992. }
  5993. if (this._listeners) {
  5994. this._listeners.push(listener);
  5995. } else {
  5996. this._listeners = [listener];
  5997. }
  5998. }
  5999. /**
  6000. * Unsubscribe from the cancel signal
  6001. */
  6002. }, {
  6003. key: "unsubscribe",
  6004. value: function unsubscribe(listener) {
  6005. if (!this._listeners) {
  6006. return;
  6007. }
  6008. var index = this._listeners.indexOf(listener);
  6009. if (index !== -1) {
  6010. this._listeners.splice(index, 1);
  6011. }
  6012. }
  6013. }, {
  6014. key: "toAbortSignal",
  6015. value: function toAbortSignal() {
  6016. var _this = this;
  6017. var controller = new AbortController();
  6018. var abort = function abort(err) {
  6019. controller.abort(err);
  6020. };
  6021. this.subscribe(abort);
  6022. controller.signal.unsubscribe = function () {
  6023. return _this.unsubscribe(abort);
  6024. };
  6025. return controller.signal;
  6026. }
  6027. /**
  6028. * Returns an object that contains a new `CancelToken` and a function that, when called,
  6029. * cancels the `CancelToken`.
  6030. */
  6031. }], [{
  6032. key: "source",
  6033. value: function source() {
  6034. var cancel;
  6035. var token = new CancelToken(function executor(c) {
  6036. cancel = c;
  6037. });
  6038. return {
  6039. token: token,
  6040. cancel: cancel
  6041. };
  6042. }
  6043. }]);
  6044. }();
  6045. /**
  6046. * Syntactic sugar for invoking a function and expanding an array for arguments.
  6047. *
  6048. * Common use case would be to use `Function.prototype.apply`.
  6049. *
  6050. * ```js
  6051. * function f(x, y, z) {}
  6052. * const args = [1, 2, 3];
  6053. * f.apply(null, args);
  6054. * ```
  6055. *
  6056. * With `spread` this example can be re-written.
  6057. *
  6058. * ```js
  6059. * spread(function(x, y, z) {})([1, 2, 3]);
  6060. * ```
  6061. *
  6062. * @param {Function} callback
  6063. *
  6064. * @returns {Function}
  6065. */
  6066. function spread(callback) {
  6067. return function wrap(arr) {
  6068. return callback.apply(null, arr);
  6069. };
  6070. }
  6071. /**
  6072. * Determines whether the payload is an error thrown by Axios
  6073. *
  6074. * @param {*} payload The value to test
  6075. *
  6076. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  6077. */
  6078. function isAxiosError(payload) {
  6079. return utils$1.isObject(payload) && payload.isAxiosError === true;
  6080. }
  6081. var HttpStatusCode = {
  6082. Continue: 100,
  6083. SwitchingProtocols: 101,
  6084. Processing: 102,
  6085. EarlyHints: 103,
  6086. Ok: 200,
  6087. Created: 201,
  6088. Accepted: 202,
  6089. NonAuthoritativeInformation: 203,
  6090. NoContent: 204,
  6091. ResetContent: 205,
  6092. PartialContent: 206,
  6093. MultiStatus: 207,
  6094. AlreadyReported: 208,
  6095. ImUsed: 226,
  6096. MultipleChoices: 300,
  6097. MovedPermanently: 301,
  6098. Found: 302,
  6099. SeeOther: 303,
  6100. NotModified: 304,
  6101. UseProxy: 305,
  6102. Unused: 306,
  6103. TemporaryRedirect: 307,
  6104. PermanentRedirect: 308,
  6105. BadRequest: 400,
  6106. Unauthorized: 401,
  6107. PaymentRequired: 402,
  6108. Forbidden: 403,
  6109. NotFound: 404,
  6110. MethodNotAllowed: 405,
  6111. NotAcceptable: 406,
  6112. ProxyAuthenticationRequired: 407,
  6113. RequestTimeout: 408,
  6114. Conflict: 409,
  6115. Gone: 410,
  6116. LengthRequired: 411,
  6117. PreconditionFailed: 412,
  6118. /**
  6119. * @deprecated Use `ContentTooLarge` instead.
  6120. */
  6121. PayloadTooLarge: 413,
  6122. ContentTooLarge: 413,
  6123. UriTooLong: 414,
  6124. UnsupportedMediaType: 415,
  6125. RangeNotSatisfiable: 416,
  6126. ExpectationFailed: 417,
  6127. ImATeapot: 418,
  6128. MisdirectedRequest: 421,
  6129. /**
  6130. * @deprecated Use `UnprocessableContent` instead.
  6131. */
  6132. UnprocessableEntity: 422,
  6133. UnprocessableContent: 422,
  6134. Locked: 423,
  6135. FailedDependency: 424,
  6136. TooEarly: 425,
  6137. UpgradeRequired: 426,
  6138. PreconditionRequired: 428,
  6139. TooManyRequests: 429,
  6140. RequestHeaderFieldsTooLarge: 431,
  6141. UnavailableForLegalReasons: 451,
  6142. InternalServerError: 500,
  6143. NotImplemented: 501,
  6144. BadGateway: 502,
  6145. ServiceUnavailable: 503,
  6146. GatewayTimeout: 504,
  6147. HttpVersionNotSupported: 505,
  6148. VariantAlsoNegotiates: 506,
  6149. InsufficientStorage: 507,
  6150. LoopDetected: 508,
  6151. NotExtended: 510,
  6152. NetworkAuthenticationRequired: 511,
  6153. WebServerReturnsAnUnknownError: 520,
  6154. WebServerIsDown: 521,
  6155. ConnectionTimedOut: 522,
  6156. OriginIsUnreachable: 523,
  6157. TimeoutOccurred: 524,
  6158. SslHandshakeFailed: 525,
  6159. InvalidSslCertificate: 526
  6160. };
  6161. Object.entries(HttpStatusCode).forEach(function (_ref) {
  6162. var _ref2 = _slicedToArray(_ref, 2),
  6163. key = _ref2[0],
  6164. value = _ref2[1];
  6165. if (HttpStatusCode[value] === undefined) {
  6166. HttpStatusCode[value] = key;
  6167. }
  6168. });
  6169. /**
  6170. * Create an instance of Axios
  6171. *
  6172. * @param {Object} defaultConfig The default config for the instance
  6173. *
  6174. * @returns {Axios} A new instance of Axios
  6175. */
  6176. function createInstance(defaultConfig) {
  6177. var context = new Axios(defaultConfig);
  6178. var instance = bind(Axios.prototype.request, context);
  6179. // Copy axios.prototype to instance
  6180. utils$1.extend(instance, Axios.prototype, context, {
  6181. allOwnKeys: true
  6182. });
  6183. // Copy context to instance
  6184. utils$1.extend(instance, context, null, {
  6185. allOwnKeys: true
  6186. });
  6187. // Factory for creating new instances
  6188. instance.create = function create(instanceConfig) {
  6189. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  6190. };
  6191. return instance;
  6192. }
  6193. // Create the default instance to be exported
  6194. var axios = createInstance(defaults);
  6195. // Expose Axios class to allow class inheritance
  6196. axios.Axios = Axios;
  6197. // Expose Cancel & CancelToken
  6198. axios.CanceledError = CanceledError;
  6199. axios.CancelToken = CancelToken;
  6200. axios.isCancel = isCancel;
  6201. axios.VERSION = VERSION;
  6202. axios.toFormData = toFormData;
  6203. // Expose AxiosError class
  6204. axios.AxiosError = AxiosError;
  6205. // alias for CanceledError for backward compatibility
  6206. axios.Cancel = axios.CanceledError;
  6207. // Expose all/spread
  6208. axios.all = function all(promises) {
  6209. return Promise.all(promises);
  6210. };
  6211. axios.spread = spread;
  6212. // Expose isAxiosError
  6213. axios.isAxiosError = isAxiosError;
  6214. // Expose mergeConfig
  6215. axios.mergeConfig = mergeConfig;
  6216. axios.AxiosHeaders = AxiosHeaders;
  6217. axios.formToJSON = function (thing) {
  6218. return formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  6219. };
  6220. axios.getAdapter = adapters.getAdapter;
  6221. axios.HttpStatusCode = HttpStatusCode;
  6222. axios["default"] = axios;
  6223. return axios;
  6224. }));