axios.js 191 KB

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