@cccsaurora/clue-ui 1.0.1-dev.70 → 1.0.2-patch.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/ActionForm-Sw7D-KOE.js +340 -0
  2. package/AnnotationDetails-BoX61_IF.js +160 -0
  3. package/AnnotationPreview-dYinoSA9.js +140 -0
  4. package/ClueEnrichContext-CvCIPOMC.js +412 -0
  5. package/FlexOne-BXWFOd1T.js +6 -0
  6. package/_Map-DXNg_Z-q.js +54 -0
  7. package/_MapCache-Cu25RRDU.js +129 -0
  8. package/_Uint8Array-DlJCtTvG.js +102 -0
  9. package/_baseAssignValue-CUmzp727.js +20 -0
  10. package/_baseClone-BlMmRXeX.js +208 -0
  11. package/_baseExtremum-P_0akmCi.js +27 -0
  12. package/_baseFlatten-CN7vDNEQ.js +72 -0
  13. package/_baseGet-Dgf6_xCm.js +80 -0
  14. package/_baseIsEqual-Cpjtfb3Q.js +173 -0
  15. package/_baseIteratee-CP1bocOX.js +95 -0
  16. package/_baseSlice-M5RKzt1A.js +10 -0
  17. package/_baseSum-wEbgNeUs.js +10 -0
  18. package/_baseUniq-tMFmk80M.js +61 -0
  19. package/_commonjsHelpers-C6fGbg64.js +6 -0
  20. package/_createAggregator-B4Cav8ZM.js +53 -0
  21. package/_getPrototype-CHAFQYL_.js +5 -0
  22. package/_getTag-BV_UoLYG.js +90 -0
  23. package/cloneDeep-BPVpFBzJ.js +8 -0
  24. package/components/AnnotationBody.js +34 -49
  25. package/components/AnnotationDetailPopover.js +30 -36
  26. package/components/AnnotationDetails.js +6 -6
  27. package/components/AnnotationEntry.js +47 -50
  28. package/components/AnnotationPreview.js +5 -5
  29. package/components/ClassificationChip.js +23 -44
  30. package/components/CountBadge.js +26 -31
  31. package/components/EnrichedCard.js +92 -104
  32. package/components/EnrichedChip.js +109 -134
  33. package/components/EnrichedTypography.js +110 -136
  34. package/components/ErrorBoundary.js +24 -28
  35. package/components/RetryFailedEnrichments.js +9 -10
  36. package/components/SourcePicker.js +49 -57
  37. package/components/actions/ActionForm.js +4 -4
  38. package/components/actions/ExecutePopover.js +50 -64
  39. package/components/actions/ResultModal.js +34 -37
  40. package/components/actions/form/schemaAdapter.js +20 -39
  41. package/components/display/graph/ExpandMoreButton.js +10 -10
  42. package/components/display/graph/elements/NodeCard.js +76 -92
  43. package/components/display/graph/elements/NodeTag.js +13 -15
  44. package/components/display/graph/index.js +200 -258
  45. package/components/display/graph/visualizations/Leaf.js +69 -88
  46. package/components/display/graph/visualizations/cloud/index.js +81 -98
  47. package/components/display/graph/visualizations/icons/BaseIcon.js +21 -26
  48. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  49. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  50. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  51. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  53. package/components/display/graph/visualizations/icons/index.js +13 -14
  54. package/components/display/graph/visualizations/panels/NodePanel.js +8 -10
  55. package/components/display/graph/visualizations/tree/BundleLine.js +81 -108
  56. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  57. package/components/display/graph/visualizations/tree/index.js +305 -407
  58. package/components/display/icons/Iconified.js +12 -27
  59. package/components/display/json/index.js +4 -4
  60. package/components/display/markdown/DynamicTabs.js +17 -22
  61. package/components/display/markdown/index.js +5674 -8531
  62. package/components/display/markdown/markdownPlugins/tabs.js +1 -1
  63. package/components/enrichment/EnrichPopover.js +47 -55
  64. package/components/fetchers/Fetcher.js +95 -123
  65. package/components/fetchers/PreviewModal.js +17 -20
  66. package/components/fetchers/StatusChip.js +18 -22
  67. package/components/group/Entry.js +11 -13
  68. package/components/group/Group.js +10 -13
  69. package/components/group/GroupControl.js +65 -76
  70. package/components/stats/QueryStatus.js +28 -37
  71. package/countBy-DOutsa_w.js +8 -0
  72. package/data/event.js +4 -6
  73. package/database/index.js +2 -2
  74. package/debounce-DryYcbJ4.js +56 -0
  75. package/get-Bow1vKwx.js +8 -0
  76. package/groupBy-BheQYl6f.js +8 -0
  77. package/hooks/ClueActionContext.js +6 -6
  78. package/hooks/ClueComponentContext.js +23 -29
  79. package/hooks/ClueConfigProvider.js +12 -14
  80. package/hooks/ClueDatabaseContext.js +13 -19
  81. package/hooks/ClueEnrichContext.js +8 -8
  82. package/hooks/ClueEnrichContextType.d.ts +7 -0
  83. package/hooks/ClueFetcherContext.js +46 -74
  84. package/hooks/ClueGroupContext.js +14 -17
  85. package/hooks/CluePopupContext.js +5 -5
  86. package/hooks/ClueProvider.js +10 -12
  87. package/hooks/selectors.js +11 -22
  88. package/hooks/useAnnotations.js +29 -45
  89. package/hooks/useClue.js +4 -6
  90. package/hooks/useClueActions.js +3 -3
  91. package/hooks/useClueConfig.js +5 -5
  92. package/hooks/useClueTypeConfig.js +3 -3
  93. package/hooks/useComparator.js +435 -722
  94. package/hooks/useErrors.js +18 -22
  95. package/hooks/useMyHighlights.js +36 -66
  96. package/hooks/useMyLocalStorage.js +43 -63
  97. package/iconify-BBckr5AQ.js +1263 -0
  98. package/icons/Action.js +49 -66
  99. package/icons/Assessment.js +68 -84
  100. package/icons/Context.js +61 -75
  101. package/icons/Opinion.js +65 -77
  102. package/icons/iconMap.js +2 -2
  103. package/identity-ByMq8VxU.js +6 -0
  104. package/index-CnaCBNrd.js +358 -0
  105. package/index-E7g8cRyW.js +568 -0
  106. package/index-V7wwd05F.js +975 -0
  107. package/index-p5_wX7q1.js +11729 -0
  108. package/index-pQg5VUAZ.js +12734 -0
  109. package/isEmpty-g47Qir2A.js +21 -0
  110. package/isNil-CjWwlQS3.js +6 -0
  111. package/isObject-B53jY8Qg.js +7 -0
  112. package/isObjectLike-BatpeCIi.js +29 -0
  113. package/isSymbol-C3_SC0Qp.js +8 -0
  114. package/last-7CdUxN0r.js +7 -0
  115. package/main.d.ts +3 -2
  116. package/main.js +62 -58
  117. package/package.json +1 -1
  118. package/sortBy-ITdmD17L.js +79 -0
  119. package/sumBy-DxJUU2E8.js +8 -0
  120. package/tabs-CgADNA57.js +195 -0
  121. package/text/Frequency.js +23 -42
  122. package/toFinite-BMy6GObD.js +14 -0
  123. package/toNumber-YVhnnJv4.js +31 -0
  124. package/types/config.d.ts +4 -1
  125. package/useClueTypeConfig-CneP98N_.js +2260 -0
  126. package/utils/chain.js +64 -91
  127. package/utils/classificationParser.d.ts +8 -8
  128. package/utils/classificationParser.js +257 -520
  129. package/utils/constants.js +10 -35
  130. package/utils/graph.js +45 -72
  131. package/utils/hashUtil.js +7 -7
  132. package/utils/line.js +81 -131
  133. package/utils/loggerUtil.js +3 -5
  134. package/utils/sessionStorage.js +29 -41
  135. package/utils/utils.js +9 -9
  136. package/utils/window.js +10 -21
  137. package/utils-CD0rFIFU.js +2704 -0
  138. package/ActionForm-D4ryHO0M.js +0 -436
  139. package/AnnotationDetails-YAPoqw3R.js +0 -175
  140. package/AnnotationPreview-DiQDjt9s.js +0 -188
  141. package/ClueEnrichContext-DIn6g8tw.js +0 -522
  142. package/FlexOne-BSYAhhtG.js +0 -9
  143. package/_Map-kgDsDYxq.js +0 -64
  144. package/_MapCache-DabaaWfq.js +0 -161
  145. package/_Uint8Array-BlVVH1tp.js +0 -129
  146. package/_baseAssignValue-CNbcU6Nb.js +0 -25
  147. package/_baseClone-D3a8Pa4T.js +0 -284
  148. package/_baseExtremum-B1o1zHjR.js +0 -33
  149. package/_baseFlatten-D4huXoEI.js +0 -92
  150. package/_baseGet-BSK_nnoz.js +0 -109
  151. package/_baseIsEqual-B5xLoweL.js +0 -238
  152. package/_baseIteratee-p6Nj07-n.js +0 -126
  153. package/_baseSlice-GAv_YFTT.js +0 -20
  154. package/_baseSum-D0WC1dN0.js +0 -13
  155. package/_baseUniq-CpupKWcL.js +0 -89
  156. package/_commonjsHelpers-CUmg6egw.js +0 -6
  157. package/_createAggregator-BpVy5xMi.js +0 -63
  158. package/_getPrototype-D1LAdQKO.js +0 -5
  159. package/_getTag-D3ToyefI.js +0 -126
  160. package/cloneDeep-CjP5k9zW.js +0 -8
  161. package/countBy-C69WslUA.js +0 -14
  162. package/debounce-bV0h5FC5.js +0 -92
  163. package/get-D3C3lEU3.js +0 -8
  164. package/groupBy-DC2oOuBN.js +0 -14
  165. package/iconify-CXMreGTg.js +0 -1782
  166. package/identity-CPGTqrE4.js +0 -6
  167. package/index-BDVjGvMI.js +0 -696
  168. package/index-BHPT3qoB.js +0 -1172
  169. package/index-BMxyILVD.js +0 -465
  170. package/index-BbPn6-Mw.js +0 -15750
  171. package/index-Dz1kF2MU.js +0 -17654
  172. package/isEmpty-BQkZubqU.js +0 -29
  173. package/isNil-CIubwp4T.js +0 -6
  174. package/isObject-FTY-5JQX.js +0 -7
  175. package/isObjectLike-OAgjjZye.js +0 -48
  176. package/isSymbol-Xd2FsJyp.js +0 -8
  177. package/last-CUCl67Im.js +0 -7
  178. package/sortBy-B-UKp4GT.js +0 -100
  179. package/sumBy-MYkDPHZL.js +0 -8
  180. package/tabs-xGuUGsJd.js +0 -254
  181. package/toFinite-Bc55msYj.js +0 -16
  182. package/toNumber-DPxy1FBy.js +0 -39
  183. package/useClueTypeConfig-CH-nGq6a.js +0 -3184
  184. package/utils-Dr4wbKBZ.js +0 -4182
