@rhinestone/deposit-modal 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -2
- package/bridge-transcript.json +653 -0
- package/dist/ClaimModal-IKTJU43Y.cjs +13 -0
- package/dist/ClaimModal-SEKNWRMA.mjs +13 -0
- package/dist/{DepositModalReown-YNNHLAV2.cjs → DepositModalReown-46LPVFB6.cjs} +16 -15
- package/dist/{DepositModalReown-3H75G3XQ.mjs → DepositModalReown-Q2JMLT47.mjs} +6 -5
- package/dist/WithdrawModal-5ICGD4HJ.mjs +12 -0
- package/dist/WithdrawModal-VP6PMIRO.cjs +12 -0
- package/dist/{chunk-GACIGCSN.cjs → chunk-6KG642KH.cjs} +1 -1
- package/dist/{chunk-RAADLTSW.cjs → chunk-7ICSHJFE.cjs} +179 -138
- package/dist/{chunk-COCBCQQC.mjs → chunk-7SR7ENVJ.mjs} +46 -5
- package/dist/{chunk-OLCD75JK.mjs → chunk-CFKC77SV.mjs} +451 -131
- package/dist/{chunk-EOMT5LKX.mjs → chunk-IN77XSWO.mjs} +526 -3
- package/dist/{chunk-FZ5FZFIG.mjs → chunk-K4H6TGBE.mjs} +1 -1
- package/dist/{chunk-DSIZNRWA.mjs → chunk-KTUVSKR4.mjs} +979 -360
- package/dist/{chunk-HOGZKHHY.cjs → chunk-LZFRL2AL.cjs} +3 -3
- package/dist/{chunk-7N77GIP4.cjs → chunk-MTFJSE52.cjs} +465 -171
- package/dist/{chunk-LTMMETAB.mjs → chunk-PKML3XVS.mjs} +404 -110
- package/dist/{chunk-ZMT4ATHR.cjs → chunk-V2OBGLJD.cjs} +564 -41
- package/dist/{chunk-XYJFEN5D.mjs → chunk-WUJIKCFU.mjs} +1 -1
- package/dist/{chunk-CVGNCUVU.cjs → chunk-X2IPAPXU.cjs} +22 -13
- package/dist/{chunk-2G2EIN4A.cjs → chunk-YCQZJQO6.cjs} +1272 -653
- package/dist/{chunk-5NUIKYSF.cjs → chunk-YWMWI7PZ.cjs} +458 -138
- package/dist/{chunk-YREVFB64.mjs → chunk-ZEO6ADM3.mjs} +16 -7
- package/dist/claim.cjs +6 -6
- package/dist/claim.d.cts +3 -3
- package/dist/claim.d.ts +3 -3
- package/dist/claim.mjs +5 -5
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +6 -6
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +5 -5
- package/dist/embed.cjs +310 -102
- package/dist/embed.d.cts +7 -1
- package/dist/embed.d.ts +7 -1
- package/dist/embed.mjs +285 -77
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +8 -8
- package/dist/types-Bho4OA03.d.ts +982 -0
- package/dist/types-DP_3KwlD.d.cts +982 -0
- package/dist/withdraw.cjs +5 -5
- package/dist/withdraw.d.cts +3 -3
- package/dist/withdraw.d.ts +3 -3
- package/dist/withdraw.mjs +4 -4
- package/package.json +28 -7
- package/dist/ClaimModal-CREZO27I.mjs +0 -11
- package/dist/ClaimModal-JRIA32U2.cjs +0 -11
- package/dist/WithdrawModal-NVRX44IZ.mjs +0 -10
- package/dist/WithdrawModal-YYSBPCJJ.cjs +0 -10
- package/dist/types-B89I8_8H.d.ts +0 -638
- package/dist/types-nnDR4tqA.d.cts +0 -638
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
var _chunk6KG642KHcjs = require('./chunk-6KG642KH.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -83,7 +84,7 @@ function Modal({
|
|
|
83
84
|
(event) => {
|
|
84
85
|
if (event.key === "Escape") {
|
|
85
86
|
event.preventDefault();
|
|
86
|
-
onClose();
|
|
87
|
+
onClose("escape");
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
90
|
if (event.key === "Tab" && contentRef.current) {
|
|
@@ -109,7 +110,7 @@ function Modal({
|
|
|
109
110
|
const handleOverlayClick = _react.useCallback.call(void 0,
|
|
110
111
|
(event) => {
|
|
111
112
|
if (closeOnOverlayClick && event.target === overlayRef.current) {
|
|
112
|
-
onClose();
|
|
113
|
+
onClose("overlay");
|
|
113
114
|
}
|
|
114
115
|
},
|
|
115
116
|
[closeOnOverlayClick, onClose]
|
|
@@ -891,7 +892,7 @@ function createDepositService(baseUrl, options) {
|
|
|
891
892
|
try {
|
|
892
893
|
const response = await fetch(apiUrl("/qr/tokens"), {
|
|
893
894
|
method: "GET",
|
|
894
|
-
headers:
|
|
895
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, )
|
|
895
896
|
});
|
|
896
897
|
if (!response.ok) {
|
|
897
898
|
debugLog(debug, scope, "getTopTokens:unavailable", {
|
|
@@ -918,7 +919,7 @@ function createDepositService(baseUrl, options) {
|
|
|
918
919
|
try {
|
|
919
920
|
const response = await fetch(apiUrl("/chains"), {
|
|
920
921
|
method: "GET",
|
|
921
|
-
headers:
|
|
922
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, )
|
|
922
923
|
});
|
|
923
924
|
if (!response.ok) {
|
|
924
925
|
debugLog(debug, scope, "getChains:unavailable", {
|
|
@@ -972,7 +973,7 @@ function createDepositService(baseUrl, options) {
|
|
|
972
973
|
});
|
|
973
974
|
const response = await fetch(url, {
|
|
974
975
|
method: "POST",
|
|
975
|
-
headers:
|
|
976
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
976
977
|
body: JSON.stringify({ account: params })
|
|
977
978
|
});
|
|
978
979
|
if (!response.ok) {
|
|
@@ -1004,7 +1005,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1004
1005
|
debugLog(debug, scope, "fetchPortfolio:request", { url, address });
|
|
1005
1006
|
const response = await fetch(url, {
|
|
1006
1007
|
method: "GET",
|
|
1007
|
-
headers:
|
|
1008
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, )
|
|
1008
1009
|
});
|
|
1009
1010
|
if (!response.ok) {
|
|
1010
1011
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -1055,7 +1056,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1055
1056
|
});
|
|
1056
1057
|
const response = await fetch(url, {
|
|
1057
1058
|
method: "GET",
|
|
1058
|
-
headers:
|
|
1059
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, )
|
|
1059
1060
|
});
|
|
1060
1061
|
if (!response.ok) {
|
|
1061
1062
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -1084,7 +1085,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1084
1085
|
debugLog(debug, scope, "checkAccount:request", { url, address });
|
|
1085
1086
|
const response = await fetch(url, {
|
|
1086
1087
|
method: "GET",
|
|
1087
|
-
headers:
|
|
1088
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, )
|
|
1088
1089
|
});
|
|
1089
1090
|
if (!response.ok) {
|
|
1090
1091
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -1120,7 +1121,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1120
1121
|
);
|
|
1121
1122
|
const response = await fetch(url, {
|
|
1122
1123
|
method: "GET",
|
|
1123
|
-
headers:
|
|
1124
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1124
1125
|
cache: "no-store"
|
|
1125
1126
|
});
|
|
1126
1127
|
if (!response.ok) {
|
|
@@ -1148,7 +1149,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1148
1149
|
);
|
|
1149
1150
|
const response = await fetch(url, {
|
|
1150
1151
|
method: "GET",
|
|
1151
|
-
headers:
|
|
1152
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1152
1153
|
cache: "no-store"
|
|
1153
1154
|
});
|
|
1154
1155
|
if (!response.ok) {
|
|
@@ -1172,7 +1173,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1172
1173
|
);
|
|
1173
1174
|
const response = await fetch(url, {
|
|
1174
1175
|
method: "GET",
|
|
1175
|
-
headers:
|
|
1176
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1176
1177
|
cache: "no-store"
|
|
1177
1178
|
});
|
|
1178
1179
|
if (!response.ok) {
|
|
@@ -1194,7 +1195,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1194
1195
|
async getPositions(address) {
|
|
1195
1196
|
const url = apiUrl(`/positions/${address}`);
|
|
1196
1197
|
debugLog(debug, scope, "getPositions:request", { url, address });
|
|
1197
|
-
const response = await fetch(url, { headers:
|
|
1198
|
+
const response = await fetch(url, { headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ) });
|
|
1198
1199
|
if (!response.ok) {
|
|
1199
1200
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1200
1201
|
debugError(debug, scope, "getPositions:failed", error, {
|
|
@@ -1228,7 +1229,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1228
1229
|
});
|
|
1229
1230
|
const response = await fetch(url, {
|
|
1230
1231
|
method: "POST",
|
|
1231
|
-
headers:
|
|
1232
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1232
1233
|
body: JSON.stringify({ account, market, chainId, asset, amount })
|
|
1233
1234
|
});
|
|
1234
1235
|
if (!response.ok) {
|
|
@@ -1264,7 +1265,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1264
1265
|
});
|
|
1265
1266
|
const response = await fetch(url, {
|
|
1266
1267
|
method: "POST",
|
|
1267
|
-
headers:
|
|
1268
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1268
1269
|
body: JSON.stringify({
|
|
1269
1270
|
depositWallet,
|
|
1270
1271
|
owner,
|
|
@@ -1306,7 +1307,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1306
1307
|
});
|
|
1307
1308
|
const response = await fetch(url, {
|
|
1308
1309
|
method: "GET",
|
|
1309
|
-
headers:
|
|
1310
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1310
1311
|
cache: "no-store"
|
|
1311
1312
|
});
|
|
1312
1313
|
if (!response.ok) {
|
|
@@ -1356,7 +1357,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1356
1357
|
});
|
|
1357
1358
|
const response = await fetch(url, {
|
|
1358
1359
|
method: "GET",
|
|
1359
|
-
headers:
|
|
1360
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1360
1361
|
cache: "no-store"
|
|
1361
1362
|
});
|
|
1362
1363
|
if (!response.ok) {
|
|
@@ -1404,7 +1405,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1404
1405
|
try {
|
|
1405
1406
|
const response = await fetch(url, {
|
|
1406
1407
|
method: "POST",
|
|
1407
|
-
headers:
|
|
1408
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1408
1409
|
body: JSON.stringify(body),
|
|
1409
1410
|
cache: "no-store"
|
|
1410
1411
|
});
|
|
@@ -1444,7 +1445,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1444
1445
|
try {
|
|
1445
1446
|
const response = await fetch(url, {
|
|
1446
1447
|
method: "POST",
|
|
1447
|
-
headers:
|
|
1448
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1448
1449
|
body: JSON.stringify({ ...params, kind: "auto" }),
|
|
1449
1450
|
cache: "no-store"
|
|
1450
1451
|
});
|
|
@@ -1538,7 +1539,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1538
1539
|
try {
|
|
1539
1540
|
response = await fetch(url, {
|
|
1540
1541
|
method: "POST",
|
|
1541
|
-
headers:
|
|
1542
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1542
1543
|
body: JSON.stringify(params)
|
|
1543
1544
|
});
|
|
1544
1545
|
} catch (error) {
|
|
@@ -1589,7 +1590,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1589
1590
|
try {
|
|
1590
1591
|
const response = await fetch(url, {
|
|
1591
1592
|
method: "GET",
|
|
1592
|
-
headers:
|
|
1593
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1593
1594
|
cache: "no-store"
|
|
1594
1595
|
});
|
|
1595
1596
|
if (!response.ok) {
|
|
@@ -1621,7 +1622,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1621
1622
|
try {
|
|
1622
1623
|
const response = await fetch(url, {
|
|
1623
1624
|
method: "GET",
|
|
1624
|
-
headers:
|
|
1625
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1625
1626
|
cache: "no-store"
|
|
1626
1627
|
});
|
|
1627
1628
|
if (!response.ok) {
|
|
@@ -1646,7 +1647,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1646
1647
|
});
|
|
1647
1648
|
const response = await fetch(url, {
|
|
1648
1649
|
method: "POST",
|
|
1649
|
-
headers:
|
|
1650
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1650
1651
|
body: JSON.stringify(params)
|
|
1651
1652
|
});
|
|
1652
1653
|
if (!response.ok) {
|
|
@@ -1678,7 +1679,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1678
1679
|
});
|
|
1679
1680
|
const response = await fetch(url, {
|
|
1680
1681
|
method: "POST",
|
|
1681
|
-
headers:
|
|
1682
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1682
1683
|
body: JSON.stringify(params)
|
|
1683
1684
|
});
|
|
1684
1685
|
if (!response.ok) {
|
|
@@ -1715,7 +1716,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1715
1716
|
debugLog(debug, scope, "getSwappedConnectExchanges:request");
|
|
1716
1717
|
const response = await fetch(url, {
|
|
1717
1718
|
method: "GET",
|
|
1718
|
-
headers:
|
|
1719
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1719
1720
|
cache: "no-store"
|
|
1720
1721
|
});
|
|
1721
1722
|
if (!response.ok) {
|
|
@@ -1768,7 +1769,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1768
1769
|
try {
|
|
1769
1770
|
const response = await fetch(url, {
|
|
1770
1771
|
method: "GET",
|
|
1771
|
-
headers:
|
|
1772
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1772
1773
|
cache: "no-store"
|
|
1773
1774
|
});
|
|
1774
1775
|
if (!response.ok) {
|
|
@@ -1854,7 +1855,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1854
1855
|
try {
|
|
1855
1856
|
const response = await fetch(url, {
|
|
1856
1857
|
method: "GET",
|
|
1857
|
-
headers:
|
|
1858
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1858
1859
|
cache: "no-store"
|
|
1859
1860
|
});
|
|
1860
1861
|
if (!response.ok) {
|
|
@@ -1881,7 +1882,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1881
1882
|
);
|
|
1882
1883
|
const response = await fetch(url, {
|
|
1883
1884
|
method: "GET",
|
|
1884
|
-
headers:
|
|
1885
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
1885
1886
|
cache: "no-store"
|
|
1886
1887
|
});
|
|
1887
1888
|
if (!response.ok) return null;
|
|
@@ -2875,6 +2876,524 @@ function formatReceiveEstimate(params) {
|
|
|
2875
2876
|
return sameSymbol ? `${formatted} ${params.targetSymbol}` : `~${formatted} ${params.targetSymbol}`;
|
|
2876
2877
|
}
|
|
2877
2878
|
|
|
2879
|
+
// src/core/analytics.tsx
|
|
2880
|
+
|
|
2881
|
+
|
|
2882
|
+
|
|
2883
|
+
|
|
2884
|
+
|
|
2885
|
+
|
|
2886
|
+
|
|
2887
|
+
|
|
2888
|
+
|
|
2889
|
+
// src/core/analytics-ingest.ts
|
|
2890
|
+
var DEFAULT_ANALYTICS_INGEST_URL = "https://v1.orchestrator.rhinestone.dev/deposit-processor/analytics/events";
|
|
2891
|
+
var MAX_BATCH = 20;
|
|
2892
|
+
var MAX_QUEUE = 200;
|
|
2893
|
+
var FLUSH_DELAY_MS = 5e3;
|
|
2894
|
+
var MAX_BODY_BYTES = 48 * 1024;
|
|
2895
|
+
var TOKEN_REFRESH_MARGIN_MS = 6e4;
|
|
2896
|
+
var TOKEN_TIMEOUT_MS = 3e3;
|
|
2897
|
+
var MAX_ATTEMPTS = 3;
|
|
2898
|
+
var MAX_BACKOFF_MS = 3e4;
|
|
2899
|
+
var ENVELOPE_FIELDS = /* @__PURE__ */ new Set([
|
|
2900
|
+
"type",
|
|
2901
|
+
"timestamp",
|
|
2902
|
+
"session_id",
|
|
2903
|
+
"modal",
|
|
2904
|
+
"widget_version",
|
|
2905
|
+
"session_properties",
|
|
2906
|
+
"funding_method"
|
|
2907
|
+
]);
|
|
2908
|
+
function createIngestTransport(options) {
|
|
2909
|
+
const {
|
|
2910
|
+
ingestUrl,
|
|
2911
|
+
backendUrl,
|
|
2912
|
+
proxyOrigin,
|
|
2913
|
+
sessionId,
|
|
2914
|
+
modal,
|
|
2915
|
+
widgetVersion,
|
|
2916
|
+
sessionProperties,
|
|
2917
|
+
onFailure
|
|
2918
|
+
} = options;
|
|
2919
|
+
const fetchImpl = _nullishCoalesce(options.fetchImpl, () => ( (typeof globalThis.fetch === "function" ? globalThis.fetch.bind(globalThis) : void 0)));
|
|
2920
|
+
const now = _nullishCoalesce(options.now, () => ( (() => Date.now())));
|
|
2921
|
+
const createEventId = _nullishCoalesce(options.createEventId, () => ( randomUuid));
|
|
2922
|
+
const mintUrl = `${backendUrl.replace(/\/$/, "")}/analytics/ingest-token`;
|
|
2923
|
+
const queue = [];
|
|
2924
|
+
let sequence = 0;
|
|
2925
|
+
let dropped = 0;
|
|
2926
|
+
let token = null;
|
|
2927
|
+
let mintUnavailable = false;
|
|
2928
|
+
let mintFailures = 0;
|
|
2929
|
+
let mintBackoffUntil = 0;
|
|
2930
|
+
let timer = null;
|
|
2931
|
+
let sending = false;
|
|
2932
|
+
let disposed = false;
|
|
2933
|
+
let pendingTerminal = false;
|
|
2934
|
+
let terminalRequested = false;
|
|
2935
|
+
let mintAbort = null;
|
|
2936
|
+
const sleepers = /* @__PURE__ */ new Set();
|
|
2937
|
+
function report(reason, status) {
|
|
2938
|
+
try {
|
|
2939
|
+
onFailure({ reason, status, droppedEvents: dropped });
|
|
2940
|
+
} catch (e6) {
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
function drop(batch, reason, status) {
|
|
2944
|
+
dropped += batch.length;
|
|
2945
|
+
report(reason, status);
|
|
2946
|
+
}
|
|
2947
|
+
function toWireEvent(event) {
|
|
2948
|
+
const payload = {};
|
|
2949
|
+
for (const [key, value] of Object.entries(event)) {
|
|
2950
|
+
if (!ENVELOPE_FIELDS.has(key)) payload[key] = value;
|
|
2951
|
+
}
|
|
2952
|
+
const wire = {
|
|
2953
|
+
event_id: createEventId(),
|
|
2954
|
+
session_id: sessionId,
|
|
2955
|
+
sequence: sequence++,
|
|
2956
|
+
type: String(event.type),
|
|
2957
|
+
timestamp: String(event.timestamp),
|
|
2958
|
+
widget_version: widgetVersion,
|
|
2959
|
+
proxy_origin: proxyOrigin,
|
|
2960
|
+
modal,
|
|
2961
|
+
session_properties: sessionProperties,
|
|
2962
|
+
payload
|
|
2963
|
+
};
|
|
2964
|
+
if (modal === "deposit") wire.funding_method = _nullishCoalesce(event.funding_method, () => ( null));
|
|
2965
|
+
return wire;
|
|
2966
|
+
}
|
|
2967
|
+
function takeBatch() {
|
|
2968
|
+
const batch = queue.slice(0, MAX_BATCH);
|
|
2969
|
+
while (batch.length > 1 && bodyOf(batch).length > MAX_BODY_BYTES) {
|
|
2970
|
+
batch.pop();
|
|
2971
|
+
}
|
|
2972
|
+
queue.splice(0, batch.length);
|
|
2973
|
+
return batch;
|
|
2974
|
+
}
|
|
2975
|
+
function bodyOf(batch) {
|
|
2976
|
+
return JSON.stringify({ events: batch });
|
|
2977
|
+
}
|
|
2978
|
+
function backoff(attempt) {
|
|
2979
|
+
return Math.min(1e3 * 2 ** (attempt - 1), MAX_BACKOFF_MS);
|
|
2980
|
+
}
|
|
2981
|
+
function sleep(ms) {
|
|
2982
|
+
return new Promise((resolve) => {
|
|
2983
|
+
const timeout = setTimeout(finish, ms);
|
|
2984
|
+
function finish() {
|
|
2985
|
+
clearTimeout(timeout);
|
|
2986
|
+
sleepers.delete(finish);
|
|
2987
|
+
resolve();
|
|
2988
|
+
}
|
|
2989
|
+
sleepers.add(finish);
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2992
|
+
function interruptForUnload() {
|
|
2993
|
+
for (const wake of [...sleepers]) wake();
|
|
2994
|
+
_optionalChain([mintAbort, 'optionalAccess', _109 => _109.abort, 'call', _110 => _110()]);
|
|
2995
|
+
}
|
|
2996
|
+
function retryDelay(response, attempt) {
|
|
2997
|
+
const seconds = Number(_optionalChain([response, 'access', _111 => _111.headers, 'optionalAccess', _112 => _112.get, 'optionalCall', _113 => _113("Retry-After")]));
|
|
2998
|
+
if (Number.isFinite(seconds) && seconds > 0) {
|
|
2999
|
+
return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
|
|
3000
|
+
}
|
|
3001
|
+
return backoff(attempt);
|
|
3002
|
+
}
|
|
3003
|
+
async function mintToken() {
|
|
3004
|
+
if (mintUnavailable || !fetchImpl) return;
|
|
3005
|
+
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
3006
|
+
mintAbort = controller;
|
|
3007
|
+
const timeout = controller ? setTimeout(() => controller.abort(), TOKEN_TIMEOUT_MS) : null;
|
|
3008
|
+
let response;
|
|
3009
|
+
try {
|
|
3010
|
+
response = await fetchImpl(mintUrl, {
|
|
3011
|
+
method: "POST",
|
|
3012
|
+
headers: _chunk6KG642KHcjs.serviceHeaders.call(void 0, ),
|
|
3013
|
+
signal: _optionalChain([controller, 'optionalAccess', _114 => _114.signal])
|
|
3014
|
+
});
|
|
3015
|
+
} catch (e7) {
|
|
3016
|
+
if (!terminalRequested) {
|
|
3017
|
+
mintFailures += 1;
|
|
3018
|
+
mintBackoffUntil = now() + backoff(mintFailures);
|
|
3019
|
+
}
|
|
3020
|
+
return;
|
|
3021
|
+
} finally {
|
|
3022
|
+
if (timeout !== null) clearTimeout(timeout);
|
|
3023
|
+
mintAbort = null;
|
|
3024
|
+
}
|
|
3025
|
+
if (response.status === 404 || response.status === 401 || response.status === 403) {
|
|
3026
|
+
mintUnavailable = true;
|
|
3027
|
+
report("token_unavailable", response.status);
|
|
3028
|
+
return;
|
|
3029
|
+
}
|
|
3030
|
+
if (!response.ok) {
|
|
3031
|
+
mintFailures += 1;
|
|
3032
|
+
mintBackoffUntil = now() + backoff(mintFailures);
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
try {
|
|
3036
|
+
const data = await response.json();
|
|
3037
|
+
const value = typeof data.token === "string" ? data.token : "";
|
|
3038
|
+
const expiresAt = Date.parse(String(data.expiresAt));
|
|
3039
|
+
if (!value || Number.isNaN(expiresAt)) throw new Error("malformed");
|
|
3040
|
+
token = { value, expiresAt };
|
|
3041
|
+
mintFailures = 0;
|
|
3042
|
+
mintBackoffUntil = 0;
|
|
3043
|
+
} catch (e8) {
|
|
3044
|
+
mintUnavailable = true;
|
|
3045
|
+
report("token_unavailable", response.status);
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
async function ensureToken() {
|
|
3049
|
+
if (mintUnavailable) return;
|
|
3050
|
+
if (token && token.expiresAt - now() > TOKEN_REFRESH_MARGIN_MS) return;
|
|
3051
|
+
if (now() < mintBackoffUntil) return;
|
|
3052
|
+
await mintToken();
|
|
3053
|
+
}
|
|
3054
|
+
async function deliver(batch, isTerminal) {
|
|
3055
|
+
if (!fetchImpl) return drop(batch, "unsupported");
|
|
3056
|
+
let attempt = 0;
|
|
3057
|
+
let refreshed = false;
|
|
3058
|
+
let unattributed = false;
|
|
3059
|
+
for (; ; ) {
|
|
3060
|
+
const terminal = isTerminal || terminalRequested;
|
|
3061
|
+
attempt += 1;
|
|
3062
|
+
const headers = {
|
|
3063
|
+
"Content-Type": "application/json"
|
|
3064
|
+
};
|
|
3065
|
+
if (token && !unattributed) headers.Authorization = `Bearer ${token.value}`;
|
|
3066
|
+
let response;
|
|
3067
|
+
try {
|
|
3068
|
+
response = await fetchImpl(ingestUrl, {
|
|
3069
|
+
method: "POST",
|
|
3070
|
+
headers,
|
|
3071
|
+
body: bodyOf(batch),
|
|
3072
|
+
keepalive: true
|
|
3073
|
+
});
|
|
3074
|
+
} catch (e9) {
|
|
3075
|
+
if (terminal || attempt >= MAX_ATTEMPTS) {
|
|
3076
|
+
return drop(batch, "network");
|
|
3077
|
+
}
|
|
3078
|
+
await sleep(backoff(attempt));
|
|
3079
|
+
continue;
|
|
3080
|
+
}
|
|
3081
|
+
if (response.ok) return;
|
|
3082
|
+
const status = response.status;
|
|
3083
|
+
if (status === 401) {
|
|
3084
|
+
token = null;
|
|
3085
|
+
if (!refreshed && !terminal) {
|
|
3086
|
+
refreshed = true;
|
|
3087
|
+
await mintToken();
|
|
3088
|
+
if (token) continue;
|
|
3089
|
+
}
|
|
3090
|
+
if (!unattributed) {
|
|
3091
|
+
unattributed = true;
|
|
3092
|
+
continue;
|
|
3093
|
+
}
|
|
3094
|
+
return drop(batch, "unauthorized", status);
|
|
3095
|
+
}
|
|
3096
|
+
if (status === 409) return drop(batch, "conflict", status);
|
|
3097
|
+
if (status === 429 || status >= 500) {
|
|
3098
|
+
if (terminal || attempt >= MAX_ATTEMPTS) {
|
|
3099
|
+
return drop(batch, status === 429 ? "throttled" : "unavailable", status);
|
|
3100
|
+
}
|
|
3101
|
+
await sleep(retryDelay(response, attempt));
|
|
3102
|
+
continue;
|
|
3103
|
+
}
|
|
3104
|
+
return drop(batch, "rejected", status);
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
async function run(requestedTerminal) {
|
|
3108
|
+
if (requestedTerminal) terminalRequested = true;
|
|
3109
|
+
if (sending) {
|
|
3110
|
+
if (requestedTerminal) {
|
|
3111
|
+
pendingTerminal = true;
|
|
3112
|
+
interruptForUnload();
|
|
3113
|
+
}
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
sending = true;
|
|
3117
|
+
try {
|
|
3118
|
+
while (queue.length > 0) {
|
|
3119
|
+
const terminal = requestedTerminal || terminalRequested;
|
|
3120
|
+
const batch = takeBatch();
|
|
3121
|
+
if (!terminal) await ensureToken();
|
|
3122
|
+
await deliver(batch, terminal);
|
|
3123
|
+
if (!terminal && disposed) break;
|
|
3124
|
+
}
|
|
3125
|
+
} finally {
|
|
3126
|
+
sending = false;
|
|
3127
|
+
}
|
|
3128
|
+
if (pendingTerminal) {
|
|
3129
|
+
pendingTerminal = false;
|
|
3130
|
+
await run(true);
|
|
3131
|
+
return;
|
|
3132
|
+
}
|
|
3133
|
+
if (!disposed && queue.length === 0) terminalRequested = false;
|
|
3134
|
+
}
|
|
3135
|
+
function clearFlushTimer() {
|
|
3136
|
+
if (timer !== null) {
|
|
3137
|
+
clearTimeout(timer);
|
|
3138
|
+
timer = null;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
function scheduleFlush() {
|
|
3142
|
+
if (timer !== null || disposed) return;
|
|
3143
|
+
timer = setTimeout(() => {
|
|
3144
|
+
timer = null;
|
|
3145
|
+
void run(false);
|
|
3146
|
+
}, FLUSH_DELAY_MS);
|
|
3147
|
+
}
|
|
3148
|
+
return {
|
|
3149
|
+
enqueue(event) {
|
|
3150
|
+
if (disposed) return;
|
|
3151
|
+
queue.push(toWireEvent(event));
|
|
3152
|
+
if (queue.length > MAX_QUEUE) {
|
|
3153
|
+
dropped += queue.length - MAX_QUEUE;
|
|
3154
|
+
queue.splice(0, queue.length - MAX_QUEUE);
|
|
3155
|
+
}
|
|
3156
|
+
if (queue.length >= MAX_BATCH) {
|
|
3157
|
+
clearFlushTimer();
|
|
3158
|
+
void run(false);
|
|
3159
|
+
} else {
|
|
3160
|
+
scheduleFlush();
|
|
3161
|
+
}
|
|
3162
|
+
},
|
|
3163
|
+
flush(flushOptions) {
|
|
3164
|
+
const terminal = _nullishCoalesce(_optionalChain([flushOptions, 'optionalAccess', _115 => _115.terminal]), () => ( false));
|
|
3165
|
+
if (disposed && !terminal) return;
|
|
3166
|
+
clearFlushTimer();
|
|
3167
|
+
void run(terminal);
|
|
3168
|
+
},
|
|
3169
|
+
dispose() {
|
|
3170
|
+
if (disposed) return;
|
|
3171
|
+
disposed = true;
|
|
3172
|
+
clearFlushTimer();
|
|
3173
|
+
void run(true);
|
|
3174
|
+
}
|
|
3175
|
+
};
|
|
3176
|
+
}
|
|
3177
|
+
function randomUuid() {
|
|
3178
|
+
if (typeof _optionalChain([globalThis, 'access', _116 => _116.crypto, 'optionalAccess', _117 => _117.randomUUID]) === "function") {
|
|
3179
|
+
return globalThis.crypto.randomUUID();
|
|
3180
|
+
}
|
|
3181
|
+
const bytes = new Uint8Array(16);
|
|
3182
|
+
_optionalChain([globalThis, 'access', _118 => _118.crypto, 'optionalAccess', _119 => _119.getRandomValues, 'optionalCall', _120 => _120(bytes)]);
|
|
3183
|
+
if (!bytes.some(Boolean)) {
|
|
3184
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
3185
|
+
bytes[index] = Math.floor(Math.random() * 256);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
3189
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
3190
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
|
|
3191
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
3192
|
+
}
|
|
3193
|
+
function resolveProxyOrigin(backendUrl) {
|
|
3194
|
+
if (!backendUrl.trim()) return null;
|
|
3195
|
+
try {
|
|
3196
|
+
const { origin } = new URL(backendUrl, _optionalChain([globalThis, 'access', _121 => _121.location, 'optionalAccess', _122 => _122.href]));
|
|
3197
|
+
return origin.startsWith("http") ? origin : null;
|
|
3198
|
+
} catch (e10) {
|
|
3199
|
+
return null;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
// src/core/analytics.tsx
|
|
3204
|
+
|
|
3205
|
+
var AnalyticsContext = _react.createContext.call(void 0, null);
|
|
3206
|
+
var noopDepositEmitter = () => {
|
|
3207
|
+
};
|
|
3208
|
+
var noopWithdrawEmitter = () => {
|
|
3209
|
+
};
|
|
3210
|
+
var noopClaimEmitter = () => {
|
|
3211
|
+
};
|
|
3212
|
+
function cloneAndFreeze(value) {
|
|
3213
|
+
if (Array.isArray(value)) {
|
|
3214
|
+
return Object.freeze(value.map(cloneAndFreeze));
|
|
3215
|
+
}
|
|
3216
|
+
if (value && typeof value === "object") {
|
|
3217
|
+
const clone = Object.fromEntries(
|
|
3218
|
+
Object.entries(value).map(([key, child]) => [key, cloneAndFreeze(child)])
|
|
3219
|
+
);
|
|
3220
|
+
return Object.freeze(clone);
|
|
3221
|
+
}
|
|
3222
|
+
return value;
|
|
3223
|
+
}
|
|
3224
|
+
function AnalyticsSession(props) {
|
|
3225
|
+
const sessionIdRef = _react.useRef.call(void 0, void 0);
|
|
3226
|
+
if (sessionIdRef.current === void 0) {
|
|
3227
|
+
sessionIdRef.current = (_nullishCoalesce(props.createSessionId, () => ( randomUuid)))();
|
|
3228
|
+
}
|
|
3229
|
+
const sessionPropertiesRef = _react.useRef.call(void 0, void 0);
|
|
3230
|
+
if (sessionPropertiesRef.current === void 0) {
|
|
3231
|
+
sessionPropertiesRef.current = cloneAndFreeze(props.sessionProperties);
|
|
3232
|
+
}
|
|
3233
|
+
const onEventRef = _react.useRef.call(void 0, props.onEvent);
|
|
3234
|
+
onEventRef.current = props.onEvent;
|
|
3235
|
+
const nowRef = _react.useRef.call(void 0, _nullishCoalesce(props.now, () => ( (() => /* @__PURE__ */ new Date()))));
|
|
3236
|
+
nowRef.current = _nullishCoalesce(props.now, () => ( (() => /* @__PURE__ */ new Date())));
|
|
3237
|
+
const modal = props.modal;
|
|
3238
|
+
const reportedFailuresRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
3239
|
+
const emitFailure = _react.useCallback.call(void 0,
|
|
3240
|
+
({ reason, status, droppedEvents }) => {
|
|
3241
|
+
if (reportedFailuresRef.current.has(reason)) return;
|
|
3242
|
+
reportedFailuresRef.current.add(reason);
|
|
3243
|
+
const event = {
|
|
3244
|
+
type: "analytics_ingest_failure",
|
|
3245
|
+
session_id: sessionIdRef.current,
|
|
3246
|
+
modal,
|
|
3247
|
+
widget_version: _chunk6KG642KHcjs.MODAL_VERSION,
|
|
3248
|
+
timestamp: nowRef.current().toISOString(),
|
|
3249
|
+
reason,
|
|
3250
|
+
...status === void 0 ? {} : { status },
|
|
3251
|
+
dropped_events: droppedEvents
|
|
3252
|
+
};
|
|
3253
|
+
_optionalChain([onEventRef, 'access', _123 => _123.current, 'optionalCall', _124 => _124(event)]);
|
|
3254
|
+
},
|
|
3255
|
+
[modal]
|
|
3256
|
+
);
|
|
3257
|
+
function createIngest() {
|
|
3258
|
+
if (props.enableIngest === false) {
|
|
3259
|
+
return { transport: null, initialFailure: null };
|
|
3260
|
+
}
|
|
3261
|
+
const proxyOrigin = resolveProxyOrigin(_nullishCoalesce(props.backendUrl, () => ( "")));
|
|
3262
|
+
if (!proxyOrigin || typeof globalThis.fetch !== "function") {
|
|
3263
|
+
return {
|
|
3264
|
+
transport: null,
|
|
3265
|
+
initialFailure: { reason: "unsupported", droppedEvents: 0 }
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
return {
|
|
3269
|
+
transport: createIngestTransport({
|
|
3270
|
+
ingestUrl: _nullishCoalesce(props.ingestUrl, () => ( DEFAULT_ANALYTICS_INGEST_URL)),
|
|
3271
|
+
backendUrl: props.backendUrl,
|
|
3272
|
+
proxyOrigin,
|
|
3273
|
+
sessionId: sessionIdRef.current,
|
|
3274
|
+
modal,
|
|
3275
|
+
widgetVersion: _chunk6KG642KHcjs.MODAL_VERSION,
|
|
3276
|
+
sessionProperties: sessionPropertiesRef.current,
|
|
3277
|
+
onFailure: (failure) => emitFailure(failure),
|
|
3278
|
+
fetchImpl: props.fetchImpl,
|
|
3279
|
+
createEventId: props.createEventId
|
|
3280
|
+
}),
|
|
3281
|
+
initialFailure: null
|
|
3282
|
+
};
|
|
3283
|
+
}
|
|
3284
|
+
const ingestRef = _react.useRef.call(void 0, void 0);
|
|
3285
|
+
if (ingestRef.current === void 0) {
|
|
3286
|
+
ingestRef.current = createIngest();
|
|
3287
|
+
}
|
|
3288
|
+
const pendingDisposalRef = _react.useRef.call(void 0, null);
|
|
3289
|
+
const enqueue = _react.useCallback.call(void 0,
|
|
3290
|
+
(event) => {
|
|
3291
|
+
try {
|
|
3292
|
+
_optionalChain([ingestRef, 'access', _125 => _125.current, 'optionalAccess', _126 => _126.transport, 'optionalAccess', _127 => _127.enqueue, 'call', _128 => _128(
|
|
3293
|
+
event
|
|
3294
|
+
)]);
|
|
3295
|
+
} catch (e11) {
|
|
3296
|
+
}
|
|
3297
|
+
},
|
|
3298
|
+
[]
|
|
3299
|
+
);
|
|
3300
|
+
_react.useEffect.call(void 0, () => {
|
|
3301
|
+
if (pendingDisposalRef.current !== null) {
|
|
3302
|
+
clearTimeout(pendingDisposalRef.current);
|
|
3303
|
+
pendingDisposalRef.current = null;
|
|
3304
|
+
}
|
|
3305
|
+
const setup = ingestRef.current;
|
|
3306
|
+
if (setup.initialFailure) emitFailure(setup.initialFailure);
|
|
3307
|
+
const transport = setup.transport;
|
|
3308
|
+
if (!transport) return;
|
|
3309
|
+
const flush = () => transport.flush({ terminal: true });
|
|
3310
|
+
const onVisibilityChange = () => {
|
|
3311
|
+
if (document.visibilityState === "hidden") flush();
|
|
3312
|
+
};
|
|
3313
|
+
window.addEventListener("pagehide", flush);
|
|
3314
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
3315
|
+
return () => {
|
|
3316
|
+
window.removeEventListener("pagehide", flush);
|
|
3317
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
3318
|
+
pendingDisposalRef.current = setTimeout(() => {
|
|
3319
|
+
pendingDisposalRef.current = null;
|
|
3320
|
+
transport.dispose();
|
|
3321
|
+
}, 0);
|
|
3322
|
+
};
|
|
3323
|
+
}, [emitFailure]);
|
|
3324
|
+
const emitDeposit = _react.useCallback.call(void 0,
|
|
3325
|
+
(...[payload, fundingMethod]) => {
|
|
3326
|
+
if (modal !== "deposit") return;
|
|
3327
|
+
const event = {
|
|
3328
|
+
...payload,
|
|
3329
|
+
session_id: sessionIdRef.current,
|
|
3330
|
+
modal,
|
|
3331
|
+
widget_version: _chunk6KG642KHcjs.MODAL_VERSION,
|
|
3332
|
+
timestamp: nowRef.current().toISOString(),
|
|
3333
|
+
session_properties: sessionPropertiesRef.current,
|
|
3334
|
+
funding_method: fundingMethod
|
|
3335
|
+
};
|
|
3336
|
+
_optionalChain([onEventRef, 'access', _129 => _129.current, 'optionalCall', _130 => _130(
|
|
3337
|
+
event
|
|
3338
|
+
)]);
|
|
3339
|
+
enqueue(event);
|
|
3340
|
+
},
|
|
3341
|
+
[enqueue, modal, nowRef, onEventRef]
|
|
3342
|
+
);
|
|
3343
|
+
const emitWithdraw = _react.useCallback.call(void 0,
|
|
3344
|
+
(payload) => {
|
|
3345
|
+
if (modal !== "withdraw") return;
|
|
3346
|
+
const event = {
|
|
3347
|
+
...payload,
|
|
3348
|
+
session_id: sessionIdRef.current,
|
|
3349
|
+
modal,
|
|
3350
|
+
widget_version: _chunk6KG642KHcjs.MODAL_VERSION,
|
|
3351
|
+
timestamp: nowRef.current().toISOString(),
|
|
3352
|
+
session_properties: sessionPropertiesRef.current
|
|
3353
|
+
};
|
|
3354
|
+
_optionalChain([onEventRef, 'access', _131 => _131.current, 'optionalCall', _132 => _132(event)]);
|
|
3355
|
+
enqueue(event);
|
|
3356
|
+
},
|
|
3357
|
+
[enqueue, modal, nowRef, onEventRef]
|
|
3358
|
+
);
|
|
3359
|
+
const emitClaim = _react.useCallback.call(void 0,
|
|
3360
|
+
(payload) => {
|
|
3361
|
+
if (modal !== "claim") return;
|
|
3362
|
+
const event = {
|
|
3363
|
+
...payload,
|
|
3364
|
+
session_id: sessionIdRef.current,
|
|
3365
|
+
modal,
|
|
3366
|
+
widget_version: _chunk6KG642KHcjs.MODAL_VERSION,
|
|
3367
|
+
timestamp: nowRef.current().toISOString(),
|
|
3368
|
+
session_properties: sessionPropertiesRef.current
|
|
3369
|
+
};
|
|
3370
|
+
_optionalChain([onEventRef, 'access', _133 => _133.current, 'optionalCall', _134 => _134(event)]);
|
|
3371
|
+
enqueue(event);
|
|
3372
|
+
},
|
|
3373
|
+
[enqueue, modal, nowRef, onEventRef]
|
|
3374
|
+
);
|
|
3375
|
+
const context = _react.useMemo.call(void 0,
|
|
3376
|
+
() => modal === "deposit" ? { modal, emit: emitDeposit } : modal === "withdraw" ? { modal, emit: emitWithdraw } : { modal, emit: emitClaim },
|
|
3377
|
+
[modal, emitDeposit, emitWithdraw, emitClaim]
|
|
3378
|
+
);
|
|
3379
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AnalyticsContext.Provider, { value: context, children: props.children });
|
|
3380
|
+
}
|
|
3381
|
+
function useDepositAnalyticsEmitter() {
|
|
3382
|
+
const context = _react.useContext.call(void 0, AnalyticsContext);
|
|
3383
|
+
if (!context || context.modal !== "deposit") return noopDepositEmitter;
|
|
3384
|
+
return context.emit;
|
|
3385
|
+
}
|
|
3386
|
+
function useWithdrawAnalyticsEmitter() {
|
|
3387
|
+
const context = _react.useContext.call(void 0, AnalyticsContext);
|
|
3388
|
+
if (!context || context.modal !== "withdraw") return noopWithdrawEmitter;
|
|
3389
|
+
return context.emit;
|
|
3390
|
+
}
|
|
3391
|
+
function useClaimAnalyticsEmitter() {
|
|
3392
|
+
const context = _react.useContext.call(void 0, AnalyticsContext);
|
|
3393
|
+
if (!context || context.modal !== "claim") return noopClaimEmitter;
|
|
3394
|
+
return context.emit;
|
|
3395
|
+
}
|
|
3396
|
+
|
|
2878
3397
|
// src/core/theme.ts
|
|
2879
3398
|
var RADIUS_SCALE = {
|
|
2880
3399
|
none: { sm: "0", md: "0", lg: "0" },
|
|
@@ -2979,11 +3498,11 @@ var NOTHING_TO_STOP = () => {
|
|
|
2979
3498
|
};
|
|
2980
3499
|
function resolveThemeMode(mode) {
|
|
2981
3500
|
if (mode !== "system") return mode;
|
|
2982
|
-
return _optionalChain([globalThis, 'access',
|
|
3501
|
+
return _optionalChain([globalThis, 'access', _135 => _135.matchMedia, 'optionalCall', _136 => _136(DARK_SCHEME_QUERY), 'access', _137 => _137.matches]) ? "dark" : "light";
|
|
2983
3502
|
}
|
|
2984
3503
|
function followSystemAppearance(mode, onChange) {
|
|
2985
3504
|
if (mode !== "system") return NOTHING_TO_STOP;
|
|
2986
|
-
const query = _optionalChain([globalThis, 'access',
|
|
3505
|
+
const query = _optionalChain([globalThis, 'access', _138 => _138.matchMedia, 'optionalCall', _139 => _139(DARK_SCHEME_QUERY)]);
|
|
2987
3506
|
if (!query) return NOTHING_TO_STOP;
|
|
2988
3507
|
query.addEventListener("change", onChange);
|
|
2989
3508
|
return () => query.removeEventListener("change", onChange);
|
|
@@ -2991,22 +3510,22 @@ function followSystemAppearance(mode, onChange) {
|
|
|
2991
3510
|
function applyTheme(element, theme) {
|
|
2992
3511
|
if (!element) return NOTHING_TO_STOP;
|
|
2993
3512
|
const parent = element.parentElement;
|
|
2994
|
-
const targets = _optionalChain([parent, 'optionalAccess',
|
|
3513
|
+
const targets = _optionalChain([parent, 'optionalAccess', _140 => _140.classList, 'access', _141 => _141.contains, 'call', _142 => _142("rs-modal-content")]) ? [element, parent] : [element];
|
|
2995
3514
|
const paintMode = () => {
|
|
2996
|
-
const resolved = resolveThemeMode(_optionalChain([theme, 'optionalAccess',
|
|
3515
|
+
const resolved = resolveThemeMode(_optionalChain([theme, 'optionalAccess', _143 => _143.mode]));
|
|
2997
3516
|
for (const t of targets) {
|
|
2998
3517
|
if (resolved) t.setAttribute("data-theme", resolved);
|
|
2999
3518
|
else t.removeAttribute("data-theme");
|
|
3000
3519
|
}
|
|
3001
3520
|
};
|
|
3002
3521
|
paintMode();
|
|
3003
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3522
|
+
if (_optionalChain([theme, 'optionalAccess', _144 => _144.fontColor])) {
|
|
3004
3523
|
setVar(targets, "--rs-foreground", theme.fontColor);
|
|
3005
3524
|
}
|
|
3006
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3525
|
+
if (_optionalChain([theme, 'optionalAccess', _145 => _145.iconColor])) {
|
|
3007
3526
|
setVar(targets, "--rs-icon", theme.iconColor);
|
|
3008
3527
|
}
|
|
3009
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3528
|
+
if (_optionalChain([theme, 'optionalAccess', _146 => _146.ctaColor])) {
|
|
3010
3529
|
const derived = deriveCustomPrimary(theme.ctaColor);
|
|
3011
3530
|
if (derived) {
|
|
3012
3531
|
setVar(targets, "--rs-primary", derived.base);
|
|
@@ -3031,25 +3550,25 @@ function applyTheme(element, theme) {
|
|
|
3031
3550
|
}
|
|
3032
3551
|
} else {
|
|
3033
3552
|
for (const v of CUSTOM_PRIMARY_VARS) clearVar(targets, v);
|
|
3034
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3553
|
+
if (_optionalChain([theme, 'optionalAccess', _147 => _147.ctaHoverColor])) {
|
|
3035
3554
|
setVar(targets, "--rs-primary-hover", theme.ctaHoverColor);
|
|
3036
3555
|
}
|
|
3037
3556
|
}
|
|
3038
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3557
|
+
if (_optionalChain([theme, 'optionalAccess', _148 => _148.borderColor])) {
|
|
3039
3558
|
setVar(targets, "--rs-border", theme.borderColor);
|
|
3040
3559
|
setVar(targets, "--rs-border-surface", theme.borderColor);
|
|
3041
3560
|
}
|
|
3042
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3561
|
+
if (_optionalChain([theme, 'optionalAccess', _149 => _149.backgroundColor])) {
|
|
3043
3562
|
setVar(targets, "--rs-background", theme.backgroundColor);
|
|
3044
3563
|
}
|
|
3045
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
3564
|
+
if (_optionalChain([theme, 'optionalAccess', _150 => _150.radius])) {
|
|
3046
3565
|
const scale = RADIUS_SCALE[theme.radius];
|
|
3047
3566
|
setVar(targets, "--rs-radius-sm", scale.sm);
|
|
3048
3567
|
setVar(targets, "--rs-radius-md", scale.md);
|
|
3049
3568
|
setVar(targets, "--rs-radius-lg", scale.lg);
|
|
3050
3569
|
setVar(targets, "--rs-radius", scale.md);
|
|
3051
3570
|
}
|
|
3052
|
-
return followSystemAppearance(_optionalChain([theme, 'optionalAccess',
|
|
3571
|
+
return followSystemAppearance(_optionalChain([theme, 'optionalAccess', _151 => _151.mode]), paintMode);
|
|
3053
3572
|
}
|
|
3054
3573
|
|
|
3055
3574
|
// src/core/backend-url.ts
|
|
@@ -3143,4 +3662,8 @@ function checkBackendUrl(component, backendUrl) {
|
|
|
3143
3662
|
|
|
3144
3663
|
|
|
3145
3664
|
|
|
3146
|
-
|
|
3665
|
+
|
|
3666
|
+
|
|
3667
|
+
|
|
3668
|
+
|
|
3669
|
+
exports.Modal = Modal; exports.WalletIcon = WalletIcon; exports.ExternalLinkIcon = ExternalLinkIcon; exports.CheckIcon = CheckIcon; exports.TransferCryptoIcon = TransferCryptoIcon; exports.ChevronRightIcon = ChevronRightIcon; exports.ChevronLeftIcon = ChevronLeftIcon; exports.ChevronDownIcon = ChevronDownIcon; exports.CloseIcon = CloseIcon; exports.HandCoinsIcon = HandCoinsIcon; exports.CoinsIcon = CoinsIcon; exports.HistoryIcon = HistoryIcon; exports.InfoIcon = InfoIcon; exports.CopyIcon = CopyIcon; exports.ArrowUpRightIcon = ArrowUpRightIcon; exports.AlertTriangleIcon = AlertTriangleIcon; exports.CircleArrowOutUpLeftIcon = CircleArrowOutUpLeftIcon; exports.CardIcon = CardIcon; exports.BankIcon = BankIcon; exports.UnplugIcon = UnplugIcon; exports.MigrateAssetsIcon = MigrateAssetsIcon; exports.AppleIcon = AppleIcon; exports.BodyHeader = BodyHeader; exports.CdnIcon = CdnIcon; exports.PoweredBy = PoweredBy; exports.Spinner = Spinner; exports.catalogKeyForChain = catalogKeyForChain; exports.debugLog = debugLog; exports.debugError = debugError; exports.getAssetId = getAssetId; exports.chainIdsByValue = chainIdsByValue; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.formatFeeUsd = formatFeeUsd; exports.quoteFeeRow = quoteFeeRow; exports.quoteFeeGroups = quoteFeeGroups; exports.SwappedConnectFeeChangedError = SwappedConnectFeeChangedError; exports.SUPPORTED_CONNECT_EXCHANGE_COUNT = SUPPORTED_CONNECT_EXCHANGE_COUNT; exports.resolveAppFeeBps = resolveAppFeeBps; exports.PermitDepositSubmitError = PermitDepositSubmitError; exports.createDepositService = createDepositService; exports.rpcUrlFor = rpcUrlFor; exports.RpcUrlsProvider = RpcUrlsProvider; exports.useRpcUrls = useRpcUrls; exports.useStableRpcUrls = useStableRpcUrls; exports.getPublicClient = getPublicClient; exports.peekRuntimeChains = peekRuntimeChains; exports.primeRuntimeChains = primeRuntimeChains; exports.useChainCatalog = useChainCatalog; exports.useCatalogChain = useCatalogChain; exports.useDepositChainIds = useDepositChainIds; exports.useDestinationChains = useDestinationChains; exports.useTargetTokens = useTargetTokens; exports.useIsDepositChain = useIsDepositChain; exports.useChainName = useChainName; exports.useReadClient = useReadClient; exports.useExplorerTxUrl = useExplorerTxUrl; exports.ChainCatalogProvider = ChainCatalogProvider; exports.useLatestRef = useLatestRef; exports.Button = Button; exports.Callout = Callout; exports.TokenIcon = TokenIcon; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.isUnsupportedChainSwitchError = isUnsupportedChainSwitchError; exports.formatUserError = formatUserError; exports.resolveTokenDisplay = resolveTokenDisplay; exports.formatTokenAmount = formatTokenAmount; exports.tokenAmountToNumber = tokenAmountToNumber; exports.formatRawTokenAmount = formatRawTokenAmount; exports.isDisplayStablecoinSymbol = isDisplayStablecoinSymbol; exports.isRecognizedToken = isRecognizedToken; exports.estimateReceiveAmount = estimateReceiveAmount; exports.formatQuotedReceive = formatQuotedReceive; exports.formatReceiveEstimate = formatReceiveEstimate; exports.AnalyticsSession = AnalyticsSession; exports.useDepositAnalyticsEmitter = useDepositAnalyticsEmitter; exports.useWithdrawAnalyticsEmitter = useWithdrawAnalyticsEmitter; exports.useClaimAnalyticsEmitter = useClaimAnalyticsEmitter; exports.resolveThemeMode = resolveThemeMode; exports.followSystemAppearance = followSystemAppearance; exports.applyTheme = applyTheme; exports.checkBackendUrl = checkBackendUrl;
|