@tagadapay/plugin-sdk 3.1.24 → 3.1.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.
Files changed (39) hide show
  1. package/dist/external-tracker.js +243 -2871
  2. package/dist/external-tracker.min.js +2 -2
  3. package/dist/external-tracker.min.js.map +4 -4
  4. package/dist/react/hooks/useCheckout.js +7 -2
  5. package/dist/tagada-react-sdk-minimal.min.js +2 -2
  6. package/dist/tagada-react-sdk-minimal.min.js.map +3 -3
  7. package/dist/tagada-react-sdk.js +340 -173
  8. package/dist/tagada-react-sdk.min.js +2 -2
  9. package/dist/tagada-react-sdk.min.js.map +3 -3
  10. package/dist/tagada-sdk.js +776 -3327
  11. package/dist/tagada-sdk.min.js +2 -2
  12. package/dist/tagada-sdk.min.js.map +4 -4
  13. package/dist/v2/core/client.js +1 -0
  14. package/dist/v2/core/funnelClient.d.ts +8 -0
  15. package/dist/v2/core/funnelClient.js +1 -1
  16. package/dist/v2/core/resources/apiClient.d.ts +18 -14
  17. package/dist/v2/core/resources/apiClient.js +151 -109
  18. package/dist/v2/core/resources/checkout.d.ts +1 -1
  19. package/dist/v2/core/resources/index.d.ts +1 -1
  20. package/dist/v2/core/resources/index.js +1 -1
  21. package/dist/v2/core/resources/offers.js +4 -4
  22. package/dist/v2/core/resources/payments.d.ts +1 -0
  23. package/dist/v2/core/utils/currency.d.ts +3 -0
  24. package/dist/v2/core/utils/currency.js +40 -2
  25. package/dist/v2/core/utils/deviceInfo.d.ts +1 -0
  26. package/dist/v2/core/utils/deviceInfo.js +1 -0
  27. package/dist/v2/core/utils/previewMode.js +12 -0
  28. package/dist/v2/react/components/ApplePayButton.js +39 -16
  29. package/dist/v2/react/components/StripeExpressButton.js +1 -2
  30. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +1 -0
  31. package/dist/v2/react/hooks/useApiQuery.d.ts +1 -1
  32. package/dist/v2/react/hooks/useApiQuery.js +1 -1
  33. package/dist/v2/react/hooks/useCheckoutQuery.js +6 -2
  34. package/dist/v2/react/hooks/usePreviewOffer.js +1 -1
  35. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +7 -0
  36. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +97 -9
  37. package/dist/v2/react/providers/TagadaProvider.js +1 -1
  38. package/dist/v2/standalone/payment-service.js +1 -0
  39. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TagadaPay External Tracker v3.1.24
2
+ * TagadaPay External Tracker v3.1.25
3
3
  * CDN Bundle - Standalone tracking for external pages (Debug Build)
4
4
  * @license MIT
5
5
  */
