axios.js 112 KB

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