strapi-plugin-faqchatbot 1.0.5 → 1.0.9

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.
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
+ const dns = require("dns/promises");
2
3
  const OpenAI = require("openai");
3
4
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
5
+ const dns__default = /* @__PURE__ */ _interopDefault(dns);
4
6
  const OpenAI__default = /* @__PURE__ */ _interopDefault(OpenAI);
5
7
  const bootstrap = ({ strapi }) => {
6
8
  const UID = "plugin::faqchatbot.faqqa";
@@ -76,6 +78,2494 @@ const controller = ({ strapi }) => ({
76
78
  ctx.body = strapi.plugin("faqchatbot").service("service").getWelcomeMessage();
77
79
  }
78
80
  });
81
+ function bind(fn, thisArg) {
82
+ return function wrap() {
83
+ return fn.apply(thisArg, arguments);
84
+ };
85
+ }
86
+ const { toString } = Object.prototype;
87
+ const { getPrototypeOf } = Object;
88
+ const { iterator, toStringTag } = Symbol;
89
+ const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
90
+ const str = toString.call(thing);
91
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
92
+ })(/* @__PURE__ */ Object.create(null));
93
+ const kindOfTest = (type) => {
94
+ type = type.toLowerCase();
95
+ return (thing) => kindOf(thing) === type;
96
+ };
97
+ const typeOfTest = (type) => (thing) => typeof thing === type;
98
+ const { isArray } = Array;
99
+ const isUndefined = typeOfTest("undefined");
100
+ function isBuffer(val) {
101
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
102
+ }
103
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
104
+ function isArrayBufferView(val) {
105
+ let result;
106
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
107
+ result = ArrayBuffer.isView(val);
108
+ } else {
109
+ result = val && val.buffer && isArrayBuffer(val.buffer);
110
+ }
111
+ return result;
112
+ }
113
+ const isString = typeOfTest("string");
114
+ const isFunction$1 = typeOfTest("function");
115
+ const isNumber = typeOfTest("number");
116
+ const isObject = (thing) => thing !== null && typeof thing === "object";
117
+ const isBoolean = (thing) => thing === true || thing === false;
118
+ const isPlainObject = (val) => {
119
+ if (kindOf(val) !== "object") {
120
+ return false;
121
+ }
122
+ const prototype2 = getPrototypeOf(val);
123
+ return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
124
+ };
125
+ const isEmptyObject = (val) => {
126
+ if (!isObject(val) || isBuffer(val)) {
127
+ return false;
128
+ }
129
+ try {
130
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
131
+ } catch (e) {
132
+ return false;
133
+ }
134
+ };
135
+ const isDate = kindOfTest("Date");
136
+ const isFile = kindOfTest("File");
137
+ const isBlob = kindOfTest("Blob");
138
+ const isFileList = kindOfTest("FileList");
139
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
140
+ const isFormData = (thing) => {
141
+ let kind2;
142
+ return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction$1(thing.append) && ((kind2 = kindOf(thing)) === "formdata" || // detect form-data instance
143
+ kind2 === "object" && isFunction$1(thing.toString) && thing.toString() === "[object FormData]"));
144
+ };
145
+ const isURLSearchParams = kindOfTest("URLSearchParams");
146
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
147
+ const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
148
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
149
+ if (obj === null || typeof obj === "undefined") {
150
+ return;
151
+ }
152
+ let i;
153
+ let l;
154
+ if (typeof obj !== "object") {
155
+ obj = [obj];
156
+ }
157
+ if (isArray(obj)) {
158
+ for (i = 0, l = obj.length; i < l; i++) {
159
+ fn.call(null, obj[i], i, obj);
160
+ }
161
+ } else {
162
+ if (isBuffer(obj)) {
163
+ return;
164
+ }
165
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
166
+ const len = keys.length;
167
+ let key;
168
+ for (i = 0; i < len; i++) {
169
+ key = keys[i];
170
+ fn.call(null, obj[key], key, obj);
171
+ }
172
+ }
173
+ }
174
+ function findKey(obj, key) {
175
+ if (isBuffer(obj)) {
176
+ return null;
177
+ }
178
+ key = key.toLowerCase();
179
+ const keys = Object.keys(obj);
180
+ let i = keys.length;
181
+ let _key;
182
+ while (i-- > 0) {
183
+ _key = keys[i];
184
+ if (key === _key.toLowerCase()) {
185
+ return _key;
186
+ }
187
+ }
188
+ return null;
189
+ }
190
+ const _global = (() => {
191
+ if (typeof globalThis !== "undefined") return globalThis;
192
+ return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
193
+ })();
194
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
195
+ function merge() {
196
+ const { caseless, skipUndefined } = isContextDefined(this) && this || {};
197
+ const result = {};
198
+ const assignValue = (val, key) => {
199
+ const targetKey = caseless && findKey(result, key) || key;
200
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
201
+ result[targetKey] = merge(result[targetKey], val);
202
+ } else if (isPlainObject(val)) {
203
+ result[targetKey] = merge({}, val);
204
+ } else if (isArray(val)) {
205
+ result[targetKey] = val.slice();
206
+ } else if (!skipUndefined || !isUndefined(val)) {
207
+ result[targetKey] = val;
208
+ }
209
+ };
210
+ for (let i = 0, l = arguments.length; i < l; i++) {
211
+ arguments[i] && forEach(arguments[i], assignValue);
212
+ }
213
+ return result;
214
+ }
215
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
216
+ forEach(b, (val, key) => {
217
+ if (thisArg && isFunction$1(val)) {
218
+ a[key] = bind(val, thisArg);
219
+ } else {
220
+ a[key] = val;
221
+ }
222
+ }, { allOwnKeys });
223
+ return a;
224
+ };
225
+ const stripBOM = (content) => {
226
+ if (content.charCodeAt(0) === 65279) {
227
+ content = content.slice(1);
228
+ }
229
+ return content;
230
+ };
231
+ const inherits = (constructor, superConstructor, props, descriptors2) => {
232
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
233
+ constructor.prototype.constructor = constructor;
234
+ Object.defineProperty(constructor, "super", {
235
+ value: superConstructor.prototype
236
+ });
237
+ props && Object.assign(constructor.prototype, props);
238
+ };
239
+ const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
240
+ let props;
241
+ let i;
242
+ let prop;
243
+ const merged = {};
244
+ destObj = destObj || {};
245
+ if (sourceObj == null) return destObj;
246
+ do {
247
+ props = Object.getOwnPropertyNames(sourceObj);
248
+ i = props.length;
249
+ while (i-- > 0) {
250
+ prop = props[i];
251
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
252
+ destObj[prop] = sourceObj[prop];
253
+ merged[prop] = true;
254
+ }
255
+ }
256
+ sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
257
+ } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
258
+ return destObj;
259
+ };
260
+ const endsWith = (str, searchString, position) => {
261
+ str = String(str);
262
+ if (position === void 0 || position > str.length) {
263
+ position = str.length;
264
+ }
265
+ position -= searchString.length;
266
+ const lastIndex = str.indexOf(searchString, position);
267
+ return lastIndex !== -1 && lastIndex === position;
268
+ };
269
+ const toArray = (thing) => {
270
+ if (!thing) return null;
271
+ if (isArray(thing)) return thing;
272
+ let i = thing.length;
273
+ if (!isNumber(i)) return null;
274
+ const arr = new Array(i);
275
+ while (i-- > 0) {
276
+ arr[i] = thing[i];
277
+ }
278
+ return arr;
279
+ };
280
+ const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
281
+ return (thing) => {
282
+ return TypedArray && thing instanceof TypedArray;
283
+ };
284
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
285
+ const forEachEntry = (obj, fn) => {
286
+ const generator = obj && obj[iterator];
287
+ const _iterator = generator.call(obj);
288
+ let result;
289
+ while ((result = _iterator.next()) && !result.done) {
290
+ const pair = result.value;
291
+ fn.call(obj, pair[0], pair[1]);
292
+ }
293
+ };
294
+ const matchAll = (regExp, str) => {
295
+ let matches;
296
+ const arr = [];
297
+ while ((matches = regExp.exec(str)) !== null) {
298
+ arr.push(matches);
299
+ }
300
+ return arr;
301
+ };
302
+ const isHTMLForm = kindOfTest("HTMLFormElement");
303
+ const toCamelCase = (str) => {
304
+ return str.toLowerCase().replace(
305
+ /[-_\s]([a-z\d])(\w*)/g,
306
+ function replacer(m, p1, p2) {
307
+ return p1.toUpperCase() + p2;
308
+ }
309
+ );
310
+ };
311
+ const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
312
+ const isRegExp = kindOfTest("RegExp");
313
+ const reduceDescriptors = (obj, reducer) => {
314
+ const descriptors2 = Object.getOwnPropertyDescriptors(obj);
315
+ const reducedDescriptors = {};
316
+ forEach(descriptors2, (descriptor, name) => {
317
+ let ret;
318
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
319
+ reducedDescriptors[name] = ret || descriptor;
320
+ }
321
+ });
322
+ Object.defineProperties(obj, reducedDescriptors);
323
+ };
324
+ const freezeMethods = (obj) => {
325
+ reduceDescriptors(obj, (descriptor, name) => {
326
+ if (isFunction$1(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
327
+ return false;
328
+ }
329
+ const value = obj[name];
330
+ if (!isFunction$1(value)) return;
331
+ descriptor.enumerable = false;
332
+ if ("writable" in descriptor) {
333
+ descriptor.writable = false;
334
+ return;
335
+ }
336
+ if (!descriptor.set) {
337
+ descriptor.set = () => {
338
+ throw Error("Can not rewrite read-only method '" + name + "'");
339
+ };
340
+ }
341
+ });
342
+ };
343
+ const toObjectSet = (arrayOrString, delimiter) => {
344
+ const obj = {};
345
+ const define = (arr) => {
346
+ arr.forEach((value) => {
347
+ obj[value] = true;
348
+ });
349
+ };
350
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
351
+ return obj;
352
+ };
353
+ const noop = () => {
354
+ };
355
+ const toFiniteNumber = (value, defaultValue) => {
356
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
357
+ };
358
+ function isSpecCompliantForm(thing) {
359
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
360
+ }
361
+ const toJSONObject = (obj) => {
362
+ const stack = new Array(10);
363
+ const visit = (source, i) => {
364
+ if (isObject(source)) {
365
+ if (stack.indexOf(source) >= 0) {
366
+ return;
367
+ }
368
+ if (isBuffer(source)) {
369
+ return source;
370
+ }
371
+ if (!("toJSON" in source)) {
372
+ stack[i] = source;
373
+ const target = isArray(source) ? [] : {};
374
+ forEach(source, (value, key) => {
375
+ const reducedValue = visit(value, i + 1);
376
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
377
+ });
378
+ stack[i] = void 0;
379
+ return target;
380
+ }
381
+ }
382
+ return source;
383
+ };
384
+ return visit(obj, 0);
385
+ };
386
+ const isAsyncFn = kindOfTest("AsyncFunction");
387
+ const isThenable = (thing) => thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
388
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
389
+ if (setImmediateSupported) {
390
+ return setImmediate;
391
+ }
392
+ return postMessageSupported ? ((token, callbacks) => {
393
+ _global.addEventListener("message", ({ source, data }) => {
394
+ if (source === _global && data === token) {
395
+ callbacks.length && callbacks.shift()();
396
+ }
397
+ }, false);
398
+ return (cb) => {
399
+ callbacks.push(cb);
400
+ _global.postMessage(token, "*");
401
+ };
402
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
403
+ })(
404
+ typeof setImmediate === "function",
405
+ isFunction$1(_global.postMessage)
406
+ );
407
+ const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
408
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
409
+ const utils$1 = {
410
+ isArray,
411
+ isArrayBuffer,
412
+ isBuffer,
413
+ isFormData,
414
+ isArrayBufferView,
415
+ isString,
416
+ isNumber,
417
+ isBoolean,
418
+ isObject,
419
+ isPlainObject,
420
+ isEmptyObject,
421
+ isReadableStream,
422
+ isRequest,
423
+ isResponse,
424
+ isHeaders,
425
+ isUndefined,
426
+ isDate,
427
+ isFile,
428
+ isBlob,
429
+ isRegExp,
430
+ isFunction: isFunction$1,
431
+ isStream,
432
+ isURLSearchParams,
433
+ isTypedArray,
434
+ isFileList,
435
+ forEach,
436
+ merge,
437
+ extend,
438
+ trim,
439
+ stripBOM,
440
+ inherits,
441
+ toFlatObject,
442
+ kindOf,
443
+ kindOfTest,
444
+ endsWith,
445
+ toArray,
446
+ forEachEntry,
447
+ matchAll,
448
+ isHTMLForm,
449
+ hasOwnProperty,
450
+ hasOwnProp: hasOwnProperty,
451
+ // an alias to avoid ESLint no-prototype-builtins detection
452
+ reduceDescriptors,
453
+ freezeMethods,
454
+ toObjectSet,
455
+ toCamelCase,
456
+ noop,
457
+ toFiniteNumber,
458
+ findKey,
459
+ global: _global,
460
+ isContextDefined,
461
+ isSpecCompliantForm,
462
+ toJSONObject,
463
+ isAsyncFn,
464
+ isThenable,
465
+ setImmediate: _setImmediate,
466
+ asap,
467
+ isIterable
468
+ };
469
+ function AxiosError$1(message, code, config2, request, response) {
470
+ Error.call(this);
471
+ if (Error.captureStackTrace) {
472
+ Error.captureStackTrace(this, this.constructor);
473
+ } else {
474
+ this.stack = new Error().stack;
475
+ }
476
+ this.message = message;
477
+ this.name = "AxiosError";
478
+ code && (this.code = code);
479
+ config2 && (this.config = config2);
480
+ request && (this.request = request);
481
+ if (response) {
482
+ this.response = response;
483
+ this.status = response.status ? response.status : null;
484
+ }
485
+ }
486
+ utils$1.inherits(AxiosError$1, Error, {
487
+ toJSON: function toJSON() {
488
+ return {
489
+ // Standard
490
+ message: this.message,
491
+ name: this.name,
492
+ // Microsoft
493
+ description: this.description,
494
+ number: this.number,
495
+ // Mozilla
496
+ fileName: this.fileName,
497
+ lineNumber: this.lineNumber,
498
+ columnNumber: this.columnNumber,
499
+ stack: this.stack,
500
+ // Axios
501
+ config: utils$1.toJSONObject(this.config),
502
+ code: this.code,
503
+ status: this.status
504
+ };
505
+ }
506
+ });
507
+ const prototype$1 = AxiosError$1.prototype;
508
+ const descriptors = {};
509
+ [
510
+ "ERR_BAD_OPTION_VALUE",
511
+ "ERR_BAD_OPTION",
512
+ "ECONNABORTED",
513
+ "ETIMEDOUT",
514
+ "ERR_NETWORK",
515
+ "ERR_FR_TOO_MANY_REDIRECTS",
516
+ "ERR_DEPRECATED",
517
+ "ERR_BAD_RESPONSE",
518
+ "ERR_BAD_REQUEST",
519
+ "ERR_CANCELED",
520
+ "ERR_NOT_SUPPORT",
521
+ "ERR_INVALID_URL"
522
+ // eslint-disable-next-line func-names
523
+ ].forEach((code) => {
524
+ descriptors[code] = { value: code };
525
+ });
526
+ Object.defineProperties(AxiosError$1, descriptors);
527
+ Object.defineProperty(prototype$1, "isAxiosError", { value: true });
528
+ AxiosError$1.from = (error, code, config2, request, response, customProps) => {
529
+ const axiosError = Object.create(prototype$1);
530
+ utils$1.toFlatObject(error, axiosError, function filter2(obj) {
531
+ return obj !== Error.prototype;
532
+ }, (prop) => {
533
+ return prop !== "isAxiosError";
534
+ });
535
+ const msg = error && error.message ? error.message : "Error";
536
+ const errCode = code == null && error ? error.code : code;
537
+ AxiosError$1.call(axiosError, msg, errCode, config2, request, response);
538
+ if (error && axiosError.cause == null) {
539
+ Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
540
+ }
541
+ axiosError.name = error && error.name || "Error";
542
+ customProps && Object.assign(axiosError, customProps);
543
+ return axiosError;
544
+ };
545
+ const httpAdapter = null;
546
+ function isVisitable(thing) {
547
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
548
+ }
549
+ function removeBrackets(key) {
550
+ return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
551
+ }
552
+ function renderKey(path, key, dots) {
553
+ if (!path) return key;
554
+ return path.concat(key).map(function each(token, i) {
555
+ token = removeBrackets(token);
556
+ return !dots && i ? "[" + token + "]" : token;
557
+ }).join(dots ? "." : "");
558
+ }
559
+ function isFlatArray(arr) {
560
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
561
+ }
562
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
563
+ return /^is[A-Z]/.test(prop);
564
+ });
565
+ function toFormData$1(obj, formData, options2) {
566
+ if (!utils$1.isObject(obj)) {
567
+ throw new TypeError("target must be an object");
568
+ }
569
+ formData = formData || new FormData();
570
+ options2 = utils$1.toFlatObject(options2, {
571
+ metaTokens: true,
572
+ dots: false,
573
+ indexes: false
574
+ }, false, function defined(option, source) {
575
+ return !utils$1.isUndefined(source[option]);
576
+ });
577
+ const metaTokens = options2.metaTokens;
578
+ const visitor = options2.visitor || defaultVisitor;
579
+ const dots = options2.dots;
580
+ const indexes = options2.indexes;
581
+ const _Blob = options2.Blob || typeof Blob !== "undefined" && Blob;
582
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
583
+ if (!utils$1.isFunction(visitor)) {
584
+ throw new TypeError("visitor must be a function");
585
+ }
586
+ function convertValue(value) {
587
+ if (value === null) return "";
588
+ if (utils$1.isDate(value)) {
589
+ return value.toISOString();
590
+ }
591
+ if (utils$1.isBoolean(value)) {
592
+ return value.toString();
593
+ }
594
+ if (!useBlob && utils$1.isBlob(value)) {
595
+ throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
596
+ }
597
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
598
+ return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
599
+ }
600
+ return value;
601
+ }
602
+ function defaultVisitor(value, key, path) {
603
+ let arr = value;
604
+ if (value && !path && typeof value === "object") {
605
+ if (utils$1.endsWith(key, "{}")) {
606
+ key = metaTokens ? key : key.slice(0, -2);
607
+ value = JSON.stringify(value);
608
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
609
+ key = removeBrackets(key);
610
+ arr.forEach(function each(el, index2) {
611
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
612
+ // eslint-disable-next-line no-nested-ternary
613
+ indexes === true ? renderKey([key], index2, dots) : indexes === null ? key : key + "[]",
614
+ convertValue(el)
615
+ );
616
+ });
617
+ return false;
618
+ }
619
+ }
620
+ if (isVisitable(value)) {
621
+ return true;
622
+ }
623
+ formData.append(renderKey(path, key, dots), convertValue(value));
624
+ return false;
625
+ }
626
+ const stack = [];
627
+ const exposedHelpers = Object.assign(predicates, {
628
+ defaultVisitor,
629
+ convertValue,
630
+ isVisitable
631
+ });
632
+ function build(value, path) {
633
+ if (utils$1.isUndefined(value)) return;
634
+ if (stack.indexOf(value) !== -1) {
635
+ throw Error("Circular reference detected in " + path.join("."));
636
+ }
637
+ stack.push(value);
638
+ utils$1.forEach(value, function each(el, key) {
639
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
640
+ formData,
641
+ el,
642
+ utils$1.isString(key) ? key.trim() : key,
643
+ path,
644
+ exposedHelpers
645
+ );
646
+ if (result === true) {
647
+ build(el, path ? path.concat(key) : [key]);
648
+ }
649
+ });
650
+ stack.pop();
651
+ }
652
+ if (!utils$1.isObject(obj)) {
653
+ throw new TypeError("data must be an object");
654
+ }
655
+ build(obj);
656
+ return formData;
657
+ }
658
+ function encode$1(str) {
659
+ const charMap = {
660
+ "!": "%21",
661
+ "'": "%27",
662
+ "(": "%28",
663
+ ")": "%29",
664
+ "~": "%7E",
665
+ "%20": "+",
666
+ "%00": "\0"
667
+ };
668
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
669
+ return charMap[match];
670
+ });
671
+ }
672
+ function AxiosURLSearchParams(params, options2) {
673
+ this._pairs = [];
674
+ params && toFormData$1(params, this, options2);
675
+ }
676
+ const prototype = AxiosURLSearchParams.prototype;
677
+ prototype.append = function append(name, value) {
678
+ this._pairs.push([name, value]);
679
+ };
680
+ prototype.toString = function toString2(encoder) {
681
+ const _encode = encoder ? function(value) {
682
+ return encoder.call(this, value, encode$1);
683
+ } : encode$1;
684
+ return this._pairs.map(function each(pair) {
685
+ return _encode(pair[0]) + "=" + _encode(pair[1]);
686
+ }, "").join("&");
687
+ };
688
+ function encode(val) {
689
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
690
+ }
691
+ function buildURL(url, params, options2) {
692
+ if (!params) {
693
+ return url;
694
+ }
695
+ const _encode = options2 && options2.encode || encode;
696
+ if (utils$1.isFunction(options2)) {
697
+ options2 = {
698
+ serialize: options2
699
+ };
700
+ }
701
+ const serializeFn = options2 && options2.serialize;
702
+ let serializedParams;
703
+ if (serializeFn) {
704
+ serializedParams = serializeFn(params, options2);
705
+ } else {
706
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options2).toString(_encode);
707
+ }
708
+ if (serializedParams) {
709
+ const hashmarkIndex = url.indexOf("#");
710
+ if (hashmarkIndex !== -1) {
711
+ url = url.slice(0, hashmarkIndex);
712
+ }
713
+ url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
714
+ }
715
+ return url;
716
+ }
717
+ class InterceptorManager {
718
+ constructor() {
719
+ this.handlers = [];
720
+ }
721
+ /**
722
+ * Add a new interceptor to the stack
723
+ *
724
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
725
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
726
+ *
727
+ * @return {Number} An ID used to remove interceptor later
728
+ */
729
+ use(fulfilled, rejected, options2) {
730
+ this.handlers.push({
731
+ fulfilled,
732
+ rejected,
733
+ synchronous: options2 ? options2.synchronous : false,
734
+ runWhen: options2 ? options2.runWhen : null
735
+ });
736
+ return this.handlers.length - 1;
737
+ }
738
+ /**
739
+ * Remove an interceptor from the stack
740
+ *
741
+ * @param {Number} id The ID that was returned by `use`
742
+ *
743
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
744
+ */
745
+ eject(id) {
746
+ if (this.handlers[id]) {
747
+ this.handlers[id] = null;
748
+ }
749
+ }
750
+ /**
751
+ * Clear all interceptors from the stack
752
+ *
753
+ * @returns {void}
754
+ */
755
+ clear() {
756
+ if (this.handlers) {
757
+ this.handlers = [];
758
+ }
759
+ }
760
+ /**
761
+ * Iterate over all the registered interceptors
762
+ *
763
+ * This method is particularly useful for skipping over any
764
+ * interceptors that may have become `null` calling `eject`.
765
+ *
766
+ * @param {Function} fn The function to call for each interceptor
767
+ *
768
+ * @returns {void}
769
+ */
770
+ forEach(fn) {
771
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
772
+ if (h !== null) {
773
+ fn(h);
774
+ }
775
+ });
776
+ }
777
+ }
778
+ const transitionalDefaults = {
779
+ silentJSONParsing: true,
780
+ forcedJSONParsing: true,
781
+ clarifyTimeoutError: false
782
+ };
783
+ const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
784
+ const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
785
+ const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
786
+ const platform$1 = {
787
+ isBrowser: true,
788
+ classes: {
789
+ URLSearchParams: URLSearchParams$1,
790
+ FormData: FormData$1,
791
+ Blob: Blob$1
792
+ },
793
+ protocols: ["http", "https", "file", "blob", "url", "data"]
794
+ };
795
+ const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
796
+ const _navigator = typeof navigator === "object" && navigator || void 0;
797
+ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
798
+ const hasStandardBrowserWebWorkerEnv = (() => {
799
+ return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
800
+ self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
801
+ })();
802
+ const origin = hasBrowserEnv && window.location.href || "http://localhost";
803
+ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
804
+ __proto__: null,
805
+ hasBrowserEnv,
806
+ hasStandardBrowserEnv,
807
+ hasStandardBrowserWebWorkerEnv,
808
+ navigator: _navigator,
809
+ origin
810
+ }, Symbol.toStringTag, { value: "Module" }));
811
+ const platform = {
812
+ ...utils,
813
+ ...platform$1
814
+ };
815
+ function toURLEncodedForm(data, options2) {
816
+ return toFormData$1(data, new platform.classes.URLSearchParams(), {
817
+ visitor: function(value, key, path, helpers) {
818
+ if (platform.isNode && utils$1.isBuffer(value)) {
819
+ this.append(key, value.toString("base64"));
820
+ return false;
821
+ }
822
+ return helpers.defaultVisitor.apply(this, arguments);
823
+ },
824
+ ...options2
825
+ });
826
+ }
827
+ function parsePropPath(name) {
828
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
829
+ return match[0] === "[]" ? "" : match[1] || match[0];
830
+ });
831
+ }
832
+ function arrayToObject(arr) {
833
+ const obj = {};
834
+ const keys = Object.keys(arr);
835
+ let i;
836
+ const len = keys.length;
837
+ let key;
838
+ for (i = 0; i < len; i++) {
839
+ key = keys[i];
840
+ obj[key] = arr[key];
841
+ }
842
+ return obj;
843
+ }
844
+ function formDataToJSON(formData) {
845
+ function buildPath(path, value, target, index2) {
846
+ let name = path[index2++];
847
+ if (name === "__proto__") return true;
848
+ const isNumericKey = Number.isFinite(+name);
849
+ const isLast = index2 >= path.length;
850
+ name = !name && utils$1.isArray(target) ? target.length : name;
851
+ if (isLast) {
852
+ if (utils$1.hasOwnProp(target, name)) {
853
+ target[name] = [target[name], value];
854
+ } else {
855
+ target[name] = value;
856
+ }
857
+ return !isNumericKey;
858
+ }
859
+ if (!target[name] || !utils$1.isObject(target[name])) {
860
+ target[name] = [];
861
+ }
862
+ const result = buildPath(path, value, target[name], index2);
863
+ if (result && utils$1.isArray(target[name])) {
864
+ target[name] = arrayToObject(target[name]);
865
+ }
866
+ return !isNumericKey;
867
+ }
868
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
869
+ const obj = {};
870
+ utils$1.forEachEntry(formData, (name, value) => {
871
+ buildPath(parsePropPath(name), value, obj, 0);
872
+ });
873
+ return obj;
874
+ }
875
+ return null;
876
+ }
877
+ function stringifySafely(rawValue, parser, encoder) {
878
+ if (utils$1.isString(rawValue)) {
879
+ try {
880
+ (parser || JSON.parse)(rawValue);
881
+ return utils$1.trim(rawValue);
882
+ } catch (e) {
883
+ if (e.name !== "SyntaxError") {
884
+ throw e;
885
+ }
886
+ }
887
+ }
888
+ return (encoder || JSON.stringify)(rawValue);
889
+ }
890
+ const defaults = {
891
+ transitional: transitionalDefaults,
892
+ adapter: ["xhr", "http", "fetch"],
893
+ transformRequest: [function transformRequest(data, headers) {
894
+ const contentType = headers.getContentType() || "";
895
+ const hasJSONContentType = contentType.indexOf("application/json") > -1;
896
+ const isObjectPayload = utils$1.isObject(data);
897
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
898
+ data = new FormData(data);
899
+ }
900
+ const isFormData2 = utils$1.isFormData(data);
901
+ if (isFormData2) {
902
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
903
+ }
904
+ 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)) {
905
+ return data;
906
+ }
907
+ if (utils$1.isArrayBufferView(data)) {
908
+ return data.buffer;
909
+ }
910
+ if (utils$1.isURLSearchParams(data)) {
911
+ headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
912
+ return data.toString();
913
+ }
914
+ let isFileList2;
915
+ if (isObjectPayload) {
916
+ if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
917
+ return toURLEncodedForm(data, this.formSerializer).toString();
918
+ }
919
+ if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
920
+ const _FormData = this.env && this.env.FormData;
921
+ return toFormData$1(
922
+ isFileList2 ? { "files[]": data } : data,
923
+ _FormData && new _FormData(),
924
+ this.formSerializer
925
+ );
926
+ }
927
+ }
928
+ if (isObjectPayload || hasJSONContentType) {
929
+ headers.setContentType("application/json", false);
930
+ return stringifySafely(data);
931
+ }
932
+ return data;
933
+ }],
934
+ transformResponse: [function transformResponse(data) {
935
+ const transitional2 = this.transitional || defaults.transitional;
936
+ const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
937
+ const JSONRequested = this.responseType === "json";
938
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
939
+ return data;
940
+ }
941
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
942
+ const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
943
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
944
+ try {
945
+ return JSON.parse(data, this.parseReviver);
946
+ } catch (e) {
947
+ if (strictJSONParsing) {
948
+ if (e.name === "SyntaxError") {
949
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
950
+ }
951
+ throw e;
952
+ }
953
+ }
954
+ }
955
+ return data;
956
+ }],
957
+ /**
958
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
959
+ * timeout is not created.
960
+ */
961
+ timeout: 0,
962
+ xsrfCookieName: "XSRF-TOKEN",
963
+ xsrfHeaderName: "X-XSRF-TOKEN",
964
+ maxContentLength: -1,
965
+ maxBodyLength: -1,
966
+ env: {
967
+ FormData: platform.classes.FormData,
968
+ Blob: platform.classes.Blob
969
+ },
970
+ validateStatus: function validateStatus(status) {
971
+ return status >= 200 && status < 300;
972
+ },
973
+ headers: {
974
+ common: {
975
+ "Accept": "application/json, text/plain, */*",
976
+ "Content-Type": void 0
977
+ }
978
+ }
979
+ };
980
+ utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
981
+ defaults.headers[method] = {};
982
+ });
983
+ const ignoreDuplicateOf = utils$1.toObjectSet([
984
+ "age",
985
+ "authorization",
986
+ "content-length",
987
+ "content-type",
988
+ "etag",
989
+ "expires",
990
+ "from",
991
+ "host",
992
+ "if-modified-since",
993
+ "if-unmodified-since",
994
+ "last-modified",
995
+ "location",
996
+ "max-forwards",
997
+ "proxy-authorization",
998
+ "referer",
999
+ "retry-after",
1000
+ "user-agent"
1001
+ ]);
1002
+ const parseHeaders = (rawHeaders) => {
1003
+ const parsed = {};
1004
+ let key;
1005
+ let val;
1006
+ let i;
1007
+ rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
1008
+ i = line.indexOf(":");
1009
+ key = line.substring(0, i).trim().toLowerCase();
1010
+ val = line.substring(i + 1).trim();
1011
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1012
+ return;
1013
+ }
1014
+ if (key === "set-cookie") {
1015
+ if (parsed[key]) {
1016
+ parsed[key].push(val);
1017
+ } else {
1018
+ parsed[key] = [val];
1019
+ }
1020
+ } else {
1021
+ parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
1022
+ }
1023
+ });
1024
+ return parsed;
1025
+ };
1026
+ const $internals = Symbol("internals");
1027
+ function normalizeHeader(header) {
1028
+ return header && String(header).trim().toLowerCase();
1029
+ }
1030
+ function normalizeValue(value) {
1031
+ if (value === false || value == null) {
1032
+ return value;
1033
+ }
1034
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1035
+ }
1036
+ function parseTokens(str) {
1037
+ const tokens = /* @__PURE__ */ Object.create(null);
1038
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1039
+ let match;
1040
+ while (match = tokensRE.exec(str)) {
1041
+ tokens[match[1]] = match[2];
1042
+ }
1043
+ return tokens;
1044
+ }
1045
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1046
+ function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
1047
+ if (utils$1.isFunction(filter2)) {
1048
+ return filter2.call(this, value, header);
1049
+ }
1050
+ if (isHeaderNameFilter) {
1051
+ value = header;
1052
+ }
1053
+ if (!utils$1.isString(value)) return;
1054
+ if (utils$1.isString(filter2)) {
1055
+ return value.indexOf(filter2) !== -1;
1056
+ }
1057
+ if (utils$1.isRegExp(filter2)) {
1058
+ return filter2.test(value);
1059
+ }
1060
+ }
1061
+ function formatHeader(header) {
1062
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1063
+ return char.toUpperCase() + str;
1064
+ });
1065
+ }
1066
+ function buildAccessors(obj, header) {
1067
+ const accessorName = utils$1.toCamelCase(" " + header);
1068
+ ["get", "set", "has"].forEach((methodName) => {
1069
+ Object.defineProperty(obj, methodName + accessorName, {
1070
+ value: function(arg1, arg2, arg3) {
1071
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1072
+ },
1073
+ configurable: true
1074
+ });
1075
+ });
1076
+ }
1077
+ let AxiosHeaders$1 = class AxiosHeaders {
1078
+ constructor(headers) {
1079
+ headers && this.set(headers);
1080
+ }
1081
+ set(header, valueOrRewrite, rewrite) {
1082
+ const self2 = this;
1083
+ function setHeader(_value, _header, _rewrite) {
1084
+ const lHeader = normalizeHeader(_header);
1085
+ if (!lHeader) {
1086
+ throw new Error("header name must be a non-empty string");
1087
+ }
1088
+ const key = utils$1.findKey(self2, lHeader);
1089
+ if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
1090
+ self2[key || _header] = normalizeValue(_value);
1091
+ }
1092
+ }
1093
+ const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1094
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1095
+ setHeaders(header, valueOrRewrite);
1096
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1097
+ setHeaders(parseHeaders(header), valueOrRewrite);
1098
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1099
+ let obj = {}, dest, key;
1100
+ for (const entry of header) {
1101
+ if (!utils$1.isArray(entry)) {
1102
+ throw TypeError("Object iterator must return a key-value pair");
1103
+ }
1104
+ obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
1105
+ }
1106
+ setHeaders(obj, valueOrRewrite);
1107
+ } else {
1108
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1109
+ }
1110
+ return this;
1111
+ }
1112
+ get(header, parser) {
1113
+ header = normalizeHeader(header);
1114
+ if (header) {
1115
+ const key = utils$1.findKey(this, header);
1116
+ if (key) {
1117
+ const value = this[key];
1118
+ if (!parser) {
1119
+ return value;
1120
+ }
1121
+ if (parser === true) {
1122
+ return parseTokens(value);
1123
+ }
1124
+ if (utils$1.isFunction(parser)) {
1125
+ return parser.call(this, value, key);
1126
+ }
1127
+ if (utils$1.isRegExp(parser)) {
1128
+ return parser.exec(value);
1129
+ }
1130
+ throw new TypeError("parser must be boolean|regexp|function");
1131
+ }
1132
+ }
1133
+ }
1134
+ has(header, matcher) {
1135
+ header = normalizeHeader(header);
1136
+ if (header) {
1137
+ const key = utils$1.findKey(this, header);
1138
+ return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1139
+ }
1140
+ return false;
1141
+ }
1142
+ delete(header, matcher) {
1143
+ const self2 = this;
1144
+ let deleted = false;
1145
+ function deleteHeader(_header) {
1146
+ _header = normalizeHeader(_header);
1147
+ if (_header) {
1148
+ const key = utils$1.findKey(self2, _header);
1149
+ if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
1150
+ delete self2[key];
1151
+ deleted = true;
1152
+ }
1153
+ }
1154
+ }
1155
+ if (utils$1.isArray(header)) {
1156
+ header.forEach(deleteHeader);
1157
+ } else {
1158
+ deleteHeader(header);
1159
+ }
1160
+ return deleted;
1161
+ }
1162
+ clear(matcher) {
1163
+ const keys = Object.keys(this);
1164
+ let i = keys.length;
1165
+ let deleted = false;
1166
+ while (i--) {
1167
+ const key = keys[i];
1168
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1169
+ delete this[key];
1170
+ deleted = true;
1171
+ }
1172
+ }
1173
+ return deleted;
1174
+ }
1175
+ normalize(format) {
1176
+ const self2 = this;
1177
+ const headers = {};
1178
+ utils$1.forEach(this, (value, header) => {
1179
+ const key = utils$1.findKey(headers, header);
1180
+ if (key) {
1181
+ self2[key] = normalizeValue(value);
1182
+ delete self2[header];
1183
+ return;
1184
+ }
1185
+ const normalized = format ? formatHeader(header) : String(header).trim();
1186
+ if (normalized !== header) {
1187
+ delete self2[header];
1188
+ }
1189
+ self2[normalized] = normalizeValue(value);
1190
+ headers[normalized] = true;
1191
+ });
1192
+ return this;
1193
+ }
1194
+ concat(...targets) {
1195
+ return this.constructor.concat(this, ...targets);
1196
+ }
1197
+ toJSON(asStrings) {
1198
+ const obj = /* @__PURE__ */ Object.create(null);
1199
+ utils$1.forEach(this, (value, header) => {
1200
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
1201
+ });
1202
+ return obj;
1203
+ }
1204
+ [Symbol.iterator]() {
1205
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1206
+ }
1207
+ toString() {
1208
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1209
+ }
1210
+ getSetCookie() {
1211
+ return this.get("set-cookie") || [];
1212
+ }
1213
+ get [Symbol.toStringTag]() {
1214
+ return "AxiosHeaders";
1215
+ }
1216
+ static from(thing) {
1217
+ return thing instanceof this ? thing : new this(thing);
1218
+ }
1219
+ static concat(first, ...targets) {
1220
+ const computed = new this(first);
1221
+ targets.forEach((target) => computed.set(target));
1222
+ return computed;
1223
+ }
1224
+ static accessor(header) {
1225
+ const internals = this[$internals] = this[$internals] = {
1226
+ accessors: {}
1227
+ };
1228
+ const accessors = internals.accessors;
1229
+ const prototype2 = this.prototype;
1230
+ function defineAccessor(_header) {
1231
+ const lHeader = normalizeHeader(_header);
1232
+ if (!accessors[lHeader]) {
1233
+ buildAccessors(prototype2, _header);
1234
+ accessors[lHeader] = true;
1235
+ }
1236
+ }
1237
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1238
+ return this;
1239
+ }
1240
+ };
1241
+ AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1242
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
1243
+ let mapped = key[0].toUpperCase() + key.slice(1);
1244
+ return {
1245
+ get: () => value,
1246
+ set(headerValue) {
1247
+ this[mapped] = headerValue;
1248
+ }
1249
+ };
1250
+ });
1251
+ utils$1.freezeMethods(AxiosHeaders$1);
1252
+ function transformData(fns, response) {
1253
+ const config2 = this || defaults;
1254
+ const context = response || config2;
1255
+ const headers = AxiosHeaders$1.from(context.headers);
1256
+ let data = context.data;
1257
+ utils$1.forEach(fns, function transform(fn) {
1258
+ data = fn.call(config2, data, headers.normalize(), response ? response.status : void 0);
1259
+ });
1260
+ headers.normalize();
1261
+ return data;
1262
+ }
1263
+ function isCancel$1(value) {
1264
+ return !!(value && value.__CANCEL__);
1265
+ }
1266
+ function CanceledError$1(message, config2, request) {
1267
+ AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config2, request);
1268
+ this.name = "CanceledError";
1269
+ }
1270
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1271
+ __CANCEL__: true
1272
+ });
1273
+ function settle(resolve, reject, response) {
1274
+ const validateStatus2 = response.config.validateStatus;
1275
+ if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
1276
+ resolve(response);
1277
+ } else {
1278
+ reject(new AxiosError$1(
1279
+ "Request failed with status code " + response.status,
1280
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1281
+ response.config,
1282
+ response.request,
1283
+ response
1284
+ ));
1285
+ }
1286
+ }
1287
+ function parseProtocol(url) {
1288
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1289
+ return match && match[1] || "";
1290
+ }
1291
+ function speedometer(samplesCount, min) {
1292
+ samplesCount = samplesCount || 10;
1293
+ const bytes = new Array(samplesCount);
1294
+ const timestamps = new Array(samplesCount);
1295
+ let head = 0;
1296
+ let tail = 0;
1297
+ let firstSampleTS;
1298
+ min = min !== void 0 ? min : 1e3;
1299
+ return function push(chunkLength) {
1300
+ const now = Date.now();
1301
+ const startedAt = timestamps[tail];
1302
+ if (!firstSampleTS) {
1303
+ firstSampleTS = now;
1304
+ }
1305
+ bytes[head] = chunkLength;
1306
+ timestamps[head] = now;
1307
+ let i = tail;
1308
+ let bytesCount = 0;
1309
+ while (i !== head) {
1310
+ bytesCount += bytes[i++];
1311
+ i = i % samplesCount;
1312
+ }
1313
+ head = (head + 1) % samplesCount;
1314
+ if (head === tail) {
1315
+ tail = (tail + 1) % samplesCount;
1316
+ }
1317
+ if (now - firstSampleTS < min) {
1318
+ return;
1319
+ }
1320
+ const passed = startedAt && now - startedAt;
1321
+ return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1322
+ };
1323
+ }
1324
+ function throttle(fn, freq) {
1325
+ let timestamp = 0;
1326
+ let threshold = 1e3 / freq;
1327
+ let lastArgs;
1328
+ let timer;
1329
+ const invoke = (args, now = Date.now()) => {
1330
+ timestamp = now;
1331
+ lastArgs = null;
1332
+ if (timer) {
1333
+ clearTimeout(timer);
1334
+ timer = null;
1335
+ }
1336
+ fn(...args);
1337
+ };
1338
+ const throttled = (...args) => {
1339
+ const now = Date.now();
1340
+ const passed = now - timestamp;
1341
+ if (passed >= threshold) {
1342
+ invoke(args, now);
1343
+ } else {
1344
+ lastArgs = args;
1345
+ if (!timer) {
1346
+ timer = setTimeout(() => {
1347
+ timer = null;
1348
+ invoke(lastArgs);
1349
+ }, threshold - passed);
1350
+ }
1351
+ }
1352
+ };
1353
+ const flush = () => lastArgs && invoke(lastArgs);
1354
+ return [throttled, flush];
1355
+ }
1356
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
1357
+ let bytesNotified = 0;
1358
+ const _speedometer = speedometer(50, 250);
1359
+ return throttle((e) => {
1360
+ const loaded = e.loaded;
1361
+ const total = e.lengthComputable ? e.total : void 0;
1362
+ const progressBytes = loaded - bytesNotified;
1363
+ const rate = _speedometer(progressBytes);
1364
+ const inRange = loaded <= total;
1365
+ bytesNotified = loaded;
1366
+ const data = {
1367
+ loaded,
1368
+ total,
1369
+ progress: total ? loaded / total : void 0,
1370
+ bytes: progressBytes,
1371
+ rate: rate ? rate : void 0,
1372
+ estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
1373
+ event: e,
1374
+ lengthComputable: total != null,
1375
+ [isDownloadStream ? "download" : "upload"]: true
1376
+ };
1377
+ listener(data);
1378
+ }, freq);
1379
+ };
1380
+ const progressEventDecorator = (total, throttled) => {
1381
+ const lengthComputable = total != null;
1382
+ return [(loaded) => throttled[0]({
1383
+ lengthComputable,
1384
+ total,
1385
+ loaded
1386
+ }), throttled[1]];
1387
+ };
1388
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
1389
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
1390
+ url = new URL(url, platform.origin);
1391
+ return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
1392
+ })(
1393
+ new URL(platform.origin),
1394
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
1395
+ ) : () => true;
1396
+ const cookies = platform.hasStandardBrowserEnv ? (
1397
+ // Standard browser envs support document.cookie
1398
+ {
1399
+ write(name, value, expires, path, domain, secure) {
1400
+ const cookie = [name + "=" + encodeURIComponent(value)];
1401
+ utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
1402
+ utils$1.isString(path) && cookie.push("path=" + path);
1403
+ utils$1.isString(domain) && cookie.push("domain=" + domain);
1404
+ secure === true && cookie.push("secure");
1405
+ document.cookie = cookie.join("; ");
1406
+ },
1407
+ read(name) {
1408
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
1409
+ return match ? decodeURIComponent(match[3]) : null;
1410
+ },
1411
+ remove(name) {
1412
+ this.write(name, "", Date.now() - 864e5);
1413
+ }
1414
+ }
1415
+ ) : (
1416
+ // Non-standard browser env (web workers, react-native) lack needed support.
1417
+ {
1418
+ write() {
1419
+ },
1420
+ read() {
1421
+ return null;
1422
+ },
1423
+ remove() {
1424
+ }
1425
+ }
1426
+ );
1427
+ function isAbsoluteURL(url) {
1428
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1429
+ }
1430
+ function combineURLs(baseURL, relativeURL) {
1431
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1432
+ }
1433
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
1434
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
1435
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
1436
+ return combineURLs(baseURL, requestedURL);
1437
+ }
1438
+ return requestedURL;
1439
+ }
1440
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
1441
+ function mergeConfig$1(config1, config2) {
1442
+ config2 = config2 || {};
1443
+ const config3 = {};
1444
+ function getMergedValue(target, source, prop, caseless) {
1445
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
1446
+ return utils$1.merge.call({ caseless }, target, source);
1447
+ } else if (utils$1.isPlainObject(source)) {
1448
+ return utils$1.merge({}, source);
1449
+ } else if (utils$1.isArray(source)) {
1450
+ return source.slice();
1451
+ }
1452
+ return source;
1453
+ }
1454
+ function mergeDeepProperties(a, b, prop, caseless) {
1455
+ if (!utils$1.isUndefined(b)) {
1456
+ return getMergedValue(a, b, prop, caseless);
1457
+ } else if (!utils$1.isUndefined(a)) {
1458
+ return getMergedValue(void 0, a, prop, caseless);
1459
+ }
1460
+ }
1461
+ function valueFromConfig2(a, b) {
1462
+ if (!utils$1.isUndefined(b)) {
1463
+ return getMergedValue(void 0, b);
1464
+ }
1465
+ }
1466
+ function defaultToConfig2(a, b) {
1467
+ if (!utils$1.isUndefined(b)) {
1468
+ return getMergedValue(void 0, b);
1469
+ } else if (!utils$1.isUndefined(a)) {
1470
+ return getMergedValue(void 0, a);
1471
+ }
1472
+ }
1473
+ function mergeDirectKeys(a, b, prop) {
1474
+ if (prop in config2) {
1475
+ return getMergedValue(a, b);
1476
+ } else if (prop in config1) {
1477
+ return getMergedValue(void 0, a);
1478
+ }
1479
+ }
1480
+ const mergeMap = {
1481
+ url: valueFromConfig2,
1482
+ method: valueFromConfig2,
1483
+ data: valueFromConfig2,
1484
+ baseURL: defaultToConfig2,
1485
+ transformRequest: defaultToConfig2,
1486
+ transformResponse: defaultToConfig2,
1487
+ paramsSerializer: defaultToConfig2,
1488
+ timeout: defaultToConfig2,
1489
+ timeoutMessage: defaultToConfig2,
1490
+ withCredentials: defaultToConfig2,
1491
+ withXSRFToken: defaultToConfig2,
1492
+ adapter: defaultToConfig2,
1493
+ responseType: defaultToConfig2,
1494
+ xsrfCookieName: defaultToConfig2,
1495
+ xsrfHeaderName: defaultToConfig2,
1496
+ onUploadProgress: defaultToConfig2,
1497
+ onDownloadProgress: defaultToConfig2,
1498
+ decompress: defaultToConfig2,
1499
+ maxContentLength: defaultToConfig2,
1500
+ maxBodyLength: defaultToConfig2,
1501
+ beforeRedirect: defaultToConfig2,
1502
+ transport: defaultToConfig2,
1503
+ httpAgent: defaultToConfig2,
1504
+ httpsAgent: defaultToConfig2,
1505
+ cancelToken: defaultToConfig2,
1506
+ socketPath: defaultToConfig2,
1507
+ responseEncoding: defaultToConfig2,
1508
+ validateStatus: mergeDirectKeys,
1509
+ headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
1510
+ };
1511
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
1512
+ const merge2 = mergeMap[prop] || mergeDeepProperties;
1513
+ const configValue = merge2(config1[prop], config2[prop], prop);
1514
+ utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config3[prop] = configValue);
1515
+ });
1516
+ return config3;
1517
+ }
1518
+ const resolveConfig = (config2) => {
1519
+ const newConfig = mergeConfig$1({}, config2);
1520
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
1521
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
1522
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config2.params, config2.paramsSerializer);
1523
+ if (auth) {
1524
+ headers.set(
1525
+ "Authorization",
1526
+ "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
1527
+ );
1528
+ }
1529
+ if (utils$1.isFormData(data)) {
1530
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
1531
+ headers.setContentType(void 0);
1532
+ } else if (utils$1.isFunction(data.getHeaders)) {
1533
+ const formHeaders = data.getHeaders();
1534
+ const allowedHeaders = ["content-type", "content-length"];
1535
+ Object.entries(formHeaders).forEach(([key, val]) => {
1536
+ if (allowedHeaders.includes(key.toLowerCase())) {
1537
+ headers.set(key, val);
1538
+ }
1539
+ });
1540
+ }
1541
+ }
1542
+ if (platform.hasStandardBrowserEnv) {
1543
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
1544
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
1545
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
1546
+ if (xsrfValue) {
1547
+ headers.set(xsrfHeaderName, xsrfValue);
1548
+ }
1549
+ }
1550
+ }
1551
+ return newConfig;
1552
+ };
1553
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
1554
+ const xhrAdapter = isXHRAdapterSupported && function(config2) {
1555
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
1556
+ const _config = resolveConfig(config2);
1557
+ let requestData = _config.data;
1558
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
1559
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
1560
+ let onCanceled;
1561
+ let uploadThrottled, downloadThrottled;
1562
+ let flushUpload, flushDownload;
1563
+ function done() {
1564
+ flushUpload && flushUpload();
1565
+ flushDownload && flushDownload();
1566
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
1567
+ _config.signal && _config.signal.removeEventListener("abort", onCanceled);
1568
+ }
1569
+ let request = new XMLHttpRequest();
1570
+ request.open(_config.method.toUpperCase(), _config.url, true);
1571
+ request.timeout = _config.timeout;
1572
+ function onloadend() {
1573
+ if (!request) {
1574
+ return;
1575
+ }
1576
+ const responseHeaders = AxiosHeaders$1.from(
1577
+ "getAllResponseHeaders" in request && request.getAllResponseHeaders()
1578
+ );
1579
+ const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
1580
+ const response = {
1581
+ data: responseData,
1582
+ status: request.status,
1583
+ statusText: request.statusText,
1584
+ headers: responseHeaders,
1585
+ config: config2,
1586
+ request
1587
+ };
1588
+ settle(function _resolve(value) {
1589
+ resolve(value);
1590
+ done();
1591
+ }, function _reject(err) {
1592
+ reject(err);
1593
+ done();
1594
+ }, response);
1595
+ request = null;
1596
+ }
1597
+ if ("onloadend" in request) {
1598
+ request.onloadend = onloadend;
1599
+ } else {
1600
+ request.onreadystatechange = function handleLoad() {
1601
+ if (!request || request.readyState !== 4) {
1602
+ return;
1603
+ }
1604
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
1605
+ return;
1606
+ }
1607
+ setTimeout(onloadend);
1608
+ };
1609
+ }
1610
+ request.onabort = function handleAbort() {
1611
+ if (!request) {
1612
+ return;
1613
+ }
1614
+ reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config2, request));
1615
+ request = null;
1616
+ };
1617
+ request.onerror = function handleError(event) {
1618
+ const msg = event && event.message ? event.message : "Network Error";
1619
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config2, request);
1620
+ err.event = event || null;
1621
+ reject(err);
1622
+ request = null;
1623
+ };
1624
+ request.ontimeout = function handleTimeout() {
1625
+ let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
1626
+ const transitional2 = _config.transitional || transitionalDefaults;
1627
+ if (_config.timeoutErrorMessage) {
1628
+ timeoutErrorMessage = _config.timeoutErrorMessage;
1629
+ }
1630
+ reject(new AxiosError$1(
1631
+ timeoutErrorMessage,
1632
+ transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
1633
+ config2,
1634
+ request
1635
+ ));
1636
+ request = null;
1637
+ };
1638
+ requestData === void 0 && requestHeaders.setContentType(null);
1639
+ if ("setRequestHeader" in request) {
1640
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
1641
+ request.setRequestHeader(key, val);
1642
+ });
1643
+ }
1644
+ if (!utils$1.isUndefined(_config.withCredentials)) {
1645
+ request.withCredentials = !!_config.withCredentials;
1646
+ }
1647
+ if (responseType && responseType !== "json") {
1648
+ request.responseType = _config.responseType;
1649
+ }
1650
+ if (onDownloadProgress) {
1651
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
1652
+ request.addEventListener("progress", downloadThrottled);
1653
+ }
1654
+ if (onUploadProgress && request.upload) {
1655
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
1656
+ request.upload.addEventListener("progress", uploadThrottled);
1657
+ request.upload.addEventListener("loadend", flushUpload);
1658
+ }
1659
+ if (_config.cancelToken || _config.signal) {
1660
+ onCanceled = (cancel) => {
1661
+ if (!request) {
1662
+ return;
1663
+ }
1664
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config2, request) : cancel);
1665
+ request.abort();
1666
+ request = null;
1667
+ };
1668
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
1669
+ if (_config.signal) {
1670
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
1671
+ }
1672
+ }
1673
+ const protocol = parseProtocol(_config.url);
1674
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
1675
+ reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config2));
1676
+ return;
1677
+ }
1678
+ request.send(requestData || null);
1679
+ });
1680
+ };
1681
+ const composeSignals = (signals, timeout) => {
1682
+ const { length } = signals = signals ? signals.filter(Boolean) : [];
1683
+ if (timeout || length) {
1684
+ let controller2 = new AbortController();
1685
+ let aborted;
1686
+ const onabort = function(reason) {
1687
+ if (!aborted) {
1688
+ aborted = true;
1689
+ unsubscribe();
1690
+ const err = reason instanceof Error ? reason : this.reason;
1691
+ controller2.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
1692
+ }
1693
+ };
1694
+ let timer = timeout && setTimeout(() => {
1695
+ timer = null;
1696
+ onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
1697
+ }, timeout);
1698
+ const unsubscribe = () => {
1699
+ if (signals) {
1700
+ timer && clearTimeout(timer);
1701
+ timer = null;
1702
+ signals.forEach((signal2) => {
1703
+ signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
1704
+ });
1705
+ signals = null;
1706
+ }
1707
+ };
1708
+ signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
1709
+ const { signal } = controller2;
1710
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
1711
+ return signal;
1712
+ }
1713
+ };
1714
+ const streamChunk = function* (chunk, chunkSize) {
1715
+ let len = chunk.byteLength;
1716
+ if (len < chunkSize) {
1717
+ yield chunk;
1718
+ return;
1719
+ }
1720
+ let pos = 0;
1721
+ let end;
1722
+ while (pos < len) {
1723
+ end = pos + chunkSize;
1724
+ yield chunk.slice(pos, end);
1725
+ pos = end;
1726
+ }
1727
+ };
1728
+ const readBytes = async function* (iterable, chunkSize) {
1729
+ for await (const chunk of readStream(iterable)) {
1730
+ yield* streamChunk(chunk, chunkSize);
1731
+ }
1732
+ };
1733
+ const readStream = async function* (stream) {
1734
+ if (stream[Symbol.asyncIterator]) {
1735
+ yield* stream;
1736
+ return;
1737
+ }
1738
+ const reader = stream.getReader();
1739
+ try {
1740
+ for (; ; ) {
1741
+ const { done, value } = await reader.read();
1742
+ if (done) {
1743
+ break;
1744
+ }
1745
+ yield value;
1746
+ }
1747
+ } finally {
1748
+ await reader.cancel();
1749
+ }
1750
+ };
1751
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
1752
+ const iterator2 = readBytes(stream, chunkSize);
1753
+ let bytes = 0;
1754
+ let done;
1755
+ let _onFinish = (e) => {
1756
+ if (!done) {
1757
+ done = true;
1758
+ onFinish && onFinish(e);
1759
+ }
1760
+ };
1761
+ return new ReadableStream({
1762
+ async pull(controller2) {
1763
+ try {
1764
+ const { done: done2, value } = await iterator2.next();
1765
+ if (done2) {
1766
+ _onFinish();
1767
+ controller2.close();
1768
+ return;
1769
+ }
1770
+ let len = value.byteLength;
1771
+ if (onProgress) {
1772
+ let loadedBytes = bytes += len;
1773
+ onProgress(loadedBytes);
1774
+ }
1775
+ controller2.enqueue(new Uint8Array(value));
1776
+ } catch (err) {
1777
+ _onFinish(err);
1778
+ throw err;
1779
+ }
1780
+ },
1781
+ cancel(reason) {
1782
+ _onFinish(reason);
1783
+ return iterator2.return();
1784
+ }
1785
+ }, {
1786
+ highWaterMark: 2
1787
+ });
1788
+ };
1789
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
1790
+ const { isFunction } = utils$1;
1791
+ const globalFetchAPI = (({ Request, Response }) => ({
1792
+ Request,
1793
+ Response
1794
+ }))(utils$1.global);
1795
+ const {
1796
+ ReadableStream: ReadableStream$1,
1797
+ TextEncoder
1798
+ } = utils$1.global;
1799
+ const test = (fn, ...args) => {
1800
+ try {
1801
+ return !!fn(...args);
1802
+ } catch (e) {
1803
+ return false;
1804
+ }
1805
+ };
1806
+ const factory = (env) => {
1807
+ env = utils$1.merge.call({
1808
+ skipUndefined: true
1809
+ }, globalFetchAPI, env);
1810
+ const { fetch: envFetch, Request, Response } = env;
1811
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === "function";
1812
+ const isRequestSupported = isFunction(Request);
1813
+ const isResponseSupported = isFunction(Response);
1814
+ if (!isFetchSupported) {
1815
+ return false;
1816
+ }
1817
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
1818
+ const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
1819
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
1820
+ let duplexAccessed = false;
1821
+ const hasContentType = new Request(platform.origin, {
1822
+ body: new ReadableStream$1(),
1823
+ method: "POST",
1824
+ get duplex() {
1825
+ duplexAccessed = true;
1826
+ return "half";
1827
+ }
1828
+ }).headers.has("Content-Type");
1829
+ return duplexAccessed && !hasContentType;
1830
+ });
1831
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
1832
+ const resolvers = {
1833
+ stream: supportsResponseStream && ((res) => res.body)
1834
+ };
1835
+ isFetchSupported && (() => {
1836
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
1837
+ !resolvers[type] && (resolvers[type] = (res, config2) => {
1838
+ let method = res && res[type];
1839
+ if (method) {
1840
+ return method.call(res);
1841
+ }
1842
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config2);
1843
+ });
1844
+ });
1845
+ })();
1846
+ const getBodyLength = async (body) => {
1847
+ if (body == null) {
1848
+ return 0;
1849
+ }
1850
+ if (utils$1.isBlob(body)) {
1851
+ return body.size;
1852
+ }
1853
+ if (utils$1.isSpecCompliantForm(body)) {
1854
+ const _request = new Request(platform.origin, {
1855
+ method: "POST",
1856
+ body
1857
+ });
1858
+ return (await _request.arrayBuffer()).byteLength;
1859
+ }
1860
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
1861
+ return body.byteLength;
1862
+ }
1863
+ if (utils$1.isURLSearchParams(body)) {
1864
+ body = body + "";
1865
+ }
1866
+ if (utils$1.isString(body)) {
1867
+ return (await encodeText(body)).byteLength;
1868
+ }
1869
+ };
1870
+ const resolveBodyLength = async (headers, body) => {
1871
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
1872
+ return length == null ? getBodyLength(body) : length;
1873
+ };
1874
+ return async (config2) => {
1875
+ let {
1876
+ url,
1877
+ method,
1878
+ data,
1879
+ signal,
1880
+ cancelToken,
1881
+ timeout,
1882
+ onDownloadProgress,
1883
+ onUploadProgress,
1884
+ responseType,
1885
+ headers,
1886
+ withCredentials = "same-origin",
1887
+ fetchOptions
1888
+ } = resolveConfig(config2);
1889
+ let _fetch = envFetch || fetch;
1890
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
1891
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
1892
+ let request = null;
1893
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
1894
+ composedSignal.unsubscribe();
1895
+ });
1896
+ let requestContentLength;
1897
+ try {
1898
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
1899
+ let _request = new Request(url, {
1900
+ method: "POST",
1901
+ body: data,
1902
+ duplex: "half"
1903
+ });
1904
+ let contentTypeHeader;
1905
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
1906
+ headers.setContentType(contentTypeHeader);
1907
+ }
1908
+ if (_request.body) {
1909
+ const [onProgress, flush] = progressEventDecorator(
1910
+ requestContentLength,
1911
+ progressEventReducer(asyncDecorator(onUploadProgress))
1912
+ );
1913
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
1914
+ }
1915
+ }
1916
+ if (!utils$1.isString(withCredentials)) {
1917
+ withCredentials = withCredentials ? "include" : "omit";
1918
+ }
1919
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
1920
+ const resolvedOptions = {
1921
+ ...fetchOptions,
1922
+ signal: composedSignal,
1923
+ method: method.toUpperCase(),
1924
+ headers: headers.normalize().toJSON(),
1925
+ body: data,
1926
+ duplex: "half",
1927
+ credentials: isCredentialsSupported ? withCredentials : void 0
1928
+ };
1929
+ request = isRequestSupported && new Request(url, resolvedOptions);
1930
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
1931
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
1932
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
1933
+ const options2 = {};
1934
+ ["status", "statusText", "headers"].forEach((prop) => {
1935
+ options2[prop] = response[prop];
1936
+ });
1937
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
1938
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
1939
+ responseContentLength,
1940
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
1941
+ ) || [];
1942
+ response = new Response(
1943
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
1944
+ flush && flush();
1945
+ unsubscribe && unsubscribe();
1946
+ }),
1947
+ options2
1948
+ );
1949
+ }
1950
+ responseType = responseType || "text";
1951
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config2);
1952
+ !isStreamResponse && unsubscribe && unsubscribe();
1953
+ return await new Promise((resolve, reject) => {
1954
+ settle(resolve, reject, {
1955
+ data: responseData,
1956
+ headers: AxiosHeaders$1.from(response.headers),
1957
+ status: response.status,
1958
+ statusText: response.statusText,
1959
+ config: config2,
1960
+ request
1961
+ });
1962
+ });
1963
+ } catch (err) {
1964
+ unsubscribe && unsubscribe();
1965
+ if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
1966
+ throw Object.assign(
1967
+ new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config2, request),
1968
+ {
1969
+ cause: err.cause || err
1970
+ }
1971
+ );
1972
+ }
1973
+ throw AxiosError$1.from(err, err && err.code, config2, request);
1974
+ }
1975
+ };
1976
+ };
1977
+ const seedCache = /* @__PURE__ */ new Map();
1978
+ const getFetch = (config2) => {
1979
+ let env = config2 ? config2.env : {};
1980
+ const { fetch: fetch2, Request, Response } = env;
1981
+ const seeds = [
1982
+ Request,
1983
+ Response,
1984
+ fetch2
1985
+ ];
1986
+ let len = seeds.length, i = len, seed, target, map = seedCache;
1987
+ while (i--) {
1988
+ seed = seeds[i];
1989
+ target = map.get(seed);
1990
+ target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
1991
+ map = target;
1992
+ }
1993
+ return target;
1994
+ };
1995
+ getFetch();
1996
+ const knownAdapters = {
1997
+ http: httpAdapter,
1998
+ xhr: xhrAdapter,
1999
+ fetch: {
2000
+ get: getFetch
2001
+ }
2002
+ };
2003
+ utils$1.forEach(knownAdapters, (fn, value) => {
2004
+ if (fn) {
2005
+ try {
2006
+ Object.defineProperty(fn, "name", { value });
2007
+ } catch (e) {
2008
+ }
2009
+ Object.defineProperty(fn, "adapterName", { value });
2010
+ }
2011
+ });
2012
+ const renderReason = (reason) => `- ${reason}`;
2013
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
2014
+ const adapters = {
2015
+ getAdapter: (adapters2, config2) => {
2016
+ adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
2017
+ const { length } = adapters2;
2018
+ let nameOrAdapter;
2019
+ let adapter;
2020
+ const rejectedReasons = {};
2021
+ for (let i = 0; i < length; i++) {
2022
+ nameOrAdapter = adapters2[i];
2023
+ let id;
2024
+ adapter = nameOrAdapter;
2025
+ if (!isResolvedHandle(nameOrAdapter)) {
2026
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
2027
+ if (adapter === void 0) {
2028
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
2029
+ }
2030
+ }
2031
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config2)))) {
2032
+ break;
2033
+ }
2034
+ rejectedReasons[id || "#" + i] = adapter;
2035
+ }
2036
+ if (!adapter) {
2037
+ const reasons = Object.entries(rejectedReasons).map(
2038
+ ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
2039
+ );
2040
+ let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
2041
+ throw new AxiosError$1(
2042
+ `There is no suitable adapter to dispatch the request ` + s,
2043
+ "ERR_NOT_SUPPORT"
2044
+ );
2045
+ }
2046
+ return adapter;
2047
+ },
2048
+ adapters: knownAdapters
2049
+ };
2050
+ function throwIfCancellationRequested(config2) {
2051
+ if (config2.cancelToken) {
2052
+ config2.cancelToken.throwIfRequested();
2053
+ }
2054
+ if (config2.signal && config2.signal.aborted) {
2055
+ throw new CanceledError$1(null, config2);
2056
+ }
2057
+ }
2058
+ function dispatchRequest(config2) {
2059
+ throwIfCancellationRequested(config2);
2060
+ config2.headers = AxiosHeaders$1.from(config2.headers);
2061
+ config2.data = transformData.call(
2062
+ config2,
2063
+ config2.transformRequest
2064
+ );
2065
+ if (["post", "put", "patch"].indexOf(config2.method) !== -1) {
2066
+ config2.headers.setContentType("application/x-www-form-urlencoded", false);
2067
+ }
2068
+ const adapter = adapters.getAdapter(config2.adapter || defaults.adapter, config2);
2069
+ return adapter(config2).then(function onAdapterResolution(response) {
2070
+ throwIfCancellationRequested(config2);
2071
+ response.data = transformData.call(
2072
+ config2,
2073
+ config2.transformResponse,
2074
+ response
2075
+ );
2076
+ response.headers = AxiosHeaders$1.from(response.headers);
2077
+ return response;
2078
+ }, function onAdapterRejection(reason) {
2079
+ if (!isCancel$1(reason)) {
2080
+ throwIfCancellationRequested(config2);
2081
+ if (reason && reason.response) {
2082
+ reason.response.data = transformData.call(
2083
+ config2,
2084
+ config2.transformResponse,
2085
+ reason.response
2086
+ );
2087
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2088
+ }
2089
+ }
2090
+ return Promise.reject(reason);
2091
+ });
2092
+ }
2093
+ const VERSION$1 = "1.12.2";
2094
+ const validators$1 = {};
2095
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
2096
+ validators$1[type] = function validator2(thing) {
2097
+ return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
2098
+ };
2099
+ });
2100
+ const deprecatedWarnings = {};
2101
+ validators$1.transitional = function transitional(validator2, version, message) {
2102
+ function formatMessage(opt, desc) {
2103
+ return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
2104
+ }
2105
+ return (value, opt, opts) => {
2106
+ if (validator2 === false) {
2107
+ throw new AxiosError$1(
2108
+ formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
2109
+ AxiosError$1.ERR_DEPRECATED
2110
+ );
2111
+ }
2112
+ if (version && !deprecatedWarnings[opt]) {
2113
+ deprecatedWarnings[opt] = true;
2114
+ console.warn(
2115
+ formatMessage(
2116
+ opt,
2117
+ " has been deprecated since v" + version + " and will be removed in the near future"
2118
+ )
2119
+ );
2120
+ }
2121
+ return validator2 ? validator2(value, opt, opts) : true;
2122
+ };
2123
+ };
2124
+ validators$1.spelling = function spelling(correctSpelling) {
2125
+ return (value, opt) => {
2126
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2127
+ return true;
2128
+ };
2129
+ };
2130
+ function assertOptions(options2, schema2, allowUnknown) {
2131
+ if (typeof options2 !== "object") {
2132
+ throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
2133
+ }
2134
+ const keys = Object.keys(options2);
2135
+ let i = keys.length;
2136
+ while (i-- > 0) {
2137
+ const opt = keys[i];
2138
+ const validator2 = schema2[opt];
2139
+ if (validator2) {
2140
+ const value = options2[opt];
2141
+ const result = value === void 0 || validator2(value, opt, options2);
2142
+ if (result !== true) {
2143
+ throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2144
+ }
2145
+ continue;
2146
+ }
2147
+ if (allowUnknown !== true) {
2148
+ throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
2149
+ }
2150
+ }
2151
+ }
2152
+ const validator = {
2153
+ assertOptions,
2154
+ validators: validators$1
2155
+ };
2156
+ const validators = validator.validators;
2157
+ let Axios$1 = class Axios {
2158
+ constructor(instanceConfig) {
2159
+ this.defaults = instanceConfig || {};
2160
+ this.interceptors = {
2161
+ request: new InterceptorManager(),
2162
+ response: new InterceptorManager()
2163
+ };
2164
+ }
2165
+ /**
2166
+ * Dispatch a request
2167
+ *
2168
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2169
+ * @param {?Object} config
2170
+ *
2171
+ * @returns {Promise} The Promise to be fulfilled
2172
+ */
2173
+ async request(configOrUrl, config2) {
2174
+ try {
2175
+ return await this._request(configOrUrl, config2);
2176
+ } catch (err) {
2177
+ if (err instanceof Error) {
2178
+ let dummy = {};
2179
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2180
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
2181
+ try {
2182
+ if (!err.stack) {
2183
+ err.stack = stack;
2184
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
2185
+ err.stack += "\n" + stack;
2186
+ }
2187
+ } catch (e) {
2188
+ }
2189
+ }
2190
+ throw err;
2191
+ }
2192
+ }
2193
+ _request(configOrUrl, config2) {
2194
+ if (typeof configOrUrl === "string") {
2195
+ config2 = config2 || {};
2196
+ config2.url = configOrUrl;
2197
+ } else {
2198
+ config2 = configOrUrl || {};
2199
+ }
2200
+ config2 = mergeConfig$1(this.defaults, config2);
2201
+ const { transitional: transitional2, paramsSerializer, headers } = config2;
2202
+ if (transitional2 !== void 0) {
2203
+ validator.assertOptions(transitional2, {
2204
+ silentJSONParsing: validators.transitional(validators.boolean),
2205
+ forcedJSONParsing: validators.transitional(validators.boolean),
2206
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2207
+ }, false);
2208
+ }
2209
+ if (paramsSerializer != null) {
2210
+ if (utils$1.isFunction(paramsSerializer)) {
2211
+ config2.paramsSerializer = {
2212
+ serialize: paramsSerializer
2213
+ };
2214
+ } else {
2215
+ validator.assertOptions(paramsSerializer, {
2216
+ encode: validators.function,
2217
+ serialize: validators.function
2218
+ }, true);
2219
+ }
2220
+ }
2221
+ if (config2.allowAbsoluteUrls !== void 0) ;
2222
+ else if (this.defaults.allowAbsoluteUrls !== void 0) {
2223
+ config2.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
2224
+ } else {
2225
+ config2.allowAbsoluteUrls = true;
2226
+ }
2227
+ validator.assertOptions(config2, {
2228
+ baseUrl: validators.spelling("baseURL"),
2229
+ withXsrfToken: validators.spelling("withXSRFToken")
2230
+ }, true);
2231
+ config2.method = (config2.method || this.defaults.method || "get").toLowerCase();
2232
+ let contextHeaders = headers && utils$1.merge(
2233
+ headers.common,
2234
+ headers[config2.method]
2235
+ );
2236
+ headers && utils$1.forEach(
2237
+ ["delete", "get", "head", "post", "put", "patch", "common"],
2238
+ (method) => {
2239
+ delete headers[method];
2240
+ }
2241
+ );
2242
+ config2.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2243
+ const requestInterceptorChain = [];
2244
+ let synchronousRequestInterceptors = true;
2245
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2246
+ if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config2) === false) {
2247
+ return;
2248
+ }
2249
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2250
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2251
+ });
2252
+ const responseInterceptorChain = [];
2253
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2254
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2255
+ });
2256
+ let promise;
2257
+ let i = 0;
2258
+ let len;
2259
+ if (!synchronousRequestInterceptors) {
2260
+ const chain = [dispatchRequest.bind(this), void 0];
2261
+ chain.unshift(...requestInterceptorChain);
2262
+ chain.push(...responseInterceptorChain);
2263
+ len = chain.length;
2264
+ promise = Promise.resolve(config2);
2265
+ while (i < len) {
2266
+ promise = promise.then(chain[i++], chain[i++]);
2267
+ }
2268
+ return promise;
2269
+ }
2270
+ len = requestInterceptorChain.length;
2271
+ let newConfig = config2;
2272
+ while (i < len) {
2273
+ const onFulfilled = requestInterceptorChain[i++];
2274
+ const onRejected = requestInterceptorChain[i++];
2275
+ try {
2276
+ newConfig = onFulfilled(newConfig);
2277
+ } catch (error) {
2278
+ onRejected.call(this, error);
2279
+ break;
2280
+ }
2281
+ }
2282
+ try {
2283
+ promise = dispatchRequest.call(this, newConfig);
2284
+ } catch (error) {
2285
+ return Promise.reject(error);
2286
+ }
2287
+ i = 0;
2288
+ len = responseInterceptorChain.length;
2289
+ while (i < len) {
2290
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2291
+ }
2292
+ return promise;
2293
+ }
2294
+ getUri(config2) {
2295
+ config2 = mergeConfig$1(this.defaults, config2);
2296
+ const fullPath = buildFullPath(config2.baseURL, config2.url, config2.allowAbsoluteUrls);
2297
+ return buildURL(fullPath, config2.params, config2.paramsSerializer);
2298
+ }
2299
+ };
2300
+ utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
2301
+ Axios$1.prototype[method] = function(url, config2) {
2302
+ return this.request(mergeConfig$1(config2 || {}, {
2303
+ method,
2304
+ url,
2305
+ data: (config2 || {}).data
2306
+ }));
2307
+ };
2308
+ });
2309
+ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
2310
+ function generateHTTPMethod(isForm) {
2311
+ return function httpMethod(url, data, config2) {
2312
+ return this.request(mergeConfig$1(config2 || {}, {
2313
+ method,
2314
+ headers: isForm ? {
2315
+ "Content-Type": "multipart/form-data"
2316
+ } : {},
2317
+ url,
2318
+ data
2319
+ }));
2320
+ };
2321
+ }
2322
+ Axios$1.prototype[method] = generateHTTPMethod();
2323
+ Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
2324
+ });
2325
+ let CancelToken$1 = class CancelToken {
2326
+ constructor(executor) {
2327
+ if (typeof executor !== "function") {
2328
+ throw new TypeError("executor must be a function.");
2329
+ }
2330
+ let resolvePromise;
2331
+ this.promise = new Promise(function promiseExecutor(resolve) {
2332
+ resolvePromise = resolve;
2333
+ });
2334
+ const token = this;
2335
+ this.promise.then((cancel) => {
2336
+ if (!token._listeners) return;
2337
+ let i = token._listeners.length;
2338
+ while (i-- > 0) {
2339
+ token._listeners[i](cancel);
2340
+ }
2341
+ token._listeners = null;
2342
+ });
2343
+ this.promise.then = (onfulfilled) => {
2344
+ let _resolve;
2345
+ const promise = new Promise((resolve) => {
2346
+ token.subscribe(resolve);
2347
+ _resolve = resolve;
2348
+ }).then(onfulfilled);
2349
+ promise.cancel = function reject() {
2350
+ token.unsubscribe(_resolve);
2351
+ };
2352
+ return promise;
2353
+ };
2354
+ executor(function cancel(message, config2, request) {
2355
+ if (token.reason) {
2356
+ return;
2357
+ }
2358
+ token.reason = new CanceledError$1(message, config2, request);
2359
+ resolvePromise(token.reason);
2360
+ });
2361
+ }
2362
+ /**
2363
+ * Throws a `CanceledError` if cancellation has been requested.
2364
+ */
2365
+ throwIfRequested() {
2366
+ if (this.reason) {
2367
+ throw this.reason;
2368
+ }
2369
+ }
2370
+ /**
2371
+ * Subscribe to the cancel signal
2372
+ */
2373
+ subscribe(listener) {
2374
+ if (this.reason) {
2375
+ listener(this.reason);
2376
+ return;
2377
+ }
2378
+ if (this._listeners) {
2379
+ this._listeners.push(listener);
2380
+ } else {
2381
+ this._listeners = [listener];
2382
+ }
2383
+ }
2384
+ /**
2385
+ * Unsubscribe from the cancel signal
2386
+ */
2387
+ unsubscribe(listener) {
2388
+ if (!this._listeners) {
2389
+ return;
2390
+ }
2391
+ const index2 = this._listeners.indexOf(listener);
2392
+ if (index2 !== -1) {
2393
+ this._listeners.splice(index2, 1);
2394
+ }
2395
+ }
2396
+ toAbortSignal() {
2397
+ const controller2 = new AbortController();
2398
+ const abort = (err) => {
2399
+ controller2.abort(err);
2400
+ };
2401
+ this.subscribe(abort);
2402
+ controller2.signal.unsubscribe = () => this.unsubscribe(abort);
2403
+ return controller2.signal;
2404
+ }
2405
+ /**
2406
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
2407
+ * cancels the `CancelToken`.
2408
+ */
2409
+ static source() {
2410
+ let cancel;
2411
+ const token = new CancelToken(function executor(c) {
2412
+ cancel = c;
2413
+ });
2414
+ return {
2415
+ token,
2416
+ cancel
2417
+ };
2418
+ }
2419
+ };
2420
+ function spread$1(callback) {
2421
+ return function wrap(arr) {
2422
+ return callback.apply(null, arr);
2423
+ };
2424
+ }
2425
+ function isAxiosError$1(payload) {
2426
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
2427
+ }
2428
+ const HttpStatusCode$1 = {
2429
+ Continue: 100,
2430
+ SwitchingProtocols: 101,
2431
+ Processing: 102,
2432
+ EarlyHints: 103,
2433
+ Ok: 200,
2434
+ Created: 201,
2435
+ Accepted: 202,
2436
+ NonAuthoritativeInformation: 203,
2437
+ NoContent: 204,
2438
+ ResetContent: 205,
2439
+ PartialContent: 206,
2440
+ MultiStatus: 207,
2441
+ AlreadyReported: 208,
2442
+ ImUsed: 226,
2443
+ MultipleChoices: 300,
2444
+ MovedPermanently: 301,
2445
+ Found: 302,
2446
+ SeeOther: 303,
2447
+ NotModified: 304,
2448
+ UseProxy: 305,
2449
+ Unused: 306,
2450
+ TemporaryRedirect: 307,
2451
+ PermanentRedirect: 308,
2452
+ BadRequest: 400,
2453
+ Unauthorized: 401,
2454
+ PaymentRequired: 402,
2455
+ Forbidden: 403,
2456
+ NotFound: 404,
2457
+ MethodNotAllowed: 405,
2458
+ NotAcceptable: 406,
2459
+ ProxyAuthenticationRequired: 407,
2460
+ RequestTimeout: 408,
2461
+ Conflict: 409,
2462
+ Gone: 410,
2463
+ LengthRequired: 411,
2464
+ PreconditionFailed: 412,
2465
+ PayloadTooLarge: 413,
2466
+ UriTooLong: 414,
2467
+ UnsupportedMediaType: 415,
2468
+ RangeNotSatisfiable: 416,
2469
+ ExpectationFailed: 417,
2470
+ ImATeapot: 418,
2471
+ MisdirectedRequest: 421,
2472
+ UnprocessableEntity: 422,
2473
+ Locked: 423,
2474
+ FailedDependency: 424,
2475
+ TooEarly: 425,
2476
+ UpgradeRequired: 426,
2477
+ PreconditionRequired: 428,
2478
+ TooManyRequests: 429,
2479
+ RequestHeaderFieldsTooLarge: 431,
2480
+ UnavailableForLegalReasons: 451,
2481
+ InternalServerError: 500,
2482
+ NotImplemented: 501,
2483
+ BadGateway: 502,
2484
+ ServiceUnavailable: 503,
2485
+ GatewayTimeout: 504,
2486
+ HttpVersionNotSupported: 505,
2487
+ VariantAlsoNegotiates: 506,
2488
+ InsufficientStorage: 507,
2489
+ LoopDetected: 508,
2490
+ NotExtended: 510,
2491
+ NetworkAuthenticationRequired: 511
2492
+ };
2493
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
2494
+ HttpStatusCode$1[value] = key;
2495
+ });
2496
+ function createInstance(defaultConfig) {
2497
+ const context = new Axios$1(defaultConfig);
2498
+ const instance = bind(Axios$1.prototype.request, context);
2499
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
2500
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
2501
+ instance.create = function create(instanceConfig) {
2502
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2503
+ };
2504
+ return instance;
2505
+ }
2506
+ const axios = createInstance(defaults);
2507
+ axios.Axios = Axios$1;
2508
+ axios.CanceledError = CanceledError$1;
2509
+ axios.CancelToken = CancelToken$1;
2510
+ axios.isCancel = isCancel$1;
2511
+ axios.VERSION = VERSION$1;
2512
+ axios.toFormData = toFormData$1;
2513
+ axios.AxiosError = AxiosError$1;
2514
+ axios.Cancel = axios.CanceledError;
2515
+ axios.all = function all(promises) {
2516
+ return Promise.all(promises);
2517
+ };
2518
+ axios.spread = spread$1;
2519
+ axios.isAxiosError = isAxiosError$1;
2520
+ axios.mergeConfig = mergeConfig$1;
2521
+ axios.AxiosHeaders = AxiosHeaders$1;
2522
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
2523
+ axios.getAdapter = adapters.getAdapter;
2524
+ axios.HttpStatusCode = HttpStatusCode$1;
2525
+ axios.default = axios;
2526
+ const {
2527
+ Axios: Axios2,
2528
+ AxiosError,
2529
+ CanceledError,
2530
+ isCancel,
2531
+ CancelToken: CancelToken2,
2532
+ VERSION,
2533
+ all: all2,
2534
+ Cancel,
2535
+ isAxiosError,
2536
+ spread,
2537
+ toFormData,
2538
+ AxiosHeaders: AxiosHeaders2,
2539
+ HttpStatusCode,
2540
+ formToJSON,
2541
+ getAdapter,
2542
+ mergeConfig
2543
+ } = axios;
2544
+ async function validateBaseDomain(url, isDev) {
2545
+ try {
2546
+ if (!url) return { valid: true };
2547
+ let normalized = url.trim().toLowerCase();
2548
+ if (!normalized.startsWith("http://") && !normalized.startsWith("https://")) {
2549
+ normalized = "https://" + normalized;
2550
+ }
2551
+ normalized = normalized.replace(/\/+$/, "");
2552
+ const parsed = new URL(normalized);
2553
+ if (isDev) {
2554
+ return { valid: true };
2555
+ }
2556
+ await dns__default.default.lookup(parsed.hostname);
2557
+ await axios.get(parsed.origin, {
2558
+ timeout: 2e3,
2559
+ validateStatus: () => true
2560
+ });
2561
+ return { valid: true };
2562
+ } catch {
2563
+ return {
2564
+ valid: false,
2565
+ message: "Base domain is invalid, DNS failed, or site not reachable."
2566
+ };
2567
+ }
2568
+ }
79
2569
  const config$1 = ({ strapi }) => ({
80
2570
  async index(ctx) {
81
2571
  const settings = await strapi.plugin("faqchatbot").service("config").getConfig();
@@ -93,6 +2583,13 @@ const config$1 = ({ strapi }) => ({
93
2583
  },
94
2584
  async update(ctx) {
95
2585
  const settings = ctx.request.body;
2586
+ const isDev = process.env.NODE_ENV !== "production";
2587
+ const check = await validateBaseDomain(settings.baseDomain, isDev);
2588
+ if (!check.valid) {
2589
+ ctx.status = 400;
2590
+ ctx.body = { error: check.message };
2591
+ return;
2592
+ }
96
2593
  const data = await strapi.plugin("faqchatbot").service("config").setConfig(settings);
97
2594
  ctx.body = data;
98
2595
  }
@@ -131,6 +2628,15 @@ async function getInstructions(strapi) {
131
2628
  response: settings?.responseInstructions || ""
132
2629
  };
133
2630
  }
2631
+ async function getCardStyles(strapi) {
2632
+ const pluginStore = strapi.store({
2633
+ environment: null,
2634
+ type: "plugin",
2635
+ name: "faqchatbot"
2636
+ });
2637
+ const settings = await pluginStore.get({ key: "settings" });
2638
+ return settings?.cardStyles || {};
2639
+ }
134
2640
  async function getActiveCollections(strapi) {
135
2641
  try {
136
2642
  const pluginStore = strapi.store({
@@ -142,10 +2648,9 @@ async function getActiveCollections(strapi) {
142
2648
  if (!settings) return [];
143
2649
  const activeList = [];
144
2650
  for (const item of settings) {
145
- const ignored = ["faqitem", "item"];
146
- const name = item.name.toLowerCase();
147
2651
  const hasEnabledFields = item.fields?.some((f) => f.enabled);
148
- if (!hasEnabledFields || ignored.includes(name)) {
2652
+ if (!hasEnabledFields) {
2653
+ console.log(` - Skipping '${item.name}' (no enabled fields)`);
149
2654
  continue;
150
2655
  }
151
2656
  const uid = `api::${item.name}.${item.name}`;
@@ -154,9 +2659,9 @@ async function getActiveCollections(strapi) {
154
2659
  console.warn(` [WARNING] Content type not found for UID: ${uid}`);
155
2660
  continue;
156
2661
  }
157
- const fields = Object.keys(contentType.attributes).filter((key) => {
158
- const attr = contentType.attributes[key];
159
- return [
2662
+ const enabledFields = item.fields?.filter((f) => f.enabled)?.map((f) => f.name)?.filter((fieldName) => {
2663
+ const attr = contentType.attributes[fieldName];
2664
+ return attr && [
160
2665
  "string",
161
2666
  "text",
162
2667
  "email",
@@ -170,14 +2675,18 @@ async function getActiveCollections(strapi) {
170
2675
  "date",
171
2676
  "datetime",
172
2677
  "time",
173
- "relation"
2678
+ "relation",
2679
+ "media"
174
2680
  ].includes(attr.type);
175
2681
  });
176
- activeList.push({ name: item.name, fields });
2682
+ if (!enabledFields || enabledFields.length === 0) continue;
2683
+ activeList.push({
2684
+ name: item.name,
2685
+ fields: enabledFields
2686
+ });
177
2687
  }
178
2688
  return activeList;
179
2689
  } catch (err) {
180
- console.error(" [ERROR] Error loading active collections:", err);
181
2690
  return [];
182
2691
  }
183
2692
  }
@@ -274,15 +2783,33 @@ function updateJsonContext(prevContext, question) {
274
2783
  ctx.lastQuestion = question;
275
2784
  return ctx;
276
2785
  }
2786
+ function extractFilterFields(filters, collected = /* @__PURE__ */ new Set()) {
2787
+ if (!filters || typeof filters !== "object") return [];
2788
+ for (const key in filters) {
2789
+ if (key.startsWith("$")) {
2790
+ extractFilterFields(filters[key], collected);
2791
+ } else {
2792
+ collected.add(key);
2793
+ extractFilterFields(filters[key], collected);
2794
+ }
2795
+ }
2796
+ return Array.from(collected);
2797
+ }
277
2798
  async function searchRealtime(strapi, plan, activeCollections) {
278
2799
  if (!plan || !plan.collection) {
279
2800
  return null;
280
2801
  }
281
- const sanitizedFilters = sanitizeFilters(plan.filters || {});
282
2802
  const config2 = activeCollections.find((c) => c.name === plan.collection);
283
2803
  if (!config2) {
284
2804
  return null;
285
2805
  }
2806
+ const sanitizedFilters = sanitizeFilters(plan.filters || {});
2807
+ const requestedFields = extractFilterFields(sanitizedFilters);
2808
+ for (const field of requestedFields) {
2809
+ if (!config2.fields.includes(field)) {
2810
+ return null;
2811
+ }
2812
+ }
286
2813
  const uid = `api::${plan.collection}.${plan.collection}`;
287
2814
  try {
288
2815
  if (plan.operation === "count") {
@@ -295,14 +2822,35 @@ async function searchRealtime(strapi, plan, activeCollections) {
295
2822
  value: count
296
2823
  };
297
2824
  }
2825
+ const contentType = strapi.contentTypes[uid];
2826
+ const mediaFields = config2.fields.filter((field) => {
2827
+ const attr = contentType.attributes[field];
2828
+ return attr?.type === "media";
2829
+ });
2830
+ let populateObj = void 0;
2831
+ if (mediaFields.length > 0) {
2832
+ populateObj = {};
2833
+ mediaFields.forEach((field) => {
2834
+ populateObj[field] = true;
2835
+ });
2836
+ }
298
2837
  const result = await strapi.entityService.findMany(uid, {
299
2838
  filters: sanitizedFilters,
300
2839
  sort: plan.sort,
301
- limit: 10
2840
+ limit: 10,
2841
+ ...populateObj ? { populate: populateObj } : {}
302
2842
  });
303
2843
  const cleaned = result.map((row) => {
304
2844
  const clean = {};
305
- for (const f of config2.fields) clean[f] = row[f];
2845
+ for (const f of config2.fields) {
2846
+ const value = row[f];
2847
+ if (value && typeof value === "object" && value.url) {
2848
+ console.log(`🖼 Extracted image for field '${f}':`, value.url);
2849
+ clean[f] = value.url;
2850
+ } else {
2851
+ clean[f] = value;
2852
+ }
2853
+ }
306
2854
  return clean;
307
2855
  });
308
2856
  return {
@@ -573,7 +3121,7 @@ ${JSON.stringify(realtimeData)}
573
3121
  const text = response.choices[0].message.content;
574
3122
  return text;
575
3123
  }
576
- async function finalAggregator(strapi, ctx, question, faq, realtimeMeta, realtimeText, contactLink, instructions) {
3124
+ async function finalAggregator(strapi, ctx, question, faq, realtimeMeta, realtimeText, contactLink, instructions, cardStyles) {
577
3125
  ctx.set("Content-Type", "text/event-stream");
578
3126
  ctx.set("Cache-Control", "no-cache");
579
3127
  ctx.set("Connection", "keep-alive");
@@ -680,10 +3228,12 @@ ${realtimeText}
680
3228
  }
681
3229
  }
682
3230
  if (realtimeMeta && realtimeMeta.type === "list") {
3231
+ const collectionUid = `api::${realtimeMeta.collection}.${realtimeMeta.collection}`;
683
3232
  const cardsPayload = {
684
3233
  title: realtimeMeta.collection,
685
3234
  schema: realtimeMeta.schema,
686
- items: realtimeMeta.items
3235
+ items: realtimeMeta.items,
3236
+ cardStyle: cardStyles?.[collectionUid] || null
687
3237
  };
688
3238
  ctx.res.write(`event: cards
689
3239
  `);
@@ -721,6 +3271,7 @@ const ask = ({ strapi }) => ({
721
3271
  }
722
3272
  const rewritten = await rephraseQuestion(strapi, history, question);
723
3273
  const contactLink = await getContactLink(strapi);
3274
+ const cardStyles = await getCardStyles(strapi);
724
3275
  const faqResults = await searchFAQ(rewritten, strapi);
725
3276
  const plan = await simplePlanner(strapi, rewritten, activeCollections, instructions);
726
3277
  let realtimeResults = null;
@@ -738,7 +3289,8 @@ const ask = ({ strapi }) => ({
738
3289
  realtimeResults,
739
3290
  realtimeAIText,
740
3291
  contactLink,
741
- instructions
3292
+ instructions,
3293
+ cardStyles
742
3294
  );
743
3295
  return;
744
3296
  } catch (err) {
@@ -830,20 +3382,6 @@ const contentApi = () => ({
830
3382
  config: {
831
3383
  auth: false
832
3384
  }
833
- },
834
- {
835
- method: "GET",
836
- path: "/card-mapping",
837
- handler: "cardMapping.index",
838
- config: { auth: false }
839
- },
840
- {
841
- method: "POST",
842
- path: "/validate-key",
843
- handler: "ask.validateKey",
844
- config: {
845
- auth: false
846
- }
847
3385
  }
848
3386
  ]
849
3387
  });
@@ -900,10 +3438,31 @@ const config = ({ strapi }) => ({
900
3438
  });
901
3439
  const existingRaw = await pluginStore.get({ key: "settings" });
902
3440
  const existingSettings = existingRaw && typeof existingRaw === "object" ? existingRaw : {};
3441
+ let rebuiltCollections = [];
3442
+ if (newSettings.config) {
3443
+ rebuiltCollections = Object.entries(newSettings.config).map(([uid, selectedFields]) => {
3444
+ const contentType = strapi.contentTypes[uid];
3445
+ if (!contentType) return null;
3446
+ const allFields = Object.keys(contentType.attributes);
3447
+ return {
3448
+ name: uid.split(".")[1],
3449
+ fields: allFields.map((field) => ({
3450
+ name: field,
3451
+ enabled: selectedFields.includes(field)
3452
+ }))
3453
+ };
3454
+ }).filter(Boolean);
3455
+ }
903
3456
  const mergedSettings = {
904
3457
  ...existingSettings,
905
3458
  ...newSettings
906
3459
  };
3460
+ if (rebuiltCollections.length > 0) {
3461
+ await pluginStore.set({
3462
+ key: "collections",
3463
+ value: rebuiltCollections
3464
+ });
3465
+ }
907
3466
  await pluginStore.set({
908
3467
  key: "settings",
909
3468
  value: mergedSettings