@@ -13,10 +13,6 @@ var TagadaTrackerBundle = (() => {
13
13
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
15
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
16
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
17
- var __typeError = (msg) => {
18
- throw TypeError(msg);
19
- };
20
16
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21
17
  var __spreadValues = (a, b) => {
22
18
  for (var prop in b || (b = {}))
@@ -33,9 +29,9 @@ var TagadaTrackerBundle = (() => {
33
29
  var __esm = (fn, res) => function __init() {
34
30
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
35
31
  };
36
- var __export = (target, all3) => {
37
- for (var name in all3)
38
- __defProp(target, name, { get: all3[name], enumerable: true });
32
+ var __export = (target, all) => {
33
+ for (var name in all)
34
+ __defProp(target, name, { get: all[name], enumerable: true });
39
35
  };
40
36
  var __copyProps = (to, from, except, desc) => {
41
37
  if (from && typeof from === "object" || typeof from === "function") {
@@ -46,50 +42,6 @@ var TagadaTrackerBundle = (() => {
46
42
  return to;
47
43
  };
48
44
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
- var __await = function(promise, isYieldStar) {
50
- this[0] = promise;
51
- this[1] = isYieldStar;
52
- };
53
- var __asyncGenerator = (__this, __arguments, generator) => {
54
- var resume = (k, v, yes, no) => {
55
- try {
56
- var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
57
- Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
58
- } catch (e) {
59
- no(e);
60
- }
61
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
62
- return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
63
- };
64
- var __yieldStar = (value) => {
65
- var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
66
- if (obj == null) {
67
- obj = value[__knownSymbol("iterator")]();
68
- method = (k) => it[k] = (x) => obj[k](x);
69
- } else {
70
- obj = obj.call(value);
71
- method = (k) => it[k] = (v) => {
72
- if (isAwait) {
73
- isAwait = false;
74
- if (k === "throw") throw v;
75
- return v;
76
- }
77
- isAwait = true;
78
- return {
79
- done: false,
80
- value: new __await(new Promise((resolve) => {
81
- var x = obj[k](v);
82
- if (!(x instanceof Object)) __typeError("Object expected");
83
- resolve(x);
84
- }), 1)
85
- };
86
- };
87
- }
88
- return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
89
- throw x;
90
- }, "return" in obj && method("return"), it;
91
- };
92
- var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
93
45
 
94
46
  // src/v2/core/config/environment.ts
95
47
  function getCookie(name) {
@@ -617,6 +569,16 @@ var TagadaTrackerBundle = (() => {
617
569
  if (urlBaseUrl) {
618
570
  setClientBaseUrl(urlBaseUrl);
619
571
  }
572
+ const urlCurrency = urlParams.get("currency");
573
+ if (urlCurrency) {
574
+ setInStorage(STORAGE_KEYS.CURRENCY, urlCurrency.toUpperCase());
575
+ setInCookie(STORAGE_KEYS.CURRENCY, urlCurrency.toUpperCase(), 86400);
576
+ }
577
+ const urlLocale = urlParams.get("locale");
578
+ if (urlLocale) {
579
+ setInStorage(STORAGE_KEYS.LOCALE, urlLocale);
580
+ setInCookie(STORAGE_KEYS.LOCALE, urlLocale, 86400);
581
+ }
620
582
  }
621
583
  function setFunnelTracking(enabled) {
622
584
  if (typeof window === "undefined") return;
@@ -1517,7 +1479,7 @@ var TagadaTrackerBundle = (() => {
1517
1479
  if (this.config.debugMode) {
1518
1480
  console.log("\u{1F680} [FunnelClient] Auto-redirecting to:", result.url, "(skipped session refresh - next page will initialize)");
1519
1481
  }
1520
- window.location.href = result.url;
1482
+ window.location.replace(result.url);
1521
1483
  }
1522
1484
  return result;
1523
1485
  } catch (error) {
@@ -1638,2822 +1600,252 @@ var TagadaTrackerBundle = (() => {
1638
1600
  init_environment();
1639
1601
  init_funnelClient();
1640
1602
 
1641
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/bind.js
1642
- function bind(fn, thisArg) {
1643
- return function wrap() {
1644
- return fn.apply(thisArg, arguments);
1645
- };
1646
- }
1647
-
1648
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/utils.js
1649
- var { toString } = Object.prototype;
1650
- var { getPrototypeOf } = Object;
1651
- var { iterator, toStringTag } = Symbol;
1652
- var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
1653
- const str = toString.call(thing);
1654
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
1655
- })(/* @__PURE__ */ Object.create(null));
1656
- var kindOfTest = (type) => {
1657
- type = type.toLowerCase();
1658
- return (thing) => kindOf(thing) === type;
1603
+ // src/v2/core/errors.ts
1604
+ var TagadaErrorCode = {
1605
+ NETWORK_ERROR: "network_error",
1606
+ API_ERROR: "api_error",
1607
+ AUTH_REQUIRED: "auth_required",
1608
+ TOKEN_EXPIRED: "token_expired",
1609
+ NOT_FOUND: "not_found",
1610
+ VALIDATION_ERROR: "validation_error",
1611
+ CIRCUIT_BREAKER: "circuit_breaker",
1612
+ PAYMENT_FAILED: "payment_failed",
1613
+ CARD_DECLINED: "card_declined",
1614
+ SESSION_EXPIRED: "session_expired",
1615
+ RATE_LIMITED: "rate_limited",
1616
+ TIMEOUT: "timeout",
1617
+ UNKNOWN: "unknown"
1659
1618
  };
1660
- var typeOfTest = (type) => (thing) => typeof thing === type;
1661
- var { isArray } = Array;
1662
- var isUndefined = typeOfTest("undefined");
1663
- function isBuffer(val) {
1664
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
1665
- }
1666
- var isArrayBuffer = kindOfTest("ArrayBuffer");
1667
- function isArrayBufferView(val) {
1668
- let result;
1669
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
1670
- result = ArrayBuffer.isView(val);
1671
- } else {
1672
- result = val && val.buffer && isArrayBuffer(val.buffer);
1619
+ var TagadaError = class extends Error {
1620
+ constructor(message, options) {
1621
+ var _a;
1622
+ super(message);
1623
+ this.name = "TagadaError";
1624
+ this.code = options.code;
1625
+ this.statusCode = options.statusCode;
1626
+ this.retryable = (_a = options.retryable) != null ? _a : false;
1627
+ this.details = options.details;
1628
+ Object.setPrototypeOf(this, new.target.prototype);
1673
1629
  }
1674
- return result;
1675
- }
1676
- var isString = typeOfTest("string");
1677
- var isFunction = typeOfTest("function");
1678
- var isNumber = typeOfTest("number");
1679
- var isObject = (thing) => thing !== null && typeof thing === "object";
1680
- var isBoolean = (thing) => thing === true || thing === false;
1681
- var isPlainObject = (val) => {
1682
- if (kindOf(val) !== "object") {
1683
- return false;
1630
+ };
1631
+ var TagadaApiError = class extends TagadaError {
1632
+ constructor(message, statusCode, options) {
1633
+ var _a, _b;
1634
+ super(message, {
1635
+ code: (_a = options == null ? void 0 : options.code) != null ? _a : TagadaErrorCode.API_ERROR,
1636
+ statusCode,
1637
+ retryable: (_b = options == null ? void 0 : options.retryable) != null ? _b : statusCode >= 500,
1638
+ details: options == null ? void 0 : options.details
1639
+ });
1640
+ this.name = "TagadaApiError";
1684
1641
  }
1685
- const prototype3 = getPrototypeOf(val);
1686
- return (prototype3 === null || prototype3 === Object.prototype || Object.getPrototypeOf(prototype3) === null) && !(toStringTag in val) && !(iterator in val);
1687
1642
  };
1688
- var isEmptyObject = (val) => {
1689
- if (!isObject(val) || isBuffer(val)) {
1690
- return false;
1643
+ var TagadaNetworkError = class extends TagadaError {
1644
+ constructor(message = "Network request failed") {
1645
+ super(message, {
1646
+ code: TagadaErrorCode.NETWORK_ERROR,
1647
+ retryable: true
1648
+ });
1649
+ this.name = "TagadaNetworkError";
1691
1650
  }
1692
- try {
1693
- return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
1694
- } catch (e) {
1695
- return false;
1651
+ };
1652
+ var TagadaAuthError = class extends TagadaError {
1653
+ constructor(message = "Authentication required", statusCode = 401) {
1654
+ super(message, {
1655
+ code: TagadaErrorCode.AUTH_REQUIRED,
1656
+ statusCode,
1657
+ retryable: false
1658
+ });
1659
+ this.name = "TagadaAuthError";
1696
1660
  }
1697
1661
  };
1698
- var isDate = kindOfTest("Date");
1699
- var isFile = kindOfTest("File");
1700
- var isBlob = kindOfTest("Blob");
1701
- var isFileList = kindOfTest("FileList");
1702
- var isStream = (val) => isObject(val) && isFunction(val.pipe);
1703
- var isFormData = (thing) => {
1704
- let kind;
1705
- return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
1706
- kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
1662
+ var TagadaCircuitBreakerError = class extends TagadaError {
1663
+ constructor(message) {
1664
+ super(message, {
1665
+ code: TagadaErrorCode.CIRCUIT_BREAKER,
1666
+ retryable: false
1667
+ });
1668
+ this.name = "TagadaCircuitBreakerError";
1669
+ }
1707
1670
  };
1708
- var isURLSearchParams = kindOfTest("URLSearchParams");
1709
- var [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
1710
- var trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
1711
- function forEach(obj, fn, { allOwnKeys = false } = {}) {
1712
- if (obj === null || typeof obj === "undefined") {
1713
- return;
1671
+
1672
+ // src/v2/core/resources/apiClient.ts
1673
+ var ApiClient = class {
1674
+ // Max 30 requests per endpoint in window
1675
+ constructor(config) {
1676
+ this.currentToken = null;
1677
+ this.tokenProvider = null;
1678
+ // Circuit breaker state
1679
+ this.requestHistory = /* @__PURE__ */ new Map();
1680
+ this.WINDOW_MS = 5e3;
1681
+ // 5 seconds window
1682
+ this.MAX_REQUESTS = 30;
1683
+ this.baseURL = config.baseURL;
1684
+ this.timeout = config.timeout || 6e4;
1685
+ this.defaultHeaders = __spreadValues({
1686
+ "Content-Type": "application/json"
1687
+ }, config.headers);
1688
+ if (typeof setInterval !== "undefined") {
1689
+ setInterval(() => this.cleanupHistory(), 1e4);
1690
+ }
1714
1691
  }
1715
- let i;
1716
- let l;
1717
- if (typeof obj !== "object") {
1718
- obj = [obj];
1692
+ // Set a provider that returns a promise resolving to the token
1693
+ // This allows requests to wait until the token is ready
1694
+ setTokenProvider(provider) {
1695
+ this.tokenProvider = provider;
1719
1696
  }
1720
- if (isArray(obj)) {
1721
- for (i = 0, l = obj.length; i < l; i++) {
1722
- fn.call(null, obj[i], i, obj);
1723
- }
1724
- } else {
1725
- if (isBuffer(obj)) {
1726
- return;
1727
- }
1728
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
1729
- const len = keys.length;
1730
- let key;
1731
- for (i = 0; i < len; i++) {
1732
- key = keys[i];
1733
- fn.call(null, obj[key], key, obj);
1734
- }
1697
+ // Convenience methods
1698
+ async get(url, config) {
1699
+ return this.request("GET", url, void 0, config);
1735
1700
  }
1736
- }
1737
- function findKey(obj, key) {
1738
- if (isBuffer(obj)) {
1739
- return null;
1701
+ async post(url, data, config) {
1702
+ return this.request("POST", url, data, config);
1740
1703
  }
1741
- key = key.toLowerCase();
1742
- const keys = Object.keys(obj);
1743
- let i = keys.length;
1744
- let _key;
1745
- while (i-- > 0) {
1746
- _key = keys[i];
1747
- if (key === _key.toLowerCase()) {
1748
- return _key;
1749
- }
1704
+ async put(url, data, config) {
1705
+ return this.request("PUT", url, data, config);
1750
1706
  }
1751
- return null;
1752
- }
1753
- var _global = (() => {
1754
- if (typeof globalThis !== "undefined") return globalThis;
1755
- return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
1756
- })();
1757
- var isContextDefined = (context) => !isUndefined(context) && context !== _global;
1758
- function merge() {
1759
- const { caseless, skipUndefined } = isContextDefined(this) && this || {};
1760
- const result = {};
1761
- const assignValue = (val, key) => {
1762
- const targetKey = caseless && findKey(result, key) || key;
1763
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
1764
- result[targetKey] = merge(result[targetKey], val);
1765
- } else if (isPlainObject(val)) {
1766
- result[targetKey] = merge({}, val);
1767
- } else if (isArray(val)) {
1768
- result[targetKey] = val.slice();
1769
- } else if (!skipUndefined || !isUndefined(val)) {
1770
- result[targetKey] = val;
1771
- }
1772
- };
1773
- for (let i = 0, l = arguments.length; i < l; i++) {
1774
- arguments[i] && forEach(arguments[i], assignValue);
1707
+ async patch(url, data, config) {
1708
+ return this.request("PATCH", url, data, config);
1775
1709
  }
1776
- return result;
1777
- }
1778
- var extend = (a, b, thisArg, { allOwnKeys } = {}) => {
1779
- forEach(b, (val, key) => {
1780
- if (thisArg && isFunction(val)) {
1781
- a[key] = bind(val, thisArg);
1710
+ async delete(url, config) {
1711
+ return this.request("DELETE", url, void 0, config);
1712
+ }
1713
+ // Update headers (useful for auth tokens)
1714
+ setHeader(key, value) {
1715
+ this.defaultHeaders[key] = value;
1716
+ }
1717
+ removeHeader(key) {
1718
+ delete this.defaultHeaders[key];
1719
+ }
1720
+ // Token management methods (matching old ApiService pattern)
1721
+ updateToken(token) {
1722
+ this.currentToken = token;
1723
+ if (token) {
1724
+ this.setHeader("x-cms-token", token);
1782
1725
  } else {
1783
- a[key] = val;
1726
+ this.removeHeader("x-cms-token");
1727
+ console.log("[SDK] Token removed from ApiClient");
1784
1728
  }
1785
- }, { allOwnKeys });
1786
- return a;
1787
- };
1788
- var stripBOM = (content) => {
1789
- if (content.charCodeAt(0) === 65279) {
1790
- content = content.slice(1);
1791
1729
  }
1792
- return content;
1793
- };
1794
- var inherits = (constructor, superConstructor, props, descriptors2) => {
1795
- constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
1796
- constructor.prototype.constructor = constructor;
1797
- Object.defineProperty(constructor, "super", {
1798
- value: superConstructor.prototype
1799
- });
1800
- props && Object.assign(constructor.prototype, props);
1801
- };
1802
- var toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
1803
- let props;
1804
- let i;
1805
- let prop;
1806
- const merged = {};
1807
- destObj = destObj || {};
1808
- if (sourceObj == null) return destObj;
1809
- do {
1810
- props = Object.getOwnPropertyNames(sourceObj);
1811
- i = props.length;
1812
- while (i-- > 0) {
1813
- prop = props[i];
1814
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
1815
- destObj[prop] = sourceObj[prop];
1816
- merged[prop] = true;
1817
- }
1818
- }
1819
- sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
1820
- } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
1821
- return destObj;
1822
- };
1823
- var endsWith = (str, searchString, position) => {
1824
- str = String(str);
1825
- if (position === void 0 || position > str.length) {
1826
- position = str.length;
1827
- }
1828
- position -= searchString.length;
1829
- const lastIndex = str.indexOf(searchString, position);
1830
- return lastIndex !== -1 && lastIndex === position;
1831
- };
1832
- var toArray = (thing) => {
1833
- if (!thing) return null;
1834
- if (isArray(thing)) return thing;
1835
- let i = thing.length;
1836
- if (!isNumber(i)) return null;
1837
- const arr = new Array(i);
1838
- while (i-- > 0) {
1839
- arr[i] = thing[i];
1840
- }
1841
- return arr;
1842
- };
1843
- var isTypedArray = /* @__PURE__ */ ((TypedArray) => {
1844
- return (thing) => {
1845
- return TypedArray && thing instanceof TypedArray;
1846
- };
1847
- })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
1848
- var forEachEntry = (obj, fn) => {
1849
- const generator = obj && obj[iterator];
1850
- const _iterator = generator.call(obj);
1851
- let result;
1852
- while ((result = _iterator.next()) && !result.done) {
1853
- const pair = result.value;
1854
- fn.call(obj, pair[0], pair[1]);
1730
+ getCurrentToken() {
1731
+ return this.currentToken;
1855
1732
  }
1856
- };
1857
- var matchAll = (regExp, str) => {
1858
- let matches;
1859
- const arr = [];
1860
- while ((matches = regExp.exec(str)) !== null) {
1861
- arr.push(matches);
1733
+ // Update configuration (useful for environment changes)
1734
+ updateConfig(config) {
1735
+ if (config.baseURL) {
1736
+ this.baseURL = config.baseURL;
1737
+ }
1738
+ if (config.timeout) {
1739
+ this.timeout = config.timeout;
1740
+ }
1741
+ if (config.headers) {
1742
+ Object.assign(this.defaultHeaders, config.headers);
1743
+ }
1744
+ console.log("[SDK] ApiClient configuration updated");
1862
1745
  }
1863
- return arr;
1864
- };
1865
- var isHTMLForm = kindOfTest("HTMLFormElement");
1866
- var toCamelCase = (str) => {
1867
- return str.toLowerCase().replace(
1868
- /[-_\s]([a-z\d])(\w*)/g,
1869
- function replacer(m, p1, p2) {
1870
- return p1.toUpperCase() + p2;
1746
+ // ---- Core request method ----
1747
+ async request(method, url, data, config) {
1748
+ const requestKey = "".concat(method, ":").concat(url);
1749
+ try {
1750
+ this.checkRequestLimit(requestKey);
1751
+ } catch (error) {
1752
+ console.error("[SDK] \u{1F6D1} Request blocked by Circuit Breaker:", error);
1753
+ throw error;
1871
1754
  }
1872
- );
1873
- };
1874
- var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
1875
- var isRegExp = kindOfTest("RegExp");
1876
- var reduceDescriptors = (obj, reducer) => {
1877
- const descriptors2 = Object.getOwnPropertyDescriptors(obj);
1878
- const reducedDescriptors = {};
1879
- forEach(descriptors2, (descriptor, name) => {
1880
- let ret;
1881
- if ((ret = reducer(descriptor, name, obj)) !== false) {
1882
- reducedDescriptors[name] = ret || descriptor;
1755
+ if (!(config == null ? void 0 : config.skipAuth) && !this.currentToken && this.tokenProvider) {
1756
+ try {
1757
+ console.log("[SDK] Waiting for token...");
1758
+ const token = await this.tokenProvider();
1759
+ if (token) {
1760
+ this.updateToken(token);
1761
+ }
1762
+ } catch (error) {
1763
+ console.error("[SDK] Failed to get token from provider:", error);
1764
+ }
1883
1765
  }
1884
- });
1885
- Object.defineProperties(obj, reducedDescriptors);
1886
- };
1887
- var freezeMethods = (obj) => {
1888
- reduceDescriptors(obj, (descriptor, name) => {
1889
- if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
1890
- return false;
1891
- }
1892
- const value = obj[name];
1893
- if (!isFunction(value)) return;
1894
- descriptor.enumerable = false;
1895
- if ("writable" in descriptor) {
1896
- descriptor.writable = false;
1897
- return;
1766
+ const headers = __spreadValues({}, this.defaultHeaders);
1767
+ if (config == null ? void 0 : config.headers) {
1768
+ Object.assign(headers, config.headers);
1898
1769
  }
1899
- if (!descriptor.set) {
1900
- descriptor.set = () => {
1901
- throw Error("Can not rewrite read-only method '" + name + "'");
1902
- };
1770
+ if (!(config == null ? void 0 : config.skipAuth) && this.currentToken) {
1771
+ headers["x-cms-token"] = this.currentToken;
1903
1772
  }
1904
- });
1905
- };
1906
- var toObjectSet = (arrayOrString, delimiter) => {
1907
- const obj = {};
1908
- const define = (arr) => {
1909
- arr.forEach((value) => {
1910
- obj[value] = true;
1911
- });
1912
- };
1913
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
1914
- return obj;
1915
- };
1916
- var noop = () => {
1917
- };
1918
- var toFiniteNumber = (value, defaultValue) => {
1919
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
1920
- };
1921
- function isSpecCompliantForm(thing) {
1922
- return !!(thing && isFunction(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
1923
- }
1924
- var toJSONObject = (obj) => {
1925
- const stack = new Array(10);
1926
- const visit = (source, i) => {
1927
- if (isObject(source)) {
1928
- if (stack.indexOf(source) >= 0) {
1929
- return;
1773
+ let fullUrl = "".concat(this.baseURL).concat(url);
1774
+ if (config == null ? void 0 : config.params) {
1775
+ const searchParams = new URLSearchParams(config.params);
1776
+ fullUrl += "?".concat(searchParams.toString());
1777
+ }
1778
+ console.log("[SDK] Making ".concat(method, " request to: ").concat(fullUrl));
1779
+ const controller = new AbortController();
1780
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
1781
+ const signal = (config == null ? void 0 : config.signal) ? anySignal([config.signal, controller.signal]) : controller.signal;
1782
+ try {
1783
+ const fetchOptions = {
1784
+ method,
1785
+ headers,
1786
+ signal
1787
+ };
1788
+ if (data !== void 0) {
1789
+ fetchOptions.body = JSON.stringify(data);
1930
1790
  }
1931
- if (isBuffer(source)) {
1932
- return source;
1791
+ const response = await fetch(fullUrl, fetchOptions);
1792
+ if (!response.ok) {
1793
+ const errorData = await this.safeParseJson(response);
1794
+ throw this.toTagadaError(response.status, errorData, response.statusText);
1795
+ }
1796
+ const responseData = await response.json();
1797
+ return responseData;
1798
+ } catch (error) {
1799
+ if (error instanceof TagadaError) {
1800
+ throw error;
1933
1801
  }
1934
- if (!("toJSON" in source)) {
1935
- stack[i] = source;
1936
- const target = isArray(source) ? [] : {};
1937
- forEach(source, (value, key) => {
1938
- const reducedValue = visit(value, i + 1);
1939
- !isUndefined(reducedValue) && (target[key] = reducedValue);
1802
+ if (error instanceof DOMException && error.name === "AbortError") {
1803
+ throw new TagadaApiError("Request timed out", 0, {
1804
+ code: TagadaErrorCode.TIMEOUT,
1805
+ retryable: true
1940
1806
  });
1941
- stack[i] = void 0;
1942
- return target;
1943
1807
  }
1944
- }
1945
- return source;
1946
- };
1947
- return visit(obj, 0);
1948
- };
1949
- var isAsyncFn = kindOfTest("AsyncFunction");
1950
- var isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
1951
- var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1952
- if (setImmediateSupported) {
1953
- return setImmediate;
1954
- }
1955
- return postMessageSupported ? ((token, callbacks) => {
1956
- _global.addEventListener("message", ({ source, data }) => {
1957
- if (source === _global && data === token) {
1958
- callbacks.length && callbacks.shift()();
1808
+ if (error instanceof TypeError) {
1809
+ throw new TagadaNetworkError(error.message);
1959
1810
  }
1960
- }, false);
1961
- return (cb) => {
1962
- callbacks.push(cb);
1963
- _global.postMessage(token, "*");
1964
- };
1965
- })("axios@".concat(Math.random()), []) : (cb) => setTimeout(cb);
1966
- })(
1967
- typeof setImmediate === "function",
1968
- isFunction(_global.postMessage)
1969
- );
1970
- var asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
1971
- var isIterable = (thing) => thing != null && isFunction(thing[iterator]);
1972
- var utils_default = {
1973
- isArray,
1974
- isArrayBuffer,
1975
- isBuffer,
1976
- isFormData,
1977
- isArrayBufferView,
1978
- isString,
1979
- isNumber,
1980
- isBoolean,
1981
- isObject,
1982
- isPlainObject,
1983
- isEmptyObject,
1984
- isReadableStream,
1985
- isRequest,
1986
- isResponse,
1987
- isHeaders,
1988
- isUndefined,
1989
- isDate,
1990
- isFile,
1991
- isBlob,
1992
- isRegExp,
1993
- isFunction,
1994
- isStream,
1995
- isURLSearchParams,
1996
- isTypedArray,
1997
- isFileList,
1998
- forEach,
1999
- merge,
2000
- extend,
2001
- trim,
2002
- stripBOM,
2003
- inherits,
2004
- toFlatObject,
2005
- kindOf,
2006
- kindOfTest,
2007
- endsWith,
2008
- toArray,
2009
- forEachEntry,
2010
- matchAll,
2011
- isHTMLForm,
2012
- hasOwnProperty,
2013
- hasOwnProp: hasOwnProperty,
2014
- // an alias to avoid ESLint no-prototype-builtins detection
2015
- reduceDescriptors,
2016
- freezeMethods,
2017
- toObjectSet,
2018
- toCamelCase,
2019
- noop,
2020
- toFiniteNumber,
2021
- findKey,
2022
- global: _global,
2023
- isContextDefined,
2024
- isSpecCompliantForm,
2025
- toJSONObject,
2026
- isAsyncFn,
2027
- isThenable,
2028
- setImmediate: _setImmediate,
2029
- asap,
2030
- isIterable
2031
- };
2032
-
2033
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/AxiosError.js
2034
- function AxiosError(message, code, config, request, response) {
2035
- Error.call(this);
2036
- if (Error.captureStackTrace) {
2037
- Error.captureStackTrace(this, this.constructor);
2038
- } else {
2039
- this.stack = new Error().stack;
2040
- }
2041
- this.message = message;
2042
- this.name = "AxiosError";
2043
- code && (this.code = code);
2044
- config && (this.config = config);
2045
- request && (this.request = request);
2046
- if (response) {
2047
- this.response = response;
2048
- this.status = response.status ? response.status : null;
2049
- }
2050
- }
2051
- utils_default.inherits(AxiosError, Error, {
2052
- toJSON: function toJSON() {
2053
- return {
2054
- // Standard
2055
- message: this.message,
2056
- name: this.name,
2057
- // Microsoft
2058
- description: this.description,
2059
- number: this.number,
2060
- // Mozilla
2061
- fileName: this.fileName,
2062
- lineNumber: this.lineNumber,
2063
- columnNumber: this.columnNumber,
2064
- stack: this.stack,
2065
- // Axios
2066
- config: utils_default.toJSONObject(this.config),
2067
- code: this.code,
2068
- status: this.status
2069
- };
1811
+ throw error instanceof Error ? error : new Error(String(error));
1812
+ } finally {
1813
+ clearTimeout(timeoutId);
1814
+ }
2070
1815
  }
2071
- });
2072
- var prototype = AxiosError.prototype;
2073
- var descriptors = {};
2074
- [
2075
- "ERR_BAD_OPTION_VALUE",
2076
- "ERR_BAD_OPTION",
2077
- "ECONNABORTED",
2078
- "ETIMEDOUT",
2079
- "ERR_NETWORK",
2080
- "ERR_FR_TOO_MANY_REDIRECTS",
2081
- "ERR_DEPRECATED",
2082
- "ERR_BAD_RESPONSE",
2083
- "ERR_BAD_REQUEST",
2084
- "ERR_CANCELED",
2085
- "ERR_NOT_SUPPORT",
2086
- "ERR_INVALID_URL"
2087
- // eslint-disable-next-line func-names
2088
- ].forEach((code) => {
2089
- descriptors[code] = { value: code };
2090
- });
2091
- Object.defineProperties(AxiosError, descriptors);
2092
- Object.defineProperty(prototype, "isAxiosError", { value: true });
2093
- AxiosError.from = (error, code, config, request, response, customProps) => {
2094
- const axiosError = Object.create(prototype);
2095
- utils_default.toFlatObject(error, axiosError, function filter2(obj) {
2096
- return obj !== Error.prototype;
2097
- }, (prop) => {
2098
- return prop !== "isAxiosError";
2099
- });
2100
- const msg = error && error.message ? error.message : "Error";
2101
- const errCode = code == null && error ? error.code : code;
2102
- AxiosError.call(axiosError, msg, errCode, config, request, response);
2103
- if (error && axiosError.cause == null) {
2104
- Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
2105
- }
2106
- axiosError.name = error && error.name || "Error";
2107
- customProps && Object.assign(axiosError, customProps);
2108
- return axiosError;
2109
- };
2110
- var AxiosError_default = AxiosError;
2111
-
2112
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/null.js
2113
- var null_default = null;
2114
-
2115
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/toFormData.js
2116
- function isVisitable(thing) {
2117
- return utils_default.isPlainObject(thing) || utils_default.isArray(thing);
2118
- }
2119
- function removeBrackets(key) {
2120
- return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
2121
- }
2122
- function renderKey(path, key, dots) {
2123
- if (!path) return key;
2124
- return path.concat(key).map(function each(token, i) {
2125
- token = removeBrackets(token);
2126
- return !dots && i ? "[" + token + "]" : token;
2127
- }).join(dots ? "." : "");
2128
- }
2129
- function isFlatArray(arr) {
2130
- return utils_default.isArray(arr) && !arr.some(isVisitable);
2131
- }
2132
- var predicates = utils_default.toFlatObject(utils_default, {}, null, function filter(prop) {
2133
- return /^is[A-Z]/.test(prop);
2134
- });
2135
- function toFormData(obj, formData, options) {
2136
- if (!utils_default.isObject(obj)) {
2137
- throw new TypeError("target must be an object");
2138
- }
2139
- formData = formData || new (null_default || FormData)();
2140
- options = utils_default.toFlatObject(options, {
2141
- metaTokens: true,
2142
- dots: false,
2143
- indexes: false
2144
- }, false, function defined(option, source) {
2145
- return !utils_default.isUndefined(source[option]);
2146
- });
2147
- const metaTokens = options.metaTokens;
2148
- const visitor = options.visitor || defaultVisitor;
2149
- const dots = options.dots;
2150
- const indexes = options.indexes;
2151
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
2152
- const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
2153
- if (!utils_default.isFunction(visitor)) {
2154
- throw new TypeError("visitor must be a function");
2155
- }
2156
- function convertValue(value) {
2157
- if (value === null) return "";
2158
- if (utils_default.isDate(value)) {
2159
- return value.toISOString();
2160
- }
2161
- if (utils_default.isBoolean(value)) {
2162
- return value.toString();
2163
- }
2164
- if (!useBlob && utils_default.isBlob(value)) {
2165
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.");
2166
- }
2167
- if (utils_default.isArrayBuffer(value) || utils_default.isTypedArray(value)) {
2168
- return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
2169
- }
2170
- return value;
2171
- }
2172
- function defaultVisitor(value, key, path) {
2173
- let arr = value;
2174
- if (value && !path && typeof value === "object") {
2175
- if (utils_default.endsWith(key, "{}")) {
2176
- key = metaTokens ? key : key.slice(0, -2);
2177
- value = JSON.stringify(value);
2178
- } else if (utils_default.isArray(value) && isFlatArray(value) || (utils_default.isFileList(value) || utils_default.endsWith(key, "[]")) && (arr = utils_default.toArray(value))) {
2179
- key = removeBrackets(key);
2180
- arr.forEach(function each(el, index) {
2181
- !(utils_default.isUndefined(el) || el === null) && formData.append(
2182
- // eslint-disable-next-line no-nested-ternary
2183
- indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
2184
- convertValue(el)
2185
- );
2186
- });
2187
- return false;
2188
- }
1816
+ // ---- Error mapping ----
1817
+ /** Convert a non-ok fetch response into the appropriate TagadaError subclass. */
1818
+ toTagadaError(status, data, statusText) {
1819
+ var _a, _b, _c;
1820
+ const serverMessage = (_b = (_a = data == null ? void 0 : data.message) != null ? _a : data == null ? void 0 : data.error) != null ? _b : statusText;
1821
+ if (status === 401 || status === 403) {
1822
+ return new TagadaAuthError(serverMessage, status);
2189
1823
  }
2190
- if (isVisitable(value)) {
2191
- return true;
1824
+ if (status === 429) {
1825
+ return new TagadaApiError(serverMessage, 429, {
1826
+ code: TagadaErrorCode.RATE_LIMITED,
1827
+ retryable: true
1828
+ });
2192
1829
  }
2193
- formData.append(renderKey(path, key, dots), convertValue(value));
2194
- return false;
2195
- }
2196
- const stack = [];
2197
- const exposedHelpers = Object.assign(predicates, {
2198
- defaultVisitor,
2199
- convertValue,
2200
- isVisitable
2201
- });
2202
- function build(value, path) {
2203
- if (utils_default.isUndefined(value)) return;
2204
- if (stack.indexOf(value) !== -1) {
2205
- throw Error("Circular reference detected in " + path.join("."));
2206
- }
2207
- stack.push(value);
2208
- utils_default.forEach(value, function each(el, key) {
2209
- const result = !(utils_default.isUndefined(el) || el === null) && visitor.call(
2210
- formData,
2211
- el,
2212
- utils_default.isString(key) ? key.trim() : key,
2213
- path,
2214
- exposedHelpers
2215
- );
2216
- if (result === true) {
2217
- build(el, path ? path.concat(key) : [key]);
2218
- }
1830
+ if (status === 404) {
1831
+ return new TagadaApiError(serverMessage, 404, {
1832
+ code: TagadaErrorCode.NOT_FOUND,
1833
+ retryable: false
1834
+ });
1835
+ }
1836
+ return new TagadaApiError(serverMessage, status, {
1837
+ code: (_c = data == null ? void 0 : data.code) != null ? _c : TagadaErrorCode.API_ERROR,
1838
+ details: data,
1839
+ retryable: status >= 500
2219
1840
  });
2220
- stack.pop();
2221
1841
  }
2222
- if (!utils_default.isObject(obj)) {
2223
- throw new TypeError("data must be an object");
2224
- }
2225
- build(obj);
2226
- return formData;
2227
- }
2228
- var toFormData_default = toFormData;
2229
-
2230
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/AxiosURLSearchParams.js
2231
- function encode(str) {
2232
- const charMap = {
2233
- "!": "%21",
2234
- "'": "%27",
2235
- "(": "%28",
2236
- ")": "%29",
2237
- "~": "%7E",
2238
- "%20": "+",
2239
- "%00": "\0"
2240
- };
2241
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match2) {
2242
- return charMap[match2];
2243
- });
2244
- }
2245
- function AxiosURLSearchParams(params, options) {
2246
- this._pairs = [];
2247
- params && toFormData_default(params, this, options);
2248
- }
2249
- var prototype2 = AxiosURLSearchParams.prototype;
2250
- prototype2.append = function append(name, value) {
2251
- this._pairs.push([name, value]);
2252
- };
2253
- prototype2.toString = function toString2(encoder) {
2254
- const _encode = encoder ? function(value) {
2255
- return encoder.call(this, value, encode);
2256
- } : encode;
2257
- return this._pairs.map(function each(pair) {
2258
- return _encode(pair[0]) + "=" + _encode(pair[1]);
2259
- }, "").join("&");
2260
- };
2261
- var AxiosURLSearchParams_default = AxiosURLSearchParams;
2262
-
2263
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/buildURL.js
2264
- function encode2(val) {
2265
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
2266
- }
2267
- function buildURL(url, params, options) {
2268
- if (!params) {
2269
- return url;
2270
- }
2271
- const _encode = options && options.encode || encode2;
2272
- if (utils_default.isFunction(options)) {
2273
- options = {
2274
- serialize: options
2275
- };
2276
- }
2277
- const serializeFn = options && options.serialize;
2278
- let serializedParams;
2279
- if (serializeFn) {
2280
- serializedParams = serializeFn(params, options);
2281
- } else {
2282
- serializedParams = utils_default.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams_default(params, options).toString(_encode);
2283
- }
2284
- if (serializedParams) {
2285
- const hashmarkIndex = url.indexOf("#");
2286
- if (hashmarkIndex !== -1) {
2287
- url = url.slice(0, hashmarkIndex);
2288
- }
2289
- url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
2290
- }
2291
- return url;
2292
- }
2293
-
2294
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/InterceptorManager.js
2295
- var InterceptorManager = class {
2296
- constructor() {
2297
- this.handlers = [];
2298
- }
2299
- /**
2300
- * Add a new interceptor to the stack
2301
- *
2302
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
2303
- * @param {Function} rejected The function to handle `reject` for a `Promise`
2304
- *
2305
- * @return {Number} An ID used to remove interceptor later
2306
- */
2307
- use(fulfilled, rejected, options) {
2308
- this.handlers.push({
2309
- fulfilled,
2310
- rejected,
2311
- synchronous: options ? options.synchronous : false,
2312
- runWhen: options ? options.runWhen : null
2313
- });
2314
- return this.handlers.length - 1;
2315
- }
2316
- /**
2317
- * Remove an interceptor from the stack
2318
- *
2319
- * @param {Number} id The ID that was returned by `use`
2320
- *
2321
- * @returns {void}
2322
- */
2323
- eject(id) {
2324
- if (this.handlers[id]) {
2325
- this.handlers[id] = null;
2326
- }
2327
- }
2328
- /**
2329
- * Clear all interceptors from the stack
2330
- *
2331
- * @returns {void}
2332
- */
2333
- clear() {
2334
- if (this.handlers) {
2335
- this.handlers = [];
2336
- }
2337
- }
2338
- /**
2339
- * Iterate over all the registered interceptors
2340
- *
2341
- * This method is particularly useful for skipping over any
2342
- * interceptors that may have become `null` calling `eject`.
2343
- *
2344
- * @param {Function} fn The function to call for each interceptor
2345
- *
2346
- * @returns {void}
2347
- */
2348
- forEach(fn) {
2349
- utils_default.forEach(this.handlers, function forEachHandler(h) {
2350
- if (h !== null) {
2351
- fn(h);
2352
- }
2353
- });
2354
- }
2355
- };
2356
- var InterceptorManager_default = InterceptorManager;
2357
-
2358
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/defaults/transitional.js
2359
- var transitional_default = {
2360
- silentJSONParsing: true,
2361
- forcedJSONParsing: true,
2362
- clarifyTimeoutError: false
2363
- };
2364
-
2365
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
2366
- var URLSearchParams_default = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams_default;
2367
-
2368
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/platform/browser/classes/FormData.js
2369
- var FormData_default = typeof FormData !== "undefined" ? FormData : null;
2370
-
2371
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/platform/browser/classes/Blob.js
2372
- var Blob_default = typeof Blob !== "undefined" ? Blob : null;
2373
-
2374
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/platform/browser/index.js
2375
- var browser_default = {
2376
- isBrowser: true,
2377
- classes: {
2378
- URLSearchParams: URLSearchParams_default,
2379
- FormData: FormData_default,
2380
- Blob: Blob_default
2381
- },
2382
- protocols: ["http", "https", "file", "blob", "url", "data"]
2383
- };
2384
-
2385
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/platform/common/utils.js
2386
- var utils_exports = {};
2387
- __export(utils_exports, {
2388
- hasBrowserEnv: () => hasBrowserEnv,
2389
- hasStandardBrowserEnv: () => hasStandardBrowserEnv,
2390
- hasStandardBrowserWebWorkerEnv: () => hasStandardBrowserWebWorkerEnv,
2391
- navigator: () => _navigator,
2392
- origin: () => origin
2393
- });
2394
- var hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
2395
- var _navigator = typeof navigator === "object" && navigator || void 0;
2396
- var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
2397
- var hasStandardBrowserWebWorkerEnv = (() => {
2398
- return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
2399
- self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
2400
- })();
2401
- var origin = hasBrowserEnv && window.location.href || "http://localhost";
2402
-
2403
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/platform/index.js
2404
- var platform_default = __spreadValues(__spreadValues({}, utils_exports), browser_default);
2405
-
2406
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/toURLEncodedForm.js
2407
- function toURLEncodedForm(data, options) {
2408
- return toFormData_default(data, new platform_default.classes.URLSearchParams(), __spreadValues({
2409
- visitor: function(value, key, path, helpers) {
2410
- if (platform_default.isNode && utils_default.isBuffer(value)) {
2411
- this.append(key, value.toString("base64"));
2412
- return false;
2413
- }
2414
- return helpers.defaultVisitor.apply(this, arguments);
2415
- }
2416
- }, options));
2417
- }
2418
-
2419
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/formDataToJSON.js
2420
- function parsePropPath(name) {
2421
- return utils_default.matchAll(/\w+|\[(\w*)]/g, name).map((match2) => {
2422
- return match2[0] === "[]" ? "" : match2[1] || match2[0];
2423
- });
2424
- }
2425
- function arrayToObject(arr) {
2426
- const obj = {};
2427
- const keys = Object.keys(arr);
2428
- let i;
2429
- const len = keys.length;
2430
- let key;
2431
- for (i = 0; i < len; i++) {
2432
- key = keys[i];
2433
- obj[key] = arr[key];
2434
- }
2435
- return obj;
2436
- }
2437
- function formDataToJSON(formData) {
2438
- function buildPath(path, value, target, index) {
2439
- let name = path[index++];
2440
- if (name === "__proto__") return true;
2441
- const isNumericKey = Number.isFinite(+name);
2442
- const isLast = index >= path.length;
2443
- name = !name && utils_default.isArray(target) ? target.length : name;
2444
- if (isLast) {
2445
- if (utils_default.hasOwnProp(target, name)) {
2446
- target[name] = [target[name], value];
2447
- } else {
2448
- target[name] = value;
2449
- }
2450
- return !isNumericKey;
2451
- }
2452
- if (!target[name] || !utils_default.isObject(target[name])) {
2453
- target[name] = [];
2454
- }
2455
- const result = buildPath(path, value, target[name], index);
2456
- if (result && utils_default.isArray(target[name])) {
2457
- target[name] = arrayToObject(target[name]);
2458
- }
2459
- return !isNumericKey;
2460
- }
2461
- if (utils_default.isFormData(formData) && utils_default.isFunction(formData.entries)) {
2462
- const obj = {};
2463
- utils_default.forEachEntry(formData, (name, value) => {
2464
- buildPath(parsePropPath(name), value, obj, 0);
2465
- });
2466
- return obj;
2467
- }
2468
- return null;
2469
- }
2470
- var formDataToJSON_default = formDataToJSON;
2471
-
2472
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/defaults/index.js
2473
- function stringifySafely(rawValue, parser, encoder) {
2474
- if (utils_default.isString(rawValue)) {
2475
- try {
2476
- (parser || JSON.parse)(rawValue);
2477
- return utils_default.trim(rawValue);
2478
- } catch (e) {
2479
- if (e.name !== "SyntaxError") {
2480
- throw e;
2481
- }
2482
- }
2483
- }
2484
- return (encoder || JSON.stringify)(rawValue);
2485
- }
2486
- var defaults = {
2487
- transitional: transitional_default,
2488
- adapter: ["xhr", "http", "fetch"],
2489
- transformRequest: [function transformRequest(data, headers) {
2490
- const contentType = headers.getContentType() || "";
2491
- const hasJSONContentType = contentType.indexOf("application/json") > -1;
2492
- const isObjectPayload = utils_default.isObject(data);
2493
- if (isObjectPayload && utils_default.isHTMLForm(data)) {
2494
- data = new FormData(data);
2495
- }
2496
- const isFormData2 = utils_default.isFormData(data);
2497
- if (isFormData2) {
2498
- return hasJSONContentType ? JSON.stringify(formDataToJSON_default(data)) : data;
2499
- }
2500
- if (utils_default.isArrayBuffer(data) || utils_default.isBuffer(data) || utils_default.isStream(data) || utils_default.isFile(data) || utils_default.isBlob(data) || utils_default.isReadableStream(data)) {
2501
- return data;
2502
- }
2503
- if (utils_default.isArrayBufferView(data)) {
2504
- return data.buffer;
2505
- }
2506
- if (utils_default.isURLSearchParams(data)) {
2507
- headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
2508
- return data.toString();
2509
- }
2510
- let isFileList2;
2511
- if (isObjectPayload) {
2512
- if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
2513
- return toURLEncodedForm(data, this.formSerializer).toString();
2514
- }
2515
- if ((isFileList2 = utils_default.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
2516
- const _FormData = this.env && this.env.FormData;
2517
- return toFormData_default(
2518
- isFileList2 ? { "files[]": data } : data,
2519
- _FormData && new _FormData(),
2520
- this.formSerializer
2521
- );
2522
- }
2523
- }
2524
- if (isObjectPayload || hasJSONContentType) {
2525
- headers.setContentType("application/json", false);
2526
- return stringifySafely(data);
2527
- }
2528
- return data;
2529
- }],
2530
- transformResponse: [function transformResponse(data) {
2531
- const transitional2 = this.transitional || defaults.transitional;
2532
- const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
2533
- const JSONRequested = this.responseType === "json";
2534
- if (utils_default.isResponse(data) || utils_default.isReadableStream(data)) {
2535
- return data;
2536
- }
2537
- if (data && utils_default.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
2538
- const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
2539
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
2540
- try {
2541
- return JSON.parse(data, this.parseReviver);
2542
- } catch (e) {
2543
- if (strictJSONParsing) {
2544
- if (e.name === "SyntaxError") {
2545
- throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_RESPONSE, this, null, this.response);
2546
- }
2547
- throw e;
2548
- }
2549
- }
2550
- }
2551
- return data;
2552
- }],
2553
- /**
2554
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
2555
- * timeout is not created.
2556
- */
2557
- timeout: 0,
2558
- xsrfCookieName: "XSRF-TOKEN",
2559
- xsrfHeaderName: "X-XSRF-TOKEN",
2560
- maxContentLength: -1,
2561
- maxBodyLength: -1,
2562
- env: {
2563
- FormData: platform_default.classes.FormData,
2564
- Blob: platform_default.classes.Blob
2565
- },
2566
- validateStatus: function validateStatus(status) {
2567
- return status >= 200 && status < 300;
2568
- },
2569
- headers: {
2570
- common: {
2571
- "Accept": "application/json, text/plain, */*",
2572
- "Content-Type": void 0
2573
- }
2574
- }
2575
- };
2576
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
2577
- defaults.headers[method] = {};
2578
- });
2579
- var defaults_default = defaults;
2580
-
2581
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/parseHeaders.js
2582
- var ignoreDuplicateOf = utils_default.toObjectSet([
2583
- "age",
2584
- "authorization",
2585
- "content-length",
2586
- "content-type",
2587
- "etag",
2588
- "expires",
2589
- "from",
2590
- "host",
2591
- "if-modified-since",
2592
- "if-unmodified-since",
2593
- "last-modified",
2594
- "location",
2595
- "max-forwards",
2596
- "proxy-authorization",
2597
- "referer",
2598
- "retry-after",
2599
- "user-agent"
2600
- ]);
2601
- var parseHeaders_default = (rawHeaders) => {
2602
- const parsed = {};
2603
- let key;
2604
- let val;
2605
- let i;
2606
- rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
2607
- i = line.indexOf(":");
2608
- key = line.substring(0, i).trim().toLowerCase();
2609
- val = line.substring(i + 1).trim();
2610
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
2611
- return;
2612
- }
2613
- if (key === "set-cookie") {
2614
- if (parsed[key]) {
2615
- parsed[key].push(val);
2616
- } else {
2617
- parsed[key] = [val];
2618
- }
2619
- } else {
2620
- parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
2621
- }
2622
- });
2623
- return parsed;
2624
- };
2625
-
2626
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/AxiosHeaders.js
2627
- var $internals = Symbol("internals");
2628
- function normalizeHeader(header) {
2629
- return header && String(header).trim().toLowerCase();
2630
- }
2631
- function normalizeValue(value) {
2632
- if (value === false || value == null) {
2633
- return value;
2634
- }
2635
- return utils_default.isArray(value) ? value.map(normalizeValue) : String(value);
2636
- }
2637
- function parseTokens(str) {
2638
- const tokens = /* @__PURE__ */ Object.create(null);
2639
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2640
- let match2;
2641
- while (match2 = tokensRE.exec(str)) {
2642
- tokens[match2[1]] = match2[2];
2643
- }
2644
- return tokens;
2645
- }
2646
- var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2647
- function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
2648
- if (utils_default.isFunction(filter2)) {
2649
- return filter2.call(this, value, header);
2650
- }
2651
- if (isHeaderNameFilter) {
2652
- value = header;
2653
- }
2654
- if (!utils_default.isString(value)) return;
2655
- if (utils_default.isString(filter2)) {
2656
- return value.indexOf(filter2) !== -1;
2657
- }
2658
- if (utils_default.isRegExp(filter2)) {
2659
- return filter2.test(value);
2660
- }
2661
- }
2662
- function formatHeader(header) {
2663
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2664
- return char.toUpperCase() + str;
2665
- });
2666
- }
2667
- function buildAccessors(obj, header) {
2668
- const accessorName = utils_default.toCamelCase(" " + header);
2669
- ["get", "set", "has"].forEach((methodName) => {
2670
- Object.defineProperty(obj, methodName + accessorName, {
2671
- value: function(arg1, arg2, arg3) {
2672
- return this[methodName].call(this, header, arg1, arg2, arg3);
2673
- },
2674
- configurable: true
2675
- });
2676
- });
2677
- }
2678
- var AxiosHeaders = class {
2679
- constructor(headers) {
2680
- headers && this.set(headers);
2681
- }
2682
- set(header, valueOrRewrite, rewrite) {
2683
- const self2 = this;
2684
- function setHeader(_value, _header, _rewrite) {
2685
- const lHeader = normalizeHeader(_header);
2686
- if (!lHeader) {
2687
- throw new Error("header name must be a non-empty string");
2688
- }
2689
- const key = utils_default.findKey(self2, lHeader);
2690
- if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
2691
- self2[key || _header] = normalizeValue(_value);
2692
- }
2693
- }
2694
- const setHeaders = (headers, _rewrite) => utils_default.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2695
- if (utils_default.isPlainObject(header) || header instanceof this.constructor) {
2696
- setHeaders(header, valueOrRewrite);
2697
- } else if (utils_default.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2698
- setHeaders(parseHeaders_default(header), valueOrRewrite);
2699
- } else if (utils_default.isObject(header) && utils_default.isIterable(header)) {
2700
- let obj = {}, dest, key;
2701
- for (const entry of header) {
2702
- if (!utils_default.isArray(entry)) {
2703
- throw TypeError("Object iterator must return a key-value pair");
2704
- }
2705
- obj[key = entry[0]] = (dest = obj[key]) ? utils_default.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
2706
- }
2707
- setHeaders(obj, valueOrRewrite);
2708
- } else {
2709
- header != null && setHeader(valueOrRewrite, header, rewrite);
2710
- }
2711
- return this;
2712
- }
2713
- get(header, parser) {
2714
- header = normalizeHeader(header);
2715
- if (header) {
2716
- const key = utils_default.findKey(this, header);
2717
- if (key) {
2718
- const value = this[key];
2719
- if (!parser) {
2720
- return value;
2721
- }
2722
- if (parser === true) {
2723
- return parseTokens(value);
2724
- }
2725
- if (utils_default.isFunction(parser)) {
2726
- return parser.call(this, value, key);
2727
- }
2728
- if (utils_default.isRegExp(parser)) {
2729
- return parser.exec(value);
2730
- }
2731
- throw new TypeError("parser must be boolean|regexp|function");
2732
- }
2733
- }
2734
- }
2735
- has(header, matcher) {
2736
- header = normalizeHeader(header);
2737
- if (header) {
2738
- const key = utils_default.findKey(this, header);
2739
- return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2740
- }
2741
- return false;
2742
- }
2743
- delete(header, matcher) {
2744
- const self2 = this;
2745
- let deleted = false;
2746
- function deleteHeader(_header) {
2747
- _header = normalizeHeader(_header);
2748
- if (_header) {
2749
- const key = utils_default.findKey(self2, _header);
2750
- if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
2751
- delete self2[key];
2752
- deleted = true;
2753
- }
2754
- }
2755
- }
2756
- if (utils_default.isArray(header)) {
2757
- header.forEach(deleteHeader);
2758
- } else {
2759
- deleteHeader(header);
2760
- }
2761
- return deleted;
2762
- }
2763
- clear(matcher) {
2764
- const keys = Object.keys(this);
2765
- let i = keys.length;
2766
- let deleted = false;
2767
- while (i--) {
2768
- const key = keys[i];
2769
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2770
- delete this[key];
2771
- deleted = true;
2772
- }
2773
- }
2774
- return deleted;
2775
- }
2776
- normalize(format) {
2777
- const self2 = this;
2778
- const headers = {};
2779
- utils_default.forEach(this, (value, header) => {
2780
- const key = utils_default.findKey(headers, header);
2781
- if (key) {
2782
- self2[key] = normalizeValue(value);
2783
- delete self2[header];
2784
- return;
2785
- }
2786
- const normalized = format ? formatHeader(header) : String(header).trim();
2787
- if (normalized !== header) {
2788
- delete self2[header];
2789
- }
2790
- self2[normalized] = normalizeValue(value);
2791
- headers[normalized] = true;
2792
- });
2793
- return this;
2794
- }
2795
- concat(...targets) {
2796
- return this.constructor.concat(this, ...targets);
2797
- }
2798
- toJSON(asStrings) {
2799
- const obj = /* @__PURE__ */ Object.create(null);
2800
- utils_default.forEach(this, (value, header) => {
2801
- value != null && value !== false && (obj[header] = asStrings && utils_default.isArray(value) ? value.join(", ") : value);
2802
- });
2803
- return obj;
2804
- }
2805
- [Symbol.iterator]() {
2806
- return Object.entries(this.toJSON())[Symbol.iterator]();
2807
- }
2808
- toString() {
2809
- return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
2810
- }
2811
- getSetCookie() {
2812
- return this.get("set-cookie") || [];
2813
- }
2814
- get [Symbol.toStringTag]() {
2815
- return "AxiosHeaders";
2816
- }
2817
- static from(thing) {
2818
- return thing instanceof this ? thing : new this(thing);
2819
- }
2820
- static concat(first, ...targets) {
2821
- const computed = new this(first);
2822
- targets.forEach((target) => computed.set(target));
2823
- return computed;
2824
- }
2825
- static accessor(header) {
2826
- const internals = this[$internals] = this[$internals] = {
2827
- accessors: {}
2828
- };
2829
- const accessors = internals.accessors;
2830
- const prototype3 = this.prototype;
2831
- function defineAccessor(_header) {
2832
- const lHeader = normalizeHeader(_header);
2833
- if (!accessors[lHeader]) {
2834
- buildAccessors(prototype3, _header);
2835
- accessors[lHeader] = true;
2836
- }
2837
- }
2838
- utils_default.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2839
- return this;
2840
- }
2841
- };
2842
- AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
2843
- utils_default.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
2844
- let mapped = key[0].toUpperCase() + key.slice(1);
2845
- return {
2846
- get: () => value,
2847
- set(headerValue) {
2848
- this[mapped] = headerValue;
2849
- }
2850
- };
2851
- });
2852
- utils_default.freezeMethods(AxiosHeaders);
2853
- var AxiosHeaders_default = AxiosHeaders;
2854
-
2855
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/transformData.js
2856
- function transformData(fns, response) {
2857
- const config = this || defaults_default;
2858
- const context = response || config;
2859
- const headers = AxiosHeaders_default.from(context.headers);
2860
- let data = context.data;
2861
- utils_default.forEach(fns, function transform(fn) {
2862
- data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
2863
- });
2864
- headers.normalize();
2865
- return data;
2866
- }
2867
-
2868
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/cancel/isCancel.js
2869
- function isCancel(value) {
2870
- return !!(value && value.__CANCEL__);
2871
- }
2872
-
2873
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/cancel/CanceledError.js
2874
- function CanceledError(message, config, request) {
2875
- AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config, request);
2876
- this.name = "CanceledError";
2877
- }
2878
- utils_default.inherits(CanceledError, AxiosError_default, {
2879
- __CANCEL__: true
2880
- });
2881
- var CanceledError_default = CanceledError;
2882
-
2883
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/settle.js
2884
- function settle(resolve, reject, response) {
2885
- const validateStatus2 = response.config.validateStatus;
2886
- if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
2887
- resolve(response);
2888
- } else {
2889
- reject(new AxiosError_default(
2890
- "Request failed with status code " + response.status,
2891
- [AxiosError_default.ERR_BAD_REQUEST, AxiosError_default.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2892
- response.config,
2893
- response.request,
2894
- response
2895
- ));
2896
- }
2897
- }
2898
-
2899
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/parseProtocol.js
2900
- function parseProtocol(url) {
2901
- const match2 = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2902
- return match2 && match2[1] || "";
2903
- }
2904
-
2905
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/speedometer.js
2906
- function speedometer(samplesCount, min) {
2907
- samplesCount = samplesCount || 10;
2908
- const bytes = new Array(samplesCount);
2909
- const timestamps = new Array(samplesCount);
2910
- let head = 0;
2911
- let tail = 0;
2912
- let firstSampleTS;
2913
- min = min !== void 0 ? min : 1e3;
2914
- return function push(chunkLength) {
2915
- const now = Date.now();
2916
- const startedAt = timestamps[tail];
2917
- if (!firstSampleTS) {
2918
- firstSampleTS = now;
2919
- }
2920
- bytes[head] = chunkLength;
2921
- timestamps[head] = now;
2922
- let i = tail;
2923
- let bytesCount = 0;
2924
- while (i !== head) {
2925
- bytesCount += bytes[i++];
2926
- i = i % samplesCount;
2927
- }
2928
- head = (head + 1) % samplesCount;
2929
- if (head === tail) {
2930
- tail = (tail + 1) % samplesCount;
2931
- }
2932
- if (now - firstSampleTS < min) {
2933
- return;
2934
- }
2935
- const passed = startedAt && now - startedAt;
2936
- return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
2937
- };
2938
- }
2939
- var speedometer_default = speedometer;
2940
-
2941
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/throttle.js
2942
- function throttle(fn, freq) {
2943
- let timestamp = 0;
2944
- let threshold = 1e3 / freq;
2945
- let lastArgs;
2946
- let timer;
2947
- const invoke = (args, now = Date.now()) => {
2948
- timestamp = now;
2949
- lastArgs = null;
2950
- if (timer) {
2951
- clearTimeout(timer);
2952
- timer = null;
2953
- }
2954
- fn(...args);
2955
- };
2956
- const throttled = (...args) => {
2957
- const now = Date.now();
2958
- const passed = now - timestamp;
2959
- if (passed >= threshold) {
2960
- invoke(args, now);
2961
- } else {
2962
- lastArgs = args;
2963
- if (!timer) {
2964
- timer = setTimeout(() => {
2965
- timer = null;
2966
- invoke(lastArgs);
2967
- }, threshold - passed);
2968
- }
2969
- }
2970
- };
2971
- const flush = () => lastArgs && invoke(lastArgs);
2972
- return [throttled, flush];
2973
- }
2974
- var throttle_default = throttle;
2975
-
2976
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/progressEventReducer.js
2977
- var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2978
- let bytesNotified = 0;
2979
- const _speedometer = speedometer_default(50, 250);
2980
- return throttle_default((e) => {
2981
- const loaded = e.loaded;
2982
- const total = e.lengthComputable ? e.total : void 0;
2983
- const progressBytes = loaded - bytesNotified;
2984
- const rate = _speedometer(progressBytes);
2985
- const inRange = loaded <= total;
2986
- bytesNotified = loaded;
2987
- const data = {
2988
- loaded,
2989
- total,
2990
- progress: total ? loaded / total : void 0,
2991
- bytes: progressBytes,
2992
- rate: rate ? rate : void 0,
2993
- estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
2994
- event: e,
2995
- lengthComputable: total != null,
2996
- [isDownloadStream ? "download" : "upload"]: true
2997
- };
2998
- listener(data);
2999
- }, freq);
3000
- };
3001
- var progressEventDecorator = (total, throttled) => {
3002
- const lengthComputable = total != null;
3003
- return [(loaded) => throttled[0]({
3004
- lengthComputable,
3005
- total,
3006
- loaded
3007
- }), throttled[1]];
3008
- };
3009
- var asyncDecorator = (fn) => (...args) => utils_default.asap(() => fn(...args));
3010
-
3011
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/isURLSameOrigin.js
3012
- var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
3013
- url = new URL(url, platform_default.origin);
3014
- return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
3015
- })(
3016
- new URL(platform_default.origin),
3017
- platform_default.navigator && /(msie|trident)/i.test(platform_default.navigator.userAgent)
3018
- ) : () => true;
3019
-
3020
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/cookies.js
3021
- var cookies_default = platform_default.hasStandardBrowserEnv ? (
3022
- // Standard browser envs support document.cookie
3023
- {
3024
- write(name, value, expires, path, domain, secure, sameSite) {
3025
- if (typeof document === "undefined") return;
3026
- const cookie = ["".concat(name, "=").concat(encodeURIComponent(value))];
3027
- if (utils_default.isNumber(expires)) {
3028
- cookie.push("expires=".concat(new Date(expires).toUTCString()));
3029
- }
3030
- if (utils_default.isString(path)) {
3031
- cookie.push("path=".concat(path));
3032
- }
3033
- if (utils_default.isString(domain)) {
3034
- cookie.push("domain=".concat(domain));
3035
- }
3036
- if (secure === true) {
3037
- cookie.push("secure");
3038
- }
3039
- if (utils_default.isString(sameSite)) {
3040
- cookie.push("SameSite=".concat(sameSite));
3041
- }
3042
- document.cookie = cookie.join("; ");
3043
- },
3044
- read(name) {
3045
- if (typeof document === "undefined") return null;
3046
- const match2 = document.cookie.match(new RegExp("(?:^|; )" + name + "=([^;]*)"));
3047
- return match2 ? decodeURIComponent(match2[1]) : null;
3048
- },
3049
- remove(name) {
3050
- this.write(name, "", Date.now() - 864e5, "/");
3051
- }
3052
- }
3053
- ) : (
3054
- // Non-standard browser env (web workers, react-native) lack needed support.
3055
- {
3056
- write() {
3057
- },
3058
- read() {
3059
- return null;
3060
- },
3061
- remove() {
3062
- }
3063
- }
3064
- );
3065
-
3066
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/isAbsoluteURL.js
3067
- function isAbsoluteURL(url) {
3068
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
3069
- }
3070
-
3071
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/combineURLs.js
3072
- function combineURLs(baseURL, relativeURL) {
3073
- return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
3074
- }
3075
-
3076
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/buildFullPath.js
3077
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
3078
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
3079
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
3080
- return combineURLs(baseURL, requestedURL);
3081
- }
3082
- return requestedURL;
3083
- }
3084
-
3085
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/mergeConfig.js
3086
- var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? __spreadValues({}, thing) : thing;
3087
- function mergeConfig(config1, config2) {
3088
- config2 = config2 || {};
3089
- const config = {};
3090
- function getMergedValue(target, source, prop, caseless) {
3091
- if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
3092
- return utils_default.merge.call({ caseless }, target, source);
3093
- } else if (utils_default.isPlainObject(source)) {
3094
- return utils_default.merge({}, source);
3095
- } else if (utils_default.isArray(source)) {
3096
- return source.slice();
3097
- }
3098
- return source;
3099
- }
3100
- function mergeDeepProperties(a, b, prop, caseless) {
3101
- if (!utils_default.isUndefined(b)) {
3102
- return getMergedValue(a, b, prop, caseless);
3103
- } else if (!utils_default.isUndefined(a)) {
3104
- return getMergedValue(void 0, a, prop, caseless);
3105
- }
3106
- }
3107
- function valueFromConfig2(a, b) {
3108
- if (!utils_default.isUndefined(b)) {
3109
- return getMergedValue(void 0, b);
3110
- }
3111
- }
3112
- function defaultToConfig2(a, b) {
3113
- if (!utils_default.isUndefined(b)) {
3114
- return getMergedValue(void 0, b);
3115
- } else if (!utils_default.isUndefined(a)) {
3116
- return getMergedValue(void 0, a);
3117
- }
3118
- }
3119
- function mergeDirectKeys(a, b, prop) {
3120
- if (prop in config2) {
3121
- return getMergedValue(a, b);
3122
- } else if (prop in config1) {
3123
- return getMergedValue(void 0, a);
3124
- }
3125
- }
3126
- const mergeMap = {
3127
- url: valueFromConfig2,
3128
- method: valueFromConfig2,
3129
- data: valueFromConfig2,
3130
- baseURL: defaultToConfig2,
3131
- transformRequest: defaultToConfig2,
3132
- transformResponse: defaultToConfig2,
3133
- paramsSerializer: defaultToConfig2,
3134
- timeout: defaultToConfig2,
3135
- timeoutMessage: defaultToConfig2,
3136
- withCredentials: defaultToConfig2,
3137
- withXSRFToken: defaultToConfig2,
3138
- adapter: defaultToConfig2,
3139
- responseType: defaultToConfig2,
3140
- xsrfCookieName: defaultToConfig2,
3141
- xsrfHeaderName: defaultToConfig2,
3142
- onUploadProgress: defaultToConfig2,
3143
- onDownloadProgress: defaultToConfig2,
3144
- decompress: defaultToConfig2,
3145
- maxContentLength: defaultToConfig2,
3146
- maxBodyLength: defaultToConfig2,
3147
- beforeRedirect: defaultToConfig2,
3148
- transport: defaultToConfig2,
3149
- httpAgent: defaultToConfig2,
3150
- httpsAgent: defaultToConfig2,
3151
- cancelToken: defaultToConfig2,
3152
- socketPath: defaultToConfig2,
3153
- responseEncoding: defaultToConfig2,
3154
- validateStatus: mergeDirectKeys,
3155
- headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
3156
- };
3157
- utils_default.forEach(Object.keys(__spreadValues(__spreadValues({}, config1), config2)), function computeConfigValue(prop) {
3158
- const merge2 = mergeMap[prop] || mergeDeepProperties;
3159
- const configValue = merge2(config1[prop], config2[prop], prop);
3160
- utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
3161
- });
3162
- return config;
3163
- }
3164
-
3165
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/resolveConfig.js
3166
- var resolveConfig_default = (config) => {
3167
- const newConfig = mergeConfig({}, config);
3168
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3169
- newConfig.headers = headers = AxiosHeaders_default.from(headers);
3170
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
3171
- if (auth) {
3172
- headers.set(
3173
- "Authorization",
3174
- "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
3175
- );
3176
- }
3177
- if (utils_default.isFormData(data)) {
3178
- if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv) {
3179
- headers.setContentType(void 0);
3180
- } else if (utils_default.isFunction(data.getHeaders)) {
3181
- const formHeaders = data.getHeaders();
3182
- const allowedHeaders = ["content-type", "content-length"];
3183
- Object.entries(formHeaders).forEach(([key, val]) => {
3184
- if (allowedHeaders.includes(key.toLowerCase())) {
3185
- headers.set(key, val);
3186
- }
3187
- });
3188
- }
3189
- }
3190
- if (platform_default.hasStandardBrowserEnv) {
3191
- withXSRFToken && utils_default.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3192
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin_default(newConfig.url)) {
3193
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies_default.read(xsrfCookieName);
3194
- if (xsrfValue) {
3195
- headers.set(xsrfHeaderName, xsrfValue);
3196
- }
3197
- }
3198
- }
3199
- return newConfig;
3200
- };
3201
-
3202
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/adapters/xhr.js
3203
- var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
3204
- var xhr_default = isXHRAdapterSupported && function(config) {
3205
- return new Promise(function dispatchXhrRequest(resolve, reject) {
3206
- const _config = resolveConfig_default(config);
3207
- let requestData = _config.data;
3208
- const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
3209
- let { responseType, onUploadProgress, onDownloadProgress } = _config;
3210
- let onCanceled;
3211
- let uploadThrottled, downloadThrottled;
3212
- let flushUpload, flushDownload;
3213
- function done() {
3214
- flushUpload && flushUpload();
3215
- flushDownload && flushDownload();
3216
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
3217
- _config.signal && _config.signal.removeEventListener("abort", onCanceled);
3218
- }
3219
- let request = new XMLHttpRequest();
3220
- request.open(_config.method.toUpperCase(), _config.url, true);
3221
- request.timeout = _config.timeout;
3222
- function onloadend() {
3223
- if (!request) {
3224
- return;
3225
- }
3226
- const responseHeaders = AxiosHeaders_default.from(
3227
- "getAllResponseHeaders" in request && request.getAllResponseHeaders()
3228
- );
3229
- const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
3230
- const response = {
3231
- data: responseData,
3232
- status: request.status,
3233
- statusText: request.statusText,
3234
- headers: responseHeaders,
3235
- config,
3236
- request
3237
- };
3238
- settle(function _resolve(value) {
3239
- resolve(value);
3240
- done();
3241
- }, function _reject(err) {
3242
- reject(err);
3243
- done();
3244
- }, response);
3245
- request = null;
3246
- }
3247
- if ("onloadend" in request) {
3248
- request.onloadend = onloadend;
3249
- } else {
3250
- request.onreadystatechange = function handleLoad() {
3251
- if (!request || request.readyState !== 4) {
3252
- return;
3253
- }
3254
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
3255
- return;
3256
- }
3257
- setTimeout(onloadend);
3258
- };
3259
- }
3260
- request.onabort = function handleAbort() {
3261
- if (!request) {
3262
- return;
3263
- }
3264
- reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
3265
- request = null;
3266
- };
3267
- request.onerror = function handleError(event) {
3268
- const msg = event && event.message ? event.message : "Network Error";
3269
- const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK, config, request);
3270
- err.event = event || null;
3271
- reject(err);
3272
- request = null;
3273
- };
3274
- request.ontimeout = function handleTimeout() {
3275
- let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
3276
- const transitional2 = _config.transitional || transitional_default;
3277
- if (_config.timeoutErrorMessage) {
3278
- timeoutErrorMessage = _config.timeoutErrorMessage;
3279
- }
3280
- reject(new AxiosError_default(
3281
- timeoutErrorMessage,
3282
- transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
3283
- config,
3284
- request
3285
- ));
3286
- request = null;
3287
- };
3288
- requestData === void 0 && requestHeaders.setContentType(null);
3289
- if ("setRequestHeader" in request) {
3290
- utils_default.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3291
- request.setRequestHeader(key, val);
3292
- });
3293
- }
3294
- if (!utils_default.isUndefined(_config.withCredentials)) {
3295
- request.withCredentials = !!_config.withCredentials;
3296
- }
3297
- if (responseType && responseType !== "json") {
3298
- request.responseType = _config.responseType;
3299
- }
3300
- if (onDownloadProgress) {
3301
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
3302
- request.addEventListener("progress", downloadThrottled);
3303
- }
3304
- if (onUploadProgress && request.upload) {
3305
- [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
3306
- request.upload.addEventListener("progress", uploadThrottled);
3307
- request.upload.addEventListener("loadend", flushUpload);
3308
- }
3309
- if (_config.cancelToken || _config.signal) {
3310
- onCanceled = (cancel) => {
3311
- if (!request) {
3312
- return;
3313
- }
3314
- reject(!cancel || cancel.type ? new CanceledError_default(null, config, request) : cancel);
3315
- request.abort();
3316
- request = null;
3317
- };
3318
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3319
- if (_config.signal) {
3320
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
3321
- }
3322
- }
3323
- const protocol = parseProtocol(_config.url);
3324
- if (protocol && platform_default.protocols.indexOf(protocol) === -1) {
3325
- reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST, config));
3326
- return;
3327
- }
3328
- request.send(requestData || null);
3329
- });
3330
- };
3331
-
3332
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/composeSignals.js
3333
- var composeSignals = (signals, timeout) => {
3334
- const { length } = signals = signals ? signals.filter(Boolean) : [];
3335
- if (timeout || length) {
3336
- let controller = new AbortController();
3337
- let aborted;
3338
- const onabort = function(reason) {
3339
- if (!aborted) {
3340
- aborted = true;
3341
- unsubscribe();
3342
- const err = reason instanceof Error ? reason : this.reason;
3343
- controller.abort(err instanceof AxiosError_default ? err : new CanceledError_default(err instanceof Error ? err.message : err));
3344
- }
3345
- };
3346
- let timer = timeout && setTimeout(() => {
3347
- timer = null;
3348
- onabort(new AxiosError_default("timeout ".concat(timeout, " of ms exceeded"), AxiosError_default.ETIMEDOUT));
3349
- }, timeout);
3350
- const unsubscribe = () => {
3351
- if (signals) {
3352
- timer && clearTimeout(timer);
3353
- timer = null;
3354
- signals.forEach((signal2) => {
3355
- signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
3356
- });
3357
- signals = null;
3358
- }
3359
- };
3360
- signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
3361
- const { signal } = controller;
3362
- signal.unsubscribe = () => utils_default.asap(unsubscribe);
3363
- return signal;
3364
- }
3365
- };
3366
- var composeSignals_default = composeSignals;
3367
-
3368
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/trackStream.js
3369
- var streamChunk = function* (chunk, chunkSize) {
3370
- let len = chunk.byteLength;
3371
- if (!chunkSize || len < chunkSize) {
3372
- yield chunk;
3373
- return;
3374
- }
3375
- let pos = 0;
3376
- let end;
3377
- while (pos < len) {
3378
- end = pos + chunkSize;
3379
- yield chunk.slice(pos, end);
3380
- pos = end;
3381
- }
3382
- };
3383
- var readBytes = function(iterable, chunkSize) {
3384
- return __asyncGenerator(this, null, function* () {
3385
- try {
3386
- for (var iter = __forAwait(readStream(iterable)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
3387
- const chunk = temp.value;
3388
- yield* __yieldStar(streamChunk(chunk, chunkSize));
3389
- }
3390
- } catch (temp) {
3391
- error = [temp];
3392
- } finally {
3393
- try {
3394
- more && (temp = iter.return) && (yield new __await(temp.call(iter)));
3395
- } finally {
3396
- if (error)
3397
- throw error[0];
3398
- }
3399
- }
3400
- });
3401
- };
3402
- var readStream = function(stream) {
3403
- return __asyncGenerator(this, null, function* () {
3404
- if (stream[Symbol.asyncIterator]) {
3405
- yield* __yieldStar(stream);
3406
- return;
3407
- }
3408
- const reader = stream.getReader();
3409
- try {
3410
- for (; ; ) {
3411
- const { done, value } = yield new __await(reader.read());
3412
- if (done) {
3413
- break;
3414
- }
3415
- yield value;
3416
- }
3417
- } finally {
3418
- yield new __await(reader.cancel());
3419
- }
3420
- });
3421
- };
3422
- var trackStream = (stream, chunkSize, onProgress, onFinish) => {
3423
- const iterator2 = readBytes(stream, chunkSize);
3424
- let bytes = 0;
3425
- let done;
3426
- let _onFinish = (e) => {
3427
- if (!done) {
3428
- done = true;
3429
- onFinish && onFinish(e);
3430
- }
3431
- };
3432
- return new ReadableStream({
3433
- async pull(controller) {
3434
- try {
3435
- const { done: done2, value } = await iterator2.next();
3436
- if (done2) {
3437
- _onFinish();
3438
- controller.close();
3439
- return;
3440
- }
3441
- let len = value.byteLength;
3442
- if (onProgress) {
3443
- let loadedBytes = bytes += len;
3444
- onProgress(loadedBytes);
3445
- }
3446
- controller.enqueue(new Uint8Array(value));
3447
- } catch (err) {
3448
- _onFinish(err);
3449
- throw err;
3450
- }
3451
- },
3452
- cancel(reason) {
3453
- _onFinish(reason);
3454
- return iterator2.return();
3455
- }
3456
- }, {
3457
- highWaterMark: 2
3458
- });
3459
- };
3460
-
3461
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/adapters/fetch.js
3462
- var DEFAULT_CHUNK_SIZE = 64 * 1024;
3463
- var { isFunction: isFunction2 } = utils_default;
3464
- var globalFetchAPI = (({ Request, Response }) => ({
3465
- Request,
3466
- Response
3467
- }))(utils_default.global);
3468
- var {
3469
- ReadableStream: ReadableStream2,
3470
- TextEncoder
3471
- } = utils_default.global;
3472
- var test = (fn, ...args) => {
3473
- try {
3474
- return !!fn(...args);
3475
- } catch (e) {
3476
- return false;
3477
- }
3478
- };
3479
- var factory = (env) => {
3480
- env = utils_default.merge.call({
3481
- skipUndefined: true
3482
- }, globalFetchAPI, env);
3483
- const { fetch: envFetch, Request, Response } = env;
3484
- const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
3485
- const isRequestSupported = isFunction2(Request);
3486
- const isResponseSupported = isFunction2(Response);
3487
- if (!isFetchSupported) {
3488
- return false;
3489
- }
3490
- const isReadableStreamSupported = isFetchSupported && isFunction2(ReadableStream2);
3491
- const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
3492
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3493
- let duplexAccessed = false;
3494
- const hasContentType = new Request(platform_default.origin, {
3495
- body: new ReadableStream2(),
3496
- method: "POST",
3497
- get duplex() {
3498
- duplexAccessed = true;
3499
- return "half";
3500
- }
3501
- }).headers.has("Content-Type");
3502
- return duplexAccessed && !hasContentType;
3503
- });
3504
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
3505
- const resolvers = {
3506
- stream: supportsResponseStream && ((res) => res.body)
3507
- };
3508
- isFetchSupported && (() => {
3509
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
3510
- !resolvers[type] && (resolvers[type] = (res, config) => {
3511
- let method = res && res[type];
3512
- if (method) {
3513
- return method.call(res);
3514
- }
3515
- throw new AxiosError_default("Response type '".concat(type, "' is not supported"), AxiosError_default.ERR_NOT_SUPPORT, config);
3516
- });
3517
- });
3518
- })();
3519
- const getBodyLength = async (body) => {
3520
- if (body == null) {
3521
- return 0;
3522
- }
3523
- if (utils_default.isBlob(body)) {
3524
- return body.size;
3525
- }
3526
- if (utils_default.isSpecCompliantForm(body)) {
3527
- const _request = new Request(platform_default.origin, {
3528
- method: "POST",
3529
- body
3530
- });
3531
- return (await _request.arrayBuffer()).byteLength;
3532
- }
3533
- if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
3534
- return body.byteLength;
3535
- }
3536
- if (utils_default.isURLSearchParams(body)) {
3537
- body = body + "";
3538
- }
3539
- if (utils_default.isString(body)) {
3540
- return (await encodeText(body)).byteLength;
3541
- }
3542
- };
3543
- const resolveBodyLength = async (headers, body) => {
3544
- const length = utils_default.toFiniteNumber(headers.getContentLength());
3545
- return length == null ? getBodyLength(body) : length;
3546
- };
3547
- return async (config) => {
3548
- let {
3549
- url,
3550
- method,
3551
- data,
3552
- signal,
3553
- cancelToken,
3554
- timeout,
3555
- onDownloadProgress,
3556
- onUploadProgress,
3557
- responseType,
3558
- headers,
3559
- withCredentials = "same-origin",
3560
- fetchOptions
3561
- } = resolveConfig_default(config);
3562
- let _fetch = envFetch || fetch;
3563
- responseType = responseType ? (responseType + "").toLowerCase() : "text";
3564
- let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3565
- let request = null;
3566
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3567
- composedSignal.unsubscribe();
3568
- });
3569
- let requestContentLength;
3570
- try {
3571
- if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
3572
- let _request = new Request(url, {
3573
- method: "POST",
3574
- body: data,
3575
- duplex: "half"
3576
- });
3577
- let contentTypeHeader;
3578
- if (utils_default.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
3579
- headers.setContentType(contentTypeHeader);
3580
- }
3581
- if (_request.body) {
3582
- const [onProgress, flush] = progressEventDecorator(
3583
- requestContentLength,
3584
- progressEventReducer(asyncDecorator(onUploadProgress))
3585
- );
3586
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3587
- }
3588
- }
3589
- if (!utils_default.isString(withCredentials)) {
3590
- withCredentials = withCredentials ? "include" : "omit";
3591
- }
3592
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3593
- const resolvedOptions = __spreadProps(__spreadValues({}, fetchOptions), {
3594
- signal: composedSignal,
3595
- method: method.toUpperCase(),
3596
- headers: headers.normalize().toJSON(),
3597
- body: data,
3598
- duplex: "half",
3599
- credentials: isCredentialsSupported ? withCredentials : void 0
3600
- });
3601
- request = isRequestSupported && new Request(url, resolvedOptions);
3602
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
3603
- const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
3604
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
3605
- const options = {};
3606
- ["status", "statusText", "headers"].forEach((prop) => {
3607
- options[prop] = response[prop];
3608
- });
3609
- const responseContentLength = utils_default.toFiniteNumber(response.headers.get("content-length"));
3610
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3611
- responseContentLength,
3612
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
3613
- ) || [];
3614
- response = new Response(
3615
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3616
- flush && flush();
3617
- unsubscribe && unsubscribe();
3618
- }),
3619
- options
3620
- );
3621
- }
3622
- responseType = responseType || "text";
3623
- let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
3624
- !isStreamResponse && unsubscribe && unsubscribe();
3625
- return await new Promise((resolve, reject) => {
3626
- settle(resolve, reject, {
3627
- data: responseData,
3628
- headers: AxiosHeaders_default.from(response.headers),
3629
- status: response.status,
3630
- statusText: response.statusText,
3631
- config,
3632
- request
3633
- });
3634
- });
3635
- } catch (err) {
3636
- unsubscribe && unsubscribe();
3637
- if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
3638
- throw Object.assign(
3639
- new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request),
3640
- {
3641
- cause: err.cause || err
3642
- }
3643
- );
3644
- }
3645
- throw AxiosError_default.from(err, err && err.code, config, request);
3646
- }
3647
- };
3648
- };
3649
- var seedCache = /* @__PURE__ */ new Map();
3650
- var getFetch = (config) => {
3651
- let env = config && config.env || {};
3652
- const { fetch: fetch2, Request, Response } = env;
3653
- const seeds = [
3654
- Request,
3655
- Response,
3656
- fetch2
3657
- ];
3658
- let len = seeds.length, i = len, seed, target, map = seedCache;
3659
- while (i--) {
3660
- seed = seeds[i];
3661
- target = map.get(seed);
3662
- target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
3663
- map = target;
3664
- }
3665
- return target;
3666
- };
3667
- var adapter = getFetch();
3668
-
3669
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/adapters/adapters.js
3670
- var knownAdapters = {
3671
- http: null_default,
3672
- xhr: xhr_default,
3673
- fetch: {
3674
- get: getFetch
3675
- }
3676
- };
3677
- utils_default.forEach(knownAdapters, (fn, value) => {
3678
- if (fn) {
3679
- try {
3680
- Object.defineProperty(fn, "name", { value });
3681
- } catch (e) {
3682
- }
3683
- Object.defineProperty(fn, "adapterName", { value });
3684
- }
3685
- });
3686
- var renderReason = (reason) => "- ".concat(reason);
3687
- var isResolvedHandle = (adapter2) => utils_default.isFunction(adapter2) || adapter2 === null || adapter2 === false;
3688
- function getAdapter(adapters, config) {
3689
- adapters = utils_default.isArray(adapters) ? adapters : [adapters];
3690
- const { length } = adapters;
3691
- let nameOrAdapter;
3692
- let adapter2;
3693
- const rejectedReasons = {};
3694
- for (let i = 0; i < length; i++) {
3695
- nameOrAdapter = adapters[i];
3696
- let id;
3697
- adapter2 = nameOrAdapter;
3698
- if (!isResolvedHandle(nameOrAdapter)) {
3699
- adapter2 = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3700
- if (adapter2 === void 0) {
3701
- throw new AxiosError_default("Unknown adapter '".concat(id, "'"));
3702
- }
3703
- }
3704
- if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(config)))) {
3705
- break;
3706
- }
3707
- rejectedReasons[id || "#" + i] = adapter2;
3708
- }
3709
- if (!adapter2) {
3710
- const reasons = Object.entries(rejectedReasons).map(
3711
- ([id, state]) => "adapter ".concat(id, " ") + (state === false ? "is not supported by the environment" : "is not available in the build")
3712
- );
3713
- let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
3714
- throw new AxiosError_default(
3715
- "There is no suitable adapter to dispatch the request " + s,
3716
- "ERR_NOT_SUPPORT"
3717
- );
3718
- }
3719
- return adapter2;
3720
- }
3721
- var adapters_default = {
3722
- /**
3723
- * Resolve an adapter from a list of adapter names or functions.
3724
- * @type {Function}
3725
- */
3726
- getAdapter,
3727
- /**
3728
- * Exposes all known adapters
3729
- * @type {Object<string, Function|Object>}
3730
- */
3731
- adapters: knownAdapters
3732
- };
3733
-
3734
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/dispatchRequest.js
3735
- function throwIfCancellationRequested(config) {
3736
- if (config.cancelToken) {
3737
- config.cancelToken.throwIfRequested();
3738
- }
3739
- if (config.signal && config.signal.aborted) {
3740
- throw new CanceledError_default(null, config);
3741
- }
3742
- }
3743
- function dispatchRequest(config) {
3744
- throwIfCancellationRequested(config);
3745
- config.headers = AxiosHeaders_default.from(config.headers);
3746
- config.data = transformData.call(
3747
- config,
3748
- config.transformRequest
3749
- );
3750
- if (["post", "put", "patch"].indexOf(config.method) !== -1) {
3751
- config.headers.setContentType("application/x-www-form-urlencoded", false);
3752
- }
3753
- const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
3754
- return adapter2(config).then(function onAdapterResolution(response) {
3755
- throwIfCancellationRequested(config);
3756
- response.data = transformData.call(
3757
- config,
3758
- config.transformResponse,
3759
- response
3760
- );
3761
- response.headers = AxiosHeaders_default.from(response.headers);
3762
- return response;
3763
- }, function onAdapterRejection(reason) {
3764
- if (!isCancel(reason)) {
3765
- throwIfCancellationRequested(config);
3766
- if (reason && reason.response) {
3767
- reason.response.data = transformData.call(
3768
- config,
3769
- config.transformResponse,
3770
- reason.response
3771
- );
3772
- reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
3773
- }
3774
- }
3775
- return Promise.reject(reason);
3776
- });
3777
- }
3778
-
3779
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/env/data.js
3780
- var VERSION = "1.13.2";
3781
-
3782
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/validator.js
3783
- var validators = {};
3784
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
3785
- validators[type] = function validator(thing) {
3786
- return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
3787
- };
3788
- });
3789
- var deprecatedWarnings = {};
3790
- validators.transitional = function transitional(validator, version, message) {
3791
- function formatMessage(opt, desc) {
3792
- return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
3793
- }
3794
- return (value, opt, opts) => {
3795
- if (validator === false) {
3796
- throw new AxiosError_default(
3797
- formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
3798
- AxiosError_default.ERR_DEPRECATED
3799
- );
3800
- }
3801
- if (version && !deprecatedWarnings[opt]) {
3802
- deprecatedWarnings[opt] = true;
3803
- console.warn(
3804
- formatMessage(
3805
- opt,
3806
- " has been deprecated since v" + version + " and will be removed in the near future"
3807
- )
3808
- );
3809
- }
3810
- return validator ? validator(value, opt, opts) : true;
3811
- };
3812
- };
3813
- validators.spelling = function spelling(correctSpelling) {
3814
- return (value, opt) => {
3815
- console.warn("".concat(opt, " is likely a misspelling of ").concat(correctSpelling));
3816
- return true;
3817
- };
3818
- };
3819
- function assertOptions(options, schema, allowUnknown) {
3820
- if (typeof options !== "object") {
3821
- throw new AxiosError_default("options must be an object", AxiosError_default.ERR_BAD_OPTION_VALUE);
3822
- }
3823
- const keys = Object.keys(options);
3824
- let i = keys.length;
3825
- while (i-- > 0) {
3826
- const opt = keys[i];
3827
- const validator = schema[opt];
3828
- if (validator) {
3829
- const value = options[opt];
3830
- const result = value === void 0 || validator(value, opt, options);
3831
- if (result !== true) {
3832
- throw new AxiosError_default("option " + opt + " must be " + result, AxiosError_default.ERR_BAD_OPTION_VALUE);
3833
- }
3834
- continue;
3835
- }
3836
- if (allowUnknown !== true) {
3837
- throw new AxiosError_default("Unknown option " + opt, AxiosError_default.ERR_BAD_OPTION);
3838
- }
3839
- }
3840
- }
3841
- var validator_default = {
3842
- assertOptions,
3843
- validators
3844
- };
3845
-
3846
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/Axios.js
3847
- var validators2 = validator_default.validators;
3848
- var Axios = class {
3849
- constructor(instanceConfig) {
3850
- this.defaults = instanceConfig || {};
3851
- this.interceptors = {
3852
- request: new InterceptorManager_default(),
3853
- response: new InterceptorManager_default()
3854
- };
3855
- }
3856
- /**
3857
- * Dispatch a request
3858
- *
3859
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3860
- * @param {?Object} config
3861
- *
3862
- * @returns {Promise} The Promise to be fulfilled
3863
- */
3864
- async request(configOrUrl, config) {
3865
- try {
3866
- return await this._request(configOrUrl, config);
3867
- } catch (err) {
3868
- if (err instanceof Error) {
3869
- let dummy = {};
3870
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
3871
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
3872
- try {
3873
- if (!err.stack) {
3874
- err.stack = stack;
3875
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
3876
- err.stack += "\n" + stack;
3877
- }
3878
- } catch (e) {
3879
- }
3880
- }
3881
- throw err;
3882
- }
3883
- }
3884
- _request(configOrUrl, config) {
3885
- if (typeof configOrUrl === "string") {
3886
- config = config || {};
3887
- config.url = configOrUrl;
3888
- } else {
3889
- config = configOrUrl || {};
3890
- }
3891
- config = mergeConfig(this.defaults, config);
3892
- const { transitional: transitional2, paramsSerializer, headers } = config;
3893
- if (transitional2 !== void 0) {
3894
- validator_default.assertOptions(transitional2, {
3895
- silentJSONParsing: validators2.transitional(validators2.boolean),
3896
- forcedJSONParsing: validators2.transitional(validators2.boolean),
3897
- clarifyTimeoutError: validators2.transitional(validators2.boolean)
3898
- }, false);
3899
- }
3900
- if (paramsSerializer != null) {
3901
- if (utils_default.isFunction(paramsSerializer)) {
3902
- config.paramsSerializer = {
3903
- serialize: paramsSerializer
3904
- };
3905
- } else {
3906
- validator_default.assertOptions(paramsSerializer, {
3907
- encode: validators2.function,
3908
- serialize: validators2.function
3909
- }, true);
3910
- }
3911
- }
3912
- if (config.allowAbsoluteUrls !== void 0) {
3913
- } else if (this.defaults.allowAbsoluteUrls !== void 0) {
3914
- config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3915
- } else {
3916
- config.allowAbsoluteUrls = true;
3917
- }
3918
- validator_default.assertOptions(config, {
3919
- baseUrl: validators2.spelling("baseURL"),
3920
- withXsrfToken: validators2.spelling("withXSRFToken")
3921
- }, true);
3922
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
3923
- let contextHeaders = headers && utils_default.merge(
3924
- headers.common,
3925
- headers[config.method]
3926
- );
3927
- headers && utils_default.forEach(
3928
- ["delete", "get", "head", "post", "put", "patch", "common"],
3929
- (method) => {
3930
- delete headers[method];
3931
- }
3932
- );
3933
- config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
3934
- const requestInterceptorChain = [];
3935
- let synchronousRequestInterceptors = true;
3936
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3937
- if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
3938
- return;
3939
- }
3940
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3941
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3942
- });
3943
- const responseInterceptorChain = [];
3944
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3945
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3946
- });
3947
- let promise;
3948
- let i = 0;
3949
- let len;
3950
- if (!synchronousRequestInterceptors) {
3951
- const chain = [dispatchRequest.bind(this), void 0];
3952
- chain.unshift(...requestInterceptorChain);
3953
- chain.push(...responseInterceptorChain);
3954
- len = chain.length;
3955
- promise = Promise.resolve(config);
3956
- while (i < len) {
3957
- promise = promise.then(chain[i++], chain[i++]);
3958
- }
3959
- return promise;
3960
- }
3961
- len = requestInterceptorChain.length;
3962
- let newConfig = config;
3963
- while (i < len) {
3964
- const onFulfilled = requestInterceptorChain[i++];
3965
- const onRejected = requestInterceptorChain[i++];
3966
- try {
3967
- newConfig = onFulfilled(newConfig);
3968
- } catch (error) {
3969
- onRejected.call(this, error);
3970
- break;
3971
- }
3972
- }
3973
- try {
3974
- promise = dispatchRequest.call(this, newConfig);
3975
- } catch (error) {
3976
- return Promise.reject(error);
3977
- }
3978
- i = 0;
3979
- len = responseInterceptorChain.length;
3980
- while (i < len) {
3981
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3982
- }
3983
- return promise;
3984
- }
3985
- getUri(config) {
3986
- config = mergeConfig(this.defaults, config);
3987
- const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
3988
- return buildURL(fullPath, config.params, config.paramsSerializer);
3989
- }
3990
- };
3991
- utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
3992
- Axios.prototype[method] = function(url, config) {
3993
- return this.request(mergeConfig(config || {}, {
3994
- method,
3995
- url,
3996
- data: (config || {}).data
3997
- }));
3998
- };
3999
- });
4000
- utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
4001
- function generateHTTPMethod(isForm) {
4002
- return function httpMethod(url, data, config) {
4003
- return this.request(mergeConfig(config || {}, {
4004
- method,
4005
- headers: isForm ? {
4006
- "Content-Type": "multipart/form-data"
4007
- } : {},
4008
- url,
4009
- data
4010
- }));
4011
- };
4012
- }
4013
- Axios.prototype[method] = generateHTTPMethod();
4014
- Axios.prototype[method + "Form"] = generateHTTPMethod(true);
4015
- });
4016
- var Axios_default = Axios;
4017
-
4018
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/cancel/CancelToken.js
4019
- var CancelToken = class _CancelToken {
4020
- constructor(executor) {
4021
- if (typeof executor !== "function") {
4022
- throw new TypeError("executor must be a function.");
4023
- }
4024
- let resolvePromise;
4025
- this.promise = new Promise(function promiseExecutor(resolve) {
4026
- resolvePromise = resolve;
4027
- });
4028
- const token = this;
4029
- this.promise.then((cancel) => {
4030
- if (!token._listeners) return;
4031
- let i = token._listeners.length;
4032
- while (i-- > 0) {
4033
- token._listeners[i](cancel);
4034
- }
4035
- token._listeners = null;
4036
- });
4037
- this.promise.then = (onfulfilled) => {
4038
- let _resolve;
4039
- const promise = new Promise((resolve) => {
4040
- token.subscribe(resolve);
4041
- _resolve = resolve;
4042
- }).then(onfulfilled);
4043
- promise.cancel = function reject() {
4044
- token.unsubscribe(_resolve);
4045
- };
4046
- return promise;
4047
- };
4048
- executor(function cancel(message, config, request) {
4049
- if (token.reason) {
4050
- return;
4051
- }
4052
- token.reason = new CanceledError_default(message, config, request);
4053
- resolvePromise(token.reason);
4054
- });
4055
- }
4056
- /**
4057
- * Throws a `CanceledError` if cancellation has been requested.
4058
- */
4059
- throwIfRequested() {
4060
- if (this.reason) {
4061
- throw this.reason;
4062
- }
4063
- }
4064
- /**
4065
- * Subscribe to the cancel signal
4066
- */
4067
- subscribe(listener) {
4068
- if (this.reason) {
4069
- listener(this.reason);
4070
- return;
4071
- }
4072
- if (this._listeners) {
4073
- this._listeners.push(listener);
4074
- } else {
4075
- this._listeners = [listener];
4076
- }
4077
- }
4078
- /**
4079
- * Unsubscribe from the cancel signal
4080
- */
4081
- unsubscribe(listener) {
4082
- if (!this._listeners) {
4083
- return;
4084
- }
4085
- const index = this._listeners.indexOf(listener);
4086
- if (index !== -1) {
4087
- this._listeners.splice(index, 1);
4088
- }
4089
- }
4090
- toAbortSignal() {
4091
- const controller = new AbortController();
4092
- const abort = (err) => {
4093
- controller.abort(err);
4094
- };
4095
- this.subscribe(abort);
4096
- controller.signal.unsubscribe = () => this.unsubscribe(abort);
4097
- return controller.signal;
4098
- }
4099
- /**
4100
- * Returns an object that contains a new `CancelToken` and a function that, when called,
4101
- * cancels the `CancelToken`.
4102
- */
4103
- static source() {
4104
- let cancel;
4105
- const token = new _CancelToken(function executor(c) {
4106
- cancel = c;
4107
- });
4108
- return {
4109
- token,
4110
- cancel
4111
- };
4112
- }
4113
- };
4114
- var CancelToken_default = CancelToken;
4115
-
4116
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/spread.js
4117
- function spread(callback) {
4118
- return function wrap(arr) {
4119
- return callback.apply(null, arr);
4120
- };
4121
- }
4122
-
4123
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/isAxiosError.js
4124
- function isAxiosError(payload) {
4125
- return utils_default.isObject(payload) && payload.isAxiosError === true;
4126
- }
4127
-
4128
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/helpers/HttpStatusCode.js
4129
- var HttpStatusCode = {
4130
- Continue: 100,
4131
- SwitchingProtocols: 101,
4132
- Processing: 102,
4133
- EarlyHints: 103,
4134
- Ok: 200,
4135
- Created: 201,
4136
- Accepted: 202,
4137
- NonAuthoritativeInformation: 203,
4138
- NoContent: 204,
4139
- ResetContent: 205,
4140
- PartialContent: 206,
4141
- MultiStatus: 207,
4142
- AlreadyReported: 208,
4143
- ImUsed: 226,
4144
- MultipleChoices: 300,
4145
- MovedPermanently: 301,
4146
- Found: 302,
4147
- SeeOther: 303,
4148
- NotModified: 304,
4149
- UseProxy: 305,
4150
- Unused: 306,
4151
- TemporaryRedirect: 307,
4152
- PermanentRedirect: 308,
4153
- BadRequest: 400,
4154
- Unauthorized: 401,
4155
- PaymentRequired: 402,
4156
- Forbidden: 403,
4157
- NotFound: 404,
4158
- MethodNotAllowed: 405,
4159
- NotAcceptable: 406,
4160
- ProxyAuthenticationRequired: 407,
4161
- RequestTimeout: 408,
4162
- Conflict: 409,
4163
- Gone: 410,
4164
- LengthRequired: 411,
4165
- PreconditionFailed: 412,
4166
- PayloadTooLarge: 413,
4167
- UriTooLong: 414,
4168
- UnsupportedMediaType: 415,
4169
- RangeNotSatisfiable: 416,
4170
- ExpectationFailed: 417,
4171
- ImATeapot: 418,
4172
- MisdirectedRequest: 421,
4173
- UnprocessableEntity: 422,
4174
- Locked: 423,
4175
- FailedDependency: 424,
4176
- TooEarly: 425,
4177
- UpgradeRequired: 426,
4178
- PreconditionRequired: 428,
4179
- TooManyRequests: 429,
4180
- RequestHeaderFieldsTooLarge: 431,
4181
- UnavailableForLegalReasons: 451,
4182
- InternalServerError: 500,
4183
- NotImplemented: 501,
4184
- BadGateway: 502,
4185
- ServiceUnavailable: 503,
4186
- GatewayTimeout: 504,
4187
- HttpVersionNotSupported: 505,
4188
- VariantAlsoNegotiates: 506,
4189
- InsufficientStorage: 507,
4190
- LoopDetected: 508,
4191
- NotExtended: 510,
4192
- NetworkAuthenticationRequired: 511,
4193
- WebServerIsDown: 521,
4194
- ConnectionTimedOut: 522,
4195
- OriginIsUnreachable: 523,
4196
- TimeoutOccurred: 524,
4197
- SslHandshakeFailed: 525,
4198
- InvalidSslCertificate: 526
4199
- };
4200
- Object.entries(HttpStatusCode).forEach(([key, value]) => {
4201
- HttpStatusCode[value] = key;
4202
- });
4203
- var HttpStatusCode_default = HttpStatusCode;
4204
-
4205
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/axios.js
4206
- function createInstance(defaultConfig) {
4207
- const context = new Axios_default(defaultConfig);
4208
- const instance = bind(Axios_default.prototype.request, context);
4209
- utils_default.extend(instance, Axios_default.prototype, context, { allOwnKeys: true });
4210
- utils_default.extend(instance, context, null, { allOwnKeys: true });
4211
- instance.create = function create(instanceConfig) {
4212
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
4213
- };
4214
- return instance;
4215
- }
4216
- var axios = createInstance(defaults_default);
4217
- axios.Axios = Axios_default;
4218
- axios.CanceledError = CanceledError_default;
4219
- axios.CancelToken = CancelToken_default;
4220
- axios.isCancel = isCancel;
4221
- axios.VERSION = VERSION;
4222
- axios.toFormData = toFormData_default;
4223
- axios.AxiosError = AxiosError_default;
4224
- axios.Cancel = axios.CanceledError;
4225
- axios.all = function all(promises) {
4226
- return Promise.all(promises);
4227
- };
4228
- axios.spread = spread;
4229
- axios.isAxiosError = isAxiosError;
4230
- axios.mergeConfig = mergeConfig;
4231
- axios.AxiosHeaders = AxiosHeaders_default;
4232
- axios.formToJSON = (thing) => formDataToJSON_default(utils_default.isHTMLForm(thing) ? new FormData(thing) : thing);
4233
- axios.getAdapter = adapters_default.getAdapter;
4234
- axios.HttpStatusCode = HttpStatusCode_default;
4235
- axios.default = axios;
4236
- var axios_default = axios;
4237
-
4238
- // ../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/index.js
4239
- var {
4240
- Axios: Axios2,
4241
- AxiosError: AxiosError2,
4242
- CanceledError: CanceledError2,
4243
- isCancel: isCancel2,
4244
- CancelToken: CancelToken2,
4245
- VERSION: VERSION2,
4246
- all: all2,
4247
- Cancel,
4248
- isAxiosError: isAxiosError2,
4249
- spread: spread2,
4250
- toFormData: toFormData2,
4251
- AxiosHeaders: AxiosHeaders2,
4252
- HttpStatusCode: HttpStatusCode2,
4253
- formToJSON,
4254
- getAdapter: getAdapter2,
4255
- mergeConfig: mergeConfig2
4256
- } = axios_default;
4257
-
4258
- // src/v2/core/errors.ts
4259
- var TagadaErrorCode = {
4260
- NETWORK_ERROR: "network_error",
4261
- API_ERROR: "api_error",
4262
- AUTH_REQUIRED: "auth_required",
4263
- TOKEN_EXPIRED: "token_expired",
4264
- NOT_FOUND: "not_found",
4265
- VALIDATION_ERROR: "validation_error",
4266
- CIRCUIT_BREAKER: "circuit_breaker",
4267
- PAYMENT_FAILED: "payment_failed",
4268
- CARD_DECLINED: "card_declined",
4269
- SESSION_EXPIRED: "session_expired",
4270
- RATE_LIMITED: "rate_limited",
4271
- TIMEOUT: "timeout",
4272
- UNKNOWN: "unknown"
4273
- };
4274
- var TagadaError = class extends Error {
4275
- constructor(message, options) {
4276
- var _a;
4277
- super(message);
4278
- this.name = "TagadaError";
4279
- this.code = options.code;
4280
- this.statusCode = options.statusCode;
4281
- this.retryable = (_a = options.retryable) != null ? _a : false;
4282
- this.details = options.details;
4283
- Object.setPrototypeOf(this, new.target.prototype);
4284
- }
4285
- };
4286
- var TagadaApiError = class extends TagadaError {
4287
- constructor(message, statusCode, options) {
4288
- var _a, _b;
4289
- super(message, {
4290
- code: (_a = options == null ? void 0 : options.code) != null ? _a : TagadaErrorCode.API_ERROR,
4291
- statusCode,
4292
- retryable: (_b = options == null ? void 0 : options.retryable) != null ? _b : statusCode >= 500,
4293
- details: options == null ? void 0 : options.details
4294
- });
4295
- this.name = "TagadaApiError";
4296
- }
4297
- };
4298
- var TagadaNetworkError = class extends TagadaError {
4299
- constructor(message = "Network request failed") {
4300
- super(message, {
4301
- code: TagadaErrorCode.NETWORK_ERROR,
4302
- retryable: true
4303
- });
4304
- this.name = "TagadaNetworkError";
4305
- }
4306
- };
4307
- var TagadaAuthError = class extends TagadaError {
4308
- constructor(message = "Authentication required", statusCode = 401) {
4309
- super(message, {
4310
- code: TagadaErrorCode.AUTH_REQUIRED,
4311
- statusCode,
4312
- retryable: false
4313
- });
4314
- this.name = "TagadaAuthError";
4315
- }
4316
- };
4317
- var TagadaCircuitBreakerError = class extends TagadaError {
4318
- constructor(message) {
4319
- super(message, {
4320
- code: TagadaErrorCode.CIRCUIT_BREAKER,
4321
- retryable: false
4322
- });
4323
- this.name = "TagadaCircuitBreakerError";
4324
- }
4325
- };
4326
-
4327
- // src/v2/core/resources/apiClient.ts
4328
- var ApiClient = class {
4329
- // Max 30 requests per endpoint in window
4330
- constructor(config) {
4331
- this.currentToken = null;
4332
- this.tokenProvider = null;
4333
- // Circuit breaker state
4334
- this.requestHistory = /* @__PURE__ */ new Map();
4335
- this.WINDOW_MS = 5e3;
4336
- // 5 seconds window
4337
- this.MAX_REQUESTS = 30;
4338
- this.axios = axios_default.create({
4339
- baseURL: config.baseURL,
4340
- timeout: config.timeout || 6e4,
4341
- // 60 seconds for payment operations
4342
- headers: __spreadValues({
4343
- "Content-Type": "application/json"
4344
- }, config.headers)
4345
- });
4346
- if (typeof setInterval !== "undefined") {
4347
- setInterval(() => this.cleanupHistory(), 1e4);
4348
- }
4349
- this.axios.interceptors.request.use(
4350
- async (config2) => {
4351
- var _a, _b;
4352
- if (config2.url) {
4353
- try {
4354
- this.checkRequestLimit("".concat((_a = config2.method) == null ? void 0 : _a.toUpperCase(), ":").concat(config2.url));
4355
- } catch (error) {
4356
- console.error("[SDK] \u{1F6D1} Request blocked by Circuit Breaker:", error);
4357
- return Promise.reject(error);
4358
- }
4359
- }
4360
- if (!config2.skipAuth && !this.currentToken && this.tokenProvider) {
4361
- try {
4362
- console.log("[SDK] Waiting for token...");
4363
- const token = await this.tokenProvider();
4364
- if (token) {
4365
- this.updateToken(token);
4366
- config2.headers["x-cms-token"] = token;
4367
- }
4368
- } catch (error) {
4369
- console.error("[SDK] Failed to get token from provider:", error);
4370
- }
4371
- }
4372
- if (!config2.skipAuth && this.currentToken) {
4373
- config2.headers["x-cms-token"] = this.currentToken;
4374
- }
4375
- console.log("[SDK] Making ".concat((_b = config2.method) == null ? void 0 : _b.toUpperCase(), " request to: ").concat(config2.baseURL || "").concat(config2.url));
4376
- return config2;
4377
- },
4378
- (error) => {
4379
- console.error("[SDK] Request error:", error);
4380
- return Promise.reject(error instanceof Error ? error : new Error(String(error)));
4381
- }
4382
- );
4383
- this.axios.interceptors.response.use(
4384
- (response) => response,
4385
- (error) => {
4386
- console.error("[SDK] Response error:", error.message);
4387
- if (error instanceof TagadaError) {
4388
- return Promise.reject(error);
4389
- }
4390
- if (axios_default.isAxiosError(error)) {
4391
- return Promise.reject(this.toTagadaError(error));
4392
- }
4393
- return Promise.reject(
4394
- error instanceof Error ? error : new Error(String(error))
4395
- );
4396
- }
4397
- );
4398
- }
4399
- // Set a provider that returns a promise resolving to the token
4400
- // This allows requests to wait until the token is ready
4401
- setTokenProvider(provider) {
4402
- this.tokenProvider = provider;
4403
- }
4404
- // Convenience methods
4405
- async get(url, config) {
4406
- const response = await this.axios.get(url, config);
4407
- return response.data;
4408
- }
4409
- async post(url, data, config) {
4410
- const response = await this.axios.post(url, data, config);
4411
- return response.data;
4412
- }
4413
- async put(url, data, config) {
4414
- const response = await this.axios.put(url, data, config);
4415
- return response.data;
4416
- }
4417
- async patch(url, data, config) {
4418
- const response = await this.axios.patch(url, data, config);
4419
- return response.data;
4420
- }
4421
- async delete(url, config) {
4422
- const response = await this.axios.delete(url, config);
4423
- return response.data;
4424
- }
4425
- // Update headers (useful for auth tokens)
4426
- setHeader(key, value) {
4427
- this.axios.defaults.headers.common[key] = value;
4428
- }
4429
- removeHeader(key) {
4430
- delete this.axios.defaults.headers.common[key];
4431
- }
4432
- // Token management methods (matching old ApiService pattern)
4433
- updateToken(token) {
4434
- this.currentToken = token;
4435
- if (token) {
4436
- this.setHeader("x-cms-token", token);
4437
- } else {
4438
- this.removeHeader("x-cms-token");
4439
- console.log("[SDK] Token removed from ApiClient");
4440
- }
4441
- }
4442
- getCurrentToken() {
4443
- return this.currentToken;
4444
- }
4445
- // Update configuration (useful for environment changes)
4446
- updateConfig(config) {
4447
- if (config.baseURL) {
4448
- this.axios.defaults.baseURL = config.baseURL;
4449
- }
4450
- if (config.timeout) {
4451
- this.axios.defaults.timeout = config.timeout;
4452
- }
4453
- if (config.headers) {
4454
- Object.assign(this.axios.defaults.headers.common, config.headers);
4455
- }
4456
- console.log("[SDK] ApiClient configuration updated");
1842
+ // ---- Helpers ----
1843
+ async safeParseJson(response) {
1844
+ try {
1845
+ return await response.json();
1846
+ } catch (e) {
1847
+ return void 0;
1848
+ }
4457
1849
  }
4458
1850
  // Circuit Breaker Implementation
4459
1851
  checkRequestLimit(key) {
@@ -4482,43 +1874,21 @@ var TagadaTrackerBundle = (() => {
4482
1874
  }
4483
1875
  }
4484
1876
  }
4485
- /** Convert an AxiosError into the appropriate TagadaError subclass. */
4486
- toTagadaError(error) {
4487
- var _a, _b, _c, _d, _e;
4488
- const status = (_a = error.response) == null ? void 0 : _a.status;
4489
- const data = (_b = error.response) == null ? void 0 : _b.data;
4490
- const serverMessage = (_d = (_c = data == null ? void 0 : data.message) != null ? _c : data == null ? void 0 : data.error) != null ? _d : error.message;
4491
- if (!error.response) {
4492
- if (error.code === "ECONNABORTED") {
4493
- return new TagadaApiError("Request timed out", 0, {
4494
- code: TagadaErrorCode.TIMEOUT,
4495
- retryable: true
4496
- });
4497
- }
4498
- return new TagadaNetworkError(serverMessage);
4499
- }
4500
- if (status === 401 || status === 403) {
4501
- return new TagadaAuthError(serverMessage, status);
4502
- }
4503
- if (status === 429) {
4504
- return new TagadaApiError(serverMessage, 429, {
4505
- code: TagadaErrorCode.RATE_LIMITED,
4506
- retryable: true
4507
- });
4508
- }
4509
- if (status === 404) {
4510
- return new TagadaApiError(serverMessage, 404, {
4511
- code: TagadaErrorCode.NOT_FOUND,
4512
- retryable: false
4513
- });
1877
+ };
1878
+ function anySignal(signals) {
1879
+ const controller = new AbortController();
1880
+ for (const signal of signals) {
1881
+ if (signal.aborted) {
1882
+ controller.abort(signal.reason);
1883
+ return controller.signal;
4514
1884
  }
4515
- return new TagadaApiError(serverMessage, status != null ? status : 0, {
4516
- code: (_e = data == null ? void 0 : data.code) != null ? _e : TagadaErrorCode.API_ERROR,
4517
- details: data,
4518
- retryable: (status != null ? status : 0) >= 500
1885
+ signal.addEventListener("abort", () => controller.abort(signal.reason), {
1886
+ once: true,
1887
+ signal: controller.signal
4519
1888
  });
4520
1889
  }
4521
- };
1890
+ return controller.signal;
1891
+ }
4522
1892
 
4523
1893
  // src/v2/core/utils/deviceInfo.ts
4524
1894
  function getScreenResolution() {
@@ -4686,7 +2056,8 @@ var TagadaTrackerBundle = (() => {
4686
2056
  currency: params.get("currency") || void 0,
4687
2057
  utmSource: params.get("utm_source") || void 0,
4688
2058
  utmMedium: params.get("utm_medium") || void 0,
4689
- utmCampaign: params.get("utm_campaign") || void 0
2059
+ utmCampaign: params.get("utm_campaign") || void 0,
2060
+ gclid: params.get("gclid") || void 0
4690
2061
  };
4691
2062
  }
4692
2063
 
@@ -5624,6 +2995,7 @@ var TagadaTrackerBundle = (() => {
5624
2995
  utmSource: urlParams.utmSource,
5625
2996
  utmMedium: urlParams.utmMedium,
5626
2997
  utmCampaign: urlParams.utmCampaign,
2998
+ gclid: urlParams.gclid,
5627
2999
  browser: deviceInfo.userAgent.browser.name,
5628
3000
  browserVersion: deviceInfo.userAgent.browser.version,
5629
3001
  os: deviceInfo.userAgent.os.name,