@betterstore/react 0.2.24 → 0.2.25

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.
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var zustand = require('zustand');
4
+ var sdk = require('@betterstore/sdk');
4
5
  var React = require('react');
5
- var require$$0 = require('zod');
6
+ var zod = require('zod');
6
7
  var jsxRuntime = require('react/jsx-runtime');
7
8
  var reactHookForm = require('react-hook-form');
8
9
  var ReactDOM = require('react-dom');
@@ -10,7 +11,7 @@ var clsx = require('clsx');
10
11
  var tailwindMerge = require('tailwind-merge');
11
12
  var classVarianceAuthority = require('class-variance-authority');
12
13
  var lucideReact = require('lucide-react');
13
- var resolvers$1 = require('@hookform/resolvers');
14
+ var resolvers = require('@hookform/resolvers');
14
15
 
15
16
  function _interopNamespaceDefault(e) {
16
17
  var n = Object.create(null);
@@ -333,7 +334,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
333
334
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
334
335
  };
335
336
 
336
- const isString$2 = obj => typeof obj === 'string';
337
+ const isString$1 = obj => typeof obj === 'string';
337
338
  const defer = () => {
338
339
  let res;
339
340
  let rej;
@@ -356,9 +357,9 @@ const copy = (a, s, t) => {
356
357
  };
357
358
  const lastOfPathSeparatorRegExp = /###/g;
358
359
  const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
359
- const canNotTraverseDeeper = object => !object || isString$2(object);
360
+ const canNotTraverseDeeper = object => !object || isString$1(object);
360
361
  const getLastOfPath = (object, path, Empty) => {
361
- const stack = !isString$2(path) ? path : path.split('.');
362
+ const stack = !isString$1(path) ? path : path.split('.');
362
363
  let stackIndex = 0;
363
364
  while (stackIndex < stack.length - 1) {
364
365
  if (canNotTraverseDeeper(object)) return {};
@@ -427,7 +428,7 @@ const deepExtend = (target, source, overwrite) => {
427
428
  for (const prop in source) {
428
429
  if (prop !== '__proto__' && prop !== 'constructor') {
429
430
  if (prop in target) {
430
- if (isString$2(target[prop]) || target[prop] instanceof String || isString$2(source[prop]) || source[prop] instanceof String) {
431
+ if (isString$1(target[prop]) || target[prop] instanceof String || isString$1(source[prop]) || source[prop] instanceof String) {
431
432
  if (overwrite) target[prop] = source[prop];
432
433
  } else {
433
434
  deepExtend(target[prop], source[prop], overwrite);
@@ -449,7 +450,7 @@ var _entityMap = {
449
450
  '/': '&#x2F;'
450
451
  };
451
452
  const escape = data => {
452
- if (isString$2(data)) {
453
+ if (isString$1(data)) {
453
454
  return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
454
455
  }
455
456
  return data;
@@ -579,7 +580,7 @@ class Logger {
579
580
  }
580
581
  forward(args, lvl, prefix, debugOnly) {
581
582
  if (debugOnly && !this.debug) return null;
582
- if (isString$2(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
583
+ if (isString$1(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
583
584
  return this.logger[lvl](args);
584
585
  }
585
586
  create(moduleName) {
@@ -682,7 +683,7 @@ class ResourceStore extends EventEmitter {
682
683
  if (key) {
683
684
  if (Array.isArray(key)) {
684
685
  path.push(...key);
685
- } else if (isString$2(key) && keySeparator) {
686
+ } else if (isString$1(key) && keySeparator) {
686
687
  path.push(...key.split(keySeparator));
687
688
  } else {
688
689
  path.push(key);
@@ -695,7 +696,7 @@ class ResourceStore extends EventEmitter {
695
696
  ns = path[1];
696
697
  key = path.slice(2).join('.');
697
698
  }
698
- if (result || !ignoreJSONStructure || !isString$2(key)) return result;
699
+ if (result || !ignoreJSONStructure || !isString$1(key)) return result;
699
700
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
700
701
  }
701
702
  addResource(lng, ns, key, value) {
@@ -719,7 +720,7 @@ class ResourceStore extends EventEmitter {
719
720
  silent: false
720
721
  };
721
722
  for (const m in resources) {
722
- if (isString$2(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
723
+ if (isString$1(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
723
724
  silent: true
724
725
  });
725
726
  }
@@ -792,7 +793,7 @@ var postProcessor = {
792
793
  };
793
794
 
794
795
  const checkedLoadedFor = {};
795
- const shouldHandleAsObject = res => !isString$2(res) && typeof res !== 'boolean' && typeof res !== 'number';
796
+ const shouldHandleAsObject = res => !isString$1(res) && typeof res !== 'boolean' && typeof res !== 'number';
796
797
  class Translator extends EventEmitter {
797
798
  constructor(services) {
798
799
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -829,7 +830,7 @@ class Translator extends EventEmitter {
829
830
  if (m && m.length > 0) {
830
831
  return {
831
832
  key,
832
- namespaces: isString$2(namespaces) ? [namespaces] : namespaces
833
+ namespaces: isString$1(namespaces) ? [namespaces] : namespaces
833
834
  };
834
835
  }
835
836
  const parts = key.split(nsSeparator);
@@ -838,7 +839,7 @@ class Translator extends EventEmitter {
838
839
  }
839
840
  return {
840
841
  key,
841
- namespaces: isString$2(namespaces) ? [namespaces] : namespaces
842
+ namespaces: isString$1(namespaces) ? [namespaces] : namespaces
842
843
  };
843
844
  }
844
845
  translate(keys, options, lastKey) {
@@ -894,7 +895,7 @@ class Translator extends EventEmitter {
894
895
  const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
895
896
  const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
896
897
  const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
897
- const needsPluralHandling = options.count !== undefined && !isString$2(options.count);
898
+ const needsPluralHandling = options.count !== undefined && !isString$1(options.count);
898
899
  const hasDefaultValue = Translator.hasDefaultValue(options);
899
900
  const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
900
901
  const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
@@ -908,7 +909,7 @@ class Translator extends EventEmitter {
908
909
  }
909
910
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
910
911
  const resType = Object.prototype.toString.apply(resForObjHndl);
911
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$2(joinArrays) && Array.isArray(resForObjHndl))) {
912
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
912
913
  if (!options.returnObjects && !this.options.returnObjects) {
913
914
  if (!this.options.returnedObjectHandler) {
914
915
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
@@ -954,7 +955,7 @@ class Translator extends EventEmitter {
954
955
  }
955
956
  res = copy;
956
957
  }
957
- } else if (handleAsObjectInI18nFormat && isString$2(joinArrays) && Array.isArray(res)) {
958
+ } else if (handleAsObjectInI18nFormat && isString$1(joinArrays) && Array.isArray(res)) {
958
959
  res = res.join(joinArrays);
959
960
  if (res) res = this.extendTranslation(res, keys, options, lastKey);
960
961
  } else {
@@ -1048,13 +1049,13 @@ class Translator extends EventEmitter {
1048
1049
  }
1049
1050
  }
1050
1051
  });
1051
- const skipOnVariables = isString$2(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
1052
+ const skipOnVariables = isString$1(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
1052
1053
  let nestBef;
1053
1054
  if (skipOnVariables) {
1054
1055
  const nb = res.match(this.interpolator.nestingRegexp);
1055
1056
  nestBef = nb && nb.length;
1056
1057
  }
1057
- let data = options.replace && !isString$2(options.replace) ? options.replace : options;
1058
+ let data = options.replace && !isString$1(options.replace) ? options.replace : options;
1058
1059
  if (this.options.interpolation.defaultVariables) data = {
1059
1060
  ...this.options.interpolation.defaultVariables,
1060
1061
  ...data
@@ -1079,7 +1080,7 @@ class Translator extends EventEmitter {
1079
1080
  if (options.interpolation) this.interpolator.reset();
1080
1081
  }
1081
1082
  const postProcess = options.postProcess || this.options.postProcess;
1082
- const postProcessorNames = isString$2(postProcess) ? [postProcess] : postProcess;
1083
+ const postProcessorNames = isString$1(postProcess) ? [postProcess] : postProcess;
1083
1084
  if (res != null && postProcessorNames?.length && options.applyPostProcessor !== false) {
1084
1085
  res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
1085
1086
  i18nResolved: {
@@ -1098,7 +1099,7 @@ class Translator extends EventEmitter {
1098
1099
  let exactUsedKey;
1099
1100
  let usedLng;
1100
1101
  let usedNS;
1101
- if (isString$2(keys)) keys = [keys];
1102
+ if (isString$1(keys)) keys = [keys];
1102
1103
  keys.forEach(k => {
1103
1104
  if (this.isValidLookup(found)) return;
1104
1105
  const extracted = this.extractFromKey(k, options);
@@ -1106,9 +1107,9 @@ class Translator extends EventEmitter {
1106
1107
  usedKey = key;
1107
1108
  let namespaces = extracted.namespaces;
1108
1109
  if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
1109
- const needsPluralHandling = options.count !== undefined && !isString$2(options.count);
1110
+ const needsPluralHandling = options.count !== undefined && !isString$1(options.count);
1110
1111
  const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
1111
- const needsContextHandling = options.context !== undefined && (isString$2(options.context) || typeof options.context === 'number') && options.context !== '';
1112
+ const needsContextHandling = options.context !== undefined && (isString$1(options.context) || typeof options.context === 'number') && options.context !== '';
1112
1113
  const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
1113
1114
  namespaces.forEach(ns => {
1114
1115
  if (this.isValidLookup(found)) return;
@@ -1180,7 +1181,7 @@ class Translator extends EventEmitter {
1180
1181
  getUsedParamsDetails() {
1181
1182
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1182
1183
  const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
1183
- const useOptionsReplaceForData = options.replace && !isString$2(options.replace);
1184
+ const useOptionsReplaceForData = options.replace && !isString$1(options.replace);
1184
1185
  let data = useOptionsReplaceForData ? options.replace : options;
1185
1186
  if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
1186
1187
  data.count = options.count;
@@ -1234,7 +1235,7 @@ class LanguageUtil {
1234
1235
  return this.formatLanguageCode(p[0]);
1235
1236
  }
1236
1237
  formatLanguageCode(code) {
1237
- if (isString$2(code) && code.indexOf('-') > -1) {
1238
+ if (isString$1(code) && code.indexOf('-') > -1) {
1238
1239
  let formattedCode;
1239
1240
  try {
1240
1241
  formattedCode = Intl.getCanonicalLocales(code)[0];
@@ -1283,7 +1284,7 @@ class LanguageUtil {
1283
1284
  getFallbackCodes(fallbacks, code) {
1284
1285
  if (!fallbacks) return [];
1285
1286
  if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
1286
- if (isString$2(fallbacks)) fallbacks = [fallbacks];
1287
+ if (isString$1(fallbacks)) fallbacks = [fallbacks];
1287
1288
  if (Array.isArray(fallbacks)) return fallbacks;
1288
1289
  if (!code) return fallbacks.default || [];
1289
1290
  let found = fallbacks[code];
@@ -1304,11 +1305,11 @@ class LanguageUtil {
1304
1305
  this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
1305
1306
  }
1306
1307
  };
1307
- if (isString$2(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
1308
+ if (isString$1(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
1308
1309
  if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
1309
1310
  if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
1310
1311
  if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
1311
- } else if (isString$2(code)) {
1312
+ } else if (isString$1(code)) {
1312
1313
  addCode(this.formatLanguageCode(code));
1313
1314
  }
1314
1315
  fallbackCodes.forEach(fc => {
@@ -1406,7 +1407,7 @@ const deepFindWithDefaults = function (data, defaultData, key) {
1406
1407
  let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1407
1408
  let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1408
1409
  let path = getPathWithDefaults(data, defaultData, key);
1409
- if (!path && ignoreJSONStructure && isString$2(key)) {
1410
+ if (!path && ignoreJSONStructure && isString$1(key)) {
1410
1411
  path = deepFind(data, key, keySeparator);
1411
1412
  if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1412
1413
  }
@@ -1516,7 +1517,7 @@ class Interpolator {
1516
1517
  if (value === undefined) {
1517
1518
  if (typeof missingInterpolationHandler === 'function') {
1518
1519
  const temp = missingInterpolationHandler(str, match, options);
1519
- value = isString$2(temp) ? temp : '';
1520
+ value = isString$1(temp) ? temp : '';
1520
1521
  } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1521
1522
  value = '';
1522
1523
  } else if (skipOnVariables) {
@@ -1526,7 +1527,7 @@ class Interpolator {
1526
1527
  this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1527
1528
  value = '';
1528
1529
  }
1529
- } else if (!isString$2(value) && !this.useRawValueToEscape) {
1530
+ } else if (!isString$1(value) && !this.useRawValueToEscape) {
1530
1531
  value = makeString(value);
1531
1532
  }
1532
1533
  const safeValue = todo.safeValue(value);
@@ -1580,7 +1581,7 @@ class Interpolator {
1580
1581
  clonedOptions = {
1581
1582
  ...options
1582
1583
  };
1583
- clonedOptions = clonedOptions.replace && !isString$2(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1584
+ clonedOptions = clonedOptions.replace && !isString$1(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1584
1585
  clonedOptions.applyPostProcessor = false;
1585
1586
  delete clonedOptions.defaultValue;
1586
1587
  let doReduce = false;
@@ -1591,8 +1592,8 @@ class Interpolator {
1591
1592
  doReduce = true;
1592
1593
  }
1593
1594
  value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1594
- if (value && match[0] === str && !isString$2(value)) return value;
1595
- if (!isString$2(value)) value = makeString(value);
1595
+ if (value && match[0] === str && !isString$1(value)) return value;
1596
+ if (!isString$1(value)) value = makeString(value);
1596
1597
  if (!value) {
1597
1598
  this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1598
1599
  value = '';
@@ -1903,8 +1904,8 @@ class Connector extends EventEmitter {
1903
1904
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1904
1905
  return callback && callback();
1905
1906
  }
1906
- if (isString$2(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1907
- if (isString$2(namespaces)) namespaces = [namespaces];
1907
+ if (isString$1(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1908
+ if (isString$1(namespaces)) namespaces = [namespaces];
1908
1909
  const toLoad = this.queueLoad(languages, namespaces, options, callback);
1909
1910
  if (!toLoad.toLoad.length) {
1910
1911
  if (!toLoad.pending.length) callback();
@@ -2008,8 +2009,8 @@ const get = () => ({
2008
2009
  overloadTranslationOptionHandler: args => {
2009
2010
  let ret = {};
2010
2011
  if (typeof args[1] === 'object') ret = args[1];
2011
- if (isString$2(args[1])) ret.defaultValue = args[1];
2012
- if (isString$2(args[2])) ret.tDescription = args[2];
2012
+ if (isString$1(args[1])) ret.defaultValue = args[1];
2013
+ if (isString$1(args[2])) ret.tDescription = args[2];
2013
2014
  if (typeof args[2] === 'object' || typeof args[3] === 'object') {
2014
2015
  const options = args[3] || args[2];
2015
2016
  Object.keys(options).forEach(key => {
@@ -2033,9 +2034,9 @@ const get = () => ({
2033
2034
  }
2034
2035
  });
2035
2036
  const transformOptions = options => {
2036
- if (isString$2(options.ns)) options.ns = [options.ns];
2037
- if (isString$2(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
2038
- if (isString$2(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
2037
+ if (isString$1(options.ns)) options.ns = [options.ns];
2038
+ if (isString$1(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
2039
+ if (isString$1(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
2039
2040
  if (options.supportedLngs?.indexOf?.('cimode') < 0) {
2040
2041
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
2041
2042
  }
@@ -2043,7 +2044,7 @@ const transformOptions = options => {
2043
2044
  return options;
2044
2045
  };
2045
2046
 
2046
- const noop$2 = () => {};
2047
+ const noop$1 = () => {};
2047
2048
  const bindMemberFunctions = inst => {
2048
2049
  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
2049
2050
  mems.forEach(mem => {
@@ -2084,7 +2085,7 @@ class I18n extends EventEmitter {
2084
2085
  options = {};
2085
2086
  }
2086
2087
  if (options.defaultNS == null && options.ns) {
2087
- if (isString$2(options.ns)) {
2088
+ if (isString$1(options.ns)) {
2088
2089
  options.defaultNS = options.ns;
2089
2090
  } else if (options.ns.indexOf('translation') < 0) {
2090
2091
  options.defaultNS = options.ns[0];
@@ -2169,7 +2170,7 @@ class I18n extends EventEmitter {
2169
2170
  });
2170
2171
  }
2171
2172
  this.format = this.options.interpolation.format;
2172
- if (!callback) callback = noop$2;
2173
+ if (!callback) callback = noop$1;
2173
2174
  if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
2174
2175
  const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2175
2176
  if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
@@ -2212,9 +2213,9 @@ class I18n extends EventEmitter {
2212
2213
  return deferred;
2213
2214
  }
2214
2215
  loadResources(language) {
2215
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2216
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
2216
2217
  let usedCallback = callback;
2217
- const usedLng = isString$2(language) ? language : this.language;
2218
+ const usedLng = isString$1(language) ? language : this.language;
2218
2219
  if (typeof language === 'function') usedCallback = language;
2219
2220
  if (!this.options.resources || this.options.partialBundledLanguages) {
2220
2221
  if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
@@ -2255,7 +2256,7 @@ class I18n extends EventEmitter {
2255
2256
  }
2256
2257
  if (!lngs) lngs = this.languages;
2257
2258
  if (!ns) ns = this.options.ns;
2258
- if (!callback) callback = noop$2;
2259
+ if (!callback) callback = noop$1;
2259
2260
  this.services.backendConnector.reload(lngs, ns, err => {
2260
2261
  deferred.resolve();
2261
2262
  callback(err);
@@ -2330,7 +2331,7 @@ class I18n extends EventEmitter {
2330
2331
  };
2331
2332
  const setLng = lngs => {
2332
2333
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
2333
- const l = isString$2(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2334
+ const l = isString$1(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2334
2335
  if (l) {
2335
2336
  if (!this.language) {
2336
2337
  setLngProps(l);
@@ -2382,7 +2383,7 @@ class I18n extends EventEmitter {
2382
2383
  }
2383
2384
  return _this3.t(resultKey, options);
2384
2385
  };
2385
- if (isString$2(lng)) {
2386
+ if (isString$1(lng)) {
2386
2387
  fixedT.lng = lng;
2387
2388
  } else {
2388
2389
  fixedT.lngs = lng;
@@ -2439,7 +2440,7 @@ class I18n extends EventEmitter {
2439
2440
  if (callback) callback();
2440
2441
  return Promise.resolve();
2441
2442
  }
2442
- if (isString$2(ns)) ns = [ns];
2443
+ if (isString$1(ns)) ns = [ns];
2443
2444
  ns.forEach(n => {
2444
2445
  if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2445
2446
  });
@@ -2451,7 +2452,7 @@ class I18n extends EventEmitter {
2451
2452
  }
2452
2453
  loadLanguages(lngs, callback) {
2453
2454
  const deferred = defer();
2454
- if (isString$2(lngs)) lngs = [lngs];
2455
+ if (isString$1(lngs)) lngs = [lngs];
2455
2456
  const preloaded = this.options.preload || [];
2456
2457
  const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2457
2458
  if (!newLngs.length) {
@@ -2479,7 +2480,7 @@ class I18n extends EventEmitter {
2479
2480
  }
2480
2481
  cloneInstance() {
2481
2482
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2482
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2483
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
2483
2484
  const forkResourceStore = options.forkResourceStore;
2484
2485
  if (forkResourceStore) delete options.forkResourceStore;
2485
2486
  const mergedOptions = {
@@ -2562,10 +2563,10 @@ instance.loadLanguages;
2562
2563
 
2563
2564
  const {
2564
2565
  slice,
2565
- forEach: forEach$1
2566
+ forEach
2566
2567
  } = [];
2567
- function defaults$1(obj) {
2568
- forEach$1.call(slice.call(arguments, 1), source => {
2568
+ function defaults(obj) {
2569
+ forEach.call(slice.call(arguments, 1), source => {
2569
2570
  if (source) {
2570
2571
  for (const prop in source) {
2571
2572
  if (obj[prop] === undefined) obj[prop] = source[prop];
@@ -2906,7 +2907,7 @@ class Browser {
2906
2907
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2907
2908
  let i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2908
2909
  this.services = services;
2909
- this.options = defaults$1(options, this.options || {}, getDefaults$1());
2910
+ this.options = defaults(options, this.options || {}, getDefaults$1());
2910
2911
  if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
2911
2912
  this.options.convertDetectedLanguage = l => l.replace('-', '_');
2912
2913
  }
@@ -2960,7 +2961,7 @@ const warn = (i18n, code, msg, rest) => {
2960
2961
  if (i18n?.services?.logger?.forward) {
2961
2962
  return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
2962
2963
  }
2963
- if (isString$1(args[0])) args[0] = `react-i18next:: ${args[0]}`;
2964
+ if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
2964
2965
  if (i18n?.services?.logger?.warn) {
2965
2966
  i18n.services.logger.warn(...args);
2966
2967
  } else if (console?.warn) {
@@ -2969,8 +2970,8 @@ const warn = (i18n, code, msg, rest) => {
2969
2970
  };
2970
2971
  const alreadyWarned = {};
2971
2972
  const warnOnce$1 = (i18n, code, msg, rest) => {
2972
- if (isString$1(msg) && alreadyWarned[msg]) return;
2973
- if (isString$1(msg)) alreadyWarned[msg] = new Date();
2973
+ if (isString(msg) && alreadyWarned[msg]) return;
2974
+ if (isString(msg)) alreadyWarned[msg] = new Date();
2974
2975
  warn(i18n, code, msg, rest);
2975
2976
  };
2976
2977
  const loadedClb = (i18n, cb) => () => {
@@ -2990,7 +2991,7 @@ const loadNamespaces = (i18n, ns, cb) => {
2990
2991
  i18n.loadNamespaces(ns, loadedClb(i18n, cb));
2991
2992
  };
2992
2993
  const loadLanguages = (i18n, lng, ns, cb) => {
2993
- if (isString$1(ns)) ns = [ns];
2994
+ if (isString(ns)) ns = [ns];
2994
2995
  if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb);
2995
2996
  ns.forEach(n => {
2996
2997
  if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
@@ -3011,8 +3012,8 @@ const hasLoadedNamespace = (ns, i18n, options = {}) => {
3011
3012
  }
3012
3013
  });
3013
3014
  };
3014
- const isString$1 = obj => typeof obj === 'string';
3015
- const isObject$1 = obj => typeof obj === 'object' && obj !== null;
3015
+ const isString = obj => typeof obj === 'string';
3016
+ const isObject = obj => typeof obj === 'object' && obj !== null;
3016
3017
 
3017
3018
  const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
3018
3019
  const htmlEntities = {
@@ -3038,7 +3039,7 @@ const htmlEntities = {
3038
3039
  '&#47;': '/'
3039
3040
  };
3040
3041
  const unescapeHtmlEntity = m => htmlEntities[m];
3041
- const unescape$1 = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
3042
+ const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
3042
3043
 
3043
3044
  let defaultOptions = {
3044
3045
  bindI18n: 'languageChanged',
@@ -3048,7 +3049,7 @@ let defaultOptions = {
3048
3049
  transWrapTextNodes: '',
3049
3050
  transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
3050
3051
  useSuspense: true,
3051
- unescape: unescape$1
3052
+ unescape
3052
3053
  };
3053
3054
  const setDefaults = (options = {}) => {
3054
3055
  defaultOptions = {
@@ -3109,8 +3110,8 @@ const useTranslation = (ns, props = {}) => {
3109
3110
  if (!i18n) {
3110
3111
  warnOnce$1(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
3111
3112
  const notReadyT = (k, optsOrDefaultValue) => {
3112
- if (isString$1(optsOrDefaultValue)) return optsOrDefaultValue;
3113
- if (isObject$1(optsOrDefaultValue) && isString$1(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
3113
+ if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
3114
+ if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
3114
3115
  return Array.isArray(k) ? k[k.length - 1] : k;
3115
3116
  };
3116
3117
  const retNotReady = [notReadyT, {}, false];
@@ -3130,7 +3131,7 @@ const useTranslation = (ns, props = {}) => {
3130
3131
  keyPrefix
3131
3132
  } = i18nOptions;
3132
3133
  let namespaces = defaultNSFromContext || i18n.options?.defaultNS;
3133
- namespaces = isString$1(namespaces) ? [namespaces] : namespaces || ['translation'];
3134
+ namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
3134
3135
  i18n.reportNamespaces.addUsedNamespaces?.(namespaces);
3135
3136
  const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
3136
3137
  const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
@@ -3139,4191 +3140,223 @@ const useTranslation = (ns, props = {}) => {
3139
3140
  const [t, setT] = React.useState(getT);
3140
3141
  let joinedNS = namespaces.join();
3141
3142
  if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
3142
- const previousJoinedNS = usePrevious(joinedNS);
3143
- const isMounted = React.useRef(true);
3144
- React.useEffect(() => {
3145
- const {
3146
- bindI18n,
3147
- bindI18nStore
3148
- } = i18nOptions;
3149
- isMounted.current = true;
3150
- if (!ready && !useSuspense) {
3151
- if (props.lng) {
3152
- loadLanguages(i18n, props.lng, namespaces, () => {
3153
- if (isMounted.current) setT(getNewT);
3154
- });
3155
- } else {
3156
- loadNamespaces(i18n, namespaces, () => {
3157
- if (isMounted.current) setT(getNewT);
3158
- });
3159
- }
3160
- }
3161
- if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
3162
- setT(getNewT);
3163
- }
3164
- const boundReset = () => {
3165
- if (isMounted.current) setT(getNewT);
3166
- };
3167
- if (bindI18n) i18n?.on(bindI18n, boundReset);
3168
- if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
3169
- return () => {
3170
- isMounted.current = false;
3171
- if (i18n) bindI18n?.split(' ').forEach(e => i18n.off(e, boundReset));
3172
- if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
3173
- };
3174
- }, [i18n, joinedNS]);
3175
- React.useEffect(() => {
3176
- if (isMounted.current && ready) {
3177
- setT(getT);
3178
- }
3179
- }, [i18n, keyPrefix, ready]);
3180
- const ret = [t, i18n, ready];
3181
- ret.t = t;
3182
- ret.i18n = i18n;
3183
- ret.ready = ready;
3184
- if (ready) return ret;
3185
- if (!ready && !useSuspense) return ret;
3186
- throw new Promise(resolve => {
3187
- if (props.lng) {
3188
- loadLanguages(i18n, props.lng, namespaces, () => resolve());
3189
- } else {
3190
- loadNamespaces(i18n, namespaces, () => resolve());
3191
- }
3192
- });
3193
- };
3194
-
3195
- const CheckoutEmbed$2 = {
3196
- CustomerForm: {
3197
- address: {
3198
- address: "Adresa",
3199
- addressPlaceholder: "Zadejte svou adresu",
3200
- button: "Uložit adresu",
3201
- city: "Město",
3202
- cityPlaceholder: "San Francisco",
3203
- country: "Země",
3204
- countryPlaceholder: "Vstoupit do své země",
3205
- description: "Níže vyplňte údaje o vaší adrese.",
3206
- line1: "Adresa ulice",
3207
- line1Placeholder: "123 Hlavní ulice",
3208
- line2: "Byt, apartmá, jednotka atd. (Volitelné)",
3209
- line2Placeholder: "APT 4B, Suite 123, atd.",
3210
- state: "Stát (volitelné)",
3211
- statePlaceholder: "Kalifornie",
3212
- title: "Zadejte svou adresu",
3213
- zipCode: "PSČ",
3214
- zipCodePlaceholder: "12345"
3215
- },
3216
- button: "Uložit a pokračovat",
3217
- email: "E-mail",
3218
- emailPlaceholder: "Zadejte svůj e -mail",
3219
- firstName: "Křestní jméno",
3220
- firstNamePlaceholder: "Zadejte své křestní jméno",
3221
- lastName: "Příjmení",
3222
- lastNamePlaceholder: "Zadejte své příjmení",
3223
- phone: "Telefon",
3224
- phonePlaceholder: "Zadejte své telefonní číslo",
3225
- title: "Údaje o doručení"
3226
- },
3227
- Summary: {
3228
- calculatedAtNextStep: "Vypočítáno v dalším kroku",
3229
- edit: "Upravit",
3230
- shipping: "Přeprava",
3231
- subtotal: "Subtotál",
3232
- tax: "Daň",
3233
- title: "Shrnutí",
3234
- total: "Celkový"
3235
- },
3236
- loading: "Načítání ...",
3237
- Payment: {
3238
- back: "Zpět na doručení",
3239
- button: "Koupit hned teď",
3240
- description: "Všechny transakce jsou bezpečné a šifrovány.",
3241
- title: "Platba"
3242
- },
3243
- Shipping: {
3244
- back: "Zpět k informacím",
3245
- button: "Pokračujte v pokladně",
3246
- change: "Přeměna",
3247
- contact: "Kontakt:",
3248
- day: "den",
3249
- days: "dny",
3250
- estimatedDeliveryDate: "Odhadované datum dodání:",
3251
- shipTo: "Ship to:",
3252
- shipping: "Doprava:",
3253
- title: "Přeprava"
3254
- }
3255
- };
3256
- const Errors$1 = {
3257
- invalid_email: "Zadejte platnou e -mailovou adresu",
3258
- invalid_phone: "Zadejte platné telefonní číslo",
3259
- invalid_zipCode: "Zadejte platný PSČ",
3260
- required_error: "Toto pole je nutné",
3261
- unknown_error: "Došlo k neznámé chybě",
3262
- invalid_address: "Zadejte platnou adresu"
3263
- };
3264
- var cs = {
3265
- CheckoutEmbed: CheckoutEmbed$2,
3266
- Errors: Errors$1
3267
- };
3268
-
3269
- const CheckoutEmbed$1 = {
3270
- Summary: {
3271
- title: "Summary",
3272
- edit: "Edit",
3273
- total: "Total",
3274
- subtotal: "Subtotal",
3275
- shipping: "Shipping",
3276
- calculatedAtNextStep: "Calculated at next step",
3277
- tax: "Tax"
3278
- },
3279
- CustomerForm: {
3280
- address: {
3281
- address: "Address",
3282
- addressPlaceholder: "Enter your address",
3283
- title: "Enter your address",
3284
- description: "Fill in your address details below.",
3285
- line1: "Street address",
3286
- line1Placeholder: "123 Main Street",
3287
- line2: "Apartment, suite, unit, etc. (optional)",
3288
- line2Placeholder: "Apt 4B, Suite 123, etc.",
3289
- city: "City",
3290
- cityPlaceholder: "San Francisco",
3291
- country: "Country",
3292
- countryPlaceholder: "Enter your country",
3293
- state: "State (optional)",
3294
- statePlaceholder: "California",
3295
- zipCode: "Zip code",
3296
- zipCodePlaceholder: "12345",
3297
- button: "Save address"
3298
- },
3299
- title: "Basic information",
3300
- email: "Email",
3301
- emailPlaceholder: "Enter your email",
3302
- firstName: "First name",
3303
- firstNamePlaceholder: "Enter your first name",
3304
- lastName: "Last name",
3305
- lastNamePlaceholder: "Enter your last name",
3306
- phone: "Phone",
3307
- phonePlaceholder: "Enter your phone number",
3308
- button: "Save and continue"
3309
- },
3310
- loading: "Loading...",
3311
- Shipping: {
3312
- title: "Shipping",
3313
- change: "Change",
3314
- shipTo: "Ship to:",
3315
- contact: "Contact:",
3316
- button: "Continue to checkout",
3317
- back: "Back to information",
3318
- shipping: "Shipping:",
3319
- estimatedDeliveryDate: "Estimated delivery date: ",
3320
- day: "day",
3321
- days: "days"
3322
- },
3323
- Payment: {
3324
- title: "Payment",
3325
- description: "All transactions are secure and encrypted.",
3326
- back: "Back to shipping",
3327
- button: "Buy now"
3328
- }
3329
- };
3330
- const Errors = {
3331
- required_error: "This field is required",
3332
- invalid_email: "Please enter a valid email address",
3333
- invalid_phone: "Please enter a valid phone number",
3334
- invalid_zipCode: "Please enter a valid zip code",
3335
- invalid_address: "Please enter a valid address",
3336
- unknown_error: "An unknown error occurred"
3337
- };
3338
- var en = {
3339
- CheckoutEmbed: CheckoutEmbed$1,
3340
- Errors: Errors
3341
- };
3342
-
3343
- const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, function* () {
3344
- yield instance
3345
- .use(initReactI18next)
3346
- .use(Browser)
3347
- .init({
3348
- lng: locale,
3349
- fallbackLng: "en",
3350
- // debug: true,
3351
- interpolation: { escapeValue: false },
3352
- resources: {
3353
- en: { translation: en },
3354
- cs: { translation: cs },
3355
- },
3356
- });
3357
- return instance;
3358
- });
3359
-
3360
- function bind(fn, thisArg) {
3361
- return function wrap() {
3362
- return fn.apply(thisArg, arguments);
3363
- };
3364
- }
3365
-
3366
- // utils is a library of generic helper functions non-specific to axios
3367
-
3368
- const {toString} = Object.prototype;
3369
- const {getPrototypeOf} = Object;
3370
-
3371
- const kindOf = (cache => thing => {
3372
- const str = toString.call(thing);
3373
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
3374
- })(Object.create(null));
3375
-
3376
- const kindOfTest = (type) => {
3377
- type = type.toLowerCase();
3378
- return (thing) => kindOf(thing) === type
3379
- };
3380
-
3381
- const typeOfTest = type => thing => typeof thing === type;
3382
-
3383
- /**
3384
- * Determine if a value is an Array
3385
- *
3386
- * @param {Object} val The value to test
3387
- *
3388
- * @returns {boolean} True if value is an Array, otherwise false
3389
- */
3390
- const {isArray} = Array;
3391
-
3392
- /**
3393
- * Determine if a value is undefined
3394
- *
3395
- * @param {*} val The value to test
3396
- *
3397
- * @returns {boolean} True if the value is undefined, otherwise false
3398
- */
3399
- const isUndefined = typeOfTest('undefined');
3400
-
3401
- /**
3402
- * Determine if a value is a Buffer
3403
- *
3404
- * @param {*} val The value to test
3405
- *
3406
- * @returns {boolean} True if value is a Buffer, otherwise false
3407
- */
3408
- function isBuffer(val) {
3409
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
3410
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
3411
- }
3412
-
3413
- /**
3414
- * Determine if a value is an ArrayBuffer
3415
- *
3416
- * @param {*} val The value to test
3417
- *
3418
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
3419
- */
3420
- const isArrayBuffer = kindOfTest('ArrayBuffer');
3421
-
3422
-
3423
- /**
3424
- * Determine if a value is a view on an ArrayBuffer
3425
- *
3426
- * @param {*} val The value to test
3427
- *
3428
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
3429
- */
3430
- function isArrayBufferView(val) {
3431
- let result;
3432
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
3433
- result = ArrayBuffer.isView(val);
3434
- } else {
3435
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
3436
- }
3437
- return result;
3438
- }
3439
-
3440
- /**
3441
- * Determine if a value is a String
3442
- *
3443
- * @param {*} val The value to test
3444
- *
3445
- * @returns {boolean} True if value is a String, otherwise false
3446
- */
3447
- const isString = typeOfTest('string');
3448
-
3449
- /**
3450
- * Determine if a value is a Function
3451
- *
3452
- * @param {*} val The value to test
3453
- * @returns {boolean} True if value is a Function, otherwise false
3454
- */
3455
- const isFunction = typeOfTest('function');
3456
-
3457
- /**
3458
- * Determine if a value is a Number
3459
- *
3460
- * @param {*} val The value to test
3461
- *
3462
- * @returns {boolean} True if value is a Number, otherwise false
3463
- */
3464
- const isNumber = typeOfTest('number');
3465
-
3466
- /**
3467
- * Determine if a value is an Object
3468
- *
3469
- * @param {*} thing The value to test
3470
- *
3471
- * @returns {boolean} True if value is an Object, otherwise false
3472
- */
3473
- const isObject = (thing) => thing !== null && typeof thing === 'object';
3474
-
3475
- /**
3476
- * Determine if a value is a Boolean
3477
- *
3478
- * @param {*} thing The value to test
3479
- * @returns {boolean} True if value is a Boolean, otherwise false
3480
- */
3481
- const isBoolean = thing => thing === true || thing === false;
3482
-
3483
- /**
3484
- * Determine if a value is a plain Object
3485
- *
3486
- * @param {*} val The value to test
3487
- *
3488
- * @returns {boolean} True if value is a plain Object, otherwise false
3489
- */
3490
- const isPlainObject = (val) => {
3491
- if (kindOf(val) !== 'object') {
3492
- return false;
3493
- }
3494
-
3495
- const prototype = getPrototypeOf(val);
3496
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
3497
- };
3498
-
3499
- /**
3500
- * Determine if a value is a Date
3501
- *
3502
- * @param {*} val The value to test
3503
- *
3504
- * @returns {boolean} True if value is a Date, otherwise false
3505
- */
3506
- const isDate = kindOfTest('Date');
3507
-
3508
- /**
3509
- * Determine if a value is a File
3510
- *
3511
- * @param {*} val The value to test
3512
- *
3513
- * @returns {boolean} True if value is a File, otherwise false
3514
- */
3515
- const isFile = kindOfTest('File');
3516
-
3517
- /**
3518
- * Determine if a value is a Blob
3519
- *
3520
- * @param {*} val The value to test
3521
- *
3522
- * @returns {boolean} True if value is a Blob, otherwise false
3523
- */
3524
- const isBlob = kindOfTest('Blob');
3525
-
3526
- /**
3527
- * Determine if a value is a FileList
3528
- *
3529
- * @param {*} val The value to test
3530
- *
3531
- * @returns {boolean} True if value is a File, otherwise false
3532
- */
3533
- const isFileList = kindOfTest('FileList');
3534
-
3535
- /**
3536
- * Determine if a value is a Stream
3537
- *
3538
- * @param {*} val The value to test
3539
- *
3540
- * @returns {boolean} True if value is a Stream, otherwise false
3541
- */
3542
- const isStream = (val) => isObject(val) && isFunction(val.pipe);
3543
-
3544
- /**
3545
- * Determine if a value is a FormData
3546
- *
3547
- * @param {*} thing The value to test
3548
- *
3549
- * @returns {boolean} True if value is an FormData, otherwise false
3550
- */
3551
- const isFormData = (thing) => {
3552
- let kind;
3553
- return thing && (
3554
- (typeof FormData === 'function' && thing instanceof FormData) || (
3555
- isFunction(thing.append) && (
3556
- (kind = kindOf(thing)) === 'formdata' ||
3557
- // detect form-data instance
3558
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
3559
- )
3560
- )
3561
- )
3562
- };
3563
-
3564
- /**
3565
- * Determine if a value is a URLSearchParams object
3566
- *
3567
- * @param {*} val The value to test
3568
- *
3569
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
3570
- */
3571
- const isURLSearchParams = kindOfTest('URLSearchParams');
3572
-
3573
- const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
3574
-
3575
- /**
3576
- * Trim excess whitespace off the beginning and end of a string
3577
- *
3578
- * @param {String} str The String to trim
3579
- *
3580
- * @returns {String} The String freed of excess whitespace
3581
- */
3582
- const trim = (str) => str.trim ?
3583
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
3584
-
3585
- /**
3586
- * Iterate over an Array or an Object invoking a function for each item.
3587
- *
3588
- * If `obj` is an Array callback will be called passing
3589
- * the value, index, and complete array for each item.
3590
- *
3591
- * If 'obj' is an Object callback will be called passing
3592
- * the value, key, and complete object for each property.
3593
- *
3594
- * @param {Object|Array} obj The object to iterate
3595
- * @param {Function} fn The callback to invoke for each item
3596
- *
3597
- * @param {Boolean} [allOwnKeys = false]
3598
- * @returns {any}
3599
- */
3600
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
3601
- // Don't bother if no value provided
3602
- if (obj === null || typeof obj === 'undefined') {
3603
- return;
3604
- }
3605
-
3606
- let i;
3607
- let l;
3608
-
3609
- // Force an array if not already something iterable
3610
- if (typeof obj !== 'object') {
3611
- /*eslint no-param-reassign:0*/
3612
- obj = [obj];
3613
- }
3614
-
3615
- if (isArray(obj)) {
3616
- // Iterate over array values
3617
- for (i = 0, l = obj.length; i < l; i++) {
3618
- fn.call(null, obj[i], i, obj);
3619
- }
3620
- } else {
3621
- // Iterate over object keys
3622
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
3623
- const len = keys.length;
3624
- let key;
3625
-
3626
- for (i = 0; i < len; i++) {
3627
- key = keys[i];
3628
- fn.call(null, obj[key], key, obj);
3629
- }
3630
- }
3631
- }
3632
-
3633
- function findKey(obj, key) {
3634
- key = key.toLowerCase();
3635
- const keys = Object.keys(obj);
3636
- let i = keys.length;
3637
- let _key;
3638
- while (i-- > 0) {
3639
- _key = keys[i];
3640
- if (key === _key.toLowerCase()) {
3641
- return _key;
3642
- }
3643
- }
3644
- return null;
3645
- }
3646
-
3647
- const _global = (() => {
3648
- /*eslint no-undef:0*/
3649
- if (typeof globalThis !== "undefined") return globalThis;
3650
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
3651
- })();
3652
-
3653
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
3654
-
3655
- /**
3656
- * Accepts varargs expecting each argument to be an object, then
3657
- * immutably merges the properties of each object and returns result.
3658
- *
3659
- * When multiple objects contain the same key the later object in
3660
- * the arguments list will take precedence.
3661
- *
3662
- * Example:
3663
- *
3664
- * ```js
3665
- * var result = merge({foo: 123}, {foo: 456});
3666
- * console.log(result.foo); // outputs 456
3667
- * ```
3668
- *
3669
- * @param {Object} obj1 Object to merge
3670
- *
3671
- * @returns {Object} Result of all merge properties
3672
- */
3673
- function merge(/* obj1, obj2, obj3, ... */) {
3674
- const {caseless} = isContextDefined(this) && this || {};
3675
- const result = {};
3676
- const assignValue = (val, key) => {
3677
- const targetKey = caseless && findKey(result, key) || key;
3678
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
3679
- result[targetKey] = merge(result[targetKey], val);
3680
- } else if (isPlainObject(val)) {
3681
- result[targetKey] = merge({}, val);
3682
- } else if (isArray(val)) {
3683
- result[targetKey] = val.slice();
3684
- } else {
3685
- result[targetKey] = val;
3686
- }
3687
- };
3688
-
3689
- for (let i = 0, l = arguments.length; i < l; i++) {
3690
- arguments[i] && forEach(arguments[i], assignValue);
3691
- }
3692
- return result;
3693
- }
3694
-
3695
- /**
3696
- * Extends object a by mutably adding to it the properties of object b.
3697
- *
3698
- * @param {Object} a The object to be extended
3699
- * @param {Object} b The object to copy properties from
3700
- * @param {Object} thisArg The object to bind function to
3701
- *
3702
- * @param {Boolean} [allOwnKeys]
3703
- * @returns {Object} The resulting value of object a
3704
- */
3705
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
3706
- forEach(b, (val, key) => {
3707
- if (thisArg && isFunction(val)) {
3708
- a[key] = bind(val, thisArg);
3709
- } else {
3710
- a[key] = val;
3711
- }
3712
- }, {allOwnKeys});
3713
- return a;
3714
- };
3715
-
3716
- /**
3717
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
3718
- *
3719
- * @param {string} content with BOM
3720
- *
3721
- * @returns {string} content value without BOM
3722
- */
3723
- const stripBOM = (content) => {
3724
- if (content.charCodeAt(0) === 0xFEFF) {
3725
- content = content.slice(1);
3726
- }
3727
- return content;
3728
- };
3729
-
3730
- /**
3731
- * Inherit the prototype methods from one constructor into another
3732
- * @param {function} constructor
3733
- * @param {function} superConstructor
3734
- * @param {object} [props]
3735
- * @param {object} [descriptors]
3736
- *
3737
- * @returns {void}
3738
- */
3739
- const inherits = (constructor, superConstructor, props, descriptors) => {
3740
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
3741
- constructor.prototype.constructor = constructor;
3742
- Object.defineProperty(constructor, 'super', {
3743
- value: superConstructor.prototype
3744
- });
3745
- props && Object.assign(constructor.prototype, props);
3746
- };
3747
-
3748
- /**
3749
- * Resolve object with deep prototype chain to a flat object
3750
- * @param {Object} sourceObj source object
3751
- * @param {Object} [destObj]
3752
- * @param {Function|Boolean} [filter]
3753
- * @param {Function} [propFilter]
3754
- *
3755
- * @returns {Object}
3756
- */
3757
- const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
3758
- let props;
3759
- let i;
3760
- let prop;
3761
- const merged = {};
3762
-
3763
- destObj = destObj || {};
3764
- // eslint-disable-next-line no-eq-null,eqeqeq
3765
- if (sourceObj == null) return destObj;
3766
-
3767
- do {
3768
- props = Object.getOwnPropertyNames(sourceObj);
3769
- i = props.length;
3770
- while (i-- > 0) {
3771
- prop = props[i];
3772
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
3773
- destObj[prop] = sourceObj[prop];
3774
- merged[prop] = true;
3775
- }
3776
- }
3777
- sourceObj = filter !== false && getPrototypeOf(sourceObj);
3778
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
3779
-
3780
- return destObj;
3781
- };
3782
-
3783
- /**
3784
- * Determines whether a string ends with the characters of a specified string
3785
- *
3786
- * @param {String} str
3787
- * @param {String} searchString
3788
- * @param {Number} [position= 0]
3789
- *
3790
- * @returns {boolean}
3791
- */
3792
- const endsWith = (str, searchString, position) => {
3793
- str = String(str);
3794
- if (position === undefined || position > str.length) {
3795
- position = str.length;
3796
- }
3797
- position -= searchString.length;
3798
- const lastIndex = str.indexOf(searchString, position);
3799
- return lastIndex !== -1 && lastIndex === position;
3800
- };
3801
-
3802
-
3803
- /**
3804
- * Returns new array from array like object or null if failed
3805
- *
3806
- * @param {*} [thing]
3807
- *
3808
- * @returns {?Array}
3809
- */
3810
- const toArray = (thing) => {
3811
- if (!thing) return null;
3812
- if (isArray(thing)) return thing;
3813
- let i = thing.length;
3814
- if (!isNumber(i)) return null;
3815
- const arr = new Array(i);
3816
- while (i-- > 0) {
3817
- arr[i] = thing[i];
3818
- }
3819
- return arr;
3820
- };
3821
-
3822
- /**
3823
- * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
3824
- * thing passed in is an instance of Uint8Array
3825
- *
3826
- * @param {TypedArray}
3827
- *
3828
- * @returns {Array}
3829
- */
3830
- // eslint-disable-next-line func-names
3831
- const isTypedArray = (TypedArray => {
3832
- // eslint-disable-next-line func-names
3833
- return thing => {
3834
- return TypedArray && thing instanceof TypedArray;
3835
- };
3836
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
3837
-
3838
- /**
3839
- * For each entry in the object, call the function with the key and value.
3840
- *
3841
- * @param {Object<any, any>} obj - The object to iterate over.
3842
- * @param {Function} fn - The function to call for each entry.
3843
- *
3844
- * @returns {void}
3845
- */
3846
- const forEachEntry = (obj, fn) => {
3847
- const generator = obj && obj[Symbol.iterator];
3848
-
3849
- const iterator = generator.call(obj);
3850
-
3851
- let result;
3852
-
3853
- while ((result = iterator.next()) && !result.done) {
3854
- const pair = result.value;
3855
- fn.call(obj, pair[0], pair[1]);
3856
- }
3857
- };
3858
-
3859
- /**
3860
- * It takes a regular expression and a string, and returns an array of all the matches
3861
- *
3862
- * @param {string} regExp - The regular expression to match against.
3863
- * @param {string} str - The string to search.
3864
- *
3865
- * @returns {Array<boolean>}
3866
- */
3867
- const matchAll = (regExp, str) => {
3868
- let matches;
3869
- const arr = [];
3870
-
3871
- while ((matches = regExp.exec(str)) !== null) {
3872
- arr.push(matches);
3873
- }
3874
-
3875
- return arr;
3876
- };
3877
-
3878
- /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
3879
- const isHTMLForm = kindOfTest('HTMLFormElement');
3880
-
3881
- const toCamelCase = str => {
3882
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
3883
- function replacer(m, p1, p2) {
3884
- return p1.toUpperCase() + p2;
3885
- }
3886
- );
3887
- };
3888
-
3889
- /* Creating a function that will check if an object has a property. */
3890
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
3891
-
3892
- /**
3893
- * Determine if a value is a RegExp object
3894
- *
3895
- * @param {*} val The value to test
3896
- *
3897
- * @returns {boolean} True if value is a RegExp object, otherwise false
3898
- */
3899
- const isRegExp = kindOfTest('RegExp');
3900
-
3901
- const reduceDescriptors = (obj, reducer) => {
3902
- const descriptors = Object.getOwnPropertyDescriptors(obj);
3903
- const reducedDescriptors = {};
3904
-
3905
- forEach(descriptors, (descriptor, name) => {
3906
- let ret;
3907
- if ((ret = reducer(descriptor, name, obj)) !== false) {
3908
- reducedDescriptors[name] = ret || descriptor;
3909
- }
3910
- });
3911
-
3912
- Object.defineProperties(obj, reducedDescriptors);
3913
- };
3914
-
3915
- /**
3916
- * Makes all methods read-only
3917
- * @param {Object} obj
3918
- */
3919
-
3920
- const freezeMethods = (obj) => {
3921
- reduceDescriptors(obj, (descriptor, name) => {
3922
- // skip restricted props in strict mode
3923
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
3924
- return false;
3925
- }
3926
-
3927
- const value = obj[name];
3928
-
3929
- if (!isFunction(value)) return;
3930
-
3931
- descriptor.enumerable = false;
3932
-
3933
- if ('writable' in descriptor) {
3934
- descriptor.writable = false;
3935
- return;
3936
- }
3937
-
3938
- if (!descriptor.set) {
3939
- descriptor.set = () => {
3940
- throw Error('Can not rewrite read-only method \'' + name + '\'');
3941
- };
3942
- }
3943
- });
3944
- };
3945
-
3946
- const toObjectSet = (arrayOrString, delimiter) => {
3947
- const obj = {};
3948
-
3949
- const define = (arr) => {
3950
- arr.forEach(value => {
3951
- obj[value] = true;
3952
- });
3953
- };
3954
-
3955
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
3956
-
3957
- return obj;
3958
- };
3959
-
3960
- const noop$1 = () => {};
3961
-
3962
- const toFiniteNumber = (value, defaultValue) => {
3963
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
3964
- };
3965
-
3966
- /**
3967
- * If the thing is a FormData object, return true, otherwise return false.
3968
- *
3969
- * @param {unknown} thing - The thing to check.
3970
- *
3971
- * @returns {boolean}
3972
- */
3973
- function isSpecCompliantForm(thing) {
3974
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
3975
- }
3976
-
3977
- const toJSONObject = (obj) => {
3978
- const stack = new Array(10);
3979
-
3980
- const visit = (source, i) => {
3981
-
3982
- if (isObject(source)) {
3983
- if (stack.indexOf(source) >= 0) {
3984
- return;
3985
- }
3986
-
3987
- if(!('toJSON' in source)) {
3988
- stack[i] = source;
3989
- const target = isArray(source) ? [] : {};
3990
-
3991
- forEach(source, (value, key) => {
3992
- const reducedValue = visit(value, i + 1);
3993
- !isUndefined(reducedValue) && (target[key] = reducedValue);
3994
- });
3995
-
3996
- stack[i] = undefined;
3997
-
3998
- return target;
3999
- }
4000
- }
4001
-
4002
- return source;
4003
- };
4004
-
4005
- return visit(obj, 0);
4006
- };
4007
-
4008
- const isAsyncFn = kindOfTest('AsyncFunction');
4009
-
4010
- const isThenable = (thing) =>
4011
- thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
4012
-
4013
- // original code
4014
- // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
4015
-
4016
- const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
4017
- if (setImmediateSupported) {
4018
- return setImmediate;
4019
- }
4020
-
4021
- return postMessageSupported ? ((token, callbacks) => {
4022
- _global.addEventListener("message", ({source, data}) => {
4023
- if (source === _global && data === token) {
4024
- callbacks.length && callbacks.shift()();
4025
- }
4026
- }, false);
4027
-
4028
- return (cb) => {
4029
- callbacks.push(cb);
4030
- _global.postMessage(token, "*");
4031
- }
4032
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
4033
- })(
4034
- typeof setImmediate === 'function',
4035
- isFunction(_global.postMessage)
4036
- );
4037
-
4038
- const asap = typeof queueMicrotask !== 'undefined' ?
4039
- queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
4040
-
4041
- // *********************
4042
-
4043
- var utils$1 = {
4044
- isArray,
4045
- isArrayBuffer,
4046
- isBuffer,
4047
- isFormData,
4048
- isArrayBufferView,
4049
- isString,
4050
- isNumber,
4051
- isBoolean,
4052
- isObject,
4053
- isPlainObject,
4054
- isReadableStream,
4055
- isRequest,
4056
- isResponse,
4057
- isHeaders,
4058
- isUndefined,
4059
- isDate,
4060
- isFile,
4061
- isBlob,
4062
- isRegExp,
4063
- isFunction,
4064
- isStream,
4065
- isURLSearchParams,
4066
- isTypedArray,
4067
- isFileList,
4068
- forEach,
4069
- merge,
4070
- extend,
4071
- trim,
4072
- stripBOM,
4073
- inherits,
4074
- toFlatObject,
4075
- kindOf,
4076
- kindOfTest,
4077
- endsWith,
4078
- toArray,
4079
- forEachEntry,
4080
- matchAll,
4081
- isHTMLForm,
4082
- hasOwnProperty,
4083
- hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
4084
- reduceDescriptors,
4085
- freezeMethods,
4086
- toObjectSet,
4087
- toCamelCase,
4088
- noop: noop$1,
4089
- toFiniteNumber,
4090
- findKey,
4091
- global: _global,
4092
- isContextDefined,
4093
- isSpecCompliantForm,
4094
- toJSONObject,
4095
- isAsyncFn,
4096
- isThenable,
4097
- setImmediate: _setImmediate,
4098
- asap
4099
- };
4100
-
4101
- /**
4102
- * Create an Error with the specified message, config, error code, request and response.
4103
- *
4104
- * @param {string} message The error message.
4105
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
4106
- * @param {Object} [config] The config.
4107
- * @param {Object} [request] The request.
4108
- * @param {Object} [response] The response.
4109
- *
4110
- * @returns {Error} The created error.
4111
- */
4112
- function AxiosError$1(message, code, config, request, response) {
4113
- Error.call(this);
4114
-
4115
- if (Error.captureStackTrace) {
4116
- Error.captureStackTrace(this, this.constructor);
4117
- } else {
4118
- this.stack = (new Error()).stack;
4119
- }
4120
-
4121
- this.message = message;
4122
- this.name = 'AxiosError';
4123
- code && (this.code = code);
4124
- config && (this.config = config);
4125
- request && (this.request = request);
4126
- if (response) {
4127
- this.response = response;
4128
- this.status = response.status ? response.status : null;
4129
- }
4130
- }
4131
-
4132
- utils$1.inherits(AxiosError$1, Error, {
4133
- toJSON: function toJSON() {
4134
- return {
4135
- // Standard
4136
- message: this.message,
4137
- name: this.name,
4138
- // Microsoft
4139
- description: this.description,
4140
- number: this.number,
4141
- // Mozilla
4142
- fileName: this.fileName,
4143
- lineNumber: this.lineNumber,
4144
- columnNumber: this.columnNumber,
4145
- stack: this.stack,
4146
- // Axios
4147
- config: utils$1.toJSONObject(this.config),
4148
- code: this.code,
4149
- status: this.status
4150
- };
4151
- }
4152
- });
4153
-
4154
- const prototype$1 = AxiosError$1.prototype;
4155
- const descriptors = {};
4156
-
4157
- [
4158
- 'ERR_BAD_OPTION_VALUE',
4159
- 'ERR_BAD_OPTION',
4160
- 'ECONNABORTED',
4161
- 'ETIMEDOUT',
4162
- 'ERR_NETWORK',
4163
- 'ERR_FR_TOO_MANY_REDIRECTS',
4164
- 'ERR_DEPRECATED',
4165
- 'ERR_BAD_RESPONSE',
4166
- 'ERR_BAD_REQUEST',
4167
- 'ERR_CANCELED',
4168
- 'ERR_NOT_SUPPORT',
4169
- 'ERR_INVALID_URL'
4170
- // eslint-disable-next-line func-names
4171
- ].forEach(code => {
4172
- descriptors[code] = {value: code};
4173
- });
4174
-
4175
- Object.defineProperties(AxiosError$1, descriptors);
4176
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
4177
-
4178
- // eslint-disable-next-line func-names
4179
- AxiosError$1.from = (error, code, config, request, response, customProps) => {
4180
- const axiosError = Object.create(prototype$1);
4181
-
4182
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
4183
- return obj !== Error.prototype;
4184
- }, prop => {
4185
- return prop !== 'isAxiosError';
4186
- });
4187
-
4188
- AxiosError$1.call(axiosError, error.message, code, config, request, response);
4189
-
4190
- axiosError.cause = error;
4191
-
4192
- axiosError.name = error.name;
4193
-
4194
- customProps && Object.assign(axiosError, customProps);
4195
-
4196
- return axiosError;
4197
- };
4198
-
4199
- // eslint-disable-next-line strict
4200
- var httpAdapter = null;
4201
-
4202
- /**
4203
- * Determines if the given thing is a array or js object.
4204
- *
4205
- * @param {string} thing - The object or array to be visited.
4206
- *
4207
- * @returns {boolean}
4208
- */
4209
- function isVisitable(thing) {
4210
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
4211
- }
4212
-
4213
- /**
4214
- * It removes the brackets from the end of a string
4215
- *
4216
- * @param {string} key - The key of the parameter.
4217
- *
4218
- * @returns {string} the key without the brackets.
4219
- */
4220
- function removeBrackets(key) {
4221
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
4222
- }
4223
-
4224
- /**
4225
- * It takes a path, a key, and a boolean, and returns a string
4226
- *
4227
- * @param {string} path - The path to the current key.
4228
- * @param {string} key - The key of the current object being iterated over.
4229
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
4230
- *
4231
- * @returns {string} The path to the current key.
4232
- */
4233
- function renderKey(path, key, dots) {
4234
- if (!path) return key;
4235
- return path.concat(key).map(function each(token, i) {
4236
- // eslint-disable-next-line no-param-reassign
4237
- token = removeBrackets(token);
4238
- return !dots && i ? '[' + token + ']' : token;
4239
- }).join(dots ? '.' : '');
4240
- }
4241
-
4242
- /**
4243
- * If the array is an array and none of its elements are visitable, then it's a flat array.
4244
- *
4245
- * @param {Array<any>} arr - The array to check
4246
- *
4247
- * @returns {boolean}
4248
- */
4249
- function isFlatArray(arr) {
4250
- return utils$1.isArray(arr) && !arr.some(isVisitable);
4251
- }
4252
-
4253
- const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
4254
- return /^is[A-Z]/.test(prop);
4255
- });
4256
-
4257
- /**
4258
- * Convert a data object to FormData
4259
- *
4260
- * @param {Object} obj
4261
- * @param {?Object} [formData]
4262
- * @param {?Object} [options]
4263
- * @param {Function} [options.visitor]
4264
- * @param {Boolean} [options.metaTokens = true]
4265
- * @param {Boolean} [options.dots = false]
4266
- * @param {?Boolean} [options.indexes = false]
4267
- *
4268
- * @returns {Object}
4269
- **/
4270
-
4271
- /**
4272
- * It converts an object into a FormData object
4273
- *
4274
- * @param {Object<any, any>} obj - The object to convert to form data.
4275
- * @param {string} formData - The FormData object to append to.
4276
- * @param {Object<string, any>} options
4277
- *
4278
- * @returns
4279
- */
4280
- function toFormData$1(obj, formData, options) {
4281
- if (!utils$1.isObject(obj)) {
4282
- throw new TypeError('target must be an object');
4283
- }
4284
-
4285
- // eslint-disable-next-line no-param-reassign
4286
- formData = formData || new (FormData)();
4287
-
4288
- // eslint-disable-next-line no-param-reassign
4289
- options = utils$1.toFlatObject(options, {
4290
- metaTokens: true,
4291
- dots: false,
4292
- indexes: false
4293
- }, false, function defined(option, source) {
4294
- // eslint-disable-next-line no-eq-null,eqeqeq
4295
- return !utils$1.isUndefined(source[option]);
4296
- });
4297
-
4298
- const metaTokens = options.metaTokens;
4299
- // eslint-disable-next-line no-use-before-define
4300
- const visitor = options.visitor || defaultVisitor;
4301
- const dots = options.dots;
4302
- const indexes = options.indexes;
4303
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
4304
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
4305
-
4306
- if (!utils$1.isFunction(visitor)) {
4307
- throw new TypeError('visitor must be a function');
4308
- }
4309
-
4310
- function convertValue(value) {
4311
- if (value === null) return '';
4312
-
4313
- if (utils$1.isDate(value)) {
4314
- return value.toISOString();
4315
- }
4316
-
4317
- if (!useBlob && utils$1.isBlob(value)) {
4318
- throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
4319
- }
4320
-
4321
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
4322
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
4323
- }
4324
-
4325
- return value;
4326
- }
4327
-
4328
- /**
4329
- * Default visitor.
4330
- *
4331
- * @param {*} value
4332
- * @param {String|Number} key
4333
- * @param {Array<String|Number>} path
4334
- * @this {FormData}
4335
- *
4336
- * @returns {boolean} return true to visit the each prop of the value recursively
4337
- */
4338
- function defaultVisitor(value, key, path) {
4339
- let arr = value;
4340
-
4341
- if (value && !path && typeof value === 'object') {
4342
- if (utils$1.endsWith(key, '{}')) {
4343
- // eslint-disable-next-line no-param-reassign
4344
- key = metaTokens ? key : key.slice(0, -2);
4345
- // eslint-disable-next-line no-param-reassign
4346
- value = JSON.stringify(value);
4347
- } else if (
4348
- (utils$1.isArray(value) && isFlatArray(value)) ||
4349
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
4350
- )) {
4351
- // eslint-disable-next-line no-param-reassign
4352
- key = removeBrackets(key);
4353
-
4354
- arr.forEach(function each(el, index) {
4355
- !(utils$1.isUndefined(el) || el === null) && formData.append(
4356
- // eslint-disable-next-line no-nested-ternary
4357
- indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
4358
- convertValue(el)
4359
- );
4360
- });
4361
- return false;
4362
- }
4363
- }
4364
-
4365
- if (isVisitable(value)) {
4366
- return true;
4367
- }
4368
-
4369
- formData.append(renderKey(path, key, dots), convertValue(value));
4370
-
4371
- return false;
4372
- }
4373
-
4374
- const stack = [];
4375
-
4376
- const exposedHelpers = Object.assign(predicates, {
4377
- defaultVisitor,
4378
- convertValue,
4379
- isVisitable
4380
- });
4381
-
4382
- function build(value, path) {
4383
- if (utils$1.isUndefined(value)) return;
4384
-
4385
- if (stack.indexOf(value) !== -1) {
4386
- throw Error('Circular reference detected in ' + path.join('.'));
4387
- }
4388
-
4389
- stack.push(value);
4390
-
4391
- utils$1.forEach(value, function each(el, key) {
4392
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
4393
- formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
4394
- );
4395
-
4396
- if (result === true) {
4397
- build(el, path ? path.concat(key) : [key]);
4398
- }
4399
- });
4400
-
4401
- stack.pop();
4402
- }
4403
-
4404
- if (!utils$1.isObject(obj)) {
4405
- throw new TypeError('data must be an object');
4406
- }
4407
-
4408
- build(obj);
4409
-
4410
- return formData;
4411
- }
4412
-
4413
- /**
4414
- * It encodes a string by replacing all characters that are not in the unreserved set with
4415
- * their percent-encoded equivalents
4416
- *
4417
- * @param {string} str - The string to encode.
4418
- *
4419
- * @returns {string} The encoded string.
4420
- */
4421
- function encode$1(str) {
4422
- const charMap = {
4423
- '!': '%21',
4424
- "'": '%27',
4425
- '(': '%28',
4426
- ')': '%29',
4427
- '~': '%7E',
4428
- '%20': '+',
4429
- '%00': '\x00'
4430
- };
4431
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
4432
- return charMap[match];
4433
- });
4434
- }
4435
-
4436
- /**
4437
- * It takes a params object and converts it to a FormData object
4438
- *
4439
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
4440
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
4441
- *
4442
- * @returns {void}
4443
- */
4444
- function AxiosURLSearchParams(params, options) {
4445
- this._pairs = [];
4446
-
4447
- params && toFormData$1(params, this, options);
4448
- }
4449
-
4450
- const prototype = AxiosURLSearchParams.prototype;
4451
-
4452
- prototype.append = function append(name, value) {
4453
- this._pairs.push([name, value]);
4454
- };
4455
-
4456
- prototype.toString = function toString(encoder) {
4457
- const _encode = encoder ? function(value) {
4458
- return encoder.call(this, value, encode$1);
4459
- } : encode$1;
4460
-
4461
- return this._pairs.map(function each(pair) {
4462
- return _encode(pair[0]) + '=' + _encode(pair[1]);
4463
- }, '').join('&');
4464
- };
4465
-
4466
- /**
4467
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
4468
- * URI encoded counterparts
4469
- *
4470
- * @param {string} val The value to be encoded.
4471
- *
4472
- * @returns {string} The encoded value.
4473
- */
4474
- function encode(val) {
4475
- return encodeURIComponent(val).
4476
- replace(/%3A/gi, ':').
4477
- replace(/%24/g, '$').
4478
- replace(/%2C/gi, ',').
4479
- replace(/%20/g, '+').
4480
- replace(/%5B/gi, '[').
4481
- replace(/%5D/gi, ']');
4482
- }
4483
-
4484
- /**
4485
- * Build a URL by appending params to the end
4486
- *
4487
- * @param {string} url The base of the url (e.g., http://www.google.com)
4488
- * @param {object} [params] The params to be appended
4489
- * @param {?(object|Function)} options
4490
- *
4491
- * @returns {string} The formatted url
4492
- */
4493
- function buildURL(url, params, options) {
4494
- /*eslint no-param-reassign:0*/
4495
- if (!params) {
4496
- return url;
4497
- }
4498
-
4499
- const _encode = options && options.encode || encode;
4500
-
4501
- if (utils$1.isFunction(options)) {
4502
- options = {
4503
- serialize: options
4504
- };
4505
- }
4506
-
4507
- const serializeFn = options && options.serialize;
4508
-
4509
- let serializedParams;
4510
-
4511
- if (serializeFn) {
4512
- serializedParams = serializeFn(params, options);
4513
- } else {
4514
- serializedParams = utils$1.isURLSearchParams(params) ?
4515
- params.toString() :
4516
- new AxiosURLSearchParams(params, options).toString(_encode);
4517
- }
4518
-
4519
- if (serializedParams) {
4520
- const hashmarkIndex = url.indexOf("#");
4521
-
4522
- if (hashmarkIndex !== -1) {
4523
- url = url.slice(0, hashmarkIndex);
4524
- }
4525
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
4526
- }
4527
-
4528
- return url;
4529
- }
4530
-
4531
- class InterceptorManager {
4532
- constructor() {
4533
- this.handlers = [];
4534
- }
4535
-
4536
- /**
4537
- * Add a new interceptor to the stack
4538
- *
4539
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
4540
- * @param {Function} rejected The function to handle `reject` for a `Promise`
4541
- *
4542
- * @return {Number} An ID used to remove interceptor later
4543
- */
4544
- use(fulfilled, rejected, options) {
4545
- this.handlers.push({
4546
- fulfilled,
4547
- rejected,
4548
- synchronous: options ? options.synchronous : false,
4549
- runWhen: options ? options.runWhen : null
4550
- });
4551
- return this.handlers.length - 1;
4552
- }
4553
-
4554
- /**
4555
- * Remove an interceptor from the stack
4556
- *
4557
- * @param {Number} id The ID that was returned by `use`
4558
- *
4559
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
4560
- */
4561
- eject(id) {
4562
- if (this.handlers[id]) {
4563
- this.handlers[id] = null;
4564
- }
4565
- }
4566
-
4567
- /**
4568
- * Clear all interceptors from the stack
4569
- *
4570
- * @returns {void}
4571
- */
4572
- clear() {
4573
- if (this.handlers) {
4574
- this.handlers = [];
4575
- }
4576
- }
4577
-
4578
- /**
4579
- * Iterate over all the registered interceptors
4580
- *
4581
- * This method is particularly useful for skipping over any
4582
- * interceptors that may have become `null` calling `eject`.
4583
- *
4584
- * @param {Function} fn The function to call for each interceptor
4585
- *
4586
- * @returns {void}
4587
- */
4588
- forEach(fn) {
4589
- utils$1.forEach(this.handlers, function forEachHandler(h) {
4590
- if (h !== null) {
4591
- fn(h);
4592
- }
4593
- });
4594
- }
4595
- }
4596
-
4597
- var transitionalDefaults = {
4598
- silentJSONParsing: true,
4599
- forcedJSONParsing: true,
4600
- clarifyTimeoutError: false
4601
- };
4602
-
4603
- var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
4604
-
4605
- var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
4606
-
4607
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
4608
-
4609
- var platform$2 = {
4610
- isBrowser: true,
4611
- classes: {
4612
- URLSearchParams: URLSearchParams$1,
4613
- FormData: FormData$1,
4614
- Blob: Blob$1
4615
- },
4616
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
4617
- };
4618
-
4619
- const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
4620
-
4621
- const _navigator = typeof navigator === 'object' && navigator || undefined;
4622
-
4623
- /**
4624
- * Determine if we're running in a standard browser environment
4625
- *
4626
- * This allows axios to run in a web worker, and react-native.
4627
- * Both environments support XMLHttpRequest, but not fully standard globals.
4628
- *
4629
- * web workers:
4630
- * typeof window -> undefined
4631
- * typeof document -> undefined
4632
- *
4633
- * react-native:
4634
- * navigator.product -> 'ReactNative'
4635
- * nativescript
4636
- * navigator.product -> 'NativeScript' or 'NS'
4637
- *
4638
- * @returns {boolean}
4639
- */
4640
- const hasStandardBrowserEnv = hasBrowserEnv &&
4641
- (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
4642
-
4643
- /**
4644
- * Determine if we're running in a standard browser webWorker environment
4645
- *
4646
- * Although the `isStandardBrowserEnv` method indicates that
4647
- * `allows axios to run in a web worker`, the WebWorker will still be
4648
- * filtered out due to its judgment standard
4649
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
4650
- * This leads to a problem when axios post `FormData` in webWorker
4651
- */
4652
- const hasStandardBrowserWebWorkerEnv = (() => {
4653
- return (
4654
- typeof WorkerGlobalScope !== 'undefined' &&
4655
- // eslint-disable-next-line no-undef
4656
- self instanceof WorkerGlobalScope &&
4657
- typeof self.importScripts === 'function'
4658
- );
4659
- })();
4660
-
4661
- const origin = hasBrowserEnv && window.location.href || 'http://localhost';
4662
-
4663
- var utils = /*#__PURE__*/Object.freeze({
4664
- __proto__: null,
4665
- hasBrowserEnv: hasBrowserEnv,
4666
- hasStandardBrowserEnv: hasStandardBrowserEnv,
4667
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
4668
- navigator: _navigator,
4669
- origin: origin
4670
- });
4671
-
4672
- var platform$1 = {
4673
- ...utils,
4674
- ...platform$2
4675
- };
4676
-
4677
- function toURLEncodedForm(data, options) {
4678
- return toFormData$1(data, new platform$1.classes.URLSearchParams(), Object.assign({
4679
- visitor: function(value, key, path, helpers) {
4680
- if (platform$1.isNode && utils$1.isBuffer(value)) {
4681
- this.append(key, value.toString('base64'));
4682
- return false;
4683
- }
4684
-
4685
- return helpers.defaultVisitor.apply(this, arguments);
4686
- }
4687
- }, options));
4688
- }
4689
-
4690
- /**
4691
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
4692
- *
4693
- * @param {string} name - The name of the property to get.
4694
- *
4695
- * @returns An array of strings.
4696
- */
4697
- function parsePropPath(name) {
4698
- // foo[x][y][z]
4699
- // foo.x.y.z
4700
- // foo-x-y-z
4701
- // foo x y z
4702
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
4703
- return match[0] === '[]' ? '' : match[1] || match[0];
4704
- });
4705
- }
4706
-
4707
- /**
4708
- * Convert an array to an object.
4709
- *
4710
- * @param {Array<any>} arr - The array to convert to an object.
4711
- *
4712
- * @returns An object with the same keys and values as the array.
4713
- */
4714
- function arrayToObject(arr) {
4715
- const obj = {};
4716
- const keys = Object.keys(arr);
4717
- let i;
4718
- const len = keys.length;
4719
- let key;
4720
- for (i = 0; i < len; i++) {
4721
- key = keys[i];
4722
- obj[key] = arr[key];
4723
- }
4724
- return obj;
4725
- }
4726
-
4727
- /**
4728
- * It takes a FormData object and returns a JavaScript object
4729
- *
4730
- * @param {string} formData The FormData object to convert to JSON.
4731
- *
4732
- * @returns {Object<string, any> | null} The converted object.
4733
- */
4734
- function formDataToJSON(formData) {
4735
- function buildPath(path, value, target, index) {
4736
- let name = path[index++];
4737
-
4738
- if (name === '__proto__') return true;
4739
-
4740
- const isNumericKey = Number.isFinite(+name);
4741
- const isLast = index >= path.length;
4742
- name = !name && utils$1.isArray(target) ? target.length : name;
4743
-
4744
- if (isLast) {
4745
- if (utils$1.hasOwnProp(target, name)) {
4746
- target[name] = [target[name], value];
4747
- } else {
4748
- target[name] = value;
4749
- }
4750
-
4751
- return !isNumericKey;
4752
- }
4753
-
4754
- if (!target[name] || !utils$1.isObject(target[name])) {
4755
- target[name] = [];
4756
- }
4757
-
4758
- const result = buildPath(path, value, target[name], index);
4759
-
4760
- if (result && utils$1.isArray(target[name])) {
4761
- target[name] = arrayToObject(target[name]);
4762
- }
4763
-
4764
- return !isNumericKey;
4765
- }
4766
-
4767
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
4768
- const obj = {};
4769
-
4770
- utils$1.forEachEntry(formData, (name, value) => {
4771
- buildPath(parsePropPath(name), value, obj, 0);
4772
- });
4773
-
4774
- return obj;
4775
- }
4776
-
4777
- return null;
4778
- }
4779
-
4780
- /**
4781
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
4782
- * of the input
4783
- *
4784
- * @param {any} rawValue - The value to be stringified.
4785
- * @param {Function} parser - A function that parses a string into a JavaScript object.
4786
- * @param {Function} encoder - A function that takes a value and returns a string.
4787
- *
4788
- * @returns {string} A stringified version of the rawValue.
4789
- */
4790
- function stringifySafely(rawValue, parser, encoder) {
4791
- if (utils$1.isString(rawValue)) {
4792
- try {
4793
- (parser || JSON.parse)(rawValue);
4794
- return utils$1.trim(rawValue);
4795
- } catch (e) {
4796
- if (e.name !== 'SyntaxError') {
4797
- throw e;
4798
- }
4799
- }
4800
- }
4801
-
4802
- return (encoder || JSON.stringify)(rawValue);
4803
- }
4804
-
4805
- const defaults = {
4806
-
4807
- transitional: transitionalDefaults,
4808
-
4809
- adapter: ['xhr', 'http', 'fetch'],
4810
-
4811
- transformRequest: [function transformRequest(data, headers) {
4812
- const contentType = headers.getContentType() || '';
4813
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
4814
- const isObjectPayload = utils$1.isObject(data);
4815
-
4816
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
4817
- data = new FormData(data);
4818
- }
4819
-
4820
- const isFormData = utils$1.isFormData(data);
4821
-
4822
- if (isFormData) {
4823
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
4824
- }
4825
-
4826
- if (utils$1.isArrayBuffer(data) ||
4827
- utils$1.isBuffer(data) ||
4828
- utils$1.isStream(data) ||
4829
- utils$1.isFile(data) ||
4830
- utils$1.isBlob(data) ||
4831
- utils$1.isReadableStream(data)
4832
- ) {
4833
- return data;
4834
- }
4835
- if (utils$1.isArrayBufferView(data)) {
4836
- return data.buffer;
4837
- }
4838
- if (utils$1.isURLSearchParams(data)) {
4839
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
4840
- return data.toString();
4841
- }
4842
-
4843
- let isFileList;
4844
-
4845
- if (isObjectPayload) {
4846
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
4847
- return toURLEncodedForm(data, this.formSerializer).toString();
4848
- }
4849
-
4850
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
4851
- const _FormData = this.env && this.env.FormData;
4852
-
4853
- return toFormData$1(
4854
- isFileList ? {'files[]': data} : data,
4855
- _FormData && new _FormData(),
4856
- this.formSerializer
4857
- );
4858
- }
4859
- }
4860
-
4861
- if (isObjectPayload || hasJSONContentType ) {
4862
- headers.setContentType('application/json', false);
4863
- return stringifySafely(data);
4864
- }
4865
-
4866
- return data;
4867
- }],
4868
-
4869
- transformResponse: [function transformResponse(data) {
4870
- const transitional = this.transitional || defaults.transitional;
4871
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
4872
- const JSONRequested = this.responseType === 'json';
4873
-
4874
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
4875
- return data;
4876
- }
4877
-
4878
- if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
4879
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
4880
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
4881
-
4882
- try {
4883
- return JSON.parse(data);
4884
- } catch (e) {
4885
- if (strictJSONParsing) {
4886
- if (e.name === 'SyntaxError') {
4887
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
4888
- }
4889
- throw e;
4890
- }
4891
- }
4892
- }
4893
-
4894
- return data;
4895
- }],
4896
-
4897
- /**
4898
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
4899
- * timeout is not created.
4900
- */
4901
- timeout: 0,
4902
-
4903
- xsrfCookieName: 'XSRF-TOKEN',
4904
- xsrfHeaderName: 'X-XSRF-TOKEN',
4905
-
4906
- maxContentLength: -1,
4907
- maxBodyLength: -1,
4908
-
4909
- env: {
4910
- FormData: platform$1.classes.FormData,
4911
- Blob: platform$1.classes.Blob
4912
- },
4913
-
4914
- validateStatus: function validateStatus(status) {
4915
- return status >= 200 && status < 300;
4916
- },
4917
-
4918
- headers: {
4919
- common: {
4920
- 'Accept': 'application/json, text/plain, */*',
4921
- 'Content-Type': undefined
4922
- }
4923
- }
4924
- };
4925
-
4926
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
4927
- defaults.headers[method] = {};
4928
- });
4929
-
4930
- // RawAxiosHeaders whose duplicates are ignored by node
4931
- // c.f. https://nodejs.org/api/http.html#http_message_headers
4932
- const ignoreDuplicateOf = utils$1.toObjectSet([
4933
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
4934
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
4935
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
4936
- 'referer', 'retry-after', 'user-agent'
4937
- ]);
4938
-
4939
- /**
4940
- * Parse headers into an object
4941
- *
4942
- * ```
4943
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
4944
- * Content-Type: application/json
4945
- * Connection: keep-alive
4946
- * Transfer-Encoding: chunked
4947
- * ```
4948
- *
4949
- * @param {String} rawHeaders Headers needing to be parsed
4950
- *
4951
- * @returns {Object} Headers parsed into an object
4952
- */
4953
- var parseHeaders = rawHeaders => {
4954
- const parsed = {};
4955
- let key;
4956
- let val;
4957
- let i;
4958
-
4959
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
4960
- i = line.indexOf(':');
4961
- key = line.substring(0, i).trim().toLowerCase();
4962
- val = line.substring(i + 1).trim();
4963
-
4964
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
4965
- return;
4966
- }
4967
-
4968
- if (key === 'set-cookie') {
4969
- if (parsed[key]) {
4970
- parsed[key].push(val);
4971
- } else {
4972
- parsed[key] = [val];
4973
- }
4974
- } else {
4975
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
4976
- }
4977
- });
4978
-
4979
- return parsed;
4980
- };
4981
-
4982
- const $internals = Symbol('internals');
4983
-
4984
- function normalizeHeader(header) {
4985
- return header && String(header).trim().toLowerCase();
4986
- }
4987
-
4988
- function normalizeValue(value) {
4989
- if (value === false || value == null) {
4990
- return value;
4991
- }
4992
-
4993
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
4994
- }
4995
-
4996
- function parseTokens(str) {
4997
- const tokens = Object.create(null);
4998
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
4999
- let match;
5000
-
5001
- while ((match = tokensRE.exec(str))) {
5002
- tokens[match[1]] = match[2];
5003
- }
5004
-
5005
- return tokens;
5006
- }
5007
-
5008
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
5009
-
5010
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
5011
- if (utils$1.isFunction(filter)) {
5012
- return filter.call(this, value, header);
5013
- }
5014
-
5015
- if (isHeaderNameFilter) {
5016
- value = header;
5017
- }
5018
-
5019
- if (!utils$1.isString(value)) return;
5020
-
5021
- if (utils$1.isString(filter)) {
5022
- return value.indexOf(filter) !== -1;
5023
- }
5024
-
5025
- if (utils$1.isRegExp(filter)) {
5026
- return filter.test(value);
5027
- }
5028
- }
5029
-
5030
- function formatHeader(header) {
5031
- return header.trim()
5032
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
5033
- return char.toUpperCase() + str;
5034
- });
5035
- }
5036
-
5037
- function buildAccessors(obj, header) {
5038
- const accessorName = utils$1.toCamelCase(' ' + header);
5039
-
5040
- ['get', 'set', 'has'].forEach(methodName => {
5041
- Object.defineProperty(obj, methodName + accessorName, {
5042
- value: function(arg1, arg2, arg3) {
5043
- return this[methodName].call(this, header, arg1, arg2, arg3);
5044
- },
5045
- configurable: true
5046
- });
5047
- });
5048
- }
5049
-
5050
- let AxiosHeaders$1 = class AxiosHeaders {
5051
- constructor(headers) {
5052
- headers && this.set(headers);
5053
- }
5054
-
5055
- set(header, valueOrRewrite, rewrite) {
5056
- const self = this;
5057
-
5058
- function setHeader(_value, _header, _rewrite) {
5059
- const lHeader = normalizeHeader(_header);
5060
-
5061
- if (!lHeader) {
5062
- throw new Error('header name must be a non-empty string');
5063
- }
5064
-
5065
- const key = utils$1.findKey(self, lHeader);
5066
-
5067
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
5068
- self[key || _header] = normalizeValue(_value);
5069
- }
5070
- }
5071
-
5072
- const setHeaders = (headers, _rewrite) =>
5073
- utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
5074
-
5075
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
5076
- setHeaders(header, valueOrRewrite);
5077
- } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
5078
- setHeaders(parseHeaders(header), valueOrRewrite);
5079
- } else if (utils$1.isHeaders(header)) {
5080
- for (const [key, value] of header.entries()) {
5081
- setHeader(value, key, rewrite);
5082
- }
5083
- } else {
5084
- header != null && setHeader(valueOrRewrite, header, rewrite);
5085
- }
5086
-
5087
- return this;
5088
- }
5089
-
5090
- get(header, parser) {
5091
- header = normalizeHeader(header);
5092
-
5093
- if (header) {
5094
- const key = utils$1.findKey(this, header);
5095
-
5096
- if (key) {
5097
- const value = this[key];
5098
-
5099
- if (!parser) {
5100
- return value;
5101
- }
5102
-
5103
- if (parser === true) {
5104
- return parseTokens(value);
5105
- }
5106
-
5107
- if (utils$1.isFunction(parser)) {
5108
- return parser.call(this, value, key);
5109
- }
5110
-
5111
- if (utils$1.isRegExp(parser)) {
5112
- return parser.exec(value);
5113
- }
5114
-
5115
- throw new TypeError('parser must be boolean|regexp|function');
5116
- }
5117
- }
5118
- }
5119
-
5120
- has(header, matcher) {
5121
- header = normalizeHeader(header);
5122
-
5123
- if (header) {
5124
- const key = utils$1.findKey(this, header);
5125
-
5126
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
5127
- }
5128
-
5129
- return false;
5130
- }
5131
-
5132
- delete(header, matcher) {
5133
- const self = this;
5134
- let deleted = false;
5135
-
5136
- function deleteHeader(_header) {
5137
- _header = normalizeHeader(_header);
5138
-
5139
- if (_header) {
5140
- const key = utils$1.findKey(self, _header);
5141
-
5142
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
5143
- delete self[key];
5144
-
5145
- deleted = true;
5146
- }
5147
- }
5148
- }
5149
-
5150
- if (utils$1.isArray(header)) {
5151
- header.forEach(deleteHeader);
5152
- } else {
5153
- deleteHeader(header);
5154
- }
5155
-
5156
- return deleted;
5157
- }
5158
-
5159
- clear(matcher) {
5160
- const keys = Object.keys(this);
5161
- let i = keys.length;
5162
- let deleted = false;
5163
-
5164
- while (i--) {
5165
- const key = keys[i];
5166
- if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
5167
- delete this[key];
5168
- deleted = true;
5169
- }
5170
- }
5171
-
5172
- return deleted;
5173
- }
5174
-
5175
- normalize(format) {
5176
- const self = this;
5177
- const headers = {};
5178
-
5179
- utils$1.forEach(this, (value, header) => {
5180
- const key = utils$1.findKey(headers, header);
5181
-
5182
- if (key) {
5183
- self[key] = normalizeValue(value);
5184
- delete self[header];
5185
- return;
5186
- }
5187
-
5188
- const normalized = format ? formatHeader(header) : String(header).trim();
5189
-
5190
- if (normalized !== header) {
5191
- delete self[header];
5192
- }
5193
-
5194
- self[normalized] = normalizeValue(value);
5195
-
5196
- headers[normalized] = true;
5197
- });
5198
-
5199
- return this;
5200
- }
5201
-
5202
- concat(...targets) {
5203
- return this.constructor.concat(this, ...targets);
5204
- }
5205
-
5206
- toJSON(asStrings) {
5207
- const obj = Object.create(null);
5208
-
5209
- utils$1.forEach(this, (value, header) => {
5210
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
5211
- });
5212
-
5213
- return obj;
5214
- }
5215
-
5216
- [Symbol.iterator]() {
5217
- return Object.entries(this.toJSON())[Symbol.iterator]();
5218
- }
5219
-
5220
- toString() {
5221
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
5222
- }
5223
-
5224
- get [Symbol.toStringTag]() {
5225
- return 'AxiosHeaders';
5226
- }
5227
-
5228
- static from(thing) {
5229
- return thing instanceof this ? thing : new this(thing);
5230
- }
5231
-
5232
- static concat(first, ...targets) {
5233
- const computed = new this(first);
5234
-
5235
- targets.forEach((target) => computed.set(target));
5236
-
5237
- return computed;
5238
- }
5239
-
5240
- static accessor(header) {
5241
- const internals = this[$internals] = (this[$internals] = {
5242
- accessors: {}
5243
- });
5244
-
5245
- const accessors = internals.accessors;
5246
- const prototype = this.prototype;
5247
-
5248
- function defineAccessor(_header) {
5249
- const lHeader = normalizeHeader(_header);
5250
-
5251
- if (!accessors[lHeader]) {
5252
- buildAccessors(prototype, _header);
5253
- accessors[lHeader] = true;
5254
- }
5255
- }
5256
-
5257
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
5258
-
5259
- return this;
5260
- }
5261
- };
5262
-
5263
- AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
5264
-
5265
- // reserved names hotfix
5266
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
5267
- let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
5268
- return {
5269
- get: () => value,
5270
- set(headerValue) {
5271
- this[mapped] = headerValue;
5272
- }
5273
- }
5274
- });
5275
-
5276
- utils$1.freezeMethods(AxiosHeaders$1);
5277
-
5278
- /**
5279
- * Transform the data for a request or a response
5280
- *
5281
- * @param {Array|Function} fns A single function or Array of functions
5282
- * @param {?Object} response The response object
5283
- *
5284
- * @returns {*} The resulting transformed data
5285
- */
5286
- function transformData(fns, response) {
5287
- const config = this || defaults;
5288
- const context = response || config;
5289
- const headers = AxiosHeaders$1.from(context.headers);
5290
- let data = context.data;
5291
-
5292
- utils$1.forEach(fns, function transform(fn) {
5293
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
5294
- });
5295
-
5296
- headers.normalize();
5297
-
5298
- return data;
5299
- }
5300
-
5301
- function isCancel$1(value) {
5302
- return !!(value && value.__CANCEL__);
5303
- }
5304
-
5305
- /**
5306
- * A `CanceledError` is an object that is thrown when an operation is canceled.
5307
- *
5308
- * @param {string=} message The message.
5309
- * @param {Object=} config The config.
5310
- * @param {Object=} request The request.
5311
- *
5312
- * @returns {CanceledError} The created error.
5313
- */
5314
- function CanceledError$1(message, config, request) {
5315
- // eslint-disable-next-line no-eq-null,eqeqeq
5316
- AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
5317
- this.name = 'CanceledError';
5318
- }
5319
-
5320
- utils$1.inherits(CanceledError$1, AxiosError$1, {
5321
- __CANCEL__: true
5322
- });
5323
-
5324
- /**
5325
- * Resolve or reject a Promise based on response status.
5326
- *
5327
- * @param {Function} resolve A function that resolves the promise.
5328
- * @param {Function} reject A function that rejects the promise.
5329
- * @param {object} response The response.
5330
- *
5331
- * @returns {object} The response.
5332
- */
5333
- function settle(resolve, reject, response) {
5334
- const validateStatus = response.config.validateStatus;
5335
- if (!response.status || !validateStatus || validateStatus(response.status)) {
5336
- resolve(response);
5337
- } else {
5338
- reject(new AxiosError$1(
5339
- 'Request failed with status code ' + response.status,
5340
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
5341
- response.config,
5342
- response.request,
5343
- response
5344
- ));
5345
- }
5346
- }
5347
-
5348
- function parseProtocol(url) {
5349
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
5350
- return match && match[1] || '';
5351
- }
5352
-
5353
- /**
5354
- * Calculate data maxRate
5355
- * @param {Number} [samplesCount= 10]
5356
- * @param {Number} [min= 1000]
5357
- * @returns {Function}
5358
- */
5359
- function speedometer(samplesCount, min) {
5360
- samplesCount = samplesCount || 10;
5361
- const bytes = new Array(samplesCount);
5362
- const timestamps = new Array(samplesCount);
5363
- let head = 0;
5364
- let tail = 0;
5365
- let firstSampleTS;
5366
-
5367
- min = min !== undefined ? min : 1000;
5368
-
5369
- return function push(chunkLength) {
5370
- const now = Date.now();
5371
-
5372
- const startedAt = timestamps[tail];
5373
-
5374
- if (!firstSampleTS) {
5375
- firstSampleTS = now;
5376
- }
5377
-
5378
- bytes[head] = chunkLength;
5379
- timestamps[head] = now;
5380
-
5381
- let i = tail;
5382
- let bytesCount = 0;
5383
-
5384
- while (i !== head) {
5385
- bytesCount += bytes[i++];
5386
- i = i % samplesCount;
5387
- }
5388
-
5389
- head = (head + 1) % samplesCount;
5390
-
5391
- if (head === tail) {
5392
- tail = (tail + 1) % samplesCount;
5393
- }
5394
-
5395
- if (now - firstSampleTS < min) {
5396
- return;
5397
- }
5398
-
5399
- const passed = startedAt && now - startedAt;
5400
-
5401
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
5402
- };
5403
- }
5404
-
5405
- /**
5406
- * Throttle decorator
5407
- * @param {Function} fn
5408
- * @param {Number} freq
5409
- * @return {Function}
5410
- */
5411
- function throttle(fn, freq) {
5412
- let timestamp = 0;
5413
- let threshold = 1000 / freq;
5414
- let lastArgs;
5415
- let timer;
5416
-
5417
- const invoke = (args, now = Date.now()) => {
5418
- timestamp = now;
5419
- lastArgs = null;
5420
- if (timer) {
5421
- clearTimeout(timer);
5422
- timer = null;
5423
- }
5424
- fn.apply(null, args);
5425
- };
5426
-
5427
- const throttled = (...args) => {
5428
- const now = Date.now();
5429
- const passed = now - timestamp;
5430
- if ( passed >= threshold) {
5431
- invoke(args, now);
5432
- } else {
5433
- lastArgs = args;
5434
- if (!timer) {
5435
- timer = setTimeout(() => {
5436
- timer = null;
5437
- invoke(lastArgs);
5438
- }, threshold - passed);
5439
- }
5440
- }
5441
- };
5442
-
5443
- const flush = () => lastArgs && invoke(lastArgs);
5444
-
5445
- return [throttled, flush];
5446
- }
5447
-
5448
- const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
5449
- let bytesNotified = 0;
5450
- const _speedometer = speedometer(50, 250);
5451
-
5452
- return throttle(e => {
5453
- const loaded = e.loaded;
5454
- const total = e.lengthComputable ? e.total : undefined;
5455
- const progressBytes = loaded - bytesNotified;
5456
- const rate = _speedometer(progressBytes);
5457
- const inRange = loaded <= total;
5458
-
5459
- bytesNotified = loaded;
5460
-
5461
- const data = {
5462
- loaded,
5463
- total,
5464
- progress: total ? (loaded / total) : undefined,
5465
- bytes: progressBytes,
5466
- rate: rate ? rate : undefined,
5467
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
5468
- event: e,
5469
- lengthComputable: total != null,
5470
- [isDownloadStream ? 'download' : 'upload']: true
5471
- };
5472
-
5473
- listener(data);
5474
- }, freq);
5475
- };
5476
-
5477
- const progressEventDecorator = (total, throttled) => {
5478
- const lengthComputable = total != null;
5479
-
5480
- return [(loaded) => throttled[0]({
5481
- lengthComputable,
5482
- total,
5483
- loaded
5484
- }), throttled[1]];
5485
- };
5486
-
5487
- const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
5488
-
5489
- var isURLSameOrigin = platform$1.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
5490
- url = new URL(url, platform$1.origin);
5491
-
5492
- return (
5493
- origin.protocol === url.protocol &&
5494
- origin.host === url.host &&
5495
- (isMSIE || origin.port === url.port)
5496
- );
5497
- })(
5498
- new URL(platform$1.origin),
5499
- platform$1.navigator && /(msie|trident)/i.test(platform$1.navigator.userAgent)
5500
- ) : () => true;
5501
-
5502
- var cookies = platform$1.hasStandardBrowserEnv ?
5503
-
5504
- // Standard browser envs support document.cookie
5505
- {
5506
- write(name, value, expires, path, domain, secure) {
5507
- const cookie = [name + '=' + encodeURIComponent(value)];
5508
-
5509
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
5510
-
5511
- utils$1.isString(path) && cookie.push('path=' + path);
5512
-
5513
- utils$1.isString(domain) && cookie.push('domain=' + domain);
5514
-
5515
- secure === true && cookie.push('secure');
5516
-
5517
- document.cookie = cookie.join('; ');
5518
- },
5519
-
5520
- read(name) {
5521
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
5522
- return (match ? decodeURIComponent(match[3]) : null);
5523
- },
5524
-
5525
- remove(name) {
5526
- this.write(name, '', Date.now() - 86400000);
5527
- }
5528
- }
5529
-
5530
- :
5531
-
5532
- // Non-standard browser env (web workers, react-native) lack needed support.
5533
- {
5534
- write() {},
5535
- read() {
5536
- return null;
5537
- },
5538
- remove() {}
5539
- };
5540
-
5541
- /**
5542
- * Determines whether the specified URL is absolute
5543
- *
5544
- * @param {string} url The URL to test
5545
- *
5546
- * @returns {boolean} True if the specified URL is absolute, otherwise false
5547
- */
5548
- function isAbsoluteURL(url) {
5549
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
5550
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
5551
- // by any combination of letters, digits, plus, period, or hyphen.
5552
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
5553
- }
5554
-
5555
- /**
5556
- * Creates a new URL by combining the specified URLs
5557
- *
5558
- * @param {string} baseURL The base URL
5559
- * @param {string} relativeURL The relative URL
5560
- *
5561
- * @returns {string} The combined URL
5562
- */
5563
- function combineURLs(baseURL, relativeURL) {
5564
- return relativeURL
5565
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
5566
- : baseURL;
5567
- }
5568
-
5569
- /**
5570
- * Creates a new URL by combining the baseURL with the requestedURL,
5571
- * only when the requestedURL is not already an absolute URL.
5572
- * If the requestURL is absolute, this function returns the requestedURL untouched.
5573
- *
5574
- * @param {string} baseURL The base URL
5575
- * @param {string} requestedURL Absolute or relative URL to combine
5576
- *
5577
- * @returns {string} The combined full path
5578
- */
5579
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
5580
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
5581
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
5582
- return combineURLs(baseURL, requestedURL);
5583
- }
5584
- return requestedURL;
5585
- }
5586
-
5587
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
5588
-
5589
- /**
5590
- * Config-specific merge-function which creates a new config-object
5591
- * by merging two configuration objects together.
5592
- *
5593
- * @param {Object} config1
5594
- * @param {Object} config2
5595
- *
5596
- * @returns {Object} New object resulting from merging config2 to config1
5597
- */
5598
- function mergeConfig$1(config1, config2) {
5599
- // eslint-disable-next-line no-param-reassign
5600
- config2 = config2 || {};
5601
- const config = {};
5602
-
5603
- function getMergedValue(target, source, prop, caseless) {
5604
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
5605
- return utils$1.merge.call({caseless}, target, source);
5606
- } else if (utils$1.isPlainObject(source)) {
5607
- return utils$1.merge({}, source);
5608
- } else if (utils$1.isArray(source)) {
5609
- return source.slice();
5610
- }
5611
- return source;
5612
- }
5613
-
5614
- // eslint-disable-next-line consistent-return
5615
- function mergeDeepProperties(a, b, prop , caseless) {
5616
- if (!utils$1.isUndefined(b)) {
5617
- return getMergedValue(a, b, prop , caseless);
5618
- } else if (!utils$1.isUndefined(a)) {
5619
- return getMergedValue(undefined, a, prop , caseless);
5620
- }
5621
- }
5622
-
5623
- // eslint-disable-next-line consistent-return
5624
- function valueFromConfig2(a, b) {
5625
- if (!utils$1.isUndefined(b)) {
5626
- return getMergedValue(undefined, b);
5627
- }
5628
- }
5629
-
5630
- // eslint-disable-next-line consistent-return
5631
- function defaultToConfig2(a, b) {
5632
- if (!utils$1.isUndefined(b)) {
5633
- return getMergedValue(undefined, b);
5634
- } else if (!utils$1.isUndefined(a)) {
5635
- return getMergedValue(undefined, a);
5636
- }
5637
- }
5638
-
5639
- // eslint-disable-next-line consistent-return
5640
- function mergeDirectKeys(a, b, prop) {
5641
- if (prop in config2) {
5642
- return getMergedValue(a, b);
5643
- } else if (prop in config1) {
5644
- return getMergedValue(undefined, a);
5645
- }
5646
- }
5647
-
5648
- const mergeMap = {
5649
- url: valueFromConfig2,
5650
- method: valueFromConfig2,
5651
- data: valueFromConfig2,
5652
- baseURL: defaultToConfig2,
5653
- transformRequest: defaultToConfig2,
5654
- transformResponse: defaultToConfig2,
5655
- paramsSerializer: defaultToConfig2,
5656
- timeout: defaultToConfig2,
5657
- timeoutMessage: defaultToConfig2,
5658
- withCredentials: defaultToConfig2,
5659
- withXSRFToken: defaultToConfig2,
5660
- adapter: defaultToConfig2,
5661
- responseType: defaultToConfig2,
5662
- xsrfCookieName: defaultToConfig2,
5663
- xsrfHeaderName: defaultToConfig2,
5664
- onUploadProgress: defaultToConfig2,
5665
- onDownloadProgress: defaultToConfig2,
5666
- decompress: defaultToConfig2,
5667
- maxContentLength: defaultToConfig2,
5668
- maxBodyLength: defaultToConfig2,
5669
- beforeRedirect: defaultToConfig2,
5670
- transport: defaultToConfig2,
5671
- httpAgent: defaultToConfig2,
5672
- httpsAgent: defaultToConfig2,
5673
- cancelToken: defaultToConfig2,
5674
- socketPath: defaultToConfig2,
5675
- responseEncoding: defaultToConfig2,
5676
- validateStatus: mergeDirectKeys,
5677
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
5678
- };
5679
-
5680
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
5681
- const merge = mergeMap[prop] || mergeDeepProperties;
5682
- const configValue = merge(config1[prop], config2[prop], prop);
5683
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
5684
- });
5685
-
5686
- return config;
5687
- }
5688
-
5689
- var resolveConfig = (config) => {
5690
- const newConfig = mergeConfig$1({}, config);
5691
-
5692
- let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
5693
-
5694
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
5695
-
5696
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
5697
-
5698
- // HTTP basic authentication
5699
- if (auth) {
5700
- headers.set('Authorization', 'Basic ' +
5701
- btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
5702
- );
5703
- }
5704
-
5705
- let contentType;
5706
-
5707
- if (utils$1.isFormData(data)) {
5708
- if (platform$1.hasStandardBrowserEnv || platform$1.hasStandardBrowserWebWorkerEnv) {
5709
- headers.setContentType(undefined); // Let the browser set it
5710
- } else if ((contentType = headers.getContentType()) !== false) {
5711
- // fix semicolon duplication issue for ReactNative FormData implementation
5712
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
5713
- headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
5714
- }
5715
- }
5716
-
5717
- // Add xsrf header
5718
- // This is only done if running in a standard browser environment.
5719
- // Specifically not if we're in a web worker, or react-native.
5720
-
5721
- if (platform$1.hasStandardBrowserEnv) {
5722
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
5723
-
5724
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
5725
- // Add xsrf header
5726
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
5727
-
5728
- if (xsrfValue) {
5729
- headers.set(xsrfHeaderName, xsrfValue);
5730
- }
5731
- }
5732
- }
5733
-
5734
- return newConfig;
5735
- };
5736
-
5737
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
5738
-
5739
- var xhrAdapter = isXHRAdapterSupported && function (config) {
5740
- return new Promise(function dispatchXhrRequest(resolve, reject) {
5741
- const _config = resolveConfig(config);
5742
- let requestData = _config.data;
5743
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
5744
- let {responseType, onUploadProgress, onDownloadProgress} = _config;
5745
- let onCanceled;
5746
- let uploadThrottled, downloadThrottled;
5747
- let flushUpload, flushDownload;
5748
-
5749
- function done() {
5750
- flushUpload && flushUpload(); // flush events
5751
- flushDownload && flushDownload(); // flush events
5752
-
5753
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
5754
-
5755
- _config.signal && _config.signal.removeEventListener('abort', onCanceled);
5756
- }
5757
-
5758
- let request = new XMLHttpRequest();
5759
-
5760
- request.open(_config.method.toUpperCase(), _config.url, true);
5761
-
5762
- // Set the request timeout in MS
5763
- request.timeout = _config.timeout;
5764
-
5765
- function onloadend() {
5766
- if (!request) {
5767
- return;
5768
- }
5769
- // Prepare the response
5770
- const responseHeaders = AxiosHeaders$1.from(
5771
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
5772
- );
5773
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
5774
- request.responseText : request.response;
5775
- const response = {
5776
- data: responseData,
5777
- status: request.status,
5778
- statusText: request.statusText,
5779
- headers: responseHeaders,
5780
- config,
5781
- request
5782
- };
5783
-
5784
- settle(function _resolve(value) {
5785
- resolve(value);
5786
- done();
5787
- }, function _reject(err) {
5788
- reject(err);
5789
- done();
5790
- }, response);
5791
-
5792
- // Clean up request
5793
- request = null;
5794
- }
5795
-
5796
- if ('onloadend' in request) {
5797
- // Use onloadend if available
5798
- request.onloadend = onloadend;
5799
- } else {
5800
- // Listen for ready state to emulate onloadend
5801
- request.onreadystatechange = function handleLoad() {
5802
- if (!request || request.readyState !== 4) {
5803
- return;
5804
- }
5805
-
5806
- // The request errored out and we didn't get a response, this will be
5807
- // handled by onerror instead
5808
- // With one exception: request that using file: protocol, most browsers
5809
- // will return status as 0 even though it's a successful request
5810
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
5811
- return;
5812
- }
5813
- // readystate handler is calling before onerror or ontimeout handlers,
5814
- // so we should call onloadend on the next 'tick'
5815
- setTimeout(onloadend);
5816
- };
5817
- }
5818
-
5819
- // Handle browser request cancellation (as opposed to a manual cancellation)
5820
- request.onabort = function handleAbort() {
5821
- if (!request) {
5822
- return;
5823
- }
5824
-
5825
- reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
5826
-
5827
- // Clean up request
5828
- request = null;
5829
- };
5830
-
5831
- // Handle low level network errors
5832
- request.onerror = function handleError() {
5833
- // Real errors are hidden from us by the browser
5834
- // onerror should only fire if it's a network error
5835
- reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
5836
-
5837
- // Clean up request
5838
- request = null;
5839
- };
5840
-
5841
- // Handle timeout
5842
- request.ontimeout = function handleTimeout() {
5843
- let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
5844
- const transitional = _config.transitional || transitionalDefaults;
5845
- if (_config.timeoutErrorMessage) {
5846
- timeoutErrorMessage = _config.timeoutErrorMessage;
5847
- }
5848
- reject(new AxiosError$1(
5849
- timeoutErrorMessage,
5850
- transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
5851
- config,
5852
- request));
5853
-
5854
- // Clean up request
5855
- request = null;
5856
- };
5857
-
5858
- // Remove Content-Type if data is undefined
5859
- requestData === undefined && requestHeaders.setContentType(null);
5860
-
5861
- // Add headers to the request
5862
- if ('setRequestHeader' in request) {
5863
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
5864
- request.setRequestHeader(key, val);
5865
- });
5866
- }
5867
-
5868
- // Add withCredentials to request if needed
5869
- if (!utils$1.isUndefined(_config.withCredentials)) {
5870
- request.withCredentials = !!_config.withCredentials;
5871
- }
5872
-
5873
- // Add responseType to request if needed
5874
- if (responseType && responseType !== 'json') {
5875
- request.responseType = _config.responseType;
5876
- }
5877
-
5878
- // Handle progress if needed
5879
- if (onDownloadProgress) {
5880
- ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
5881
- request.addEventListener('progress', downloadThrottled);
5882
- }
5883
-
5884
- // Not all browsers support upload events
5885
- if (onUploadProgress && request.upload) {
5886
- ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
5887
-
5888
- request.upload.addEventListener('progress', uploadThrottled);
5889
-
5890
- request.upload.addEventListener('loadend', flushUpload);
5891
- }
5892
-
5893
- if (_config.cancelToken || _config.signal) {
5894
- // Handle cancellation
5895
- // eslint-disable-next-line func-names
5896
- onCanceled = cancel => {
5897
- if (!request) {
5898
- return;
5899
- }
5900
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
5901
- request.abort();
5902
- request = null;
5903
- };
5904
-
5905
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
5906
- if (_config.signal) {
5907
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
5908
- }
5909
- }
5910
-
5911
- const protocol = parseProtocol(_config.url);
5912
-
5913
- if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
5914
- reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
5915
- return;
5916
- }
5917
-
5918
-
5919
- // Send the request
5920
- request.send(requestData || null);
5921
- });
5922
- };
5923
-
5924
- const composeSignals = (signals, timeout) => {
5925
- const {length} = (signals = signals ? signals.filter(Boolean) : []);
5926
-
5927
- if (timeout || length) {
5928
- let controller = new AbortController();
5929
-
5930
- let aborted;
5931
-
5932
- const onabort = function (reason) {
5933
- if (!aborted) {
5934
- aborted = true;
5935
- unsubscribe();
5936
- const err = reason instanceof Error ? reason : this.reason;
5937
- controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
5938
- }
5939
- };
5940
-
5941
- let timer = timeout && setTimeout(() => {
5942
- timer = null;
5943
- onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
5944
- }, timeout);
5945
-
5946
- const unsubscribe = () => {
5947
- if (signals) {
5948
- timer && clearTimeout(timer);
5949
- timer = null;
5950
- signals.forEach(signal => {
5951
- signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
5952
- });
5953
- signals = null;
5954
- }
5955
- };
5956
-
5957
- signals.forEach((signal) => signal.addEventListener('abort', onabort));
5958
-
5959
- const {signal} = controller;
5960
-
5961
- signal.unsubscribe = () => utils$1.asap(unsubscribe);
5962
-
5963
- return signal;
5964
- }
5965
- };
5966
-
5967
- const streamChunk = function* (chunk, chunkSize) {
5968
- let len = chunk.byteLength;
5969
-
5970
- if (len < chunkSize) {
5971
- yield chunk;
5972
- return;
5973
- }
5974
-
5975
- let pos = 0;
5976
- let end;
5977
-
5978
- while (pos < len) {
5979
- end = pos + chunkSize;
5980
- yield chunk.slice(pos, end);
5981
- pos = end;
5982
- }
5983
- };
5984
-
5985
- const readBytes = async function* (iterable, chunkSize) {
5986
- for await (const chunk of readStream(iterable)) {
5987
- yield* streamChunk(chunk, chunkSize);
5988
- }
5989
- };
5990
-
5991
- const readStream = async function* (stream) {
5992
- if (stream[Symbol.asyncIterator]) {
5993
- yield* stream;
5994
- return;
5995
- }
5996
-
5997
- const reader = stream.getReader();
5998
- try {
5999
- for (;;) {
6000
- const {done, value} = await reader.read();
6001
- if (done) {
6002
- break;
6003
- }
6004
- yield value;
6005
- }
6006
- } finally {
6007
- await reader.cancel();
6008
- }
6009
- };
6010
-
6011
- const trackStream = (stream, chunkSize, onProgress, onFinish) => {
6012
- const iterator = readBytes(stream, chunkSize);
6013
-
6014
- let bytes = 0;
6015
- let done;
6016
- let _onFinish = (e) => {
6017
- if (!done) {
6018
- done = true;
6019
- onFinish && onFinish(e);
6020
- }
6021
- };
6022
-
6023
- return new ReadableStream({
6024
- async pull(controller) {
6025
- try {
6026
- const {done, value} = await iterator.next();
6027
-
6028
- if (done) {
6029
- _onFinish();
6030
- controller.close();
6031
- return;
6032
- }
6033
-
6034
- let len = value.byteLength;
6035
- if (onProgress) {
6036
- let loadedBytes = bytes += len;
6037
- onProgress(loadedBytes);
6038
- }
6039
- controller.enqueue(new Uint8Array(value));
6040
- } catch (err) {
6041
- _onFinish(err);
6042
- throw err;
6043
- }
6044
- },
6045
- cancel(reason) {
6046
- _onFinish(reason);
6047
- return iterator.return();
6048
- }
6049
- }, {
6050
- highWaterMark: 2
6051
- })
6052
- };
6053
-
6054
- const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
6055
- const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
6056
-
6057
- // used only inside the fetch adapter
6058
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
6059
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
6060
- async (str) => new Uint8Array(await new Response(str).arrayBuffer())
6061
- );
6062
-
6063
- const test$1 = (fn, ...args) => {
6064
- try {
6065
- return !!fn(...args);
6066
- } catch (e) {
6067
- return false
6068
- }
6069
- };
6070
-
6071
- const supportsRequestStream = isReadableStreamSupported && test$1(() => {
6072
- let duplexAccessed = false;
6073
-
6074
- const hasContentType = new Request(platform$1.origin, {
6075
- body: new ReadableStream(),
6076
- method: 'POST',
6077
- get duplex() {
6078
- duplexAccessed = true;
6079
- return 'half';
6080
- },
6081
- }).headers.has('Content-Type');
6082
-
6083
- return duplexAccessed && !hasContentType;
6084
- });
6085
-
6086
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
6087
-
6088
- const supportsResponseStream = isReadableStreamSupported &&
6089
- test$1(() => utils$1.isReadableStream(new Response('').body));
6090
-
6091
-
6092
- const resolvers = {
6093
- stream: supportsResponseStream && ((res) => res.body)
6094
- };
6095
-
6096
- isFetchSupported && (((res) => {
6097
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
6098
- !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
6099
- (_, config) => {
6100
- throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
6101
- });
6102
- });
6103
- })(new Response));
6104
-
6105
- const getBodyLength = async (body) => {
6106
- if (body == null) {
6107
- return 0;
6108
- }
6109
-
6110
- if(utils$1.isBlob(body)) {
6111
- return body.size;
6112
- }
6113
-
6114
- if(utils$1.isSpecCompliantForm(body)) {
6115
- const _request = new Request(platform$1.origin, {
6116
- method: 'POST',
6117
- body,
6118
- });
6119
- return (await _request.arrayBuffer()).byteLength;
6120
- }
6121
-
6122
- if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
6123
- return body.byteLength;
6124
- }
6125
-
6126
- if(utils$1.isURLSearchParams(body)) {
6127
- body = body + '';
6128
- }
6129
-
6130
- if(utils$1.isString(body)) {
6131
- return (await encodeText(body)).byteLength;
6132
- }
6133
- };
6134
-
6135
- const resolveBodyLength = async (headers, body) => {
6136
- const length = utils$1.toFiniteNumber(headers.getContentLength());
6137
-
6138
- return length == null ? getBodyLength(body) : length;
6139
- };
6140
-
6141
- var fetchAdapter = isFetchSupported && (async (config) => {
6142
- let {
6143
- url,
6144
- method,
6145
- data,
6146
- signal,
6147
- cancelToken,
6148
- timeout,
6149
- onDownloadProgress,
6150
- onUploadProgress,
6151
- responseType,
6152
- headers,
6153
- withCredentials = 'same-origin',
6154
- fetchOptions
6155
- } = resolveConfig(config);
6156
-
6157
- responseType = responseType ? (responseType + '').toLowerCase() : 'text';
6158
-
6159
- let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
6160
-
6161
- let request;
6162
-
6163
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
6164
- composedSignal.unsubscribe();
6165
- });
6166
-
6167
- let requestContentLength;
6168
-
6169
- try {
6170
- if (
6171
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
6172
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
6173
- ) {
6174
- let _request = new Request(url, {
6175
- method: 'POST',
6176
- body: data,
6177
- duplex: "half"
6178
- });
6179
-
6180
- let contentTypeHeader;
6181
-
6182
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
6183
- headers.setContentType(contentTypeHeader);
6184
- }
6185
-
6186
- if (_request.body) {
6187
- const [onProgress, flush] = progressEventDecorator(
6188
- requestContentLength,
6189
- progressEventReducer(asyncDecorator(onUploadProgress))
6190
- );
6191
-
6192
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
6193
- }
6194
- }
6195
-
6196
- if (!utils$1.isString(withCredentials)) {
6197
- withCredentials = withCredentials ? 'include' : 'omit';
6198
- }
6199
-
6200
- // Cloudflare Workers throws when credentials are defined
6201
- // see https://github.com/cloudflare/workerd/issues/902
6202
- const isCredentialsSupported = "credentials" in Request.prototype;
6203
- request = new Request(url, {
6204
- ...fetchOptions,
6205
- signal: composedSignal,
6206
- method: method.toUpperCase(),
6207
- headers: headers.normalize().toJSON(),
6208
- body: data,
6209
- duplex: "half",
6210
- credentials: isCredentialsSupported ? withCredentials : undefined
6211
- });
6212
-
6213
- let response = await fetch(request);
6214
-
6215
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
6216
-
6217
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
6218
- const options = {};
6219
-
6220
- ['status', 'statusText', 'headers'].forEach(prop => {
6221
- options[prop] = response[prop];
6222
- });
6223
-
6224
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
6225
-
6226
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
6227
- responseContentLength,
6228
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
6229
- ) || [];
6230
-
6231
- response = new Response(
6232
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
6233
- flush && flush();
6234
- unsubscribe && unsubscribe();
6235
- }),
6236
- options
6237
- );
6238
- }
6239
-
6240
- responseType = responseType || 'text';
6241
-
6242
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
6243
-
6244
- !isStreamResponse && unsubscribe && unsubscribe();
6245
-
6246
- return await new Promise((resolve, reject) => {
6247
- settle(resolve, reject, {
6248
- data: responseData,
6249
- headers: AxiosHeaders$1.from(response.headers),
6250
- status: response.status,
6251
- statusText: response.statusText,
6252
- config,
6253
- request
6254
- });
6255
- })
6256
- } catch (err) {
6257
- unsubscribe && unsubscribe();
6258
-
6259
- if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
6260
- throw Object.assign(
6261
- new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
6262
- {
6263
- cause: err.cause || err
6264
- }
6265
- )
6266
- }
6267
-
6268
- throw AxiosError$1.from(err, err && err.code, config, request);
6269
- }
6270
- });
6271
-
6272
- const knownAdapters = {
6273
- http: httpAdapter,
6274
- xhr: xhrAdapter,
6275
- fetch: fetchAdapter
6276
- };
6277
-
6278
- utils$1.forEach(knownAdapters, (fn, value) => {
6279
- if (fn) {
6280
- try {
6281
- Object.defineProperty(fn, 'name', {value});
6282
- } catch (e) {
6283
- // eslint-disable-next-line no-empty
6284
- }
6285
- Object.defineProperty(fn, 'adapterName', {value});
6286
- }
6287
- });
6288
-
6289
- const renderReason = (reason) => `- ${reason}`;
6290
-
6291
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
6292
-
6293
- var adapters = {
6294
- getAdapter: (adapters) => {
6295
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
6296
-
6297
- const {length} = adapters;
6298
- let nameOrAdapter;
6299
- let adapter;
6300
-
6301
- const rejectedReasons = {};
6302
-
6303
- for (let i = 0; i < length; i++) {
6304
- nameOrAdapter = adapters[i];
6305
- let id;
6306
-
6307
- adapter = nameOrAdapter;
6308
-
6309
- if (!isResolvedHandle(nameOrAdapter)) {
6310
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
6311
-
6312
- if (adapter === undefined) {
6313
- throw new AxiosError$1(`Unknown adapter '${id}'`);
6314
- }
6315
- }
6316
-
6317
- if (adapter) {
6318
- break;
6319
- }
6320
-
6321
- rejectedReasons[id || '#' + i] = adapter;
6322
- }
6323
-
6324
- if (!adapter) {
6325
-
6326
- const reasons = Object.entries(rejectedReasons)
6327
- .map(([id, state]) => `adapter ${id} ` +
6328
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
6329
- );
6330
-
6331
- let s = length ?
6332
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
6333
- 'as no adapter specified';
6334
-
6335
- throw new AxiosError$1(
6336
- `There is no suitable adapter to dispatch the request ` + s,
6337
- 'ERR_NOT_SUPPORT'
6338
- );
6339
- }
6340
-
6341
- return adapter;
6342
- },
6343
- adapters: knownAdapters
6344
- };
6345
-
6346
- /**
6347
- * Throws a `CanceledError` if cancellation has been requested.
6348
- *
6349
- * @param {Object} config The config that is to be used for the request
6350
- *
6351
- * @returns {void}
6352
- */
6353
- function throwIfCancellationRequested(config) {
6354
- if (config.cancelToken) {
6355
- config.cancelToken.throwIfRequested();
6356
- }
6357
-
6358
- if (config.signal && config.signal.aborted) {
6359
- throw new CanceledError$1(null, config);
6360
- }
6361
- }
6362
-
6363
- /**
6364
- * Dispatch a request to the server using the configured adapter.
6365
- *
6366
- * @param {object} config The config that is to be used for the request
6367
- *
6368
- * @returns {Promise} The Promise to be fulfilled
6369
- */
6370
- function dispatchRequest(config) {
6371
- throwIfCancellationRequested(config);
6372
-
6373
- config.headers = AxiosHeaders$1.from(config.headers);
6374
-
6375
- // Transform request data
6376
- config.data = transformData.call(
6377
- config,
6378
- config.transformRequest
6379
- );
6380
-
6381
- if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
6382
- config.headers.setContentType('application/x-www-form-urlencoded', false);
6383
- }
6384
-
6385
- const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
6386
-
6387
- return adapter(config).then(function onAdapterResolution(response) {
6388
- throwIfCancellationRequested(config);
6389
-
6390
- // Transform response data
6391
- response.data = transformData.call(
6392
- config,
6393
- config.transformResponse,
6394
- response
6395
- );
6396
-
6397
- response.headers = AxiosHeaders$1.from(response.headers);
6398
-
6399
- return response;
6400
- }, function onAdapterRejection(reason) {
6401
- if (!isCancel$1(reason)) {
6402
- throwIfCancellationRequested(config);
6403
-
6404
- // Transform response data
6405
- if (reason && reason.response) {
6406
- reason.response.data = transformData.call(
6407
- config,
6408
- config.transformResponse,
6409
- reason.response
6410
- );
6411
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
6412
- }
6413
- }
6414
-
6415
- return Promise.reject(reason);
6416
- });
6417
- }
6418
-
6419
- const VERSION$1 = "1.8.4";
6420
-
6421
- const validators$1 = {};
6422
-
6423
- // eslint-disable-next-line func-names
6424
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
6425
- validators$1[type] = function validator(thing) {
6426
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
6427
- };
6428
- });
6429
-
6430
- const deprecatedWarnings = {};
6431
-
6432
- /**
6433
- * Transitional option validator
6434
- *
6435
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
6436
- * @param {string?} version - deprecated version / removed since version
6437
- * @param {string?} message - some message with additional info
6438
- *
6439
- * @returns {function}
6440
- */
6441
- validators$1.transitional = function transitional(validator, version, message) {
6442
- function formatMessage(opt, desc) {
6443
- return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
6444
- }
6445
-
6446
- // eslint-disable-next-line func-names
6447
- return (value, opt, opts) => {
6448
- if (validator === false) {
6449
- throw new AxiosError$1(
6450
- formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
6451
- AxiosError$1.ERR_DEPRECATED
6452
- );
6453
- }
6454
-
6455
- if (version && !deprecatedWarnings[opt]) {
6456
- deprecatedWarnings[opt] = true;
6457
- // eslint-disable-next-line no-console
6458
- console.warn(
6459
- formatMessage(
6460
- opt,
6461
- ' has been deprecated since v' + version + ' and will be removed in the near future'
6462
- )
6463
- );
6464
- }
6465
-
6466
- return validator ? validator(value, opt, opts) : true;
6467
- };
6468
- };
6469
-
6470
- validators$1.spelling = function spelling(correctSpelling) {
6471
- return (value, opt) => {
6472
- // eslint-disable-next-line no-console
6473
- console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
6474
- return true;
6475
- }
6476
- };
6477
-
6478
- /**
6479
- * Assert object's properties type
6480
- *
6481
- * @param {object} options
6482
- * @param {object} schema
6483
- * @param {boolean?} allowUnknown
6484
- *
6485
- * @returns {object}
6486
- */
6487
-
6488
- function assertOptions(options, schema, allowUnknown) {
6489
- if (typeof options !== 'object') {
6490
- throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
6491
- }
6492
- const keys = Object.keys(options);
6493
- let i = keys.length;
6494
- while (i-- > 0) {
6495
- const opt = keys[i];
6496
- const validator = schema[opt];
6497
- if (validator) {
6498
- const value = options[opt];
6499
- const result = value === undefined || validator(value, opt, options);
6500
- if (result !== true) {
6501
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
6502
- }
6503
- continue;
6504
- }
6505
- if (allowUnknown !== true) {
6506
- throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
6507
- }
6508
- }
6509
- }
6510
-
6511
- var validator = {
6512
- assertOptions,
6513
- validators: validators$1
6514
- };
6515
-
6516
- const validators = validator.validators;
6517
-
6518
- /**
6519
- * Create a new instance of Axios
6520
- *
6521
- * @param {Object} instanceConfig The default config for the instance
6522
- *
6523
- * @return {Axios} A new instance of Axios
6524
- */
6525
- let Axios$1 = class Axios {
6526
- constructor(instanceConfig) {
6527
- this.defaults = instanceConfig;
6528
- this.interceptors = {
6529
- request: new InterceptorManager(),
6530
- response: new InterceptorManager()
6531
- };
6532
- }
6533
-
6534
- /**
6535
- * Dispatch a request
6536
- *
6537
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
6538
- * @param {?Object} config
6539
- *
6540
- * @returns {Promise} The Promise to be fulfilled
6541
- */
6542
- async request(configOrUrl, config) {
6543
- try {
6544
- return await this._request(configOrUrl, config);
6545
- } catch (err) {
6546
- if (err instanceof Error) {
6547
- let dummy = {};
6548
-
6549
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
6550
-
6551
- // slice off the Error: ... line
6552
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
6553
- try {
6554
- if (!err.stack) {
6555
- err.stack = stack;
6556
- // match without the 2 top stack lines
6557
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
6558
- err.stack += '\n' + stack;
6559
- }
6560
- } catch (e) {
6561
- // ignore the case where "stack" is an un-writable property
6562
- }
6563
- }
6564
-
6565
- throw err;
6566
- }
6567
- }
6568
-
6569
- _request(configOrUrl, config) {
6570
- /*eslint no-param-reassign:0*/
6571
- // Allow for axios('example/url'[, config]) a la fetch API
6572
- if (typeof configOrUrl === 'string') {
6573
- config = config || {};
6574
- config.url = configOrUrl;
6575
- } else {
6576
- config = configOrUrl || {};
6577
- }
6578
-
6579
- config = mergeConfig$1(this.defaults, config);
6580
-
6581
- const {transitional, paramsSerializer, headers} = config;
6582
-
6583
- if (transitional !== undefined) {
6584
- validator.assertOptions(transitional, {
6585
- silentJSONParsing: validators.transitional(validators.boolean),
6586
- forcedJSONParsing: validators.transitional(validators.boolean),
6587
- clarifyTimeoutError: validators.transitional(validators.boolean)
6588
- }, false);
6589
- }
6590
-
6591
- if (paramsSerializer != null) {
6592
- if (utils$1.isFunction(paramsSerializer)) {
6593
- config.paramsSerializer = {
6594
- serialize: paramsSerializer
6595
- };
6596
- } else {
6597
- validator.assertOptions(paramsSerializer, {
6598
- encode: validators.function,
6599
- serialize: validators.function
6600
- }, true);
6601
- }
6602
- }
6603
-
6604
- // Set config.allowAbsoluteUrls
6605
- if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
6606
- config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
6607
- } else {
6608
- config.allowAbsoluteUrls = true;
6609
- }
6610
-
6611
- validator.assertOptions(config, {
6612
- baseUrl: validators.spelling('baseURL'),
6613
- withXsrfToken: validators.spelling('withXSRFToken')
6614
- }, true);
6615
-
6616
- // Set config.method
6617
- config.method = (config.method || this.defaults.method || 'get').toLowerCase();
6618
-
6619
- // Flatten headers
6620
- let contextHeaders = headers && utils$1.merge(
6621
- headers.common,
6622
- headers[config.method]
6623
- );
6624
-
6625
- headers && utils$1.forEach(
6626
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
6627
- (method) => {
6628
- delete headers[method];
6629
- }
6630
- );
6631
-
6632
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
6633
-
6634
- // filter out skipped interceptors
6635
- const requestInterceptorChain = [];
6636
- let synchronousRequestInterceptors = true;
6637
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
6638
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
6639
- return;
6640
- }
6641
-
6642
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
6643
-
6644
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
6645
- });
6646
-
6647
- const responseInterceptorChain = [];
6648
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
6649
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
6650
- });
6651
-
6652
- let promise;
6653
- let i = 0;
6654
- let len;
6655
-
6656
- if (!synchronousRequestInterceptors) {
6657
- const chain = [dispatchRequest.bind(this), undefined];
6658
- chain.unshift.apply(chain, requestInterceptorChain);
6659
- chain.push.apply(chain, responseInterceptorChain);
6660
- len = chain.length;
6661
-
6662
- promise = Promise.resolve(config);
6663
-
6664
- while (i < len) {
6665
- promise = promise.then(chain[i++], chain[i++]);
6666
- }
6667
-
6668
- return promise;
6669
- }
6670
-
6671
- len = requestInterceptorChain.length;
6672
-
6673
- let newConfig = config;
6674
-
6675
- i = 0;
6676
-
6677
- while (i < len) {
6678
- const onFulfilled = requestInterceptorChain[i++];
6679
- const onRejected = requestInterceptorChain[i++];
6680
- try {
6681
- newConfig = onFulfilled(newConfig);
6682
- } catch (error) {
6683
- onRejected.call(this, error);
6684
- break;
6685
- }
6686
- }
6687
-
6688
- try {
6689
- promise = dispatchRequest.call(this, newConfig);
6690
- } catch (error) {
6691
- return Promise.reject(error);
6692
- }
6693
-
6694
- i = 0;
6695
- len = responseInterceptorChain.length;
6696
-
6697
- while (i < len) {
6698
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
6699
- }
6700
-
6701
- return promise;
6702
- }
6703
-
6704
- getUri(config) {
6705
- config = mergeConfig$1(this.defaults, config);
6706
- const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
6707
- return buildURL(fullPath, config.params, config.paramsSerializer);
6708
- }
6709
- };
6710
-
6711
- // Provide aliases for supported request methods
6712
- utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
6713
- /*eslint func-names:0*/
6714
- Axios$1.prototype[method] = function(url, config) {
6715
- return this.request(mergeConfig$1(config || {}, {
6716
- method,
6717
- url,
6718
- data: (config || {}).data
6719
- }));
6720
- };
6721
- });
6722
-
6723
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
6724
- /*eslint func-names:0*/
6725
-
6726
- function generateHTTPMethod(isForm) {
6727
- return function httpMethod(url, data, config) {
6728
- return this.request(mergeConfig$1(config || {}, {
6729
- method,
6730
- headers: isForm ? {
6731
- 'Content-Type': 'multipart/form-data'
6732
- } : {},
6733
- url,
6734
- data
6735
- }));
6736
- };
6737
- }
6738
-
6739
- Axios$1.prototype[method] = generateHTTPMethod();
6740
-
6741
- Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
6742
- });
6743
-
6744
- /**
6745
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
6746
- *
6747
- * @param {Function} executor The executor function.
6748
- *
6749
- * @returns {CancelToken}
6750
- */
6751
- let CancelToken$1 = class CancelToken {
6752
- constructor(executor) {
6753
- if (typeof executor !== 'function') {
6754
- throw new TypeError('executor must be a function.');
6755
- }
6756
-
6757
- let resolvePromise;
6758
-
6759
- this.promise = new Promise(function promiseExecutor(resolve) {
6760
- resolvePromise = resolve;
6761
- });
6762
-
6763
- const token = this;
6764
-
6765
- // eslint-disable-next-line func-names
6766
- this.promise.then(cancel => {
6767
- if (!token._listeners) return;
6768
-
6769
- let i = token._listeners.length;
6770
-
6771
- while (i-- > 0) {
6772
- token._listeners[i](cancel);
6773
- }
6774
- token._listeners = null;
6775
- });
6776
-
6777
- // eslint-disable-next-line func-names
6778
- this.promise.then = onfulfilled => {
6779
- let _resolve;
6780
- // eslint-disable-next-line func-names
6781
- const promise = new Promise(resolve => {
6782
- token.subscribe(resolve);
6783
- _resolve = resolve;
6784
- }).then(onfulfilled);
6785
-
6786
- promise.cancel = function reject() {
6787
- token.unsubscribe(_resolve);
6788
- };
6789
-
6790
- return promise;
6791
- };
6792
-
6793
- executor(function cancel(message, config, request) {
6794
- if (token.reason) {
6795
- // Cancellation has already been requested
6796
- return;
6797
- }
6798
-
6799
- token.reason = new CanceledError$1(message, config, request);
6800
- resolvePromise(token.reason);
6801
- });
6802
- }
6803
-
6804
- /**
6805
- * Throws a `CanceledError` if cancellation has been requested.
6806
- */
6807
- throwIfRequested() {
6808
- if (this.reason) {
6809
- throw this.reason;
6810
- }
6811
- }
6812
-
6813
- /**
6814
- * Subscribe to the cancel signal
6815
- */
6816
-
6817
- subscribe(listener) {
6818
- if (this.reason) {
6819
- listener(this.reason);
6820
- return;
6821
- }
6822
-
6823
- if (this._listeners) {
6824
- this._listeners.push(listener);
6825
- } else {
6826
- this._listeners = [listener];
6827
- }
6828
- }
6829
-
6830
- /**
6831
- * Unsubscribe from the cancel signal
6832
- */
6833
-
6834
- unsubscribe(listener) {
6835
- if (!this._listeners) {
6836
- return;
6837
- }
6838
- const index = this._listeners.indexOf(listener);
6839
- if (index !== -1) {
6840
- this._listeners.splice(index, 1);
6841
- }
6842
- }
6843
-
6844
- toAbortSignal() {
6845
- const controller = new AbortController();
6846
-
6847
- const abort = (err) => {
6848
- controller.abort(err);
6849
- };
6850
-
6851
- this.subscribe(abort);
6852
-
6853
- controller.signal.unsubscribe = () => this.unsubscribe(abort);
6854
-
6855
- return controller.signal;
6856
- }
6857
-
6858
- /**
6859
- * Returns an object that contains a new `CancelToken` and a function that, when called,
6860
- * cancels the `CancelToken`.
6861
- */
6862
- static source() {
6863
- let cancel;
6864
- const token = new CancelToken(function executor(c) {
6865
- cancel = c;
6866
- });
6867
- return {
6868
- token,
6869
- cancel
6870
- };
6871
- }
6872
- };
6873
-
6874
- /**
6875
- * Syntactic sugar for invoking a function and expanding an array for arguments.
6876
- *
6877
- * Common use case would be to use `Function.prototype.apply`.
6878
- *
6879
- * ```js
6880
- * function f(x, y, z) {}
6881
- * var args = [1, 2, 3];
6882
- * f.apply(null, args);
6883
- * ```
6884
- *
6885
- * With `spread` this example can be re-written.
6886
- *
6887
- * ```js
6888
- * spread(function(x, y, z) {})([1, 2, 3]);
6889
- * ```
6890
- *
6891
- * @param {Function} callback
6892
- *
6893
- * @returns {Function}
6894
- */
6895
- function spread$1(callback) {
6896
- return function wrap(arr) {
6897
- return callback.apply(null, arr);
6898
- };
6899
- }
6900
-
6901
- /**
6902
- * Determines whether the payload is an error thrown by Axios
6903
- *
6904
- * @param {*} payload The value to test
6905
- *
6906
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
6907
- */
6908
- function isAxiosError$1(payload) {
6909
- return utils$1.isObject(payload) && (payload.isAxiosError === true);
6910
- }
6911
-
6912
- const HttpStatusCode$1 = {
6913
- Continue: 100,
6914
- SwitchingProtocols: 101,
6915
- Processing: 102,
6916
- EarlyHints: 103,
6917
- Ok: 200,
6918
- Created: 201,
6919
- Accepted: 202,
6920
- NonAuthoritativeInformation: 203,
6921
- NoContent: 204,
6922
- ResetContent: 205,
6923
- PartialContent: 206,
6924
- MultiStatus: 207,
6925
- AlreadyReported: 208,
6926
- ImUsed: 226,
6927
- MultipleChoices: 300,
6928
- MovedPermanently: 301,
6929
- Found: 302,
6930
- SeeOther: 303,
6931
- NotModified: 304,
6932
- UseProxy: 305,
6933
- Unused: 306,
6934
- TemporaryRedirect: 307,
6935
- PermanentRedirect: 308,
6936
- BadRequest: 400,
6937
- Unauthorized: 401,
6938
- PaymentRequired: 402,
6939
- Forbidden: 403,
6940
- NotFound: 404,
6941
- MethodNotAllowed: 405,
6942
- NotAcceptable: 406,
6943
- ProxyAuthenticationRequired: 407,
6944
- RequestTimeout: 408,
6945
- Conflict: 409,
6946
- Gone: 410,
6947
- LengthRequired: 411,
6948
- PreconditionFailed: 412,
6949
- PayloadTooLarge: 413,
6950
- UriTooLong: 414,
6951
- UnsupportedMediaType: 415,
6952
- RangeNotSatisfiable: 416,
6953
- ExpectationFailed: 417,
6954
- ImATeapot: 418,
6955
- MisdirectedRequest: 421,
6956
- UnprocessableEntity: 422,
6957
- Locked: 423,
6958
- FailedDependency: 424,
6959
- TooEarly: 425,
6960
- UpgradeRequired: 426,
6961
- PreconditionRequired: 428,
6962
- TooManyRequests: 429,
6963
- RequestHeaderFieldsTooLarge: 431,
6964
- UnavailableForLegalReasons: 451,
6965
- InternalServerError: 500,
6966
- NotImplemented: 501,
6967
- BadGateway: 502,
6968
- ServiceUnavailable: 503,
6969
- GatewayTimeout: 504,
6970
- HttpVersionNotSupported: 505,
6971
- VariantAlsoNegotiates: 506,
6972
- InsufficientStorage: 507,
6973
- LoopDetected: 508,
6974
- NotExtended: 510,
6975
- NetworkAuthenticationRequired: 511,
6976
- };
6977
-
6978
- Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
6979
- HttpStatusCode$1[value] = key;
6980
- });
6981
-
6982
- /**
6983
- * Create an instance of Axios
6984
- *
6985
- * @param {Object} defaultConfig The default config for the instance
6986
- *
6987
- * @returns {Axios} A new instance of Axios
6988
- */
6989
- function createInstance(defaultConfig) {
6990
- const context = new Axios$1(defaultConfig);
6991
- const instance = bind(Axios$1.prototype.request, context);
6992
-
6993
- // Copy axios.prototype to instance
6994
- utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
6995
-
6996
- // Copy context to instance
6997
- utils$1.extend(instance, context, null, {allOwnKeys: true});
6998
-
6999
- // Factory for creating new instances
7000
- instance.create = function create(instanceConfig) {
7001
- return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
7002
- };
7003
-
7004
- return instance;
7005
- }
7006
-
7007
- // Create the default instance to be exported
7008
- const axios = createInstance(defaults);
7009
-
7010
- // Expose Axios class to allow class inheritance
7011
- axios.Axios = Axios$1;
7012
-
7013
- // Expose Cancel & CancelToken
7014
- axios.CanceledError = CanceledError$1;
7015
- axios.CancelToken = CancelToken$1;
7016
- axios.isCancel = isCancel$1;
7017
- axios.VERSION = VERSION$1;
7018
- axios.toFormData = toFormData$1;
7019
-
7020
- // Expose AxiosError class
7021
- axios.AxiosError = AxiosError$1;
7022
-
7023
- // alias for CanceledError for backward compatibility
7024
- axios.Cancel = axios.CanceledError;
7025
-
7026
- // Expose all/spread
7027
- axios.all = function all(promises) {
7028
- return Promise.all(promises);
7029
- };
7030
-
7031
- axios.spread = spread$1;
7032
-
7033
- // Expose isAxiosError
7034
- axios.isAxiosError = isAxiosError$1;
7035
-
7036
- // Expose mergeConfig
7037
- axios.mergeConfig = mergeConfig$1;
7038
-
7039
- axios.AxiosHeaders = AxiosHeaders$1;
7040
-
7041
- axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
7042
-
7043
- axios.getAdapter = adapters.getAdapter;
7044
-
7045
- axios.HttpStatusCode = HttpStatusCode$1;
7046
-
7047
- axios.default = axios;
7048
-
7049
- // This module is intended to unwrap Axios default export as named.
7050
- // Keep top-level export same with static properties
7051
- // so that it can keep same with es module or cjs
7052
- const {
7053
- Axios,
7054
- AxiosError,
7055
- CanceledError,
7056
- isCancel,
7057
- CancelToken,
7058
- VERSION,
7059
- all,
7060
- Cancel,
7061
- isAxiosError,
7062
- spread,
7063
- toFormData,
7064
- AxiosHeaders,
7065
- HttpStatusCode,
7066
- formToJSON,
7067
- getAdapter,
7068
- mergeConfig
7069
- } = axios;
7070
-
7071
- var __async = (__this, __arguments, generator) => {
7072
- return new Promise((resolve, reject) => {
7073
- var fulfilled = (value) => {
7074
- try {
7075
- step(generator.next(value));
7076
- } catch (e) {
7077
- reject(e);
3143
+ const previousJoinedNS = usePrevious(joinedNS);
3144
+ const isMounted = React.useRef(true);
3145
+ React.useEffect(() => {
3146
+ const {
3147
+ bindI18n,
3148
+ bindI18nStore
3149
+ } = i18nOptions;
3150
+ isMounted.current = true;
3151
+ if (!ready && !useSuspense) {
3152
+ if (props.lng) {
3153
+ loadLanguages(i18n, props.lng, namespaces, () => {
3154
+ if (isMounted.current) setT(getNewT);
3155
+ });
3156
+ } else {
3157
+ loadNamespaces(i18n, namespaces, () => {
3158
+ if (isMounted.current) setT(getNewT);
3159
+ });
7078
3160
  }
3161
+ }
3162
+ if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
3163
+ setT(getNewT);
3164
+ }
3165
+ const boundReset = () => {
3166
+ if (isMounted.current) setT(getNewT);
7079
3167
  };
7080
- var rejected = (value) => {
7081
- try {
7082
- step(generator.throw(value));
7083
- } catch (e) {
7084
- reject(e);
7085
- }
3168
+ if (bindI18n) i18n?.on(bindI18n, boundReset);
3169
+ if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
3170
+ return () => {
3171
+ isMounted.current = false;
3172
+ if (i18n) bindI18n?.split(' ').forEach(e => i18n.off(e, boundReset));
3173
+ if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
7086
3174
  };
7087
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
7088
- step((generator = generator.apply(__this, __arguments)).next());
7089
- });
7090
- };
7091
- var API_BASE_URL = "https://api.betterstore.io/v1";
7092
- var createApiClient = (apiKey, proxy) => {
7093
- const client = axios.create({
7094
- baseURL: proxy != null ? proxy : API_BASE_URL,
7095
- headers: {
7096
- "Content-Type": "application/json",
7097
- Authorization: `Bearer ${apiKey}`,
7098
- "Access-Control-Allow-Origin": "*",
7099
- "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
7100
- "Access-Control-Allow-Headers": "Content-Type, Authorization"
3175
+ }, [i18n, joinedNS]);
3176
+ React.useEffect(() => {
3177
+ if (isMounted.current && ready) {
3178
+ setT(getT);
7101
3179
  }
7102
- });
7103
- client.interceptors.response.use(
7104
- (response) => response.data,
7105
- (error) => {
7106
- var _a, _b;
7107
- const apiError = {
7108
- status: 500,
7109
- message: "An unexpected error occurred"
7110
- };
7111
- if (error.response) {
7112
- apiError.status = error.response.status;
7113
- apiError.message = ((_a = error.response.data) == null ? void 0 : _a.error) || "Server error occurred";
7114
- apiError.code = (_b = error.response.data) == null ? void 0 : _b.code;
7115
- apiError.details = error.response.data;
7116
- } else if (error.request) {
7117
- apiError.status = 503;
7118
- apiError.message = "Service unavailable - no response from server";
7119
- apiError.code = "SERVICE_UNAVAILABLE";
7120
- apiError.details = error;
7121
- } else {
7122
- apiError.status = 500;
7123
- apiError.message = "Request configuration error";
7124
- apiError.code = "REQUEST_SETUP_ERROR";
7125
- apiError.details = error;
7126
- }
7127
- throw apiError;
3180
+ }, [i18n, keyPrefix, ready]);
3181
+ const ret = [t, i18n, ready];
3182
+ ret.t = t;
3183
+ ret.i18n = i18n;
3184
+ ret.ready = ready;
3185
+ if (ready) return ret;
3186
+ if (!ready && !useSuspense) return ret;
3187
+ throw new Promise(resolve => {
3188
+ if (props.lng) {
3189
+ loadLanguages(i18n, props.lng, namespaces, () => resolve());
3190
+ } else {
3191
+ loadNamespaces(i18n, namespaces, () => resolve());
7128
3192
  }
7129
- );
7130
- return client;
3193
+ });
7131
3194
  };
7132
3195
 
7133
- // src/client/index.ts
7134
- var Client = class {
7135
- constructor(proxy) {
7136
- this.proxy = proxy;
7137
- }
7138
- /**
7139
- * Retrieve a checkout session by ID
7140
- */
7141
- retrieveCheckout(clientSecret, checkoutId) {
7142
- return __async(this, null, function* () {
7143
- const apiClient = createApiClient(clientSecret, this.proxy);
7144
- const data = yield apiClient.get(
7145
- `/checkout/${checkoutId}`
7146
- );
7147
- return data;
7148
- });
7149
- }
7150
- /**
7151
- * Update a checkout session
7152
- */
7153
- updateCheckout(clientSecret, checkoutId, params) {
7154
- return __async(this, null, function* () {
7155
- const apiClient = createApiClient(clientSecret, this.proxy);
7156
- const data = yield apiClient.put(
7157
- `/checkout/${checkoutId}`,
7158
- params
7159
- );
7160
- return data;
7161
- });
7162
- }
7163
- /**
7164
- * Get shipping rates for a checkout session
7165
- */
7166
- getCheckoutShippingRates(clientSecret, checkoutId) {
7167
- return __async(this, null, function* () {
7168
- const apiClient = createApiClient(clientSecret, this.proxy);
7169
- const data = yield apiClient.get(
7170
- `/checkout/shipping/${checkoutId}`
7171
- );
7172
- return data;
7173
- });
7174
- }
7175
- /**
7176
- * Generate payment secret for a checkout session
7177
- */
7178
- generateCheckoutsPaymentSecret(clientSecret, checkoutId) {
7179
- return __async(this, null, function* () {
7180
- const apiClient = createApiClient(clientSecret, this.proxy);
7181
- const data = yield apiClient.post(
7182
- `/checkout/payment/${checkoutId}`
7183
- );
7184
- return data;
7185
- });
7186
- }
7187
- /**
7188
- * Create a new customer
7189
- */
7190
- createCustomer(clientSecret, params) {
7191
- return __async(this, null, function* () {
7192
- const apiClient = createApiClient(clientSecret, this.proxy);
7193
- const data = yield apiClient.post("/customer", params);
7194
- return data;
7195
- });
7196
- }
7197
- /**
7198
- * Retrieve a customer by ID or email
7199
- */
7200
- retrieveCustomer(clientSecret, idOrEmail) {
7201
- return __async(this, null, function* () {
7202
- const apiClient = createApiClient(clientSecret, this.proxy);
7203
- const data = yield apiClient.get(`/customer/${idOrEmail}`);
7204
- if (!data) {
7205
- throw new Error("Customer not found");
7206
- }
7207
- return data;
7208
- });
7209
- }
7210
- /**
7211
- * Update a customer
7212
- */
7213
- updateCustomer(clientSecret, customerId, params) {
7214
- return __async(this, null, function* () {
7215
- const apiClient = createApiClient(clientSecret, this.proxy);
7216
- const data = yield apiClient.put(
7217
- `/customer/${customerId}`,
7218
- params
7219
- );
7220
- return data;
7221
- });
7222
- }
3196
+ const CheckoutEmbed$2 = {
3197
+ CustomerForm: {
3198
+ address: {
3199
+ address: "Adresa",
3200
+ addressPlaceholder: "Zadejte svou adresu",
3201
+ button: "Uložit adresu",
3202
+ city: "Město",
3203
+ cityPlaceholder: "San Francisco",
3204
+ country: "Země",
3205
+ countryPlaceholder: "Vstoupit do své země",
3206
+ description: "Níže vyplňte údaje o vaší adrese.",
3207
+ line1: "Adresa ulice",
3208
+ line1Placeholder: "123 Hlavní ulice",
3209
+ line2: "Byt, apartmá, jednotka atd. (Volitelné)",
3210
+ line2Placeholder: "APT 4B, Suite 123, atd.",
3211
+ state: "Stát (volitelné)",
3212
+ statePlaceholder: "Kalifornie",
3213
+ title: "Zadejte svou adresu",
3214
+ zipCode: "PSČ",
3215
+ zipCodePlaceholder: "12345"
3216
+ },
3217
+ button: "Uložit a pokračovat",
3218
+ email: "E-mail",
3219
+ emailPlaceholder: "Zadejte svůj e -mail",
3220
+ firstName: "Křestní jméno",
3221
+ firstNamePlaceholder: "Zadejte své křestní jméno",
3222
+ lastName: "Příjmení",
3223
+ lastNamePlaceholder: "Zadejte své příjmení",
3224
+ phone: "Telefon",
3225
+ phonePlaceholder: "Zadejte své telefonní číslo",
3226
+ title: "Údaje o doručení"
3227
+ },
3228
+ Summary: {
3229
+ calculatedAtNextStep: "Vypočítáno v dalším kroku",
3230
+ edit: "Upravit",
3231
+ shipping: "Přeprava",
3232
+ subtotal: "Subtotál",
3233
+ tax: "Daň",
3234
+ title: "Shrnutí",
3235
+ total: "Celkový"
3236
+ },
3237
+ loading: "Načítání ...",
3238
+ Payment: {
3239
+ back: "Zpět na doručení",
3240
+ button: "Koupit hned teď",
3241
+ description: "Všechny transakce jsou bezpečné a šifrovány.",
3242
+ title: "Platba"
3243
+ },
3244
+ Shipping: {
3245
+ back: "Zpět k informacím",
3246
+ button: "Pokračujte v pokladně",
3247
+ change: "Přeměna",
3248
+ contact: "Kontakt:",
3249
+ day: "den",
3250
+ days: "dny",
3251
+ estimatedDeliveryDate: "Odhadované datum dodání:",
3252
+ shipTo: "Ship to:",
3253
+ shipping: "Doprava:",
3254
+ title: "Přeprava"
3255
+ }
7223
3256
  };
7224
- var client_default = Client;
7225
- var Helpers = class {
7226
- constructor(proxy) {
7227
- this.proxy = proxy;
7228
- }
7229
- formatPrice(priceInCents, currency, exchangeRate) {
7230
- var _a;
7231
- const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
7232
- const isWhole = amount % 1 === 0;
7233
- const currencyLocales = {
7234
- CZK: "cs-CZ",
7235
- // Czech Koruna
7236
- USD: "en-US",
7237
- // US Dollar
7238
- EUR: "de-DE",
7239
- // Euro (Germany locale)
7240
- GBP: "en-GB",
7241
- // British Pound
7242
- JPY: "ja-JP",
7243
- // Japanese Yen
7244
- AUD: "en-AU",
7245
- // Australian Dollar
7246
- CAD: "en-CA",
7247
- // Canadian Dollar
7248
- NZD: "en-NZ",
7249
- // New Zealand Dollar
7250
- SEK: "sv-SE",
7251
- // Swedish Krona
7252
- NOK: "nb-NO",
7253
- // Norwegian Krone
7254
- DKK: "da-DK",
7255
- // Danish Krone
7256
- CHF: "de-CH",
7257
- // Swiss Franc (German Switzerland)
7258
- HUF: "hu-HU",
7259
- // Hungarian Forint
7260
- PLN: "pl-PL",
7261
- // Polish Zloty
7262
- BGN: "bg-BG",
7263
- // Bulgarian Lev
7264
- RON: "ro-RO",
7265
- // Romanian Leu
7266
- RUB: "ru-RU",
7267
- // Russian Ruble
7268
- CNY: "zh-CN",
7269
- // Chinese Yuan
7270
- INR: "en-IN",
7271
- // Indian Rupee
7272
- BRL: "pt-BR",
7273
- // Brazilian Real
7274
- MXN: "es-MX",
7275
- // Mexican Peso
7276
- ZAR: "en-ZA",
7277
- // South African Rand
7278
- KRW: "ko-KR",
7279
- // South Korean Won
7280
- MYR: "ms-MY",
7281
- // Malaysian Ringgit
7282
- SGD: "en-SG",
7283
- // Singapore Dollar
7284
- TWD: "zh-TW",
7285
- // Taiwanese Dollar
7286
- THB: "th-TH",
7287
- // Thai Baht
7288
- IDR: "id-ID",
7289
- // Indonesian Rupiah
7290
- AED: "ar-AE",
7291
- // UAE Dirham
7292
- SAR: "ar-SA",
7293
- // Saudi Riyal
7294
- TRY: "tr-TR"
7295
- // Turkish Lira
7296
- };
7297
- const locale = (_a = currencyLocales[currency]) != null ? _a : void 0;
7298
- const formattedPrice = new Intl.NumberFormat(locale, {
7299
- style: "currency",
7300
- currency,
7301
- currencyDisplay: "symbol",
7302
- minimumFractionDigits: isWhole ? 0 : 2,
7303
- maximumFractionDigits: isWhole ? 0 : 2
7304
- }).format(amount);
7305
- return formattedPrice;
7306
- }
7307
- getExchangeRate(baseCurrency, targetCurrency) {
7308
- return __async(this, null, function* () {
7309
- const { data } = yield axios.get(
7310
- `https://api.exchangerate-api.com/v4/latest/${baseCurrency}`
7311
- );
7312
- const rate = data.rates[targetCurrency];
7313
- if (!rate) {
7314
- throw new Error("Could not get exchange rate for target currency");
7315
- }
7316
- return rate;
7317
- });
7318
- }
3257
+ const Errors$1 = {
3258
+ invalid_email: "Zadejte platnou e -mailovou adresu",
3259
+ invalid_phone: "Zadejte platné telefonní číslo",
3260
+ invalid_zipCode: "Zadejte platný PSČ",
3261
+ required_error: "Toto pole je nutné",
3262
+ unknown_error: "Došlo k neznámé chybě",
3263
+ invalid_address: "Zadejte platnou adresu"
7319
3264
  };
7320
- var helpers_default = Helpers;
7321
- function createStoreClient(config) {
7322
- return new client_default(config == null ? void 0 : config.proxy);
7323
- }
7324
- function createStoreHelpers(config) {
7325
- return new helpers_default(void 0 );
7326
- }
3265
+ var cs = {
3266
+ CheckoutEmbed: CheckoutEmbed$2,
3267
+ Errors: Errors$1
3268
+ };
3269
+
3270
+ const CheckoutEmbed$1 = {
3271
+ Summary: {
3272
+ title: "Summary",
3273
+ edit: "Edit",
3274
+ total: "Total",
3275
+ subtotal: "Subtotal",
3276
+ shipping: "Shipping",
3277
+ calculatedAtNextStep: "Calculated at next step",
3278
+ tax: "Tax"
3279
+ },
3280
+ CustomerForm: {
3281
+ address: {
3282
+ address: "Address",
3283
+ addressPlaceholder: "Enter your address",
3284
+ title: "Enter your address",
3285
+ description: "Fill in your address details below.",
3286
+ line1: "Street address",
3287
+ line1Placeholder: "123 Main Street",
3288
+ line2: "Apartment, suite, unit, etc. (optional)",
3289
+ line2Placeholder: "Apt 4B, Suite 123, etc.",
3290
+ city: "City",
3291
+ cityPlaceholder: "San Francisco",
3292
+ country: "Country",
3293
+ countryPlaceholder: "Enter your country",
3294
+ state: "State (optional)",
3295
+ statePlaceholder: "California",
3296
+ zipCode: "Zip code",
3297
+ zipCodePlaceholder: "12345",
3298
+ button: "Save address"
3299
+ },
3300
+ title: "Basic information",
3301
+ email: "Email",
3302
+ emailPlaceholder: "Enter your email",
3303
+ firstName: "First name",
3304
+ firstNamePlaceholder: "Enter your first name",
3305
+ lastName: "Last name",
3306
+ lastNamePlaceholder: "Enter your last name",
3307
+ phone: "Phone",
3308
+ phonePlaceholder: "Enter your phone number",
3309
+ button: "Save and continue"
3310
+ },
3311
+ loading: "Loading...",
3312
+ Shipping: {
3313
+ title: "Shipping",
3314
+ change: "Change",
3315
+ shipTo: "Ship to:",
3316
+ contact: "Contact:",
3317
+ button: "Continue to checkout",
3318
+ back: "Back to information",
3319
+ shipping: "Shipping:",
3320
+ estimatedDeliveryDate: "Estimated delivery date: ",
3321
+ day: "day",
3322
+ days: "days"
3323
+ },
3324
+ Payment: {
3325
+ title: "Payment",
3326
+ description: "All transactions are secure and encrypted.",
3327
+ back: "Back to shipping",
3328
+ button: "Buy now"
3329
+ }
3330
+ };
3331
+ const Errors = {
3332
+ required_error: "This field is required",
3333
+ invalid_email: "Please enter a valid email address",
3334
+ invalid_phone: "Please enter a valid phone number",
3335
+ invalid_zipCode: "Please enter a valid zip code",
3336
+ invalid_address: "Please enter a valid address",
3337
+ unknown_error: "An unknown error occurred"
3338
+ };
3339
+ var en = {
3340
+ CheckoutEmbed: CheckoutEmbed$1,
3341
+ Errors: Errors
3342
+ };
3343
+
3344
+ const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, function* () {
3345
+ yield instance
3346
+ .use(initReactI18next)
3347
+ .use(Browser)
3348
+ .init({
3349
+ lng: locale,
3350
+ fallbackLng: "en",
3351
+ // debug: true,
3352
+ interpolation: { escapeValue: false },
3353
+ resources: {
3354
+ en: { translation: en },
3355
+ cs: { translation: cs },
3356
+ },
3357
+ });
3358
+ return instance;
3359
+ });
7327
3360
 
7328
3361
  function Appearance({ appearance, }) {
7329
3362
  React.useEffect(() => {
@@ -17768,33 +13801,33 @@ const motion = /*@__PURE__*/ createDOMMotionComponentProxy(createMotionComponent
17768
13801
 
17769
13802
  const phoneRegex = new RegExp(/^([+]?[\s0-9]+)?(\d{3}|[(]?[0-9]+[)])?([-]?[\s]?[0-9])+$/);
17770
13803
  // Shipping address schema
17771
- const customerSchema = require$$0.z.object({
17772
- email: require$$0.z.string().email("invalid_email"),
17773
- firstName: require$$0.z.string().min(1, "required_error"),
17774
- lastName: require$$0.z.string().min(1, "required_error"),
17775
- address: require$$0.z.object({
17776
- line1: require$$0.z.string().min(1, "required_error"),
17777
- line2: require$$0.z.string().optional(),
17778
- city: require$$0.z.string().min(1, "required_error"),
17779
- state: require$$0.z.string().optional(),
17780
- zipCode: require$$0.z.string().min(5, "invalid_zipCode"),
17781
- country: require$$0.z.string().min(1, "required_error"),
13804
+ const customerSchema = zod.z.object({
13805
+ email: zod.z.string().email("invalid_email"),
13806
+ firstName: zod.z.string().min(1, "required_error"),
13807
+ lastName: zod.z.string().min(1, "required_error"),
13808
+ address: zod.z.object({
13809
+ line1: zod.z.string().min(1, "required_error"),
13810
+ line2: zod.z.string().optional(),
13811
+ city: zod.z.string().min(1, "required_error"),
13812
+ state: zod.z.string().optional(),
13813
+ zipCode: zod.z.string().min(5, "invalid_zipCode"),
13814
+ country: zod.z.string().min(1, "required_error"),
17782
13815
  }),
17783
- saveInfo: require$$0.z.boolean().optional(),
17784
- phone: require$$0.z.string().regex(phoneRegex, "invalid_phone"),
13816
+ saveInfo: zod.z.boolean().optional(),
13817
+ phone: zod.z.string().regex(phoneRegex, "invalid_phone"),
17785
13818
  });
17786
13819
  // Shipping method schema
17787
- const shippingMethodSchema = require$$0.z.object({
17788
- rateId: require$$0.z.string().min(1, "required_error"),
17789
- name: require$$0.z.string().min(1, "required_error"),
17790
- provider: require$$0.z.string().min(1, "required_error"),
17791
- amount: require$$0.z.number().min(1, "required_error"),
13820
+ const shippingMethodSchema = zod.z.object({
13821
+ rateId: zod.z.string().min(1, "required_error"),
13822
+ name: zod.z.string().min(1, "required_error"),
13823
+ provider: zod.z.string().min(1, "required_error"),
13824
+ amount: zod.z.number().min(1, "required_error"),
17792
13825
  });
17793
13826
  // Combined checkout schema
17794
- require$$0.z.object({
13827
+ zod.z.object({
17795
13828
  customer: customerSchema,
17796
13829
  shipping: shippingMethodSchema,
17797
- customerId: require$$0.z.string().optional(),
13830
+ customerId: zod.z.string().optional(),
17798
13831
  });
17799
13832
 
17800
13833
  const formatAddress = (address) => {
@@ -18107,7 +14140,7 @@ function SubmitButton(_a) {
18107
14140
  isSubmitting ? t("CheckoutEmbed.loading") : children));
18108
14141
  }
18109
14142
 
18110
- function n$1(r,e){for(var n={};r.length;){var s=r[0],t=s.code,i=s.message,a=s.path.join(".");if(!n[a])if("unionErrors"in s){var u=s.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:t};if("unionErrors"in s&&s.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[s.code];n[a]=reactHookForm.appendErrors(a,e,n,t,f?[].concat(f,s.message):s.message);}r.shift();}return n}function s$1(o,s,t){return void 0===t&&(t={}),function(i,a,u){try{return Promise.resolve(function(e,n){try{var a=Promise.resolve(o["sync"===t.mode?"parse":"parseAsync"](i,s)).then(function(e){return u.shouldUseNativeValidation&&resolvers$1.validateFieldsNatively({},u),{errors:{},values:t.raw?Object.assign({},i):e}});}catch(r){return n(r)}return a&&a.then?a.then(void 0,n):a}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return {values:{},errors:resolvers$1.toNestErrors(n$1(r.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw r}))}catch(r){return Promise.reject(r)}}}
14143
+ function n$1(r,e){for(var n={};r.length;){var s=r[0],t=s.code,i=s.message,a=s.path.join(".");if(!n[a])if("unionErrors"in s){var u=s.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:t};if("unionErrors"in s&&s.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[s.code];n[a]=reactHookForm.appendErrors(a,e,n,t,f?[].concat(f,s.message):s.message);}r.shift();}return n}function s$1(o,s,t){return void 0===t&&(t={}),function(i,a,u){try{return Promise.resolve(function(e,n){try{var a=Promise.resolve(o["sync"===t.mode?"parse":"parseAsync"](i,s)).then(function(e){return u.shouldUseNativeValidation&&resolvers.validateFieldsNatively({},u),{errors:{},values:t.raw?Object.assign({},i):e}});}catch(r){return n(r)}return a&&a.then?a.then(void 0,n):a}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return {values:{},errors:resolvers.toNestErrors(n$1(r.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw r}))}catch(r){return Promise.reject(r)}}}
18111
14144
 
18112
14145
  var U=1,Y$1=.9,H=.8,J=.17,p=.1,u$1=.999,$=.9999;var k$1=.99,m=/[\\\/_+.#"@\[\(\{&]/,B=/[\\\/_+.#"@\[\(\{&]/g,K=/[\s-]/,X$1=/[\s-]/g;function G$1(_,C,h,P,A,f,O){if(f===C.length)return A===_.length?U:k$1;var T=`${A},${f}`;if(O[T]!==void 0)return O[T];for(var L=P.charAt(f),c=h.indexOf(L,A),S=0,E,N,R,M;c>=0;)E=G$1(_,C,h,P,c+1,f+1,O),E>S&&(c===A?E*=U:m.test(_.charAt(c-1))?(E*=H,R=_.slice(A,c-1).match(B),R&&A>0&&(E*=Math.pow(u$1,R.length))):K.test(_.charAt(c-1))?(E*=Y$1,M=_.slice(A,c-1).match(X$1),M&&A>0&&(E*=Math.pow(u$1,M.length))):(E*=J,A>0&&(E*=Math.pow(u$1,c-A))),_.charAt(c)!==C.charAt(f)&&(E*=$)),(E<p&&h.charAt(c-1)===P.charAt(f+1)||P.charAt(f+1)===P.charAt(f)&&h.charAt(c-1)!==P.charAt(f))&&(N=G$1(_,C,h,P,c+1,f+2,O),N*p>E&&(E=N*p)),E>S&&(S=E),c=h.indexOf(L,c+1);return O[T]=S,S}function D$1(_){return _.toLowerCase().replace(X$1," ")}function W(_,C,h){return _=h&&h.length>0?`${_+" "+h.join(" ")}`:_,G$1(_,C,D$1(_),D$1(C),0,0,{})}
18113
14146
 
@@ -33010,7 +29043,7 @@ function AddressInput() {
33010
29043
  return;
33011
29044
  }
33012
29045
  const newAddress = form.getValues("address");
33013
- form.setValue("address", newAddress, { shouldValidate: true });
29046
+ form.setValue("address", newAddress, { shouldValidate: false });
33014
29047
  setOpen(false);
33015
29048
  }
33016
29049
  finally {
@@ -33018,17 +29051,17 @@ function AddressInput() {
33018
29051
  }
33019
29052
  }), [form, isValidating]);
33020
29053
  React.useEffect(() => {
33021
- if (open) {
33022
- const isAddressInvalid = form.getFieldState("address").invalid;
33023
- if (isAddressInvalid) {
33024
- form.setError("address", {
33025
- message: "invalid_address",
33026
- type: "custom",
33027
- });
33028
- }
33029
- else {
33030
- form.clearErrors("address");
33031
- }
29054
+ if (!open)
29055
+ return;
29056
+ const isAddressInvalid = form.getFieldState("address").invalid;
29057
+ if (isAddressInvalid) {
29058
+ form.setError("address", {
29059
+ message: "invalid_address",
29060
+ type: "custom",
29061
+ });
29062
+ }
29063
+ else {
29064
+ form.clearErrors("address");
33032
29065
  }
33033
29066
  }, [open, form]);
33034
29067
  return (React.createElement("div", { className: "w-full md:col-span-2" },
@@ -33040,24 +29073,25 @@ function AddressInput() {
33040
29073
  React.createElement(FormControl, null,
33041
29074
  React.createElement(Input, { placeholder: t("CheckoutEmbed.CustomerForm.address.addressPlaceholder"), value: (currentValue === null || currentValue === void 0 ? void 0 : currentValue.line1) ? formatAddress(currentValue) : "", readOnly: true, className: "cursor-pointer" })),
33042
29075
  React.createElement(FormMessage, null))) }))),
33043
- React.createElement(DialogContent, { className: "sm:max-w-[500px]" },
33044
- React.createElement(DialogHeader, null,
33045
- React.createElement(DialogTitle, null, t("CheckoutEmbed.CustomerForm.address.title")),
33046
- React.createElement(DialogDescription, null, t("CheckoutEmbed.CustomerForm.address.description"))),
33047
- React.createElement("div", { className: "grid grid-cols-2 gap-4" },
33048
- React.createElement(InputGroup, { className: "col-span-2", name: "address.line1", label: t("CheckoutEmbed.CustomerForm.address.line1"), placeholder: t("CheckoutEmbed.CustomerForm.address.line1Placeholder"), autoComplete: "address-line1" }),
33049
- React.createElement(InputGroup, { className: "col-span-2", name: "address.line2", label: t("CheckoutEmbed.CustomerForm.address.line2"), placeholder: t("CheckoutEmbed.CustomerForm.address.line2Placeholder"), autoComplete: "address-line2" }),
33050
- React.createElement(InputGroup, { name: "address.city", label: t("CheckoutEmbed.CustomerForm.address.city"), placeholder: t("CheckoutEmbed.CustomerForm.address.cityPlaceholder"), autoComplete: "address-level2" }),
33051
- React.createElement(InputGroup, { name: "address.state", label: t("CheckoutEmbed.CustomerForm.address.state"), placeholder: t("CheckoutEmbed.CustomerForm.address.statePlaceholder"), autoComplete: "address-level1" }),
33052
- React.createElement(InputGroup, { name: "address.zipCode", label: t("CheckoutEmbed.CustomerForm.address.zipCode"), placeholder: t("CheckoutEmbed.CustomerForm.address.zipCodePlaceholder"), autoComplete: "postal-code" }),
33053
- React.createElement(FormField, { control: form.control, name: "address.country", render: ({ field }) => (React.createElement(FormItem, null,
33054
- React.createElement(FormLabel, null, t("CheckoutEmbed.CustomerForm.address.country")),
33055
- React.createElement(CountryDropdown, { placeholder: t("CheckoutEmbed.CustomerForm.address.countryPlaceholder"), defaultValue: field.value, onChange: (country) => {
33056
- field.onChange(country.name);
33057
- } }),
33058
- React.createElement(FormMessage, null))) })),
33059
- React.createElement(DialogFooter, null,
33060
- React.createElement(Button, { onClick: handleSave, type: "button", disabled: isValidating }, t("CheckoutEmbed.CustomerForm.address.button")))))));
29076
+ React.createElement(DialogContent, { className: "sm:max-w-[500px] fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]" },
29077
+ React.createElement("div", { className: "relative" },
29078
+ React.createElement(DialogHeader, null,
29079
+ React.createElement(DialogTitle, null, t("CheckoutEmbed.CustomerForm.address.title")),
29080
+ React.createElement(DialogDescription, null, t("CheckoutEmbed.CustomerForm.address.description"))),
29081
+ React.createElement("div", { className: "grid grid-cols-2 gap-4" },
29082
+ React.createElement(InputGroup, { className: "col-span-2", name: "address.line1", label: t("CheckoutEmbed.CustomerForm.address.line1"), placeholder: t("CheckoutEmbed.CustomerForm.address.line1Placeholder"), autoComplete: "address-line1" }),
29083
+ React.createElement(InputGroup, { className: "col-span-2", name: "address.line2", label: t("CheckoutEmbed.CustomerForm.address.line2"), placeholder: t("CheckoutEmbed.CustomerForm.address.line2Placeholder"), autoComplete: "address-line2" }),
29084
+ React.createElement(InputGroup, { name: "address.city", label: t("CheckoutEmbed.CustomerForm.address.city"), placeholder: t("CheckoutEmbed.CustomerForm.address.cityPlaceholder"), autoComplete: "address-level2" }),
29085
+ React.createElement(InputGroup, { name: "address.state", label: t("CheckoutEmbed.CustomerForm.address.state"), placeholder: t("CheckoutEmbed.CustomerForm.address.statePlaceholder"), autoComplete: "address-level1" }),
29086
+ React.createElement(InputGroup, { name: "address.zipCode", label: t("CheckoutEmbed.CustomerForm.address.zipCode"), placeholder: t("CheckoutEmbed.CustomerForm.address.zipCodePlaceholder"), autoComplete: "postal-code" }),
29087
+ React.createElement(FormField, { control: form.control, name: "address.country", render: ({ field }) => (React.createElement(FormItem, null,
29088
+ React.createElement(FormLabel, null, t("CheckoutEmbed.CustomerForm.address.country")),
29089
+ React.createElement(CountryDropdown, { placeholder: t("CheckoutEmbed.CustomerForm.address.countryPlaceholder"), defaultValue: field.value, onChange: (country) => {
29090
+ field.onChange(country.name);
29091
+ } }),
29092
+ React.createElement(FormMessage, null))) })),
29093
+ React.createElement(DialogFooter, null,
29094
+ React.createElement(Button, { onClick: handleSave, type: "button", disabled: isValidating }, t("CheckoutEmbed.CustomerForm.address.button"))))))));
33061
29095
  }
33062
29096
 
33063
29097
  function CustomerForm({ initialData, onSubmit, }) {
@@ -34898,7 +30932,7 @@ function InputGroupLoading({ className }) {
34898
30932
  React.createElement(Skeleton, { className: "w-full h-9" })));
34899
30933
  }
34900
30934
 
34901
- const storeHelpers = createStoreHelpers();
30935
+ const storeHelpers = sdk.createStoreHelpers();
34902
30936
 
34903
30937
  function CheckoutSummary({ lineItems, shipping, tax, currency, cancelUrl, exchangeRate, }) {
34904
30938
  const { t } = useTranslation();
@@ -34974,7 +31008,7 @@ function CheckoutSummaryLoading() {
34974
31008
  function CheckoutEmbed({ checkoutId, config }) {
34975
31009
  var _a, _b, _c, _d;
34976
31010
  const { cancelUrl, successUrl, appearance, locale, clientSecret, clientProxy, } = config;
34977
- const storeClient = createStoreClient({ proxy: clientProxy });
31011
+ const storeClient = sdk.createStoreClient({ proxy: clientProxy });
34978
31012
  React.useMemo(() => createI18nInstance(locale), []);
34979
31013
  const [checkout, setCheckout] = React.useState(null);
34980
31014
  const [loading, setLoading] = React.useState(true);