@rhinestone/deposit-modal 0.19.0 → 0.20.1

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 (83) hide show
  1. package/README.md +154 -61
  2. package/dist/BankOnrampStep-3SNUX6V2.cjs +435 -0
  3. package/dist/BankOnrampStep-4D24HVHV.mjs +435 -0
  4. package/dist/{DepositModalReown-UITYXJ6W.cjs → DepositModalReown-7EHOJTFW.cjs} +21 -20
  5. package/dist/{DepositModalReown-XBNY6QCI.mjs → DepositModalReown-SYQ2SCHC.mjs} +6 -5
  6. package/dist/WithdrawModal-LLJLEYXZ.cjs +12 -0
  7. package/dist/WithdrawModal-LXDIT4UV.mjs +12 -0
  8. package/dist/{bearer-transport-CVHNBgoV.d.cts → bearer-transport-DZyeDG64.d.cts} +5 -1
  9. package/dist/{bearer-transport-CVHNBgoV.d.ts → bearer-transport-DZyeDG64.d.ts} +5 -1
  10. package/dist/{caip-BMi-9t09.d.cts → caip-nwFFL46o.d.cts} +2 -2
  11. package/dist/{caip-BMi-9t09.d.ts → caip-nwFFL46o.d.ts} +2 -2
  12. package/dist/{chunk-FTWKAJGN.mjs → chunk-2FOPO4N5.mjs} +1 -1
  13. package/dist/{chunk-EG4H7OMC.cjs → chunk-CIVFT5KR.cjs} +171 -130
  14. package/dist/{chunk-PYOC6K24.cjs → chunk-D3R3O4CY.cjs} +1 -1
  15. package/dist/chunk-E7IMWVMN.mjs +346 -0
  16. package/dist/chunk-EJDBIWNH.mjs +113 -0
  17. package/dist/chunk-FKJ6EJHH.cjs +346 -0
  18. package/dist/{chunk-LVCD6RHF.cjs → chunk-FVJKUTHF.cjs} +2 -2
  19. package/dist/{chunk-NITKDXHR.mjs → chunk-FW7ZMXQS.mjs} +849 -674
  20. package/dist/chunk-G264OM23.cjs +224 -0
  21. package/dist/chunk-IPHKBBUV.cjs +113 -0
  22. package/dist/{chunk-BIL4ENC3.mjs → chunk-IPKT3FU6.mjs} +73 -32
  23. package/dist/chunk-JPX4MEHV.mjs +19 -0
  24. package/dist/{chunk-HMUGY66O.cjs → chunk-KXSU24RU.cjs} +1569 -1019
  25. package/dist/{chunk-ISLVD5HQ.cjs → chunk-LVMNNMOZ.cjs} +10 -5
  26. package/dist/chunk-O5OW4S7L.cjs +19 -0
  27. package/dist/{chunk-5NWLS5BQ.mjs → chunk-OZPMRTW3.mjs} +1511 -961
  28. package/dist/{chunk-OCWSMLOP.cjs → chunk-PVFEZ3UG.cjs} +1164 -989
  29. package/dist/{chunk-ZGHVJ2XM.mjs → chunk-YQCRXJIL.mjs} +8 -3
  30. package/dist/chunk-YY4ZOAH5.mjs +224 -0
  31. package/dist/{chunk-X6N2XPTO.mjs → chunk-ZOJMB5TZ.mjs} +1 -1
  32. package/dist/compliance.cjs +4 -7
  33. package/dist/compliance.d.cts +26 -3
  34. package/dist/compliance.d.ts +26 -3
  35. package/dist/compliance.mjs +6 -9
  36. package/dist/constants-BQDxVNgr.d.cts +29 -0
  37. package/dist/constants-DjGQW5N5.d.ts +29 -0
  38. package/dist/constants.cjs +3 -37
  39. package/dist/constants.d.cts +4 -20
  40. package/dist/constants.d.ts +4 -20
  41. package/dist/constants.mjs +4 -38
  42. package/dist/deposit.cjs +7 -6
  43. package/dist/deposit.d.cts +5 -3
  44. package/dist/deposit.d.ts +5 -3
  45. package/dist/deposit.mjs +6 -5
  46. package/dist/embed.cjs +21 -20
  47. package/dist/embed.d.cts +3 -2
  48. package/dist/embed.d.ts +3 -2
  49. package/dist/embed.mjs +7 -6
  50. package/dist/index.cjs +8 -35
  51. package/dist/index.d.cts +5 -3
  52. package/dist/index.d.ts +5 -3
  53. package/dist/index.mjs +9 -36
  54. package/dist/onramp.cjs +4 -33
  55. package/dist/onramp.d.cts +51 -33
  56. package/dist/onramp.d.ts +51 -33
  57. package/dist/onramp.mjs +5 -34
  58. package/dist/polymarket.cjs +6 -6
  59. package/dist/polymarket.mjs +2 -2
  60. package/dist/ramp-types-HYWd7CW0.d.cts +108 -0
  61. package/dist/ramp-types-HYWd7CW0.d.ts +108 -0
  62. package/dist/styles.css +255 -0
  63. package/dist/{types-BOxa1DE-.d.ts → types-BEEMfNi2.d.cts} +24 -4
  64. package/dist/{types-BShYNpvO.d.cts → types-DQDUqzsZ.d.ts} +24 -4
  65. package/dist/withdraw.cjs +6 -5
  66. package/dist/withdraw.d.cts +4 -3
  67. package/dist/withdraw.d.ts +4 -3
  68. package/dist/withdraw.mjs +5 -4
  69. package/package.json +9 -17
  70. package/dist/WithdrawModal-DY6A55OA.mjs +0 -11
  71. package/dist/WithdrawModal-V42OK7L3.cjs +0 -11
  72. package/dist/chunk-ADEWTBSN.cjs +0 -19
  73. package/dist/chunk-EAGMY3QE.mjs +0 -962
  74. package/dist/chunk-OY5N3E6L.cjs +0 -962
  75. package/dist/chunk-PP4QE32S.mjs +0 -19
  76. package/dist/constants-BT4ctuHo.d.cts +0 -64
  77. package/dist/constants-D21ZdNOP.d.ts +0 -64
  78. package/dist/offramp.cjs +0 -25
  79. package/dist/offramp.d.cts +0 -28
  80. package/dist/offramp.d.ts +0 -28
  81. package/dist/offramp.mjs +0 -25
  82. package/dist/ramp-types-C6aUz4SZ.d.cts +0 -43
  83. package/dist/ramp-types-C6aUz4SZ.d.ts +0 -43
