axios.cjs 93 KB

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