@@ -1,3184 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { i as isNil } from "./isNil-CIubwp4T.js";
5
- import { MY_LOCAL_STORAGE_PREFIX, StorageKey } from "./utils/constants.js";
6
- import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.js";
7
- import { getAxiosCache, setAxiosCache } from "./utils/sessionStorage.js";
8
- import { clueDebugLogger } from "./utils/loggerUtil.js";
9
- import { i as isEmpty } from "./isEmpty-BQkZubqU.js";
10
- import { useState, useEffect } from "react";
11
- const uri$c = () => {
12
- return joinUri(uri(), "actions");
13
- };
14
- const get$7 = (config) => {
15
- return hget(uri$c(), null, config);
16
- };
17
- const post$3 = (actionId, selectors, params, options = { timeout: null }, config) => {
18
- const searchParams = [];
19
- if (!isNil(options.timeout)) {
20
- searchParams.push(`max_timeout=${options.timeout}`);
21
- }
22
- const payload = { ...params };
23
- if (!Array.isArray(selectors)) {
24
- payload.selector = selectors;
25
- payload.selectors = [];
26
- } else if (selectors.length < 2) {
27
- payload.selector = selectors[0];
28
- payload.selectors = [];
29
- } else {
30
- payload.selectors = selectors;
31
- }
32
- return hpost(
33
- joinUri(
34
- joinUri(uri$c(), "execute"),
35
- actionId.replace(".", "/"),
36
- searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null
37
- ),
38
- payload,
39
- config
40
- );
41
- };
42
- const actions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
43
- __proto__: null,
44
- get: get$7,
45
- post: post$3,
46
- uri: uri$c
47
- }, Symbol.toStringTag, { value: "Module" }));
48
- const uri$b = (searchParams) => {
49
- return joinUri(uri$a(), "login", searchParams);
50
- };
51
- const post$2 = (body) => {
52
- return hpost(uri$b(), body);
53
- };
54
- const get$6 = (search) => {
55
- const nonce = localStorage.getItem(`${MY_LOCAL_STORAGE_PREFIX}.${StorageKey.LOGIN_NONCE}`);
56
- if (nonce) {
57
- search.set("nonce", JSON.parse(nonce));
58
- localStorage.removeItem(`${MY_LOCAL_STORAGE_PREFIX}.${StorageKey.LOGIN_NONCE}`);
59
- }
60
- return hget(uri$b(), search);
61
- };
62
- const login = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
63
- __proto__: null,
64
- get: get$6,
65
- post: post$2,
66
- uri: uri$b
67
- }, Symbol.toStringTag, { value: "Module" }));
68
- function uri$a() {
69
- return joinUri(uri(), "auth");
70
- }
71
- const auth = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
72
- __proto__: null,
73
- login,
74
- uri: uri$a
75
- }, Symbol.toStringTag, { value: "Module" }));
76
- function uri$9() {
77
- return joinUri(uri(), "configs");
78
- }
79
- function get$5(config) {
80
- return hget(uri$9(), null, config);
81
- }
82
- const configs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
83
- __proto__: null,
84
- get: get$5,
85
- uri: uri$9
86
- }, Symbol.toStringTag, { value: "Module" }));
87
- function uri$8() {
88
- return joinUri(uri(), "fetchers");
89
- }
90
- function get$4(config) {
91
- return hget(uri$8(), null, config);
92
- }
93
- function post$1(fetcherId, selector, config) {
94
- return hpost(joinAllUri(uri$8(), fetcherId.replace(".", "/")), selector, config);
95
- }
96
- const fetchers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
97
- __proto__: null,
98
- get: get$4,
99
- post: post$1,
100
- uri: uri$8
101
- }, Symbol.toStringTag, { value: "Module" }));
102
- const uri$7 = () => {
103
- return joinUri(uri$4(), "enrich");
104
- };
105
- const post = (bulkData, sources = [], options = { timeout: null, includeRaw: false, noCache: false }, config) => {
106
- const searchParams = [];
107
- if ((sources == null ? void 0 : sources.length) > 0) {
108
- searchParams.push(`sources=${sources.join()}`);
109
- }
110
- if (options.classification) {
111
- searchParams.push(`classification=${encodeURIComponent(options.classification)}`);
112
- }
113
- if (!isNil(options.timeout)) {
114
- searchParams.push(`max_timeout=${options.timeout}`);
115
- }
116
- if (options.includeRaw) {
117
- searchParams.push("include_raw=true");
118
- }
119
- if (options.noCache) {
120
- searchParams.push("no_cache=true");
121
- }
122
- return hpost(
123
- joinUri(uri$7(), "", searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null),
124
- bulkData,
125
- config
126
- );
127
- };
128
- const enrich = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
129
- __proto__: null,
130
- post,
131
- uri: uri$7
132
- }, Symbol.toStringTag, { value: "Module" }));
133
- function uri$6() {
134
- return joinUri(uri$4(), "types");
135
- }
136
- function get$3(config) {
137
- return hget(uri$6(), null, config);
138
- }
139
- const types = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
140
- __proto__: null,
141
- get: get$3,
142
- uri: uri$6
143
- }, Symbol.toStringTag, { value: "Module" }));
144
- function uri$5() {
145
- return joinUri(uri$4(), "types_detection");
146
- }
147
- function get$2(config) {
148
- return hget(uri$5(), null, config);
149
- }
150
- const types_detection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
151
- __proto__: null,
152
- get: get$2,
153
- uri: uri$5
154
- }, Symbol.toStringTag, { value: "Module" }));
155
- function uri$4() {
156
- return joinUri(uri(), "lookup");
157
- }
158
- const lookup = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
159
- __proto__: null,
160
- enrich,
161
- types,
162
- types_detection,
163
- uri: uri$4
164
- }, Symbol.toStringTag, { value: "Module" }));
165
- function uri$3(filter2) {
166
- return joinUri(uri$1(), filter2 ? "/docs?filter=" + filter2 : "/docs");
167
- }
168
- function get$1(filter2, config) {
169
- return hget(uri$3(filter2), null, config);
170
- }
171
- const all_documentation = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
172
- __proto__: null,
173
- get: get$1,
174
- uri: uri$3
175
- }, Symbol.toStringTag, { value: "Module" }));
176
- function uri$2(file) {
177
- return joinAllUri(uri$1(), "docs", file);
178
- }
179
- function get(file, config) {
180
- return hget(uri$2(file), null, config);
181
- }
182
- const documentation = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
183
- __proto__: null,
184
- get,
185
- uri: uri$2
186
- }, Symbol.toStringTag, { value: "Module" }));
187
- function uri$1() {
188
- return joinUri(uri(), "static");
189
- }
190
- const _static = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
191
- __proto__: null,
192
- all_documentation,
193
- documentation,
194
- uri: uri$1
195
- }, Symbol.toStringTag, { value: "Module" }));
196
- function bind(fn, thisArg) {
197
- return function wrap() {
198
- return fn.apply(thisArg, arguments);
199
- };
200
- }
201
- const { toString } = Object.prototype;
202
- const { getPrototypeOf } = Object;
203
- const { iterator, toStringTag } = Symbol;
204
- const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
205
- const str = toString.call(thing);
206
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
207
- })(/* @__PURE__ */ Object.create(null));
208
- const kindOfTest = (type) => {
209
- type = type.toLowerCase();
210
- return (thing) => kindOf(thing) === type;
211
- };
212
- const typeOfTest = (type) => (thing) => typeof thing === type;
213
- const { isArray } = Array;
214
- const isUndefined = typeOfTest("undefined");
215
- function isBuffer(val) {
216
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
217
- }
218
- const isArrayBuffer = kindOfTest("ArrayBuffer");
219
- function isArrayBufferView(val) {
220
- let result;
221
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
222
- result = ArrayBuffer.isView(val);
223
- } else {
224
- result = val && val.buffer && isArrayBuffer(val.buffer);
225
- }
226
- return result;
227
- }
228
- const isString = typeOfTest("string");
229
- const isFunction$1 = typeOfTest("function");
230
- const isNumber = typeOfTest("number");
231
- const isObject = (thing) => thing !== null && typeof thing === "object";
232
- const isBoolean = (thing) => thing === true || thing === false;
233
- const isPlainObject = (val) => {
234
- if (kindOf(val) !== "object") {
235
- return false;
236
- }
237
- const prototype2 = getPrototypeOf(val);
238
- return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
239
- };
240
- const isEmptyObject = (val) => {
241
- if (!isObject(val) || isBuffer(val)) {
242
- return false;
243
- }
244
- try {
245
- return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
246
- } catch (e) {
247
- return false;
248
- }
249
- };
250
- const isDate = kindOfTest("Date");
251
- const isFile = kindOfTest("File");
252
- const isBlob = kindOfTest("Blob");
253
- const isFileList = kindOfTest("FileList");
254
- const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
255
- const isFormData = (thing) => {
256
- let kind;
257
- return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction$1(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
258
- kind === "object" && isFunction$1(thing.toString) && thing.toString() === "[object FormData]"));
259
- };
260
- const isURLSearchParams = kindOfTest("URLSearchParams");
261
- const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
262
- const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
263
- function forEach(obj, fn, { allOwnKeys = false } = {}) {
264
- if (obj === null || typeof obj === "undefined") {
265
- return;
266
- }
267
- let i;
268
- let l;
269
- if (typeof obj !== "object") {
270
- obj = [obj];
271
- }
272
- if (isArray(obj)) {
273
- for (i = 0, l = obj.length; i < l; i++) {
274
- fn.call(null, obj[i], i, obj);
275
- }
276
- } else {
277
- if (isBuffer(obj)) {
278
- return;
279
- }
280
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
281
- const len = keys.length;
282
- let key;
283
- for (i = 0; i < len; i++) {
284
- key = keys[i];
285
- fn.call(null, obj[key], key, obj);
286
- }
287
- }
288
- }
289
- function findKey(obj, key) {
290
- if (isBuffer(obj)) {
291
- return null;
292
- }
293
- key = key.toLowerCase();
294
- const keys = Object.keys(obj);
295
- let i = keys.length;
296
- let _key;
297
- while (i-- > 0) {
298
- _key = keys[i];
299
- if (key === _key.toLowerCase()) {
300
- return _key;
301
- }
302
- }
303
- return null;
304
- }
305
- const _global = (() => {
306
- if (typeof globalThis !== "undefined") return globalThis;
307
- return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
308
- })();
309
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
310
- function merge() {
311
- const { caseless, skipUndefined } = isContextDefined(this) && this || {};
312
- const result = {};
313
- const assignValue = (val, key) => {
314
- const targetKey = caseless && findKey(result, key) || key;
315
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
316
- result[targetKey] = merge(result[targetKey], val);
317
- } else if (isPlainObject(val)) {
318
- result[targetKey] = merge({}, val);
319
- } else if (isArray(val)) {
320
- result[targetKey] = val.slice();
321
- } else {
322
- if (!skipUndefined || !isUndefined(val)) {
323
- result[targetKey] = val;
324
- }
325
- }
326
- };
327
- for (let i = 0, l = arguments.length; i < l; i++) {
328
- arguments[i] && forEach(arguments[i], assignValue);
329
- }
330
- return result;
331
- }
332
- const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
333
- forEach(b, (val, key) => {
334
- if (thisArg && isFunction$1(val)) {
335
- a[key] = bind(val, thisArg);
336
- } else {
337
- a[key] = val;
338
- }
339
- }, { allOwnKeys });
340
- return a;
341
- };
342
- const stripBOM = (content) => {
343
- if (content.charCodeAt(0) === 65279) {
344
- content = content.slice(1);
345
- }
346
- return content;
347
- };
348
- const inherits = (constructor, superConstructor, props, descriptors2) => {
349
- constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
350
- constructor.prototype.constructor = constructor;
351
- Object.defineProperty(constructor, "super", {
352
- value: superConstructor.prototype
353
- });
354
- props && Object.assign(constructor.prototype, props);
355
- };
356
- const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
357
- let props;
358
- let i;
359
- let prop;
360
- const merged = {};
361
- destObj = destObj || {};
362
- if (sourceObj == null) return destObj;
363
- do {
364
- props = Object.getOwnPropertyNames(sourceObj);
365
- i = props.length;
366
- while (i-- > 0) {
367
- prop = props[i];
368
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
369
- destObj[prop] = sourceObj[prop];
370
- merged[prop] = true;
371
- }
372
- }
373
- sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
374
- } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
375
- return destObj;
376
- };
377
- const endsWith = (str, searchString, position) => {
378
- str = String(str);
379
- if (position === void 0 || position > str.length) {
380
- position = str.length;
381
- }
382
- position -= searchString.length;
383
- const lastIndex = str.indexOf(searchString, position);
384
- return lastIndex !== -1 && lastIndex === position;
385
- };
386
- const toArray = (thing) => {
387
- if (!thing) return null;
388
- if (isArray(thing)) return thing;
389
- let i = thing.length;
390
- if (!isNumber(i)) return null;
391
- const arr = new Array(i);
392
- while (i-- > 0) {
393
- arr[i] = thing[i];
394
- }
395
- return arr;
396
- };
397
- const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
398
- return (thing) => {
399
- return TypedArray && thing instanceof TypedArray;
400
- };
401
- })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
402
- const forEachEntry = (obj, fn) => {
403
- const generator = obj && obj[iterator];
404
- const _iterator = generator.call(obj);
405
- let result;
406
- while ((result = _iterator.next()) && !result.done) {
407
- const pair = result.value;
408
- fn.call(obj, pair[0], pair[1]);
409
- }
410
- };
411
- const matchAll = (regExp, str) => {
412
- let matches;
413
- const arr = [];
414
- while ((matches = regExp.exec(str)) !== null) {
415
- arr.push(matches);
416
- }
417
- return arr;
418
- };
419
- const isHTMLForm = kindOfTest("HTMLFormElement");
420
- const toCamelCase = (str) => {
421
- return str.toLowerCase().replace(
422
- /[-_\s]([a-z\d])(\w*)/g,
423
- function replacer(m, p1, p2) {
424
- return p1.toUpperCase() + p2;
425
- }
426
- );
427
- };
428
- const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
429
- const isRegExp = kindOfTest("RegExp");
430
- const reduceDescriptors = (obj, reducer) => {
431
- const descriptors2 = Object.getOwnPropertyDescriptors(obj);
432
- const reducedDescriptors = {};
433
- forEach(descriptors2, (descriptor, name) => {
434
- let ret;
435
- if ((ret = reducer(descriptor, name, obj)) !== false) {
436
- reducedDescriptors[name] = ret || descriptor;
437
- }
438
- });
439
- Object.defineProperties(obj, reducedDescriptors);
440
- };
441
- const freezeMethods = (obj) => {
442
- reduceDescriptors(obj, (descriptor, name) => {
443
- if (isFunction$1(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
444
- return false;
445
- }
446
- const value = obj[name];
447
- if (!isFunction$1(value)) return;
448
- descriptor.enumerable = false;
449
- if ("writable" in descriptor) {
450
- descriptor.writable = false;
451
- return;
452
- }
453
- if (!descriptor.set) {
454
- descriptor.set = () => {
455
- throw Error("Can not rewrite read-only method '" + name + "'");
456
- };
457
- }
458
- });
459
- };
460
- const toObjectSet = (arrayOrString, delimiter) => {
461
- const obj = {};
462
- const define = (arr) => {
463
- arr.forEach((value) => {
464
- obj[value] = true;
465
- });
466
- };
467
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
468
- return obj;
469
- };
470
- const noop = () => {
471
- };
472
- const toFiniteNumber = (value, defaultValue) => {
473
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
474
- };
475
- function isSpecCompliantForm(thing) {
476
- return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
477
- }
478
- const toJSONObject = (obj) => {
479
- const stack = new Array(10);
480
- const visit = (source, i) => {
481
- if (isObject(source)) {
482
- if (stack.indexOf(source) >= 0) {
483
- return;
484
- }
485
- if (isBuffer(source)) {
486
- return source;
487
- }
488
- if (!("toJSON" in source)) {
489
- stack[i] = source;
490
- const target = isArray(source) ? [] : {};
491
- forEach(source, (value, key) => {
492
- const reducedValue = visit(value, i + 1);
493
- !isUndefined(reducedValue) && (target[key] = reducedValue);
494
- });
495
- stack[i] = void 0;
496
- return target;
497
- }
498
- }
499
- return source;
500
- };
501
- return visit(obj, 0);
502
- };
503
- const isAsyncFn = kindOfTest("AsyncFunction");
504
- const isThenable = (thing) => thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
505
- const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
506
- if (setImmediateSupported) {
507
- return setImmediate;
508
- }
509
- return postMessageSupported ? ((token, callbacks) => {
510
- _global.addEventListener("message", ({ source, data }) => {
511
- if (source === _global && data === token) {
512
- callbacks.length && callbacks.shift()();
513
- }
514
- }, false);
515
- return (cb) => {
516
- callbacks.push(cb);
517
- _global.postMessage(token, "*");
518
- };
519
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
520
- })(
521
- typeof setImmediate === "function",
522
- isFunction$1(_global.postMessage)
523
- );
524
- const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
525
- const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
526
- const utils$1 = {
527
- isArray,
528
- isArrayBuffer,
529
- isBuffer,
530
- isFormData,
531
- isArrayBufferView,
532
- isString,
533
- isNumber,
534
- isBoolean,
535
- isObject,
536
- isPlainObject,
537
- isEmptyObject,
538
- isReadableStream,
539
- isRequest,
540
- isResponse,
541
- isHeaders,
542
- isUndefined,
543
- isDate,
544
- isFile,
545
- isBlob,
546
- isRegExp,
547
- isFunction: isFunction$1,
548
- isStream,
549
- isURLSearchParams,
550
- isTypedArray,
551
- isFileList,
552
- forEach,
553
- merge,
554
- extend,
555
- trim,
556
- stripBOM,
557
- inherits,
558
- toFlatObject,
559
- kindOf,
560
- kindOfTest,
561
- endsWith,
562
- toArray,
563
- forEachEntry,
564
- matchAll,
565
- isHTMLForm,
566
- hasOwnProperty,
567
- hasOwnProp: hasOwnProperty,
568
- // an alias to avoid ESLint no-prototype-builtins detection
569
- reduceDescriptors,
570
- freezeMethods,
571
- toObjectSet,
572
- toCamelCase,
573
- noop,
574
- toFiniteNumber,
575
- findKey,
576
- global: _global,
577
- isContextDefined,
578
- isSpecCompliantForm,
579
- toJSONObject,
580
- isAsyncFn,
581
- isThenable,
582
- setImmediate: _setImmediate,
583
- asap,
584
- isIterable
585
- };
586
- function AxiosError$1(message, code, config, request, response) {
587
- Error.call(this);
588
- if (Error.captureStackTrace) {
589
- Error.captureStackTrace(this, this.constructor);
590
- } else {
591
- this.stack = new Error().stack;
592
- }
593
- this.message = message;
594
- this.name = "AxiosError";
595
- code && (this.code = code);
596
- config && (this.config = config);
597
- request && (this.request = request);
598
- if (response) {
599
- this.response = response;
600
- this.status = response.status ? response.status : null;
601
- }
602
- }
603
- utils$1.inherits(AxiosError$1, Error, {
604
- toJSON: function toJSON() {
605
- return {
606
- // Standard
607
- message: this.message,
608
- name: this.name,
609
- // Microsoft
610
- description: this.description,
611
- number: this.number,
612
- // Mozilla
613
- fileName: this.fileName,
614
- lineNumber: this.lineNumber,
615
- columnNumber: this.columnNumber,
616
- stack: this.stack,
617
- // Axios
618
- config: utils$1.toJSONObject(this.config),
619
- code: this.code,
620
- status: this.status
621
- };
622
- }
623
- });
624
- const prototype$1 = AxiosError$1.prototype;
625
- const descriptors = {};
626
- [
627
- "ERR_BAD_OPTION_VALUE",
628
- "ERR_BAD_OPTION",
629
- "ECONNABORTED",
630
- "ETIMEDOUT",
631
- "ERR_NETWORK",
632
- "ERR_FR_TOO_MANY_REDIRECTS",
633
- "ERR_DEPRECATED",
634
- "ERR_BAD_RESPONSE",
635
- "ERR_BAD_REQUEST",
636
- "ERR_CANCELED",
637
- "ERR_NOT_SUPPORT",
638
- "ERR_INVALID_URL"
639
- // eslint-disable-next-line func-names
640
- ].forEach((code) => {
641
- descriptors[code] = { value: code };
642
- });
643
- Object.defineProperties(AxiosError$1, descriptors);
644
- Object.defineProperty(prototype$1, "isAxiosError", { value: true });
645
- AxiosError$1.from = (error, code, config, request, response, customProps) => {
646
- const axiosError = Object.create(prototype$1);
647
- utils$1.toFlatObject(error, axiosError, function filter2(obj) {
648
- return obj !== Error.prototype;
649
- }, (prop) => {
650
- return prop !== "isAxiosError";
651
- });
652
- const msg = error && error.message ? error.message : "Error";
653
- const errCode = code == null && error ? error.code : code;
654
- AxiosError$1.call(axiosError, msg, errCode, config, request, response);
655
- if (error && axiosError.cause == null) {
656
- Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
657
- }
658
- axiosError.name = error && error.name || "Error";
659
- customProps && Object.assign(axiosError, customProps);
660
- return axiosError;
661
- };
662
- const httpAdapter = null;
663
- function isVisitable(thing) {
664
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
665
- }
666
- function removeBrackets(key) {
667
- return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
668
- }
669
- function renderKey(path, key, dots) {
670
- if (!path) return key;
671
- return path.concat(key).map(function each(token, i) {
672
- token = removeBrackets(token);
673
- return !dots && i ? "[" + token + "]" : token;
674
- }).join(dots ? "." : "");
675
- }
676
- function isFlatArray(arr) {
677
- return utils$1.isArray(arr) && !arr.some(isVisitable);
678
- }
679
- const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
680
- return /^is[A-Z]/.test(prop);
681
- });
682
- function toFormData$1(obj, formData, options) {
683
- if (!utils$1.isObject(obj)) {
684
- throw new TypeError("target must be an object");
685
- }
686
- formData = formData || new FormData();
687
- options = utils$1.toFlatObject(options, {
688
- metaTokens: true,
689
- dots: false,
690
- indexes: false
691
- }, false, function defined(option, source) {
692
- return !utils$1.isUndefined(source[option]);
693
- });
694
- const metaTokens = options.metaTokens;
695
- const visitor = options.visitor || defaultVisitor;
696
- const dots = options.dots;
697
- const indexes = options.indexes;
698
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
699
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
700
- if (!utils$1.isFunction(visitor)) {
701
- throw new TypeError("visitor must be a function");
702
- }
703
- function convertValue(value) {
704
- if (value === null) return "";
705
- if (utils$1.isDate(value)) {
706
- return value.toISOString();
707
- }
708
- if (utils$1.isBoolean(value)) {
709
- return value.toString();
710
- }
711
- if (!useBlob && utils$1.isBlob(value)) {
712
- throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
713
- }
714
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
715
- return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
716
- }
717
- return value;
718
- }
719
- function defaultVisitor(value, key, path) {
720
- let arr = value;
721
- if (value && !path && typeof value === "object") {
722
- if (utils$1.endsWith(key, "{}")) {
723
- key = metaTokens ? key : key.slice(0, -2);
724
- value = JSON.stringify(value);
725
- } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
726
- key = removeBrackets(key);
727
- arr.forEach(function each(el, index) {
728
- !(utils$1.isUndefined(el) || el === null) && formData.append(
729
- // eslint-disable-next-line no-nested-ternary
730
- indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
731
- convertValue(el)
732
- );
733
- });
734
- return false;
735
- }
736
- }
737
- if (isVisitable(value)) {
738
- return true;
739
- }
740
- formData.append(renderKey(path, key, dots), convertValue(value));
741
- return false;
742
- }
743
- const stack = [];
744
- const exposedHelpers = Object.assign(predicates, {
745
- defaultVisitor,
746
- convertValue,
747
- isVisitable
748
- });
749
- function build(value, path) {
750
- if (utils$1.isUndefined(value)) return;
751
- if (stack.indexOf(value) !== -1) {
752
- throw Error("Circular reference detected in " + path.join("."));
753
- }
754
- stack.push(value);
755
- utils$1.forEach(value, function each(el, key) {
756
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
757
- formData,
758
- el,
759
- utils$1.isString(key) ? key.trim() : key,
760
- path,
761
- exposedHelpers
762
- );
763
- if (result === true) {
764
- build(el, path ? path.concat(key) : [key]);
765
- }
766
- });
767
- stack.pop();
768
- }
769
- if (!utils$1.isObject(obj)) {
770
- throw new TypeError("data must be an object");
771
- }
772
- build(obj);
773
- return formData;
774
- }
775
- function encode$1(str) {
776
- const charMap = {
777
- "!": "%21",
778
- "'": "%27",
779
- "(": "%28",
780
- ")": "%29",
781
- "~": "%7E",
782
- "%20": "+",
783
- "%00": "\0"
784
- };
785
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
786
- return charMap[match];
787
- });
788
- }
789
- function AxiosURLSearchParams(params, options) {
790
- this._pairs = [];
791
- params && toFormData$1(params, this, options);
792
- }
793
- const prototype = AxiosURLSearchParams.prototype;
794
- prototype.append = function append(name, value) {
795
- this._pairs.push([name, value]);
796
- };
797
- prototype.toString = function toString2(encoder) {
798
- const _encode = encoder ? function(value) {
799
- return encoder.call(this, value, encode$1);
800
- } : encode$1;
801
- return this._pairs.map(function each(pair) {
802
- return _encode(pair[0]) + "=" + _encode(pair[1]);
803
- }, "").join("&");
804
- };
805
- function encode(val) {
806
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
807
- }
808
- function buildURL(url, params, options) {
809
- if (!params) {
810
- return url;
811
- }
812
- const _encode = options && options.encode || encode;
813
- if (utils$1.isFunction(options)) {
814
- options = {
815
- serialize: options
816
- };
817
- }
818
- const serializeFn = options && options.serialize;
819
- let serializedParams;
820
- if (serializeFn) {
821
- serializedParams = serializeFn(params, options);
822
- } else {
823
- serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
824
- }
825
- if (serializedParams) {
826
- const hashmarkIndex = url.indexOf("#");
827
- if (hashmarkIndex !== -1) {
828
- url = url.slice(0, hashmarkIndex);
829
- }
830
- url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
831
- }
832
- return url;
833
- }
834
- class InterceptorManager {
835
- constructor() {
836
- this.handlers = [];
837
- }
838
- /**
839
- * Add a new interceptor to the stack
840
- *
841
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
842
- * @param {Function} rejected The function to handle `reject` for a `Promise`
843
- *
844
- * @return {Number} An ID used to remove interceptor later
845
- */
846
- use(fulfilled, rejected, options) {
847
- this.handlers.push({
848
- fulfilled,
849
- rejected,
850
- synchronous: options ? options.synchronous : false,
851
- runWhen: options ? options.runWhen : null
852
- });
853
- return this.handlers.length - 1;
854
- }
855
- /**
856
- * Remove an interceptor from the stack
857
- *
858
- * @param {Number} id The ID that was returned by `use`
859
- *
860
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
861
- */
862
- eject(id) {
863
- if (this.handlers[id]) {
864
- this.handlers[id] = null;
865
- }
866
- }
867
- /**
868
- * Clear all interceptors from the stack
869
- *
870
- * @returns {void}
871
- */
872
- clear() {
873
- if (this.handlers) {
874
- this.handlers = [];
875
- }
876
- }
877
- /**
878
- * Iterate over all the registered interceptors
879
- *
880
- * This method is particularly useful for skipping over any
881
- * interceptors that may have become `null` calling `eject`.
882
- *
883
- * @param {Function} fn The function to call for each interceptor
884
- *
885
- * @returns {void}
886
- */
887
- forEach(fn) {
888
- utils$1.forEach(this.handlers, function forEachHandler(h) {
889
- if (h !== null) {
890
- fn(h);
891
- }
892
- });
893
- }
894
- }
895
- const transitionalDefaults = {
896
- silentJSONParsing: true,
897
- forcedJSONParsing: true,
898
- clarifyTimeoutError: false
899
- };
900
- const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
901
- const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
902
- const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
903
- const platform$1 = {
904
- isBrowser: true,
905
- classes: {
906
- URLSearchParams: URLSearchParams$1,
907
- FormData: FormData$1,
908
- Blob: Blob$1
909
- },
910
- protocols: ["http", "https", "file", "blob", "url", "data"]
911
- };
912
- const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
913
- const _navigator = typeof navigator === "object" && navigator || void 0;
914
- const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
915
- const hasStandardBrowserWebWorkerEnv = (() => {
916
- return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
917
- self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
918
- })();
919
- const origin = hasBrowserEnv && window.location.href || "http://localhost";
920
- const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
921
- __proto__: null,
922
- hasBrowserEnv,
923
- hasStandardBrowserEnv,
924
- hasStandardBrowserWebWorkerEnv,
925
- navigator: _navigator,
926
- origin
927
- }, Symbol.toStringTag, { value: "Module" }));
928
- const platform = {
929
- ...utils,
930
- ...platform$1
931
- };
932
- function toURLEncodedForm(data, options) {
933
- return toFormData$1(data, new platform.classes.URLSearchParams(), {
934
- visitor: function(value, key, path, helpers) {
935
- if (platform.isNode && utils$1.isBuffer(value)) {
936
- this.append(key, value.toString("base64"));
937
- return false;
938
- }
939
- return helpers.defaultVisitor.apply(this, arguments);
940
- },
941
- ...options
942
- });
943
- }
944
- function parsePropPath(name) {
945
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
946
- return match[0] === "[]" ? "" : match[1] || match[0];
947
- });
948
- }
949
- function arrayToObject(arr) {
950
- const obj = {};
951
- const keys = Object.keys(arr);
952
- let i;
953
- const len = keys.length;
954
- let key;
955
- for (i = 0; i < len; i++) {
956
- key = keys[i];
957
- obj[key] = arr[key];
958
- }
959
- return obj;
960
- }
961
- function formDataToJSON(formData) {
962
- function buildPath(path, value, target, index) {
963
- let name = path[index++];
964
- if (name === "__proto__") return true;
965
- const isNumericKey = Number.isFinite(+name);
966
- const isLast = index >= path.length;
967
- name = !name && utils$1.isArray(target) ? target.length : name;
968
- if (isLast) {
969
- if (utils$1.hasOwnProp(target, name)) {
970
- target[name] = [target[name], value];
971
- } else {
972
- target[name] = value;
973
- }
974
- return !isNumericKey;
975
- }
976
- if (!target[name] || !utils$1.isObject(target[name])) {
977
- target[name] = [];
978
- }
979
- const result = buildPath(path, value, target[name], index);
980
- if (result && utils$1.isArray(target[name])) {
981
- target[name] = arrayToObject(target[name]);
982
- }
983
- return !isNumericKey;
984
- }
985
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
986
- const obj = {};
987
- utils$1.forEachEntry(formData, (name, value) => {
988
- buildPath(parsePropPath(name), value, obj, 0);
989
- });
990
- return obj;
991
- }
992
- return null;
993
- }
994
- function stringifySafely(rawValue, parser, encoder) {
995
- if (utils$1.isString(rawValue)) {
996
- try {
997
- (parser || JSON.parse)(rawValue);
998
- return utils$1.trim(rawValue);
999
- } catch (e) {
1000
- if (e.name !== "SyntaxError") {
1001
- throw e;
1002
- }
1003
- }
1004
- }
1005
- return (encoder || JSON.stringify)(rawValue);
1006
- }
1007
- const defaults = {
1008
- transitional: transitionalDefaults,
1009
- adapter: ["xhr", "http", "fetch"],
1010
- transformRequest: [function transformRequest(data, headers) {
1011
- const contentType = headers.getContentType() || "";
1012
- const hasJSONContentType = contentType.indexOf("application/json") > -1;
1013
- const isObjectPayload = utils$1.isObject(data);
1014
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1015
- data = new FormData(data);
1016
- }
1017
- const isFormData2 = utils$1.isFormData(data);
1018
- if (isFormData2) {
1019
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1020
- }
1021
- if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
1022
- return data;
1023
- }
1024
- if (utils$1.isArrayBufferView(data)) {
1025
- return data.buffer;
1026
- }
1027
- if (utils$1.isURLSearchParams(data)) {
1028
- headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
1029
- return data.toString();
1030
- }
1031
- let isFileList2;
1032
- if (isObjectPayload) {
1033
- if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
1034
- return toURLEncodedForm(data, this.formSerializer).toString();
1035
- }
1036
- if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
1037
- const _FormData = this.env && this.env.FormData;
1038
- return toFormData$1(
1039
- isFileList2 ? { "files[]": data } : data,
1040
- _FormData && new _FormData(),
1041
- this.formSerializer
1042
- );
1043
- }
1044
- }
1045
- if (isObjectPayload || hasJSONContentType) {
1046
- headers.setContentType("application/json", false);
1047
- return stringifySafely(data);
1048
- }
1049
- return data;
1050
- }],
1051
- transformResponse: [function transformResponse(data) {
1052
- const transitional2 = this.transitional || defaults.transitional;
1053
- const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
1054
- const JSONRequested = this.responseType === "json";
1055
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1056
- return data;
1057
- }
1058
- if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1059
- const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
1060
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
1061
- try {
1062
- return JSON.parse(data, this.parseReviver);
1063
- } catch (e) {
1064
- if (strictJSONParsing) {
1065
- if (e.name === "SyntaxError") {
1066
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1067
- }
1068
- throw e;
1069
- }
1070
- }
1071
- }
1072
- return data;
1073
- }],
1074
- /**
1075
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
1076
- * timeout is not created.
1077
- */
1078
- timeout: 0,
1079
- xsrfCookieName: "XSRF-TOKEN",
1080
- xsrfHeaderName: "X-XSRF-TOKEN",
1081
- maxContentLength: -1,
1082
- maxBodyLength: -1,
1083
- env: {
1084
- FormData: platform.classes.FormData,
1085
- Blob: platform.classes.Blob
1086
- },
1087
- validateStatus: function validateStatus(status) {
1088
- return status >= 200 && status < 300;
1089
- },
1090
- headers: {
1091
- common: {
1092
- "Accept": "application/json, text/plain, */*",
1093
- "Content-Type": void 0
1094
- }
1095
- }
1096
- };
1097
- utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
1098
- defaults.headers[method] = {};
1099
- });
1100
- const ignoreDuplicateOf = utils$1.toObjectSet([
1101
- "age",
1102
- "authorization",
1103
- "content-length",
1104
- "content-type",
1105
- "etag",
1106
- "expires",
1107
- "from",
1108
- "host",
1109
- "if-modified-since",
1110
- "if-unmodified-since",
1111
- "last-modified",
1112
- "location",
1113
- "max-forwards",
1114
- "proxy-authorization",
1115
- "referer",
1116
- "retry-after",
1117
- "user-agent"
1118
- ]);
1119
- const parseHeaders = (rawHeaders) => {
1120
- const parsed = {};
1121
- let key;
1122
- let val;
1123
- let i;
1124
- rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
1125
- i = line.indexOf(":");
1126
- key = line.substring(0, i).trim().toLowerCase();
1127
- val = line.substring(i + 1).trim();
1128
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1129
- return;
1130
- }
1131
- if (key === "set-cookie") {
1132
- if (parsed[key]) {
1133
- parsed[key].push(val);
1134
- } else {
1135
- parsed[key] = [val];
1136
- }
1137
- } else {
1138
- parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
1139
- }
1140
- });
1141
- return parsed;
1142
- };
1143
- const $internals = Symbol("internals");
1144
- function normalizeHeader(header) {
1145
- return header && String(header).trim().toLowerCase();
1146
- }
1147
- function normalizeValue(value) {
1148
- if (value === false || value == null) {
1149
- return value;
1150
- }
1151
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1152
- }
1153
- function parseTokens(str) {
1154
- const tokens = /* @__PURE__ */ Object.create(null);
1155
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1156
- let match;
1157
- while (match = tokensRE.exec(str)) {
1158
- tokens[match[1]] = match[2];
1159
- }
1160
- return tokens;
1161
- }
1162
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1163
- function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
1164
- if (utils$1.isFunction(filter2)) {
1165
- return filter2.call(this, value, header);
1166
- }
1167
- if (isHeaderNameFilter) {
1168
- value = header;
1169
- }
1170
- if (!utils$1.isString(value)) return;
1171
- if (utils$1.isString(filter2)) {
1172
- return value.indexOf(filter2) !== -1;
1173
- }
1174
- if (utils$1.isRegExp(filter2)) {
1175
- return filter2.test(value);
1176
- }
1177
- }
1178
- function formatHeader(header) {
1179
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1180
- return char.toUpperCase() + str;
1181
- });
1182
- }
1183
- function buildAccessors(obj, header) {
1184
- const accessorName = utils$1.toCamelCase(" " + header);
1185
- ["get", "set", "has"].forEach((methodName) => {
1186
- Object.defineProperty(obj, methodName + accessorName, {
1187
- value: function(arg1, arg2, arg3) {
1188
- return this[methodName].call(this, header, arg1, arg2, arg3);
1189
- },
1190
- configurable: true
1191
- });
1192
- });
1193
- }
1194
- let AxiosHeaders$1 = class AxiosHeaders {
1195
- constructor(headers) {
1196
- headers && this.set(headers);
1197
- }
1198
- set(header, valueOrRewrite, rewrite) {
1199
- const self2 = this;
1200
- function setHeader(_value, _header, _rewrite) {
1201
- const lHeader = normalizeHeader(_header);
1202
- if (!lHeader) {
1203
- throw new Error("header name must be a non-empty string");
1204
- }
1205
- const key = utils$1.findKey(self2, lHeader);
1206
- if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
1207
- self2[key || _header] = normalizeValue(_value);
1208
- }
1209
- }
1210
- const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1211
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1212
- setHeaders(header, valueOrRewrite);
1213
- } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1214
- setHeaders(parseHeaders(header), valueOrRewrite);
1215
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1216
- let obj = {}, dest, key;
1217
- for (const entry of header) {
1218
- if (!utils$1.isArray(entry)) {
1219
- throw TypeError("Object iterator must return a key-value pair");
1220
- }
1221
- obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
1222
- }
1223
- setHeaders(obj, valueOrRewrite);
1224
- } else {
1225
- header != null && setHeader(valueOrRewrite, header, rewrite);
1226
- }
1227
- return this;
1228
- }
1229
- get(header, parser) {
1230
- header = normalizeHeader(header);
1231
- if (header) {
1232
- const key = utils$1.findKey(this, header);
1233
- if (key) {
1234
- const value = this[key];
1235
- if (!parser) {
1236
- return value;
1237
- }
1238
- if (parser === true) {
1239
- return parseTokens(value);
1240
- }
1241
- if (utils$1.isFunction(parser)) {
1242
- return parser.call(this, value, key);
1243
- }
1244
- if (utils$1.isRegExp(parser)) {
1245
- return parser.exec(value);
1246
- }
1247
- throw new TypeError("parser must be boolean|regexp|function");
1248
- }
1249
- }
1250
- }
1251
- has(header, matcher) {
1252
- header = normalizeHeader(header);
1253
- if (header) {
1254
- const key = utils$1.findKey(this, header);
1255
- return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1256
- }
1257
- return false;
1258
- }
1259
- delete(header, matcher) {
1260
- const self2 = this;
1261
- let deleted = false;
1262
- function deleteHeader(_header) {
1263
- _header = normalizeHeader(_header);
1264
- if (_header) {
1265
- const key = utils$1.findKey(self2, _header);
1266
- if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
1267
- delete self2[key];
1268
- deleted = true;
1269
- }
1270
- }
1271
- }
1272
- if (utils$1.isArray(header)) {
1273
- header.forEach(deleteHeader);
1274
- } else {
1275
- deleteHeader(header);
1276
- }
1277
- return deleted;
1278
- }
1279
- clear(matcher) {
1280
- const keys = Object.keys(this);
1281
- let i = keys.length;
1282
- let deleted = false;
1283
- while (i--) {
1284
- const key = keys[i];
1285
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1286
- delete this[key];
1287
- deleted = true;
1288
- }
1289
- }
1290
- return deleted;
1291
- }
1292
- normalize(format2) {
1293
- const self2 = this;
1294
- const headers = {};
1295
- utils$1.forEach(this, (value, header) => {
1296
- const key = utils$1.findKey(headers, header);
1297
- if (key) {
1298
- self2[key] = normalizeValue(value);
1299
- delete self2[header];
1300
- return;
1301
- }
1302
- const normalized = format2 ? formatHeader(header) : String(header).trim();
1303
- if (normalized !== header) {
1304
- delete self2[header];
1305
- }
1306
- self2[normalized] = normalizeValue(value);
1307
- headers[normalized] = true;
1308
- });
1309
- return this;
1310
- }
1311
- concat(...targets) {
1312
- return this.constructor.concat(this, ...targets);
1313
- }
1314
- toJSON(asStrings) {
1315
- const obj = /* @__PURE__ */ Object.create(null);
1316
- utils$1.forEach(this, (value, header) => {
1317
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
1318
- });
1319
- return obj;
1320
- }
1321
- [Symbol.iterator]() {
1322
- return Object.entries(this.toJSON())[Symbol.iterator]();
1323
- }
1324
- toString() {
1325
- return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1326
- }
1327
- getSetCookie() {
1328
- return this.get("set-cookie") || [];
1329
- }
1330
- get [Symbol.toStringTag]() {
1331
- return "AxiosHeaders";
1332
- }
1333
- static from(thing) {
1334
- return thing instanceof this ? thing : new this(thing);
1335
- }
1336
- static concat(first, ...targets) {
1337
- const computed = new this(first);
1338
- targets.forEach((target) => computed.set(target));
1339
- return computed;
1340
- }
1341
- static accessor(header) {
1342
- const internals = this[$internals] = this[$internals] = {
1343
- accessors: {}
1344
- };
1345
- const accessors = internals.accessors;
1346
- const prototype2 = this.prototype;
1347
- function defineAccessor(_header) {
1348
- const lHeader = normalizeHeader(_header);
1349
- if (!accessors[lHeader]) {
1350
- buildAccessors(prototype2, _header);
1351
- accessors[lHeader] = true;
1352
- }
1353
- }
1354
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1355
- return this;
1356
- }
1357
- };
1358
- AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1359
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
1360
- let mapped = key[0].toUpperCase() + key.slice(1);
1361
- return {
1362
- get: () => value,
1363
- set(headerValue) {
1364
- this[mapped] = headerValue;
1365
- }
1366
- };
1367
- });
1368
- utils$1.freezeMethods(AxiosHeaders$1);
1369
- function transformData(fns, response) {
1370
- const config = this || defaults;
1371
- const context = response || config;
1372
- const headers = AxiosHeaders$1.from(context.headers);
1373
- let data = context.data;
1374
- utils$1.forEach(fns, function transform(fn) {
1375
- data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
1376
- });
1377
- headers.normalize();
1378
- return data;
1379
- }
1380
- function isCancel$1(value) {
1381
- return !!(value && value.__CANCEL__);
1382
- }
1383
- function CanceledError$1(message, config, request) {
1384
- AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config, request);
1385
- this.name = "CanceledError";
1386
- }
1387
- utils$1.inherits(CanceledError$1, AxiosError$1, {
1388
- __CANCEL__: true
1389
- });
1390
- function settle(resolve, reject, response) {
1391
- const validateStatus2 = response.config.validateStatus;
1392
- if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
1393
- resolve(response);
1394
- } else {
1395
- reject(new AxiosError$1(
1396
- "Request failed with status code " + response.status,
1397
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1398
- response.config,
1399
- response.request,
1400
- response
1401
- ));
1402
- }
1403
- }
1404
- function parseProtocol(url) {
1405
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1406
- return match && match[1] || "";
1407
- }
1408
- function speedometer(samplesCount, min) {
1409
- samplesCount = samplesCount || 10;
1410
- const bytes = new Array(samplesCount);
1411
- const timestamps = new Array(samplesCount);
1412
- let head = 0;
1413
- let tail = 0;
1414
- let firstSampleTS;
1415
- min = min !== void 0 ? min : 1e3;
1416
- return function push(chunkLength) {
1417
- const now = Date.now();
1418
- const startedAt = timestamps[tail];
1419
- if (!firstSampleTS) {
1420
- firstSampleTS = now;
1421
- }
1422
- bytes[head] = chunkLength;
1423
- timestamps[head] = now;
1424
- let i = tail;
1425
- let bytesCount = 0;
1426
- while (i !== head) {
1427
- bytesCount += bytes[i++];
1428
- i = i % samplesCount;
1429
- }
1430
- head = (head + 1) % samplesCount;
1431
- if (head === tail) {
1432
- tail = (tail + 1) % samplesCount;
1433
- }
1434
- if (now - firstSampleTS < min) {
1435
- return;
1436
- }
1437
- const passed = startedAt && now - startedAt;
1438
- return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1439
- };
1440
- }
1441
- function throttle(fn, freq) {
1442
- let timestamp = 0;
1443
- let threshold = 1e3 / freq;
1444
- let lastArgs;
1445
- let timer;
1446
- const invoke = (args, now = Date.now()) => {
1447
- timestamp = now;
1448
- lastArgs = null;
1449
- if (timer) {
1450
- clearTimeout(timer);
1451
- timer = null;
1452
- }
1453
- fn(...args);
1454
- };
1455
- const throttled = (...args) => {
1456
- const now = Date.now();
1457
- const passed = now - timestamp;
1458
- if (passed >= threshold) {
1459
- invoke(args, now);
1460
- } else {
1461
- lastArgs = args;
1462
- if (!timer) {
1463
- timer = setTimeout(() => {
1464
- timer = null;
1465
- invoke(lastArgs);
1466
- }, threshold - passed);
1467
- }
1468
- }
1469
- };
1470
- const flush = () => lastArgs && invoke(lastArgs);
1471
- return [throttled, flush];
1472
- }
1473
- const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
1474
- let bytesNotified = 0;
1475
- const _speedometer = speedometer(50, 250);
1476
- return throttle((e) => {
1477
- const loaded = e.loaded;
1478
- const total = e.lengthComputable ? e.total : void 0;
1479
- const progressBytes = loaded - bytesNotified;
1480
- const rate = _speedometer(progressBytes);
1481
- const inRange = loaded <= total;
1482
- bytesNotified = loaded;
1483
- const data = {
1484
- loaded,
1485
- total,
1486
- progress: total ? loaded / total : void 0,
1487
- bytes: progressBytes,
1488
- rate: rate ? rate : void 0,
1489
- estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
1490
- event: e,
1491
- lengthComputable: total != null,
1492
- [isDownloadStream ? "download" : "upload"]: true
1493
- };
1494
- listener(data);
1495
- }, freq);
1496
- };
1497
- const progressEventDecorator = (total, throttled) => {
1498
- const lengthComputable = total != null;
1499
- return [(loaded) => throttled[0]({
1500
- lengthComputable,
1501
- total,
1502
- loaded
1503
- }), throttled[1]];
1504
- };
1505
- const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
1506
- const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
1507
- url = new URL(url, platform.origin);
1508
- return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
1509
- })(
1510
- new URL(platform.origin),
1511
- platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
1512
- ) : () => true;
1513
- const cookies = platform.hasStandardBrowserEnv ? (
1514
- // Standard browser envs support document.cookie
1515
- {
1516
- write(name, value, expires, path, domain, secure) {
1517
- const cookie = [name + "=" + encodeURIComponent(value)];
1518
- utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
1519
- utils$1.isString(path) && cookie.push("path=" + path);
1520
- utils$1.isString(domain) && cookie.push("domain=" + domain);
1521
- secure === true && cookie.push("secure");
1522
- document.cookie = cookie.join("; ");
1523
- },
1524
- read(name) {
1525
- const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
1526
- return match ? decodeURIComponent(match[3]) : null;
1527
- },
1528
- remove(name) {
1529
- this.write(name, "", Date.now() - 864e5);
1530
- }
1531
- }
1532
- ) : (
1533
- // Non-standard browser env (web workers, react-native) lack needed support.
1534
- {
1535
- write() {
1536
- },
1537
- read() {
1538
- return null;
1539
- },
1540
- remove() {
1541
- }
1542
- }
1543
- );
1544
- function isAbsoluteURL(url) {
1545
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1546
- }
1547
- function combineURLs(baseURL, relativeURL) {
1548
- return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1549
- }
1550
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
1551
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
1552
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
1553
- return combineURLs(baseURL, requestedURL);
1554
- }
1555
- return requestedURL;
1556
- }
1557
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
1558
- function mergeConfig$1(config1, config2) {
1559
- config2 = config2 || {};
1560
- const config = {};
1561
- function getMergedValue(target, source, prop, caseless) {
1562
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
1563
- return utils$1.merge.call({ caseless }, target, source);
1564
- } else if (utils$1.isPlainObject(source)) {
1565
- return utils$1.merge({}, source);
1566
- } else if (utils$1.isArray(source)) {
1567
- return source.slice();
1568
- }
1569
- return source;
1570
- }
1571
- function mergeDeepProperties(a, b, prop, caseless) {
1572
- if (!utils$1.isUndefined(b)) {
1573
- return getMergedValue(a, b, prop, caseless);
1574
- } else if (!utils$1.isUndefined(a)) {
1575
- return getMergedValue(void 0, a, prop, caseless);
1576
- }
1577
- }
1578
- function valueFromConfig2(a, b) {
1579
- if (!utils$1.isUndefined(b)) {
1580
- return getMergedValue(void 0, b);
1581
- }
1582
- }
1583
- function defaultToConfig2(a, b) {
1584
- if (!utils$1.isUndefined(b)) {
1585
- return getMergedValue(void 0, b);
1586
- } else if (!utils$1.isUndefined(a)) {
1587
- return getMergedValue(void 0, a);
1588
- }
1589
- }
1590
- function mergeDirectKeys(a, b, prop) {
1591
- if (prop in config2) {
1592
- return getMergedValue(a, b);
1593
- } else if (prop in config1) {
1594
- return getMergedValue(void 0, a);
1595
- }
1596
- }
1597
- const mergeMap = {
1598
- url: valueFromConfig2,
1599
- method: valueFromConfig2,
1600
- data: valueFromConfig2,
1601
- baseURL: defaultToConfig2,
1602
- transformRequest: defaultToConfig2,
1603
- transformResponse: defaultToConfig2,
1604
- paramsSerializer: defaultToConfig2,
1605
- timeout: defaultToConfig2,
1606
- timeoutMessage: defaultToConfig2,
1607
- withCredentials: defaultToConfig2,
1608
- withXSRFToken: defaultToConfig2,
1609
- adapter: defaultToConfig2,
1610
- responseType: defaultToConfig2,
1611
- xsrfCookieName: defaultToConfig2,
1612
- xsrfHeaderName: defaultToConfig2,
1613
- onUploadProgress: defaultToConfig2,
1614
- onDownloadProgress: defaultToConfig2,
1615
- decompress: defaultToConfig2,
1616
- maxContentLength: defaultToConfig2,
1617
- maxBodyLength: defaultToConfig2,
1618
- beforeRedirect: defaultToConfig2,
1619
- transport: defaultToConfig2,
1620
- httpAgent: defaultToConfig2,
1621
- httpsAgent: defaultToConfig2,
1622
- cancelToken: defaultToConfig2,
1623
- socketPath: defaultToConfig2,
1624
- responseEncoding: defaultToConfig2,
1625
- validateStatus: mergeDirectKeys,
1626
- headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
1627
- };
1628
- utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
1629
- const merge2 = mergeMap[prop] || mergeDeepProperties;
1630
- const configValue = merge2(config1[prop], config2[prop], prop);
1631
- utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
1632
- });
1633
- return config;
1634
- }
1635
- const resolveConfig = (config) => {
1636
- const newConfig = mergeConfig$1({}, config);
1637
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth: auth2 } = newConfig;
1638
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
1639
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
1640
- if (auth2) {
1641
- headers.set(
1642
- "Authorization",
1643
- "Basic " + btoa((auth2.username || "") + ":" + (auth2.password ? unescape(encodeURIComponent(auth2.password)) : ""))
1644
- );
1645
- }
1646
- if (utils$1.isFormData(data)) {
1647
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
1648
- headers.setContentType(void 0);
1649
- } else if (utils$1.isFunction(data.getHeaders)) {
1650
- const formHeaders = data.getHeaders();
1651
- const allowedHeaders = ["content-type", "content-length"];
1652
- Object.entries(formHeaders).forEach(([key, val]) => {
1653
- if (allowedHeaders.includes(key.toLowerCase())) {
1654
- headers.set(key, val);
1655
- }
1656
- });
1657
- }
1658
- }
1659
- if (platform.hasStandardBrowserEnv) {
1660
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
1661
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
1662
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
1663
- if (xsrfValue) {
1664
- headers.set(xsrfHeaderName, xsrfValue);
1665
- }
1666
- }
1667
- }
1668
- return newConfig;
1669
- };
1670
- const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
1671
- const xhrAdapter = isXHRAdapterSupported && function(config) {
1672
- return new Promise(function dispatchXhrRequest(resolve, reject) {
1673
- const _config = resolveConfig(config);
1674
- let requestData = _config.data;
1675
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
1676
- let { responseType, onUploadProgress, onDownloadProgress } = _config;
1677
- let onCanceled;
1678
- let uploadThrottled, downloadThrottled;
1679
- let flushUpload, flushDownload;
1680
- function done() {
1681
- flushUpload && flushUpload();
1682
- flushDownload && flushDownload();
1683
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
1684
- _config.signal && _config.signal.removeEventListener("abort", onCanceled);
1685
- }
1686
- let request = new XMLHttpRequest();
1687
- request.open(_config.method.toUpperCase(), _config.url, true);
1688
- request.timeout = _config.timeout;
1689
- function onloadend() {
1690
- if (!request) {
1691
- return;
1692
- }
1693
- const responseHeaders = AxiosHeaders$1.from(
1694
- "getAllResponseHeaders" in request && request.getAllResponseHeaders()
1695
- );
1696
- const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
1697
- const response = {
1698
- data: responseData,
1699
- status: request.status,
1700
- statusText: request.statusText,
1701
- headers: responseHeaders,
1702
- config,
1703
- request
1704
- };
1705
- settle(function _resolve(value) {
1706
- resolve(value);
1707
- done();
1708
- }, function _reject(err) {
1709
- reject(err);
1710
- done();
1711
- }, response);
1712
- request = null;
1713
- }
1714
- if ("onloadend" in request) {
1715
- request.onloadend = onloadend;
1716
- } else {
1717
- request.onreadystatechange = function handleLoad() {
1718
- if (!request || request.readyState !== 4) {
1719
- return;
1720
- }
1721
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
1722
- return;
1723
- }
1724
- setTimeout(onloadend);
1725
- };
1726
- }
1727
- request.onabort = function handleAbort() {
1728
- if (!request) {
1729
- return;
1730
- }
1731
- reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config, request));
1732
- request = null;
1733
- };
1734
- request.onerror = function handleError(event) {
1735
- const msg = event && event.message ? event.message : "Network Error";
1736
- const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
1737
- err.event = event || null;
1738
- reject(err);
1739
- request = null;
1740
- };
1741
- request.ontimeout = function handleTimeout() {
1742
- let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
1743
- const transitional2 = _config.transitional || transitionalDefaults;
1744
- if (_config.timeoutErrorMessage) {
1745
- timeoutErrorMessage = _config.timeoutErrorMessage;
1746
- }
1747
- reject(new AxiosError$1(
1748
- timeoutErrorMessage,
1749
- transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
1750
- config,
1751
- request
1752
- ));
1753
- request = null;
1754
- };
1755
- requestData === void 0 && requestHeaders.setContentType(null);
1756
- if ("setRequestHeader" in request) {
1757
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
1758
- request.setRequestHeader(key, val);
1759
- });
1760
- }
1761
- if (!utils$1.isUndefined(_config.withCredentials)) {
1762
- request.withCredentials = !!_config.withCredentials;
1763
- }
1764
- if (responseType && responseType !== "json") {
1765
- request.responseType = _config.responseType;
1766
- }
1767
- if (onDownloadProgress) {
1768
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
1769
- request.addEventListener("progress", downloadThrottled);
1770
- }
1771
- if (onUploadProgress && request.upload) {
1772
- [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
1773
- request.upload.addEventListener("progress", uploadThrottled);
1774
- request.upload.addEventListener("loadend", flushUpload);
1775
- }
1776
- if (_config.cancelToken || _config.signal) {
1777
- onCanceled = (cancel) => {
1778
- if (!request) {
1779
- return;
1780
- }
1781
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
1782
- request.abort();
1783
- request = null;
1784
- };
1785
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
1786
- if (_config.signal) {
1787
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
1788
- }
1789
- }
1790
- const protocol = parseProtocol(_config.url);
1791
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
1792
- reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config));
1793
- return;
1794
- }
1795
- request.send(requestData || null);
1796
- });
1797
- };
1798
- const composeSignals = (signals, timeout) => {
1799
- const { length } = signals = signals ? signals.filter(Boolean) : [];
1800
- if (timeout || length) {
1801
- let controller = new AbortController();
1802
- let aborted;
1803
- const onabort = function(reason) {
1804
- if (!aborted) {
1805
- aborted = true;
1806
- unsubscribe();
1807
- const err = reason instanceof Error ? reason : this.reason;
1808
- controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
1809
- }
1810
- };
1811
- let timer = timeout && setTimeout(() => {
1812
- timer = null;
1813
- onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
1814
- }, timeout);
1815
- const unsubscribe = () => {
1816
- if (signals) {
1817
- timer && clearTimeout(timer);
1818
- timer = null;
1819
- signals.forEach((signal2) => {
1820
- signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
1821
- });
1822
- signals = null;
1823
- }
1824
- };
1825
- signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
1826
- const { signal } = controller;
1827
- signal.unsubscribe = () => utils$1.asap(unsubscribe);
1828
- return signal;
1829
- }
1830
- };
1831
- const streamChunk = function* (chunk, chunkSize) {
1832
- let len = chunk.byteLength;
1833
- if (len < chunkSize) {
1834
- yield chunk;
1835
- return;
1836
- }
1837
- let pos = 0;
1838
- let end;
1839
- while (pos < len) {
1840
- end = pos + chunkSize;
1841
- yield chunk.slice(pos, end);
1842
- pos = end;
1843
- }
1844
- };
1845
- const readBytes = async function* (iterable, chunkSize) {
1846
- for await (const chunk of readStream(iterable)) {
1847
- yield* streamChunk(chunk, chunkSize);
1848
- }
1849
- };
1850
- const readStream = async function* (stream) {
1851
- if (stream[Symbol.asyncIterator]) {
1852
- yield* stream;
1853
- return;
1854
- }
1855
- const reader = stream.getReader();
1856
- try {
1857
- for (; ; ) {
1858
- const { done, value } = await reader.read();
1859
- if (done) {
1860
- break;
1861
- }
1862
- yield value;
1863
- }
1864
- } finally {
1865
- await reader.cancel();
1866
- }
1867
- };
1868
- const trackStream = (stream, chunkSize, onProgress, onFinish) => {
1869
- const iterator2 = readBytes(stream, chunkSize);
1870
- let bytes = 0;
1871
- let done;
1872
- let _onFinish = (e) => {
1873
- if (!done) {
1874
- done = true;
1875
- onFinish && onFinish(e);
1876
- }
1877
- };
1878
- return new ReadableStream({
1879
- async pull(controller) {
1880
- try {
1881
- const { done: done2, value } = await iterator2.next();
1882
- if (done2) {
1883
- _onFinish();
1884
- controller.close();
1885
- return;
1886
- }
1887
- let len = value.byteLength;
1888
- if (onProgress) {
1889
- let loadedBytes = bytes += len;
1890
- onProgress(loadedBytes);
1891
- }
1892
- controller.enqueue(new Uint8Array(value));
1893
- } catch (err) {
1894
- _onFinish(err);
1895
- throw err;
1896
- }
1897
- },
1898
- cancel(reason) {
1899
- _onFinish(reason);
1900
- return iterator2.return();
1901
- }
1902
- }, {
1903
- highWaterMark: 2
1904
- });
1905
- };
1906
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
1907
- const { isFunction } = utils$1;
1908
- const globalFetchAPI = (({ fetch, Request, Response }) => ({
1909
- fetch,
1910
- Request,
1911
- Response
1912
- }))(utils$1.global);
1913
- const {
1914
- ReadableStream: ReadableStream$1,
1915
- TextEncoder
1916
- } = utils$1.global;
1917
- const test = (fn, ...args) => {
1918
- try {
1919
- return !!fn(...args);
1920
- } catch (e) {
1921
- return false;
1922
- }
1923
- };
1924
- const factory = (env) => {
1925
- const { fetch, Request, Response } = Object.assign({}, globalFetchAPI, env);
1926
- const isFetchSupported = isFunction(fetch);
1927
- const isRequestSupported = isFunction(Request);
1928
- const isResponseSupported = isFunction(Response);
1929
- if (!isFetchSupported) {
1930
- return false;
1931
- }
1932
- const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
1933
- const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
1934
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
1935
- let duplexAccessed = false;
1936
- const hasContentType = new Request(platform.origin, {
1937
- body: new ReadableStream$1(),
1938
- method: "POST",
1939
- get duplex() {
1940
- duplexAccessed = true;
1941
- return "half";
1942
- }
1943
- }).headers.has("Content-Type");
1944
- return duplexAccessed && !hasContentType;
1945
- });
1946
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
1947
- const resolvers = {
1948
- stream: supportsResponseStream && ((res) => res.body)
1949
- };
1950
- isFetchSupported && (() => {
1951
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
1952
- !resolvers[type] && (resolvers[type] = (res, config) => {
1953
- let method = res && res[type];
1954
- if (method) {
1955
- return method.call(res);
1956
- }
1957
- throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
1958
- });
1959
- });
1960
- })();
1961
- const getBodyLength = async (body) => {
1962
- if (body == null) {
1963
- return 0;
1964
- }
1965
- if (utils$1.isBlob(body)) {
1966
- return body.size;
1967
- }
1968
- if (utils$1.isSpecCompliantForm(body)) {
1969
- const _request = new Request(platform.origin, {
1970
- method: "POST",
1971
- body
1972
- });
1973
- return (await _request.arrayBuffer()).byteLength;
1974
- }
1975
- if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
1976
- return body.byteLength;
1977
- }
1978
- if (utils$1.isURLSearchParams(body)) {
1979
- body = body + "";
1980
- }
1981
- if (utils$1.isString(body)) {
1982
- return (await encodeText(body)).byteLength;
1983
- }
1984
- };
1985
- const resolveBodyLength = async (headers, body) => {
1986
- const length = utils$1.toFiniteNumber(headers.getContentLength());
1987
- return length == null ? getBodyLength(body) : length;
1988
- };
1989
- return async (config) => {
1990
- let {
1991
- url,
1992
- method,
1993
- data,
1994
- signal,
1995
- cancelToken,
1996
- timeout,
1997
- onDownloadProgress,
1998
- onUploadProgress,
1999
- responseType,
2000
- headers,
2001
- withCredentials = "same-origin",
2002
- fetchOptions
2003
- } = resolveConfig(config);
2004
- responseType = responseType ? (responseType + "").toLowerCase() : "text";
2005
- let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2006
- let request = null;
2007
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2008
- composedSignal.unsubscribe();
2009
- });
2010
- let requestContentLength;
2011
- try {
2012
- if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
2013
- let _request = new Request(url, {
2014
- method: "POST",
2015
- body: data,
2016
- duplex: "half"
2017
- });
2018
- let contentTypeHeader;
2019
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
2020
- headers.setContentType(contentTypeHeader);
2021
- }
2022
- if (_request.body) {
2023
- const [onProgress, flush] = progressEventDecorator(
2024
- requestContentLength,
2025
- progressEventReducer(asyncDecorator(onUploadProgress))
2026
- );
2027
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2028
- }
2029
- }
2030
- if (!utils$1.isString(withCredentials)) {
2031
- withCredentials = withCredentials ? "include" : "omit";
2032
- }
2033
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
2034
- const resolvedOptions = {
2035
- ...fetchOptions,
2036
- signal: composedSignal,
2037
- method: method.toUpperCase(),
2038
- headers: headers.normalize().toJSON(),
2039
- body: data,
2040
- duplex: "half",
2041
- credentials: isCredentialsSupported ? withCredentials : void 0
2042
- };
2043
- request = isRequestSupported && new Request(url, resolvedOptions);
2044
- let response = await (isRequestSupported ? fetch(request, fetchOptions) : fetch(url, resolvedOptions));
2045
- const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
2046
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
2047
- const options = {};
2048
- ["status", "statusText", "headers"].forEach((prop) => {
2049
- options[prop] = response[prop];
2050
- });
2051
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
2052
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2053
- responseContentLength,
2054
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
2055
- ) || [];
2056
- response = new Response(
2057
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2058
- flush && flush();
2059
- unsubscribe && unsubscribe();
2060
- }),
2061
- options
2062
- );
2063
- }
2064
- responseType = responseType || "text";
2065
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
2066
- !isStreamResponse && unsubscribe && unsubscribe();
2067
- return await new Promise((resolve, reject) => {
2068
- settle(resolve, reject, {
2069
- data: responseData,
2070
- headers: AxiosHeaders$1.from(response.headers),
2071
- status: response.status,
2072
- statusText: response.statusText,
2073
- config,
2074
- request
2075
- });
2076
- });
2077
- } catch (err) {
2078
- unsubscribe && unsubscribe();
2079
- if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
2080
- throw Object.assign(
2081
- new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request),
2082
- {
2083
- cause: err.cause || err
2084
- }
2085
- );
2086
- }
2087
- throw AxiosError$1.from(err, err && err.code, config, request);
2088
- }
2089
- };
2090
- };
2091
- const seedCache = /* @__PURE__ */ new Map();
2092
- const getFetch = (config) => {
2093
- let env = utils$1.merge.call({
2094
- skipUndefined: true
2095
- }, globalFetchAPI, config ? config.env : null);
2096
- const { fetch, Request, Response } = env;
2097
- const seeds = [
2098
- Request,
2099
- Response,
2100
- fetch
2101
- ];
2102
- let len = seeds.length, i = len, seed, target, map = seedCache;
2103
- while (i--) {
2104
- seed = seeds[i];
2105
- target = map.get(seed);
2106
- target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
2107
- map = target;
2108
- }
2109
- return target;
2110
- };
2111
- getFetch();
2112
- const knownAdapters = {
2113
- http: httpAdapter,
2114
- xhr: xhrAdapter,
2115
- fetch: {
2116
- get: getFetch
2117
- }
2118
- };
2119
- utils$1.forEach(knownAdapters, (fn, value) => {
2120
- if (fn) {
2121
- try {
2122
- Object.defineProperty(fn, "name", { value });
2123
- } catch (e) {
2124
- }
2125
- Object.defineProperty(fn, "adapterName", { value });
2126
- }
2127
- });
2128
- const renderReason = (reason) => `- ${reason}`;
2129
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
2130
- const adapters = {
2131
- getAdapter: (adapters2, config) => {
2132
- adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
2133
- const { length } = adapters2;
2134
- let nameOrAdapter;
2135
- let adapter;
2136
- const rejectedReasons = {};
2137
- for (let i = 0; i < length; i++) {
2138
- nameOrAdapter = adapters2[i];
2139
- let id;
2140
- adapter = nameOrAdapter;
2141
- if (!isResolvedHandle(nameOrAdapter)) {
2142
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
2143
- if (adapter === void 0) {
2144
- throw new AxiosError$1(`Unknown adapter '${id}'`);
2145
- }
2146
- }
2147
- if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
2148
- break;
2149
- }
2150
- rejectedReasons[id || "#" + i] = adapter;
2151
- }
2152
- if (!adapter) {
2153
- const reasons = Object.entries(rejectedReasons).map(
2154
- ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
2155
- );
2156
- let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
2157
- throw new AxiosError$1(
2158
- `There is no suitable adapter to dispatch the request ` + s,
2159
- "ERR_NOT_SUPPORT"
2160
- );
2161
- }
2162
- return adapter;
2163
- },
2164
- adapters: knownAdapters
2165
- };
2166
- function throwIfCancellationRequested(config) {
2167
- if (config.cancelToken) {
2168
- config.cancelToken.throwIfRequested();
2169
- }
2170
- if (config.signal && config.signal.aborted) {
2171
- throw new CanceledError$1(null, config);
2172
- }
2173
- }
2174
- function dispatchRequest(config) {
2175
- throwIfCancellationRequested(config);
2176
- config.headers = AxiosHeaders$1.from(config.headers);
2177
- config.data = transformData.call(
2178
- config,
2179
- config.transformRequest
2180
- );
2181
- if (["post", "put", "patch"].indexOf(config.method) !== -1) {
2182
- config.headers.setContentType("application/x-www-form-urlencoded", false);
2183
- }
2184
- const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
2185
- return adapter(config).then(function onAdapterResolution(response) {
2186
- throwIfCancellationRequested(config);
2187
- response.data = transformData.call(
2188
- config,
2189
- config.transformResponse,
2190
- response
2191
- );
2192
- response.headers = AxiosHeaders$1.from(response.headers);
2193
- return response;
2194
- }, function onAdapterRejection(reason) {
2195
- if (!isCancel$1(reason)) {
2196
- throwIfCancellationRequested(config);
2197
- if (reason && reason.response) {
2198
- reason.response.data = transformData.call(
2199
- config,
2200
- config.transformResponse,
2201
- reason.response
2202
- );
2203
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2204
- }
2205
- }
2206
- return Promise.reject(reason);
2207
- });
2208
- }
2209
- const VERSION$1 = "1.12.0";
2210
- const validators$1 = {};
2211
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
2212
- validators$1[type] = function validator2(thing) {
2213
- return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
2214
- };
2215
- });
2216
- const deprecatedWarnings = {};
2217
- validators$1.transitional = function transitional(validator2, version, message) {
2218
- function formatMessage(opt, desc) {
2219
- return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
2220
- }
2221
- return (value, opt, opts) => {
2222
- if (validator2 === false) {
2223
- throw new AxiosError$1(
2224
- formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
2225
- AxiosError$1.ERR_DEPRECATED
2226
- );
2227
- }
2228
- if (version && !deprecatedWarnings[opt]) {
2229
- deprecatedWarnings[opt] = true;
2230
- console.warn(
2231
- formatMessage(
2232
- opt,
2233
- " has been deprecated since v" + version + " and will be removed in the near future"
2234
- )
2235
- );
2236
- }
2237
- return validator2 ? validator2(value, opt, opts) : true;
2238
- };
2239
- };
2240
- validators$1.spelling = function spelling(correctSpelling) {
2241
- return (value, opt) => {
2242
- console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2243
- return true;
2244
- };
2245
- };
2246
- function assertOptions(options, schema, allowUnknown) {
2247
- if (typeof options !== "object") {
2248
- throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
2249
- }
2250
- const keys = Object.keys(options);
2251
- let i = keys.length;
2252
- while (i-- > 0) {
2253
- const opt = keys[i];
2254
- const validator2 = schema[opt];
2255
- if (validator2) {
2256
- const value = options[opt];
2257
- const result = value === void 0 || validator2(value, opt, options);
2258
- if (result !== true) {
2259
- throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2260
- }
2261
- continue;
2262
- }
2263
- if (allowUnknown !== true) {
2264
- throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
2265
- }
2266
- }
2267
- }
2268
- const validator = {
2269
- assertOptions,
2270
- validators: validators$1
2271
- };
2272
- const validators = validator.validators;
2273
- let Axios$1 = class Axios {
2274
- constructor(instanceConfig) {
2275
- this.defaults = instanceConfig || {};
2276
- this.interceptors = {
2277
- request: new InterceptorManager(),
2278
- response: new InterceptorManager()
2279
- };
2280
- }
2281
- /**
2282
- * Dispatch a request
2283
- *
2284
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2285
- * @param {?Object} config
2286
- *
2287
- * @returns {Promise} The Promise to be fulfilled
2288
- */
2289
- async request(configOrUrl, config) {
2290
- try {
2291
- return await this._request(configOrUrl, config);
2292
- } catch (err) {
2293
- if (err instanceof Error) {
2294
- let dummy = {};
2295
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2296
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
2297
- try {
2298
- if (!err.stack) {
2299
- err.stack = stack;
2300
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
2301
- err.stack += "\n" + stack;
2302
- }
2303
- } catch (e) {
2304
- }
2305
- }
2306
- throw err;
2307
- }
2308
- }
2309
- _request(configOrUrl, config) {
2310
- if (typeof configOrUrl === "string") {
2311
- config = config || {};
2312
- config.url = configOrUrl;
2313
- } else {
2314
- config = configOrUrl || {};
2315
- }
2316
- config = mergeConfig$1(this.defaults, config);
2317
- const { transitional: transitional2, paramsSerializer, headers } = config;
2318
- if (transitional2 !== void 0) {
2319
- validator.assertOptions(transitional2, {
2320
- silentJSONParsing: validators.transitional(validators.boolean),
2321
- forcedJSONParsing: validators.transitional(validators.boolean),
2322
- clarifyTimeoutError: validators.transitional(validators.boolean)
2323
- }, false);
2324
- }
2325
- if (paramsSerializer != null) {
2326
- if (utils$1.isFunction(paramsSerializer)) {
2327
- config.paramsSerializer = {
2328
- serialize: paramsSerializer
2329
- };
2330
- } else {
2331
- validator.assertOptions(paramsSerializer, {
2332
- encode: validators.function,
2333
- serialize: validators.function
2334
- }, true);
2335
- }
2336
- }
2337
- if (config.allowAbsoluteUrls !== void 0) ;
2338
- else if (this.defaults.allowAbsoluteUrls !== void 0) {
2339
- config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
2340
- } else {
2341
- config.allowAbsoluteUrls = true;
2342
- }
2343
- validator.assertOptions(config, {
2344
- baseUrl: validators.spelling("baseURL"),
2345
- withXsrfToken: validators.spelling("withXSRFToken")
2346
- }, true);
2347
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
2348
- let contextHeaders = headers && utils$1.merge(
2349
- headers.common,
2350
- headers[config.method]
2351
- );
2352
- headers && utils$1.forEach(
2353
- ["delete", "get", "head", "post", "put", "patch", "common"],
2354
- (method) => {
2355
- delete headers[method];
2356
- }
2357
- );
2358
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2359
- const requestInterceptorChain = [];
2360
- let synchronousRequestInterceptors = true;
2361
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2362
- if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
2363
- return;
2364
- }
2365
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2366
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2367
- });
2368
- const responseInterceptorChain = [];
2369
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2370
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2371
- });
2372
- let promise;
2373
- let i = 0;
2374
- let len;
2375
- if (!synchronousRequestInterceptors) {
2376
- const chain = [dispatchRequest.bind(this), void 0];
2377
- chain.unshift(...requestInterceptorChain);
2378
- chain.push(...responseInterceptorChain);
2379
- len = chain.length;
2380
- promise = Promise.resolve(config);
2381
- while (i < len) {
2382
- promise = promise.then(chain[i++], chain[i++]);
2383
- }
2384
- return promise;
2385
- }
2386
- len = requestInterceptorChain.length;
2387
- let newConfig = config;
2388
- i = 0;
2389
- while (i < len) {
2390
- const onFulfilled = requestInterceptorChain[i++];
2391
- const onRejected = requestInterceptorChain[i++];
2392
- try {
2393
- newConfig = onFulfilled(newConfig);
2394
- } catch (error) {
2395
- onRejected.call(this, error);
2396
- break;
2397
- }
2398
- }
2399
- try {
2400
- promise = dispatchRequest.call(this, newConfig);
2401
- } catch (error) {
2402
- return Promise.reject(error);
2403
- }
2404
- i = 0;
2405
- len = responseInterceptorChain.length;
2406
- while (i < len) {
2407
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2408
- }
2409
- return promise;
2410
- }
2411
- getUri(config) {
2412
- config = mergeConfig$1(this.defaults, config);
2413
- const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
2414
- return buildURL(fullPath, config.params, config.paramsSerializer);
2415
- }
2416
- };
2417
- utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
2418
- Axios$1.prototype[method] = function(url, config) {
2419
- return this.request(mergeConfig$1(config || {}, {
2420
- method,
2421
- url,
2422
- data: (config || {}).data
2423
- }));
2424
- };
2425
- });
2426
- utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
2427
- function generateHTTPMethod(isForm) {
2428
- return function httpMethod(url, data, config) {
2429
- return this.request(mergeConfig$1(config || {}, {
2430
- method,
2431
- headers: isForm ? {
2432
- "Content-Type": "multipart/form-data"
2433
- } : {},
2434
- url,
2435
- data
2436
- }));
2437
- };
2438
- }
2439
- Axios$1.prototype[method] = generateHTTPMethod();
2440
- Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
2441
- });
2442
- let CancelToken$1 = class CancelToken {
2443
- constructor(executor) {
2444
- if (typeof executor !== "function") {
2445
- throw new TypeError("executor must be a function.");
2446
- }
2447
- let resolvePromise;
2448
- this.promise = new Promise(function promiseExecutor(resolve) {
2449
- resolvePromise = resolve;
2450
- });
2451
- const token = this;
2452
- this.promise.then((cancel) => {
2453
- if (!token._listeners) return;
2454
- let i = token._listeners.length;
2455
- while (i-- > 0) {
2456
- token._listeners[i](cancel);
2457
- }
2458
- token._listeners = null;
2459
- });
2460
- this.promise.then = (onfulfilled) => {
2461
- let _resolve;
2462
- const promise = new Promise((resolve) => {
2463
- token.subscribe(resolve);
2464
- _resolve = resolve;
2465
- }).then(onfulfilled);
2466
- promise.cancel = function reject() {
2467
- token.unsubscribe(_resolve);
2468
- };
2469
- return promise;
2470
- };
2471
- executor(function cancel(message, config, request) {
2472
- if (token.reason) {
2473
- return;
2474
- }
2475
- token.reason = new CanceledError$1(message, config, request);
2476
- resolvePromise(token.reason);
2477
- });
2478
- }
2479
- /**
2480
- * Throws a `CanceledError` if cancellation has been requested.
2481
- */
2482
- throwIfRequested() {
2483
- if (this.reason) {
2484
- throw this.reason;
2485
- }
2486
- }
2487
- /**
2488
- * Subscribe to the cancel signal
2489
- */
2490
- subscribe(listener) {
2491
- if (this.reason) {
2492
- listener(this.reason);
2493
- return;
2494
- }
2495
- if (this._listeners) {
2496
- this._listeners.push(listener);
2497
- } else {
2498
- this._listeners = [listener];
2499
- }
2500
- }
2501
- /**
2502
- * Unsubscribe from the cancel signal
2503
- */
2504
- unsubscribe(listener) {
2505
- if (!this._listeners) {
2506
- return;
2507
- }
2508
- const index = this._listeners.indexOf(listener);
2509
- if (index !== -1) {
2510
- this._listeners.splice(index, 1);
2511
- }
2512
- }
2513
- toAbortSignal() {
2514
- const controller = new AbortController();
2515
- const abort = (err) => {
2516
- controller.abort(err);
2517
- };
2518
- this.subscribe(abort);
2519
- controller.signal.unsubscribe = () => this.unsubscribe(abort);
2520
- return controller.signal;
2521
- }
2522
- /**
2523
- * Returns an object that contains a new `CancelToken` and a function that, when called,
2524
- * cancels the `CancelToken`.
2525
- */
2526
- static source() {
2527
- let cancel;
2528
- const token = new CancelToken(function executor(c) {
2529
- cancel = c;
2530
- });
2531
- return {
2532
- token,
2533
- cancel
2534
- };
2535
- }
2536
- };
2537
- function spread$1(callback) {
2538
- return function wrap(arr) {
2539
- return callback.apply(null, arr);
2540
- };
2541
- }
2542
- function isAxiosError$1(payload) {
2543
- return utils$1.isObject(payload) && payload.isAxiosError === true;
2544
- }
2545
- const HttpStatusCode$1 = {
2546
- Continue: 100,
2547
- SwitchingProtocols: 101,
2548
- Processing: 102,
2549
- EarlyHints: 103,
2550
- Ok: 200,
2551
- Created: 201,
2552
- Accepted: 202,
2553
- NonAuthoritativeInformation: 203,
2554
- NoContent: 204,
2555
- ResetContent: 205,
2556
- PartialContent: 206,
2557
- MultiStatus: 207,
2558
- AlreadyReported: 208,
2559
- ImUsed: 226,
2560
- MultipleChoices: 300,
2561
- MovedPermanently: 301,
2562
- Found: 302,
2563
- SeeOther: 303,
2564
- NotModified: 304,
2565
- UseProxy: 305,
2566
- Unused: 306,
2567
- TemporaryRedirect: 307,
2568
- PermanentRedirect: 308,
2569
- BadRequest: 400,
2570
- Unauthorized: 401,
2571
- PaymentRequired: 402,
2572
- Forbidden: 403,
2573
- NotFound: 404,
2574
- MethodNotAllowed: 405,
2575
- NotAcceptable: 406,
2576
- ProxyAuthenticationRequired: 407,
2577
- RequestTimeout: 408,
2578
- Conflict: 409,
2579
- Gone: 410,
2580
- LengthRequired: 411,
2581
- PreconditionFailed: 412,
2582
- PayloadTooLarge: 413,
2583
- UriTooLong: 414,
2584
- UnsupportedMediaType: 415,
2585
- RangeNotSatisfiable: 416,
2586
- ExpectationFailed: 417,
2587
- ImATeapot: 418,
2588
- MisdirectedRequest: 421,
2589
- UnprocessableEntity: 422,
2590
- Locked: 423,
2591
- FailedDependency: 424,
2592
- TooEarly: 425,
2593
- UpgradeRequired: 426,
2594
- PreconditionRequired: 428,
2595
- TooManyRequests: 429,
2596
- RequestHeaderFieldsTooLarge: 431,
2597
- UnavailableForLegalReasons: 451,
2598
- InternalServerError: 500,
2599
- NotImplemented: 501,
2600
- BadGateway: 502,
2601
- ServiceUnavailable: 503,
2602
- GatewayTimeout: 504,
2603
- HttpVersionNotSupported: 505,
2604
- VariantAlsoNegotiates: 506,
2605
- InsufficientStorage: 507,
2606
- LoopDetected: 508,
2607
- NotExtended: 510,
2608
- NetworkAuthenticationRequired: 511
2609
- };
2610
- Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
2611
- HttpStatusCode$1[value] = key;
2612
- });
2613
- function createInstance(defaultConfig) {
2614
- const context = new Axios$1(defaultConfig);
2615
- const instance = bind(Axios$1.prototype.request, context);
2616
- utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
2617
- utils$1.extend(instance, context, null, { allOwnKeys: true });
2618
- instance.create = function create(instanceConfig) {
2619
- return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2620
- };
2621
- return instance;
2622
- }
2623
- const axios = createInstance(defaults);
2624
- axios.Axios = Axios$1;
2625
- axios.CanceledError = CanceledError$1;
2626
- axios.CancelToken = CancelToken$1;
2627
- axios.isCancel = isCancel$1;
2628
- axios.VERSION = VERSION$1;
2629
- axios.toFormData = toFormData$1;
2630
- axios.AxiosError = AxiosError$1;
2631
- axios.Cancel = axios.CanceledError;
2632
- axios.all = function all(promises) {
2633
- return Promise.all(promises);
2634
- };
2635
- axios.spread = spread$1;
2636
- axios.isAxiosError = isAxiosError$1;
2637
- axios.mergeConfig = mergeConfig$1;
2638
- axios.AxiosHeaders = AxiosHeaders$1;
2639
- axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
2640
- axios.getAdapter = adapters.getAdapter;
2641
- axios.HttpStatusCode = HttpStatusCode$1;
2642
- axios.default = axios;
2643
- const {
2644
- Axios: Axios2,
2645
- AxiosError,
2646
- CanceledError,
2647
- isCancel,
2648
- CancelToken: CancelToken2,
2649
- VERSION,
2650
- all: all2,
2651
- Cancel,
2652
- isAxiosError,
2653
- spread,
2654
- toFormData,
2655
- AxiosHeaders: AxiosHeaders2,
2656
- HttpStatusCode,
2657
- formToJSON,
2658
- getAdapter,
2659
- mergeConfig
2660
- } = axios;
2661
- const denyList = /* @__PURE__ */ new Set([
2662
- "ENOTFOUND",
2663
- "ENETUNREACH",
2664
- // SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
2665
- "UNABLE_TO_GET_ISSUER_CERT",
2666
- "UNABLE_TO_GET_CRL",
2667
- "UNABLE_TO_DECRYPT_CERT_SIGNATURE",
2668
- "UNABLE_TO_DECRYPT_CRL_SIGNATURE",
2669
- "UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",
2670
- "CERT_SIGNATURE_FAILURE",
2671
- "CRL_SIGNATURE_FAILURE",
2672
- "CERT_NOT_YET_VALID",
2673
- "CERT_HAS_EXPIRED",
2674
- "CRL_NOT_YET_VALID",
2675
- "CRL_HAS_EXPIRED",
2676
- "ERROR_IN_CERT_NOT_BEFORE_FIELD",
2677
- "ERROR_IN_CERT_NOT_AFTER_FIELD",
2678
- "ERROR_IN_CRL_LAST_UPDATE_FIELD",
2679
- "ERROR_IN_CRL_NEXT_UPDATE_FIELD",
2680
- "OUT_OF_MEM",
2681
- "DEPTH_ZERO_SELF_SIGNED_CERT",
2682
- "SELF_SIGNED_CERT_IN_CHAIN",
2683
- "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
2684
- "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
2685
- "CERT_CHAIN_TOO_LONG",
2686
- "CERT_REVOKED",
2687
- "INVALID_CA",
2688
- "PATH_LENGTH_EXCEEDED",
2689
- "INVALID_PURPOSE",
2690
- "CERT_UNTRUSTED",
2691
- "CERT_REJECTED",
2692
- "HOSTNAME_MISMATCH"
2693
- ]);
2694
- var isRetryAllowed = (error) => !denyList.has(error && error.code);
2695
- const isRetryAllowed$1 = /* @__PURE__ */ getDefaultExportFromCjs(isRetryAllowed);
2696
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2697
- try {
2698
- var info = gen[key](arg);
2699
- var value = info.value;
2700
- } catch (error) {
2701
- reject(error);
2702
- return;
2703
- }
2704
- if (info.done) {
2705
- resolve(value);
2706
- } else {
2707
- Promise.resolve(value).then(_next, _throw);
2708
- }
2709
- }
2710
- function _asyncToGenerator(fn) {
2711
- return function() {
2712
- var self2 = this, args = arguments;
2713
- return new Promise(function(resolve, reject) {
2714
- var gen = fn.apply(self2, args);
2715
- function _next(value) {
2716
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2717
- }
2718
- function _throw(err) {
2719
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2720
- }
2721
- _next(void 0);
2722
- });
2723
- };
2724
- }
2725
- function ownKeys(object, enumerableOnly) {
2726
- var keys = Object.keys(object);
2727
- if (Object.getOwnPropertySymbols) {
2728
- var symbols = Object.getOwnPropertySymbols(object);
2729
- if (enumerableOnly) {
2730
- symbols = symbols.filter(function(sym) {
2731
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2732
- });
2733
- }
2734
- keys.push.apply(keys, symbols);
2735
- }
2736
- return keys;
2737
- }
2738
- function _objectSpread(target) {
2739
- for (var i = 1; i < arguments.length; i++) {
2740
- var source = arguments[i] != null ? arguments[i] : {};
2741
- if (i % 2) {
2742
- ownKeys(Object(source), true).forEach(function(key) {
2743
- _defineProperty(target, key, source[key]);
2744
- });
2745
- } else if (Object.getOwnPropertyDescriptors) {
2746
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2747
- } else {
2748
- ownKeys(Object(source)).forEach(function(key) {
2749
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2750
- });
2751
- }
2752
- }
2753
- return target;
2754
- }
2755
- function _defineProperty(obj, key, value) {
2756
- if (key in obj) {
2757
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
2758
- } else {
2759
- obj[key] = value;
2760
- }
2761
- return obj;
2762
- }
2763
- var namespace = "axios-retry";
2764
- function isNetworkError(error) {
2765
- var CODE_EXCLUDE_LIST = ["ERR_CANCELED", "ECONNABORTED"];
2766
- return !error.response && Boolean(error.code) && // Prevents retrying cancelled requests
2767
- !CODE_EXCLUDE_LIST.includes(error.code) && // Prevents retrying timed out & cancelled requests
2768
- isRetryAllowed$1(error);
2769
- }
2770
- var SAFE_HTTP_METHODS = ["get", "head", "options"];
2771
- var IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(["put", "delete"]);
2772
- function isRetryableError(error) {
2773
- return error.code !== "ECONNABORTED" && (!error.response || error.response.status >= 500 && error.response.status <= 599);
2774
- }
2775
- function isSafeRequestError(error) {
2776
- if (!error.config) {
2777
- return false;
2778
- }
2779
- return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
2780
- }
2781
- function isIdempotentRequestError(error) {
2782
- if (!error.config) {
2783
- return false;
2784
- }
2785
- return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
2786
- }
2787
- function isNetworkOrIdempotentRequestError(error) {
2788
- return isNetworkError(error) || isIdempotentRequestError(error);
2789
- }
2790
- function noDelay() {
2791
- return 0;
2792
- }
2793
- function exponentialDelay() {
2794
- var retryNumber = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
2795
- var delayFactor = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 100;
2796
- var delay = Math.pow(2, retryNumber) * delayFactor;
2797
- var randomSum = delay * 0.2 * Math.random();
2798
- return delay + randomSum;
2799
- }
2800
- var DEFAULT_OPTIONS = {
2801
- retries: 3,
2802
- retryCondition: isNetworkOrIdempotentRequestError,
2803
- retryDelay: noDelay,
2804
- shouldResetTimeout: false,
2805
- onRetry: () => {
2806
- }
2807
- };
2808
- function getRequestOptions(config, defaultOptions) {
2809
- return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), defaultOptions), config[namespace]);
2810
- }
2811
- function getCurrentState(config, defaultOptions) {
2812
- var currentState = getRequestOptions(config, defaultOptions);
2813
- currentState.retryCount = currentState.retryCount || 0;
2814
- config[namespace] = currentState;
2815
- return currentState;
2816
- }
2817
- function fixConfig(axios2, config) {
2818
- if (axios2.defaults.agent === config.agent) {
2819
- delete config.agent;
2820
- }
2821
- if (axios2.defaults.httpAgent === config.httpAgent) {
2822
- delete config.httpAgent;
2823
- }
2824
- if (axios2.defaults.httpsAgent === config.httpsAgent) {
2825
- delete config.httpsAgent;
2826
- }
2827
- }
2828
- function shouldRetry(_x, _x2) {
2829
- return _shouldRetry.apply(this, arguments);
2830
- }
2831
- function _shouldRetry() {
2832
- _shouldRetry = _asyncToGenerator(function* (currentState, error) {
2833
- var {
2834
- retries,
2835
- retryCondition
2836
- } = currentState;
2837
- var shouldRetryOrPromise = currentState.retryCount < retries && retryCondition(error);
2838
- if (typeof shouldRetryOrPromise === "object") {
2839
- try {
2840
- var shouldRetryPromiseResult = yield shouldRetryOrPromise;
2841
- return shouldRetryPromiseResult !== false;
2842
- } catch (_err) {
2843
- return false;
2844
- }
2845
- }
2846
- return shouldRetryOrPromise;
2847
- });
2848
- return _shouldRetry.apply(this, arguments);
2849
- }
2850
- function axiosRetry(axios2, defaultOptions) {
2851
- var requestInterceptorId = axios2.interceptors.request.use((config) => {
2852
- var currentState = getCurrentState(config, defaultOptions);
2853
- currentState.lastRequestTime = Date.now();
2854
- return config;
2855
- });
2856
- var responseInterceptorId = axios2.interceptors.response.use(null, /* @__PURE__ */ function() {
2857
- var _ref = _asyncToGenerator(function* (error) {
2858
- var {
2859
- config
2860
- } = error;
2861
- if (!config) {
2862
- return Promise.reject(error);
2863
- }
2864
- var currentState = getCurrentState(config, defaultOptions);
2865
- if (yield shouldRetry(currentState, error)) {
2866
- currentState.retryCount += 1;
2867
- var {
2868
- retryDelay,
2869
- shouldResetTimeout,
2870
- onRetry
2871
- } = currentState;
2872
- var delay = retryDelay(currentState.retryCount, error);
2873
- fixConfig(axios2, config);
2874
- if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
2875
- var lastRequestDuration = Date.now() - currentState.lastRequestTime;
2876
- var timeout = config.timeout - lastRequestDuration - delay;
2877
- if (timeout <= 0) {
2878
- return Promise.reject(error);
2879
- }
2880
- config.timeout = timeout;
2881
- }
2882
- config.transformRequest = [(data) => data];
2883
- yield onRetry(currentState.retryCount, error, config);
2884
- return new Promise((resolve) => setTimeout(() => resolve(axios2(config)), delay));
2885
- }
2886
- return Promise.reject(error);
2887
- });
2888
- return function(_x3) {
2889
- return _ref.apply(this, arguments);
2890
- };
2891
- }());
2892
- return {
2893
- requestInterceptorId,
2894
- responseInterceptorId
2895
- };
2896
- }
2897
- axiosRetry.isNetworkError = isNetworkError;
2898
- axiosRetry.isSafeRequestError = isSafeRequestError;
2899
- axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
2900
- axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
2901
- axiosRetry.exponentialDelay = exponentialDelay;
2902
- axiosRetry.isRetryableError = isRetryableError;
2903
- class AxiosCache {
2904
- constructor(_axios) {
2905
- _axios.interceptors.response.use(async (res) => {
2906
- const cache = getAxiosCache();
2907
- if (res.status >= 200 && res.status < 300 && res.headers.etag) {
2908
- setAxiosCache(res.headers.etag, res.data);
2909
- }
2910
- if (res.status === 304) {
2911
- const etag = res.config.headers["If-Match"];
2912
- if (etag) {
2913
- res.data = cache[etag];
2914
- }
2915
- }
2916
- return res;
2917
- });
2918
- }
2919
- }
2920
- class AxiosClient {
2921
- constructor() {
2922
- __publicField(this, "client");
2923
- this.client = axios.create({
2924
- validateStatus: (status) => status >= 200 && status < 300 || status === 304
2925
- });
2926
- new AxiosCache(this.client);
2927
- axiosRetry(this.client, {
2928
- retries: 3,
2929
- retryCondition: (err) => {
2930
- var _a, _b, _c;
2931
- return (
2932
- // Don't retry 502s, as we assume the server handles retries in those cases
2933
- isNetworkError(err) || ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status) >= 500 && ((_b = err == null ? void 0 : err.response) == null ? void 0 : _b.status) !== 502 || ((_c = err == null ? void 0 : err.response) == null ? void 0 : _c.status) === 429
2934
- );
2935
- },
2936
- retryDelay: exponentialDelay
2937
- });
2938
- }
2939
- async fetch(url, method = "get", body, params, axiosConfig) {
2940
- var _a;
2941
- const config = {
2942
- url,
2943
- params,
2944
- method,
2945
- withCredentials: true,
2946
- data: JSON.stringify(body),
2947
- ...axiosConfig ?? {}
2948
- };
2949
- try {
2950
- const response = await this.client(config);
2951
- return [response.data, response.status, response.headers];
2952
- } catch (e) {
2953
- if (e instanceof AxiosError && ((_a = e.response) == null ? void 0 : _a.data)) {
2954
- return [e.response.data, e.response.status, e.response.headers];
2955
- }
2956
- throw e;
2957
- }
2958
- }
2959
- }
2960
- function normalize(strArray) {
2961
- var resultArray = [];
2962
- if (strArray.length === 0) {
2963
- return "";
2964
- }
2965
- if (typeof strArray[0] !== "string") {
2966
- throw new TypeError("Url must be a string. Received " + strArray[0]);
2967
- }
2968
- if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
2969
- var first = strArray.shift();
2970
- strArray[0] = first + strArray[0];
2971
- }
2972
- if (strArray[0].match(/^file:\/\/\//)) {
2973
- strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1:///");
2974
- } else {
2975
- strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1://");
2976
- }
2977
- for (var i = 0; i < strArray.length; i++) {
2978
- var component = strArray[i];
2979
- if (typeof component !== "string") {
2980
- throw new TypeError("Url must be a string. Received " + component);
2981
- }
2982
- if (component === "") {
2983
- continue;
2984
- }
2985
- if (i > 0) {
2986
- component = component.replace(/^[\/]+/, "");
2987
- }
2988
- if (i < strArray.length - 1) {
2989
- component = component.replace(/[\/]+$/, "");
2990
- } else {
2991
- component = component.replace(/[\/]+$/, "/");
2992
- }
2993
- resultArray.push(component);
2994
- }
2995
- var str = resultArray.join("/");
2996
- str = str.replace(/\/(\?|&|#[^!])/g, "$1");
2997
- var parts = str.split("?");
2998
- str = parts.shift() + (parts.length > 0 ? "?" : "") + parts.join("&");
2999
- return str;
3000
- }
3001
- function urlJoin() {
3002
- var input;
3003
- if (typeof arguments[0] === "object") {
3004
- input = arguments[0];
3005
- } else {
3006
- input = [].slice.call(arguments);
3007
- }
3008
- return normalize(input);
3009
- }
3010
- const buildName = (name) => `${MY_LOCAL_STORAGE_PREFIX}.${name}`;
3011
- const removeStored = (name) => {
3012
- localStorage.removeItem(buildName(name));
3013
- };
3014
- const setStored = (name, item) => {
3015
- localStorage.setItem(buildName(name), JSON.stringify(item));
3016
- };
3017
- const getStored = (name) => {
3018
- try {
3019
- return JSON.parse(localStorage.getItem(buildName(name)));
3020
- } catch {
3021
- return localStorage.getItem(buildName(name));
3022
- }
3023
- };
3024
- const saveLoginCredential = (loginRes) => {
3025
- if (loginRes == null ? void 0 : loginRes.app_token) {
3026
- setStored(StorageKey.APP_TOKEN, loginRes.app_token);
3027
- if (loginRes.refresh_token) {
3028
- setStored(StorageKey.REFRESH_TOKEN, loginRes.refresh_token);
3029
- setStored(StorageKey.PROVIDER, loginRes.provider);
3030
- }
3031
- return true;
3032
- }
3033
- removeStored(StorageKey.REFRESH_TOKEN);
3034
- removeStored(StorageKey.APP_TOKEN);
3035
- removeStored(StorageKey.PROVIDER);
3036
- return false;
3037
- };
3038
- const getXSRFCookie = () => {
3039
- if (document.cookie !== void 0) {
3040
- try {
3041
- return document.cookie.split("; ").find((row) => row.startsWith("XSRF-TOKEN")).split("=")[1];
3042
- } catch {
3043
- }
3044
- }
3045
- return null;
3046
- };
3047
- const client = new AxiosClient();
3048
- const api = {
3049
- auth,
3050
- configs,
3051
- lookup,
3052
- actions,
3053
- fetchers,
3054
- _static
3055
- };
3056
- const uri = () => {
3057
- return "/api/v1";
3058
- };
3059
- const format = (_uri, baseURL) => {
3060
- const path = _uri.startsWith(uri()) ? _uri : `${uri()}/${_uri.replace(/\/$/, "")}`.replace("//", "/");
3061
- return baseURL ? baseURL + path : path;
3062
- };
3063
- const joinParams = (_uri, searchParams) => {
3064
- return `${_uri}${searchParams ? `${_uri.indexOf("?") > 0 ? "&" : "?"}${searchParams.toString()}` : ""}`;
3065
- };
3066
- const joinUri = (uri1, uri2, searchParams) => {
3067
- const _uri = format(urlJoin(uri1, uri2));
3068
- return searchParams ? joinParams(_uri, searchParams) : _uri;
3069
- };
3070
- const joinAllUri = (...urlParts) => {
3071
- return urlJoin(...urlParts);
3072
- };
3073
- const hfetch = async (_uri, method = "get", body, searchParams, axiosConfig) => {
3074
- const authToken = getStored(StorageKey.APP_TOKEN);
3075
- const config = {
3076
- ...axiosConfig ?? {},
3077
- headers: {
3078
- ...(axiosConfig == null ? void 0 : axiosConfig.headers) ?? {},
3079
- "Content-Type": "application/json",
3080
- "X-XSRF-TOKEN": getXSRFCookie()
3081
- }
3082
- };
3083
- if (authToken && !config.headers.Authorization) {
3084
- config.headers.Authorization = `Bearer ${authToken}`;
3085
- }
3086
- const [json, statusCode] = await client.fetch(
3087
- format(_uri, config.baseURL),
3088
- method,
3089
- body,
3090
- searchParams,
3091
- config
3092
- );
3093
- if (!json) {
3094
- return null;
3095
- }
3096
- if (statusCode < 300 || statusCode === 304) {
3097
- return json.api_response;
3098
- }
3099
- if (statusCode === 401) {
3100
- if (!getStored(StorageKey.NEXT_LOCATION)) {
3101
- setStored(StorageKey.NEXT_LOCATION, window.location.pathname);
3102
- setStored(StorageKey.NEXT_SEARCH, window.location.search);
3103
- }
3104
- if (!_uri.includes("/auth/login") && getStored(StorageKey.REFRESH_TOKEN)) {
3105
- const refreshToken = getStored(StorageKey.REFRESH_TOKEN);
3106
- const provider = getStored(StorageKey.PROVIDER);
3107
- const refreshResponse = await api.auth.login.post({
3108
- refresh_token: refreshToken,
3109
- provider
3110
- });
3111
- if (refreshResponse) {
3112
- saveLoginCredential(refreshResponse);
3113
- const result = await hfetch(_uri, method, body, searchParams);
3114
- removeStored(StorageKey.NEXT_LOCATION);
3115
- removeStored(StorageKey.NEXT_SEARCH);
3116
- return result;
3117
- }
3118
- }
3119
- saveLoginCredential({});
3120
- return;
3121
- }
3122
- throw new Error(
3123
- json.api_error_message || json || `Error while fetching ${_uri} - ${method.toUpperCase()}`,
3124
- {
3125
- cause: json
3126
- }
3127
- );
3128
- };
3129
- const hget = (_uri, searchParams, config = {}) => {
3130
- return hfetch(_uri, "get", null, searchParams, config);
3131
- };
3132
- const hpost = (_uri, body, config = {}) => {
3133
- return hfetch(_uri, "post", body, void 0, config);
3134
- };
3135
- const useClueTypeConfig = (ready, baseURL, debugLogging, getToken, onNetworkCall) => {
3136
- const [availableSources, setAvailableSources] = useState([]);
3137
- const [typesDetection, setTypesDetection] = useState({});
3138
- useEffect(() => {
3139
- if (!ready) {
3140
- return;
3141
- }
3142
- if ((availableSources == null ? void 0 : availableSources.length) > 0 && !isEmpty(typesDetection)) {
3143
- return;
3144
- }
3145
- const headers = {};
3146
- const token = getToken == null ? void 0 : getToken();
3147
- if (token) {
3148
- headers.Authorization = `Bearer ${token}`;
3149
- }
3150
- (async () => {
3151
- let requestConfig = { baseURL, headers };
3152
- if (onNetworkCall) {
3153
- requestConfig = onNetworkCall(requestConfig);
3154
- }
3155
- clueDebugLogger("Executing types and type detection lookup", debugLogging);
3156
- const [_typesPerSource, _typesDetections] = await Promise.all([
3157
- get$3(requestConfig),
3158
- get$2(requestConfig)
3159
- ]);
3160
- if (_typesPerSource) {
3161
- setAvailableSources(Object.keys(_typesPerSource));
3162
- }
3163
- if (_typesDetections) {
3164
- setTypesDetection(
3165
- Object.entries(_typesDetections).reduce((acc, [key, regex]) => {
3166
- if (regex !== null) {
3167
- acc[key] = new RegExp(regex);
3168
- }
3169
- return acc;
3170
- }, {})
3171
- );
3172
- }
3173
- })();
3174
- }, [baseURL, ready]);
3175
- return {
3176
- availableSources,
3177
- typesDetection
3178
- };
3179
- };
3180
- export {
3181
- api as a,
3182
- post as p,
3183
- useClueTypeConfig as u
3184
- };