@@ -0,0 +1,435 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkG264OM23cjs = require('./chunk-G264OM23.cjs');
9
+
10
+
11
+ var _chunkIPHKBBUVcjs = require('./chunk-IPHKBBUV.cjs');
12
+
13
+
14
+
15
+ var _chunkO5OW4S7Lcjs = require('./chunk-O5OW4S7L.cjs');
16
+
17
+
18
+ var _chunkLVMNNMOZcjs = require('./chunk-LVMNNMOZ.cjs');
19
+ require('./chunk-D3R3O4CY.cjs');
20
+
21
+ // src/components/steps/BankOnrampStep.tsx
22
+ var _react = require('react');
23
+
24
+ // src/core/noah-hosted.ts
25
+ var NOAH_HOSTED_ORIGINS = [
26
+ "https://checkout.noah.com",
27
+ "https://checkout.sandbox.noah.com"
28
+ ];
29
+ function isTrustedNoahHostedUrl(url) {
30
+ let parsed;
31
+ try {
32
+ parsed = new URL(url);
33
+ } catch (e) {
34
+ return false;
35
+ }
36
+ return NOAH_HOSTED_ORIGINS.includes(parsed.origin);
37
+ }
38
+ function hostedSessionRemainingMs(expiresAt, now = Date.now()) {
39
+ if (!expiresAt) return null;
40
+ const expiry = Date.parse(expiresAt);
41
+ if (!Number.isFinite(expiry)) return null;
42
+ return Math.max(0, expiry - now);
43
+ }
44
+
45
+ // src/components/steps/BankDetailsView.tsx
46
+
47
+ var _jsxruntime = require('react/jsx-runtime');
48
+ var RAILS = { BankAch: "ACH", BankFedwire: "Wire", BankSwift: "SWIFT", BankSepa: "SEPA" };
49
+ function Detail({ label, value }) {
50
+ const [copied, setCopied] = _react.useState.call(void 0, false);
51
+ const [failed, setFailed] = _react.useState.call(void 0, false);
52
+ if (!value) return null;
53
+ async function copy() {
54
+ try {
55
+ await navigator.clipboard.writeText(value);
56
+ setCopied(true);
57
+ setFailed(false);
58
+ } catch (e2) {
59
+ setFailed(true);
60
+ }
61
+ }
62
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-detail", children: [
63
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-detail-text", children: [
64
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-bank-detail-label", children: label }),
65
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-bank-detail-value", children: value }),
66
+ failed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { role: "status", className: "rs-bank-detail-label", children: "Could not copy. Select the value to copy it." })
67
+ ] }),
68
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "rs-bank-copy", "aria-label": `Copy ${label.toLowerCase()}`, onClick: () => void copy(), children: copied ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkG264OM23cjs.CheckIcon, { size: 16 }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkG264OM23cjs.CopyIcon, { size: 16 }) })
69
+ ] });
70
+ }
71
+ function BankDetailsView({ details }) {
72
+ const [selected, setSelected] = _react.useState.call(void 0, 0);
73
+ const rail = _nullishCoalesce(details.rails[selected], () => ( details.rails[0]));
74
+ const address = details.bankAddress;
75
+ const bankAddress = address && [address.street, address.street2, address.city, address.state, address.postCode, address.country].filter(Boolean).join(", ");
76
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-native", children: [
77
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-bank-rails", role: "group", "aria-label": "Transfer method", children: details.rails.map((item, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
78
+ "button",
79
+ {
80
+ type: "button",
81
+ className: "rs-bank-rail",
82
+ "aria-pressed": index === selected,
83
+ onClick: () => setSelected(index),
84
+ children: RAILS[item.type]
85
+ },
86
+ item.type
87
+ )) }),
88
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "rs-bank-detail-label", children: [
89
+ "Send ",
90
+ details.currency,
91
+ " using the selected transfer method."
92
+ ] }),
93
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-fields", children: [
94
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Detail, { label: "Account holder", value: details.accountHolderName }),
95
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Detail, { label: rail.type === "BankSepa" ? "IBAN" : "Account number", value: rail.accountNumber }),
96
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Detail, { label: rail.type === "BankAch" || rail.type === "BankFedwire" ? "Routing number" : "SWIFT / BIC", value: rail.bankCode }),
97
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Detail, { label: "Bank name", value: details.bankName }),
98
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Detail, { label: "Bank address", value: bankAddress }),
99
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Detail, { label: "Payment reference", value: details.reference })
100
+ ] }, rail.type),
101
+ details.reference && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "rs-bank-detail-label", children: "Include this payment reference with your transfer." }),
102
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-fee", children: [
103
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-detail-label", children: [
104
+ "Last quoted fee \xB7 ",
105
+ new Date(details.capturedAt).toLocaleDateString()
106
+ ] }),
107
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
108
+ rail.fee.base,
109
+ " ",
110
+ rail.fee.currency,
111
+ " + ",
112
+ rail.fee.percent,
113
+ "% \xB7 minimum ",
114
+ rail.fee.minimum,
115
+ " ",
116
+ rail.fee.currency
117
+ ] }),
118
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "rs-bank-detail-label", children: "Fees may change before your transfer arrives." })
119
+ ] })
120
+ ] });
121
+ }
122
+
123
+ // src/components/steps/BankOnrampStep.tsx
124
+
125
+ var SAFE_ERROR = "Bank details are unavailable. Try again.";
126
+ var PENDING_ERROR = "Bank details are not ready yet. Check back shortly.";
127
+ var OPTIONS_ERROR = "Bank transfer options are unavailable. Try again.";
128
+ var VERIFICATION_POLL_MS = 5e3;
129
+ var MAX_TIMEOUT_MS = 2147483647;
130
+ function BankOnrampStep({
131
+ backendUrl,
132
+ smartAccount,
133
+ bankOnramp,
134
+ onError,
135
+ openExternally,
136
+ onUnavailable,
137
+ onJourney
138
+ }) {
139
+ const getSessionRef = _chunkG264OM23cjs.useLatestRef.call(void 0, bankOnramp.getSession);
140
+ const sessionOptions = _react.useMemo.call(void 0,
141
+ () => ({
142
+ backendUrl,
143
+ getSession: () => getSessionRef.current(smartAccount)
144
+ }),
145
+ [backendUrl, getSessionRef, smartAccount]
146
+ );
147
+ const service = _react.useMemo.call(void 0,
148
+ () => _chunkIPHKBBUVcjs.createOnrampService.call(void 0, sessionOptions),
149
+ [sessionOptions]
150
+ );
151
+ const [availableForHistory, setAvailableForHistory] = _react.useState.call(void 0, false);
152
+ _react.useEffect.call(void 0, () => {
153
+ _optionalChain([onJourney, 'optionalCall', _ => _({ source: availableForHistory ? service : null })]);
154
+ return () => _optionalChain([onJourney, 'optionalCall', _2 => _2(null)]);
155
+ }, [service, onJourney, availableForHistory]);
156
+ const [noOptions, setNoOptions] = _react.useState.call(void 0, false);
157
+ const [loading, setLoading] = _react.useState.call(void 0, true);
158
+ const [selectedAccount, setSelectedAccount] = _react.useState.call(void 0,
159
+ null
160
+ );
161
+ const [hostedUrl, setHostedUrl] = _react.useState.call(void 0, null);
162
+ const [bankDetails, setBankDetails] = _react.useState.call(void 0,
163
+ null
164
+ );
165
+ const [verificationExpired, setVerificationExpired] = _react.useState.call(void 0, false);
166
+ const [verificationExpiresAt, setVerificationExpiresAt] = _react.useState.call(void 0, null);
167
+ const [iframeLoaded, setIframeLoaded] = _react.useState.call(void 0, false);
168
+ const [externalOpened, setExternalOpened] = _react.useState.call(void 0, false);
169
+ const [error, setError] = _react.useState.call(void 0, null);
170
+ const [verifying, setVerifying] = _react.useState.call(void 0, null);
171
+ const requestGenerationRef = _react.useRef.call(void 0, 0);
172
+ const verificationResumedRef = _react.useRef.call(void 0, false);
173
+ const isCurrentRequest = _react.useCallback.call(void 0,
174
+ (generation) => requestGenerationRef.current === generation,
175
+ []
176
+ );
177
+ const startVerification = _react.useCallback.call(void 0, async () => {
178
+ const session = await _chunkO5OW4S7Lcjs.startComplianceVerification.call(void 0, sessionOptions);
179
+ if (session.status === "failed") return "declined";
180
+ if (!session.nextAction) return "reviewing";
181
+ if (!isTrustedNoahHostedUrl(session.nextAction.url)) return "reviewing";
182
+ if (openExternally) {
183
+ await openExternally(session.nextAction.url);
184
+ setExternalOpened(true);
185
+ return "action_required";
186
+ }
187
+ setHostedUrl(session.nextAction.url);
188
+ setVerificationExpiresAt(session.expiresAt);
189
+ setVerificationExpired(false);
190
+ setIframeLoaded(false);
191
+ return "action_required";
192
+ }, [openExternally, sessionOptions]);
193
+ const ensureVerified = _react.useCallback.call(void 0, async () => {
194
+ const current = await _chunkO5OW4S7Lcjs.getComplianceStatus.call(void 0, sessionOptions);
195
+ if (current.status === "approved") return "approved";
196
+ if (current.status === "declined") return "declined";
197
+ return startVerification();
198
+ }, [sessionOptions, startVerification]);
199
+ const loadAccounts = _react.useCallback.call(void 0, async () => {
200
+ const generation = ++requestGenerationRef.current;
201
+ setLoading(true);
202
+ setError(null);
203
+ setNoOptions(false);
204
+ try {
205
+ const discover = () => service.getOptions().catch((error2) => {
206
+ if (error2 instanceof _chunkLVMNNMOZcjs.ScopedRequestError && error2.status === 404 && onUnavailable) {
207
+ if (isCurrentRequest(generation)) onUnavailable();
208
+ return null;
209
+ }
210
+ throw error2;
211
+ });
212
+ const available = await discover();
213
+ if (!available || !isCurrentRequest(generation)) return;
214
+ setAvailableForHistory(true);
215
+ const verification = await ensureVerified();
216
+ if (!isCurrentRequest(generation)) return;
217
+ if (verification !== "approved") {
218
+ setVerifying(verification);
219
+ return;
220
+ }
221
+ setVerifying(null);
222
+ setExternalOpened(false);
223
+ const [current, existing] = await Promise.all([
224
+ discover(),
225
+ service.listAccounts()
226
+ ]);
227
+ if (!current || !isCurrentRequest(generation)) return;
228
+ const [option] = current.options;
229
+ if (!option) {
230
+ setNoOptions(true);
231
+ return;
232
+ }
233
+ void selectOptionRef.current(
234
+ option,
235
+ existing.items.find(
236
+ (account) => account.status === "active" && account.currency === option.currency
237
+ )
238
+ );
239
+ } catch (e3) {
240
+ if (!isCurrentRequest(generation)) return;
241
+ setError(OPTIONS_ERROR);
242
+ _optionalChain([onError, 'optionalCall', _3 => _3(OPTIONS_ERROR, "BANK_ONRAMP_OPTIONS_FAILED")]);
243
+ } finally {
244
+ if (isCurrentRequest(generation)) setLoading(false);
245
+ }
246
+ }, [ensureVerified, isCurrentRequest, onError, onUnavailable, service]);
247
+ _react.useEffect.call(void 0, () => {
248
+ setSelectedAccount(null);
249
+ setBankDetails(null);
250
+ setHostedUrl(null);
251
+ setExternalOpened(false);
252
+ void loadAccounts();
253
+ return () => {
254
+ requestGenerationRef.current += 1;
255
+ };
256
+ }, [loadAccounts]);
257
+ const openDetails = _react.useCallback.call(void 0,
258
+ async (account) => {
259
+ const generation = ++requestGenerationRef.current;
260
+ setLoading(true);
261
+ setError(null);
262
+ setBankDetails(null);
263
+ try {
264
+ const { bankDetails: details } = await service.getAccountDetails(
265
+ account.id
266
+ );
267
+ if (!isCurrentRequest(generation)) return;
268
+ if (details.currency !== account.currency)
269
+ throw new Error("Bank currency mismatch");
270
+ setBankDetails(details);
271
+ } catch (error2) {
272
+ if (!isCurrentRequest(generation)) return;
273
+ const pending = error2 instanceof _chunkLVMNNMOZcjs.ScopedRequestError && error2.status === 409;
274
+ const message = pending ? PENDING_ERROR : SAFE_ERROR;
275
+ setError(message);
276
+ _optionalChain([onError, 'optionalCall', _4 => _4(
277
+ message,
278
+ pending ? "BANK_ONRAMP_DETAILS_PENDING" : "BANK_ONRAMP_DETAILS_FAILED"
279
+ )]);
280
+ } finally {
281
+ if (isCurrentRequest(generation)) setLoading(false);
282
+ }
283
+ },
284
+ [isCurrentRequest, onError, service]
285
+ );
286
+ const selectOption = _react.useCallback.call(void 0,
287
+ async (option, account) => {
288
+ if (account) {
289
+ setSelectedAccount(account);
290
+ await openDetails(account);
291
+ return;
292
+ }
293
+ const generation = ++requestGenerationRef.current;
294
+ setLoading(true);
295
+ setError(null);
296
+ try {
297
+ const request = {
298
+ currency: option.currency,
299
+ optionId: option.optionId
300
+ };
301
+ const nextAccount = (await service.createAccount(request)).account;
302
+ if (!isCurrentRequest(generation)) return;
303
+ setSelectedAccount(nextAccount);
304
+ await openDetails(nextAccount);
305
+ } catch (error2) {
306
+ if (!isCurrentRequest(generation)) return;
307
+ if (error2 instanceof _chunkLVMNNMOZcjs.ScopedRequestError && error2.status === 409 && error2.code === "VERIFICATION_REQUIRED" && !verificationResumedRef.current) {
308
+ verificationResumedRef.current = true;
309
+ try {
310
+ const verification = await startVerification();
311
+ if (!isCurrentRequest(generation)) return;
312
+ setVerifying(verification);
313
+ setLoading(false);
314
+ return;
315
+ } catch (e4) {
316
+ if (!isCurrentRequest(generation)) return;
317
+ }
318
+ }
319
+ setError(SAFE_ERROR);
320
+ _optionalChain([onError, 'optionalCall', _5 => _5(SAFE_ERROR, "BANK_ONRAMP_SETUP_FAILED")]);
321
+ setLoading(false);
322
+ }
323
+ },
324
+ [isCurrentRequest, onError, openDetails, service, startVerification]
325
+ );
326
+ const selectOptionRef = _chunkG264OM23cjs.useLatestRef.call(void 0, selectOption);
327
+ _react.useEffect.call(void 0, () => {
328
+ if (verifying !== "action_required" || !hostedUrl) return;
329
+ const remaining = hostedSessionRemainingMs(
330
+ _nullishCoalesce(verificationExpiresAt, () => ( void 0))
331
+ );
332
+ if (remaining === null) return;
333
+ if (remaining > MAX_TIMEOUT_MS) return;
334
+ const timer = setTimeout(() => setVerificationExpired(true), remaining);
335
+ return () => clearTimeout(timer);
336
+ }, [hostedUrl, verificationExpiresAt, verifying]);
337
+ _react.useEffect.call(void 0, () => {
338
+ if (verifying !== "action_required" && verifying !== "reviewing") return;
339
+ let active = true;
340
+ const timer = setInterval(() => {
341
+ void (async () => {
342
+ try {
343
+ const status = await _chunkO5OW4S7Lcjs.getComplianceStatus.call(void 0, sessionOptions);
344
+ if (!active) return;
345
+ if (status.status === "approved") {
346
+ setHostedUrl(null);
347
+ void loadAccounts();
348
+ } else if (status.status === "declined") {
349
+ setVerifying("declined");
350
+ }
351
+ } catch (e5) {
352
+ }
353
+ })();
354
+ }, VERIFICATION_POLL_MS);
355
+ return () => {
356
+ active = false;
357
+ clearInterval(timer);
358
+ };
359
+ }, [verifying, sessionOptions, loadAccounts]);
360
+ const restartVerification = _react.useCallback.call(void 0, () => {
361
+ setVerificationExpired(false);
362
+ setVerificationExpiresAt(null);
363
+ setHostedUrl(null);
364
+ void loadAccounts();
365
+ }, [loadAccounts]);
366
+ const hostedFrameMounted = Boolean(hostedUrl) && !verificationExpired;
367
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-screen rs-bank-onramp", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
368
+ !hostedFrameMounted && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
369
+ _chunkG264OM23cjs.BodyHeader,
370
+ {
371
+ icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkG264OM23cjs.BankIcon, {}),
372
+ title: "Bank transfer",
373
+ subtitle: "Your bank transfer details"
374
+ }
375
+ ),
376
+ loading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", "aria-live": "polite", children: [
377
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkG264OM23cjs.Spinner, {}),
378
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Preparing bank details\u2026" })
379
+ ] }),
380
+ !loading && error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-state", "aria-live": "polite", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: error }) }),
381
+ !loading && !error && verifying === "declined" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", "aria-live": "polite", children: [
382
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Verification unsuccessful" }),
383
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-subtitle", children: "Your provider could not verify these details. Contact support to continue." })
384
+ ] }),
385
+ !loading && !error && verifying === "reviewing" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", "aria-live": "polite", children: [
386
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkG264OM23cjs.Spinner, {}),
387
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Checking your details" }),
388
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-subtitle", children: "This usually takes a moment. You can close this and come back." })
389
+ ] }),
390
+ !loading && !error && verifying === "action_required" && externalOpened && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", "aria-live": "polite", children: [
391
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Verification opened" }),
392
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-subtitle", children: "Finish verifying in your browser, then return here." })
393
+ ] }),
394
+ !loading && !error && verifying === "action_required" && verificationExpired && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", "aria-live": "polite", children: [
395
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Verification expired" }),
396
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-subtitle", children: "That verification session timed out. Start a new one to pick up where you left off." }),
397
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-screen-button-row", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
398
+ "button",
399
+ {
400
+ type: "button",
401
+ className: "rs-button rs-button--primary",
402
+ onClick: restartVerification,
403
+ children: "Start again"
404
+ }
405
+ ) })
406
+ ] }),
407
+ !loading && !error && verifying === "action_required" && !verificationExpired && hostedUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-bank-onramp-hosted", children: [
408
+ !iframeLoaded && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
409
+ "div",
410
+ {
411
+ className: "rs-bank-onramp-frame-loading",
412
+ "aria-live": "polite",
413
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkG264OM23cjs.Spinner, {})
414
+ }
415
+ ),
416
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
417
+ "iframe",
418
+ {
419
+ title: "Verify your details",
420
+ src: hostedUrl,
421
+ sandbox: "allow-forms allow-scripts allow-same-origin",
422
+ referrerPolicy: "no-referrer",
423
+ allow: "camera; microphone; clipboard-write",
424
+ onLoad: () => setIframeLoaded(true)
425
+ }
426
+ )
427
+ ] }),
428
+ !loading && !error && !verifying && noOptions && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-state", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "No bank transfer options are available." }) }),
429
+ !loading && !error && !verifying && selectedAccount && bankDetails && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BankDetailsView, { details: bankDetails }, selectedAccount.id) })
430
+ ] }) });
431
+ }
432
+ BankOnrampStep.displayName = "BankOnrampStep";
433
+
434
+
435
+ exports.BankOnrampStep = BankOnrampStep;