axios.cjs 94 KB

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