@ab-org/predicate-market-sdk 2.0.0 → 2.1.1-beta.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.
@@ -0,0 +1,3192 @@
1
+ import { getExplorerUrl } from './chunk-XB2DFS2W.js';
2
+ import { getChains, registerPlatform, quote, getWithdrawOrder } from './chunk-TPMI3XWV.js';
3
+ import { getEnv } from './chunk-SHLNBZBY.js';
4
+ import { clientIds, stage } from './chunk-6YQEHB6P.js';
5
+ import { getSDKConfig } from './chunk-WHTI52FI.js';
6
+ import { cache_exports } from './chunk-YX56ZGDB.js';
7
+ import { useEffect, useState, useRef, useMemo, useCallback } from 'react';
8
+ import { sessionStore, createDefaultInjectedWalletRegistry, WalletConnector } from '@ab-org/sdk-core';
9
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
+ import qrcode from 'qrcode-generator';
11
+
12
+ // ../sign_in_sdk/src/ui/theme.ts
13
+ var colors = {
14
+ card: "#121214",
15
+ cardRaised: "#151821",
16
+ border: "rgba(126,135,162,0.2)",
17
+ textPrimary: "#FFFFFF",
18
+ textSecondary: "#737477",
19
+ accent: "#29FF9B",
20
+ danger: "#FF6B6B"};
21
+ var radii = {
22
+ pill: "99px",
23
+ card: "12px"};
24
+ var fonts = {
25
+ family: '"Switzer", "Inter", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
26
+ };
27
+ var GoogleIcon = () => /* @__PURE__ */ jsxs("svg", { width: "21", height: "21", viewBox: "0 0 21 21", fill: "none", children: [
28
+ /* @__PURE__ */ jsx("path", { d: "M20.3 10.73c0-.79-.07-1.54-.19-2.27H10.5v4.51h5.5a4.69 4.69 0 0 1-2.04 3.09v2.57h3.3c1.93-1.78 3.04-4.4 3.04-7.9Z", fill: "#4285F4" }),
29
+ /* @__PURE__ */ jsx("path", { d: "M10.5 21c2.76 0 5.07-.91 6.76-2.47l-3.3-2.57c-.92.61-2.09.97-3.46.97-2.66 0-4.91-1.8-5.71-4.22H1.39v2.65A10.5 10.5 0 0 0 10.5 21Z", fill: "#34A853" }),
30
+ /* @__PURE__ */ jsx("path", { d: "M4.79 12.71A6.3 6.3 0 0 1 4.46 10.5c0-.77.13-1.51.33-2.21V5.64H1.39A10.5 10.5 0 0 0 0 10.5c0 1.7.41 3.3 1.39 4.86l3.4-2.65Z", fill: "#FBBC05" }),
31
+ /* @__PURE__ */ jsx("path", { d: "M10.5 4.07c1.5 0 2.84.51 3.9 1.52l2.92-2.92C15.56 1.02 13.26 0 10.5 0A10.5 10.5 0 0 0 1.39 5.64l3.4 2.65C5.59 5.87 7.84 4.07 10.5 4.07Z", fill: "#EA4335" })
32
+ ] });
33
+ var XIcon = () => /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231 5.45-6.231Zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77Z", fill: "white" }) });
34
+ var ExpandIcon = ({ expanded }) => /* @__PURE__ */ jsxs(
35
+ "svg",
36
+ {
37
+ width: "24",
38
+ height: "24",
39
+ viewBox: "0 0 24 24",
40
+ fill: "none",
41
+ style: { transform: expanded ? "rotate(180deg)" : void 0, transition: "transform 0.2s" },
42
+ children: [
43
+ /* @__PURE__ */ jsx("path", { d: "M5 9L9 13L13 9", stroke: colors.textSecondary, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
44
+ /* @__PURE__ */ jsx("path", { d: "M11 9L15 13L19 9", stroke: colors.textSecondary, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
45
+ ]
46
+ }
47
+ );
48
+ var SpinnerIcon = () => /* @__PURE__ */ jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", style: { animation: "spin 1s linear infinite" }, children: [
49
+ /* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "8", stroke: "rgba(255,255,255,0.2)", strokeWidth: "2.5" }),
50
+ /* @__PURE__ */ jsx("path", { d: "M10 2a8 8 0 0 1 8 8", stroke: colors.textPrimary, strokeWidth: "2.5", strokeLinecap: "round" }),
51
+ /* @__PURE__ */ jsx("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
52
+ ] });
53
+ var defaultSocialProviders = [
54
+ { id: "google", label: "Continue with Google", icon: /* @__PURE__ */ jsx(GoogleIcon, {}) },
55
+ { id: "x", label: "Continue with X", icon: /* @__PURE__ */ jsx(XIcon, {}) }
56
+ ];
57
+ function resolveWalletItems(wallets, defaultWalletRegistry) {
58
+ const walletMap = new Map(
59
+ defaultWalletRegistry.map((item) => [
60
+ item.id,
61
+ {
62
+ name: item.title,
63
+ installed: item.installed,
64
+ installUrl: item.installUrl
65
+ }
66
+ ])
67
+ );
68
+ if (wallets === void 0) {
69
+ return defaultWalletRegistry.map((item) => ({
70
+ id: item.id,
71
+ name: item.title,
72
+ icon: void 0,
73
+ installed: item.installed,
74
+ installUrl: item.installUrl
75
+ }));
76
+ }
77
+ if (wallets.length === 0) {
78
+ return [];
79
+ }
80
+ return wallets.map((wallet) => {
81
+ const fallback = walletMap.get(wallet.id);
82
+ return {
83
+ ...wallet,
84
+ name: wallet.name ?? fallback?.name ?? wallet.id,
85
+ installed: wallet.installed ?? fallback?.installed,
86
+ installUrl: wallet.installUrl ?? fallback?.installUrl
87
+ };
88
+ });
89
+ }
90
+ function resolveSocialProviders(socialProviders) {
91
+ if (socialProviders === void 0) {
92
+ return defaultSocialProviders;
93
+ }
94
+ if (socialProviders.length === 0) {
95
+ return [];
96
+ }
97
+ const defaultProviderMap = new Map(
98
+ defaultSocialProviders.map((provider) => [provider.id, provider])
99
+ );
100
+ return socialProviders.map((provider) => {
101
+ const fallback = defaultProviderMap.get(provider.id);
102
+ return {
103
+ ...provider,
104
+ label: provider.label ?? fallback?.label ?? provider.id,
105
+ icon: provider.icon ?? fallback?.icon
106
+ };
107
+ });
108
+ }
109
+ var IconFrame = ({
110
+ background,
111
+ children
112
+ }) => /* @__PURE__ */ jsx(
113
+ "div",
114
+ {
115
+ style: {
116
+ width: 48,
117
+ height: 48,
118
+ borderRadius: 12,
119
+ background,
120
+ display: "flex",
121
+ alignItems: "center",
122
+ justifyContent: "center",
123
+ overflow: "hidden"
124
+ },
125
+ children
126
+ }
127
+ );
128
+ var MetaMaskWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#1A0F07", children: /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", children: [
129
+ /* @__PURE__ */ jsx("path", { d: "M8 6L15 11L12 14L8 6Z", fill: "#E17726" }),
130
+ /* @__PURE__ */ jsx("path", { d: "M24 6L17 11L20 14L24 6Z", fill: "#E27625" }),
131
+ /* @__PURE__ */ jsx("path", { d: "M11 19L15 22V17L11 19Z", fill: "#F6851B" }),
132
+ /* @__PURE__ */ jsx("path", { d: "M21 19L17 22V17L21 19Z", fill: "#F6851B" }),
133
+ /* @__PURE__ */ jsx("path", { d: "M12 14L15 11V17L11 19L12 14Z", fill: "#763D16" }),
134
+ /* @__PURE__ */ jsx("path", { d: "M20 14L17 11V17L21 19L20 14Z", fill: "#763D16" })
135
+ ] }) });
136
+ var OKXWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#FFFFFF", children: /* @__PURE__ */ jsxs("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", children: [
137
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "2", width: "8", height: "8", rx: "2", fill: "#050608" }),
138
+ /* @__PURE__ */ jsx("rect", { x: "11", y: "2", width: "8", height: "8", rx: "2", fill: "#050608" }),
139
+ /* @__PURE__ */ jsx("rect", { x: "20", y: "2", width: "8", height: "8", rx: "2", fill: "#050608" }),
140
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "11", width: "8", height: "8", rx: "2", fill: "#050608" }),
141
+ /* @__PURE__ */ jsx("rect", { x: "20", y: "11", width: "8", height: "8", rx: "2", fill: "#050608" }),
142
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "20", width: "8", height: "8", rx: "2", fill: "#050608" }),
143
+ /* @__PURE__ */ jsx("rect", { x: "11", y: "20", width: "8", height: "8", rx: "2", fill: "#050608" }),
144
+ /* @__PURE__ */ jsx("rect", { x: "20", y: "20", width: "8", height: "8", rx: "2", fill: "#050608" })
145
+ ] }) });
146
+ var CoinbaseWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#0052FF", children: /* @__PURE__ */ jsxs("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", children: [
147
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "15", r: "10", stroke: "white", strokeWidth: "4" }),
148
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "13", width: "12", height: "4", rx: "2", fill: "white" })
149
+ ] }) });
150
+ var TrustWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#3375FF", children: /* @__PURE__ */ jsxs("svg", { width: "28", height: "28", viewBox: "0 0 28 28", fill: "none", children: [
151
+ /* @__PURE__ */ jsx("path", { d: "M14 4L21 6.6V12.8C21 17.1 18.1 20.9 14 22.4C9.9 20.9 7 17.1 7 12.8V6.6L14 4Z", fill: "white" }),
152
+ /* @__PURE__ */ jsx("path", { d: "M14 8L17 9.1V12.3C17 14.7 15.7 16.8 14 17.6C12.3 16.8 11 14.7 11 12.3V9.1L14 8Z", fill: "#3375FF" })
153
+ ] }) });
154
+ var PhantomWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "linear-gradient(135deg, #6C47FF 0%, #9B6BFF 100%)", children: /* @__PURE__ */ jsxs("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", children: [
155
+ /* @__PURE__ */ jsx("path", { d: "M8 18.5C8 14.4 11.2 11 15.3 11H20.4C21.8 11 23 12.2 23 13.6C23 15 21.8 16.2 20.4 16.2H14.7", stroke: "white", strokeWidth: "3", strokeLinecap: "round" }),
156
+ /* @__PURE__ */ jsx("path", { d: "M10.5 14H19.5", stroke: "white", strokeWidth: "3", strokeLinecap: "round" }),
157
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "20", r: "1.4", fill: "white" }),
158
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "20", r: "1.4", fill: "white" })
159
+ ] }) });
160
+ var RabbyWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#EBF2FF", children: /* @__PURE__ */ jsxs("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", children: [
161
+ /* @__PURE__ */ jsx("path", { d: "M11 7L13.5 13", stroke: "#7084FF", strokeWidth: "3", strokeLinecap: "round" }),
162
+ /* @__PURE__ */ jsx("path", { d: "M19 7L16.5 13", stroke: "#7084FF", strokeWidth: "3", strokeLinecap: "round" }),
163
+ /* @__PURE__ */ jsx("rect", { x: "8", y: "12", width: "14", height: "11", rx: "6", fill: "#7084FF" }),
164
+ /* @__PURE__ */ jsx("circle", { cx: "13", cy: "17", r: "1.4", fill: "white" }),
165
+ /* @__PURE__ */ jsx("circle", { cx: "17", cy: "17", r: "1.4", fill: "white" }),
166
+ /* @__PURE__ */ jsx("path", { d: "M13 20C13.6 20.4 14.3 20.6 15 20.6C15.7 20.6 16.4 20.4 17 20", stroke: "white", strokeWidth: "1.8", strokeLinecap: "round" })
167
+ ] }) });
168
+ var RainbowWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "linear-gradient(180deg, #174299 0%, #001E59 100%)", children: /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "0 0 120 120", fill: "none", style: { overflow: "hidden", borderRadius: 12 }, children: [
169
+ /* @__PURE__ */ jsxs("defs", { children: [
170
+ /* @__PURE__ */ jsxs("radialGradient", { id: "rainbow_r1", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(26 94) rotate(-90) scale(74)", children: [
171
+ /* @__PURE__ */ jsx("stop", { offset: "0.770277", stopColor: "#FF4000" }),
172
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#8754C9" })
173
+ ] }),
174
+ /* @__PURE__ */ jsxs("linearGradient", { id: "rainbow_l2", x1: "83", y1: "97", x2: "100", y2: "97", gradientUnits: "userSpaceOnUse", children: [
175
+ /* @__PURE__ */ jsx("stop", { stopColor: "#FF4000" }),
176
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#8754C9" })
177
+ ] }),
178
+ /* @__PURE__ */ jsxs("linearGradient", { id: "rainbow_l3", x1: "23", y1: "20", x2: "23", y2: "37", gradientUnits: "userSpaceOnUse", children: [
179
+ /* @__PURE__ */ jsx("stop", { stopColor: "#8754C9" }),
180
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#FF4000" })
181
+ ] }),
182
+ /* @__PURE__ */ jsxs("radialGradient", { id: "rainbow_r4", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(26 94) rotate(-90) scale(58)", children: [
183
+ /* @__PURE__ */ jsx("stop", { offset: "0.723929", stopColor: "#FFF700" }),
184
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#FF9901" })
185
+ ] }),
186
+ /* @__PURE__ */ jsxs("linearGradient", { id: "rainbow_l5", x1: "68", y1: "97", x2: "84", y2: "97", gradientUnits: "userSpaceOnUse", children: [
187
+ /* @__PURE__ */ jsx("stop", { stopColor: "#FFF700" }),
188
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#FF9901" })
189
+ ] }),
190
+ /* @__PURE__ */ jsxs("linearGradient", { id: "rainbow_l6", x1: "23", y1: "52", x2: "23", y2: "36", gradientUnits: "userSpaceOnUse", children: [
191
+ /* @__PURE__ */ jsx("stop", { stopColor: "#FFF700" }),
192
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#FF9901" })
193
+ ] }),
194
+ /* @__PURE__ */ jsxs("radialGradient", { id: "rainbow_r7", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(26 94) rotate(-90) scale(42)", children: [
195
+ /* @__PURE__ */ jsx("stop", { offset: "0.59513", stopColor: "#00AAFF" }),
196
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#01DA40" })
197
+ ] }),
198
+ /* @__PURE__ */ jsxs("radialGradient", { id: "rainbow_r8", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(51 97) scale(17 45.3333)", children: [
199
+ /* @__PURE__ */ jsx("stop", { stopColor: "#00AAFF" }),
200
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#01DA40" })
201
+ ] }),
202
+ /* @__PURE__ */ jsxs("radialGradient", { id: "rainbow_r9", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(23 69) rotate(-90) scale(17 322.37)", children: [
203
+ /* @__PURE__ */ jsx("stop", { stopColor: "#00AAFF" }),
204
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#01DA40" })
205
+ ] })
206
+ ] }),
207
+ /* @__PURE__ */ jsx("path", { d: "M20 38H26C56.9279 38 82 63.0721 82 94V100H94C97.3137 100 100 97.3137 100 94C100 53.1309 66.8691 20 26 20C22.6863 20 20 22.6863 20 26V38Z", fill: "url(#rainbow_r1)" }),
208
+ /* @__PURE__ */ jsx("path", { d: "M84 94H100C100 97.3137 97.3137 100 94 100H84V94Z", fill: "url(#rainbow_l2)" }),
209
+ /* @__PURE__ */ jsx("path", { d: "M26 20L26 36H20L20 26C20 22.6863 22.6863 20 26 20Z", fill: "url(#rainbow_l3)" }),
210
+ /* @__PURE__ */ jsx("path", { d: "M20 36H26C58.0325 36 84 61.9675 84 94V100H66V94C66 71.9086 48.0914 54 26 54H20V36Z", fill: "url(#rainbow_r4)" }),
211
+ /* @__PURE__ */ jsx("path", { d: "M68 94H84V100H68V94Z", fill: "url(#rainbow_l5)" }),
212
+ /* @__PURE__ */ jsx("path", { d: "M20 52L20 36L26 36L26 52H20Z", fill: "url(#rainbow_l6)" }),
213
+ /* @__PURE__ */ jsx("path", { d: "M20 62C20 65.3137 22.6863 68 26 68C40.3594 68 52 79.6406 52 94C52 97.3137 54.6863 100 58 100H68V94C68 70.804 49.196 52 26 52H20V62Z", fill: "url(#rainbow_r7)" }),
214
+ /* @__PURE__ */ jsx("path", { d: "M52 94H68V100H58C54.6863 100 52 97.3137 52 94Z", fill: "url(#rainbow_r8)" }),
215
+ /* @__PURE__ */ jsx("path", { d: "M26 68C22.6863 68 20 65.3137 20 62L20 52L26 52L26 68Z", fill: "url(#rainbow_r9)" })
216
+ ] }) });
217
+ var ZerionWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#2962EF", children: /* @__PURE__ */ jsx("svg", { width: "28", height: "28", viewBox: "0 0 28 28", fill: "none", children: /* @__PURE__ */ jsx("path", { fill: "#fff", d: "M6.073 7c-.48 0-.665.593-.262.841l10.073 6.074a.577.577 0 0 0 .758-.139l4.43-5.814c.3-.404-.004-.962-.525-.962H6.073ZM21.904 21c.48 0 .67-.596.267-.844l-10.075-6.073a.569.569 0 0 0-.751.146l-4.437 5.813c-.301.404.012.958.534.958h14.462Z" }) }) });
218
+ var BraveWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#FFF", children: /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "-100 -100 2970 2970", fill: "none", style: { overflow: "hidden", borderRadius: 12 }, children: [
219
+ /* @__PURE__ */ jsxs("defs", { children: [
220
+ /* @__PURE__ */ jsxs("linearGradient", { id: "brave_a", y1: "51%", y2: "51%", children: [
221
+ /* @__PURE__ */ jsx("stop", { offset: "0.4", stopColor: "#f50" }),
222
+ /* @__PURE__ */ jsx("stop", { offset: "0.6", stopColor: "#ff2000" })
223
+ ] }),
224
+ /* @__PURE__ */ jsxs("linearGradient", { id: "brave_b", x1: "2%", y1: "51%", x2: "51%", y2: "51%", children: [
225
+ /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: "#ff452a" }),
226
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#ff2000" })
227
+ ] })
228
+ ] }),
229
+ /* @__PURE__ */ jsx("path", { fill: "url(#brave_a)", d: "m2395 723 60-147-170-176c-92-92-288-38-288-38l-222-252H992L769 363s-196-53-288 37L311 575l60 147-75 218 250 953c52 204 87 283 234 387l457 310c44 27 98 74 147 74s103-47 147-74l457-310c147-104 182-183 234-387l250-953z" }),
230
+ /* @__PURE__ */ jsx("path", { fill: "#fff", d: "M1935 524s287 347 287 420c0 75-36 94-72 133l-215 230c-20 20-63 54-38 113 25 60 60 134 20 210-40 77-110 128-155 120a820 820 0 0 1-190-90c-38-25-160-126-160-165s126-110 150-124c23-16 130-78 132-102s2-30-30-90-88-140-80-192c10-52 100-80 167-105l207-78c16-8 12-15-36-20-48-4-183-22-244-5s-163 43-173 57c-8 14-16 14-7 62l58 315c4 40 12 67-30 77-44 10-117 27-142 27s-99-17-142-27-35-37-30-77c4-40 48-268 57-315 10-48 1-48-7-62-10-14-113-40-174-57-60-17-196 1-244 6-48 4-52 10-36 20l207 77c66 25 158 53 167 105 10 53-47 132-80 192s-32 66-30 90 110 86 132 102c24 15 150 85 150 124s-119 140-159 165a820 820 0 0 1-190 90c-45 8-115-43-156-120-40-76-4-150 20-210 25-60-17-92-38-113l-215-230c-35-37-71-57-71-131s287-420 287-420l273 44c32 0 103-27 168-50 65-20 110-22 110-22s44 0 110 22 136 50 168 50c33 0 275-47 275-47zm-215 1328c18 10 7 32-10 44l-254 198c-20 20-52 50-73 50s-52-30-73-50a13200 13200 0 0 0-255-198c-16-12-27-33-10-44l150-80a870 870 0 0 1 188-73c15 0 110 34 187 73l150 80z" }),
231
+ /* @__PURE__ */ jsx("path", { fill: "url(#brave_b)", d: "m1999 363-224-253H992L769 363s-196-53-288 37c0 0 260-23 350 123l276 47c32 0 103-27 168-50 65-20 110-22 110-22s44 0 110 22 136 50 168 50c33 0 275-47 275-47 90-146 350-123 350-123-92-92-288-38-288-38" })
232
+ ] }) });
233
+ var BitgetWalletIcon = () => /* @__PURE__ */ jsx(IconFrame, { background: "#001F29", children: /* @__PURE__ */ jsx("svg", { width: "28", height: "28", viewBox: "0 0 512 512", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M219.948 95.7022C201.623 95.6929 183.33 95.6835 164.941 95.7116C153.822 95.7116 149.651 109.671 157.921 117.939L283.098 243.117C287.004 246.69 289.441 250.574 289.53 255.693C289.441 260.812 287.004 264.696 283.098 268.269L157.921 393.446C149.651 401.715 153.822 415.674 164.941 415.674C183.33 415.702 201.623 415.693 219.948 415.683C229.122 415.679 238.305 415.674 247.511 415.674C259.555 415.674 266.72 409.24 273.154 402.805L386.047 289.912C395.057 280.902 403.119 268.939 403.009 255.693C403.119 242.447 395.057 230.484 386.047 221.474L273.154 108.58C266.72 102.146 259.555 95.7116 247.511 95.7116C238.305 95.7116 229.122 95.7069 219.948 95.7022Z", fill: "#00F0FF" }) }) });
234
+ var WalletPlaceholder = ({ name }) => /* @__PURE__ */ jsx(
235
+ "div",
236
+ {
237
+ style: {
238
+ width: 48,
239
+ height: 48,
240
+ borderRadius: 10,
241
+ background: colors.cardRaised,
242
+ display: "flex",
243
+ alignItems: "center",
244
+ justifyContent: "center",
245
+ fontSize: 16,
246
+ fontWeight: 600,
247
+ color: colors.textSecondary,
248
+ fontFamily: fonts.family
249
+ },
250
+ children: name.slice(0, 2).toUpperCase()
251
+ }
252
+ );
253
+ var DefaultWalletIcon = ({
254
+ walletId,
255
+ name
256
+ }) => {
257
+ switch (walletId) {
258
+ case "metamask":
259
+ return /* @__PURE__ */ jsx(MetaMaskWalletIcon, {});
260
+ case "okx":
261
+ return /* @__PURE__ */ jsx(OKXWalletIcon, {});
262
+ case "coinbase":
263
+ return /* @__PURE__ */ jsx(CoinbaseWalletIcon, {});
264
+ case "trust":
265
+ return /* @__PURE__ */ jsx(TrustWalletIcon, {});
266
+ case "phantom":
267
+ return /* @__PURE__ */ jsx(PhantomWalletIcon, {});
268
+ case "rabby":
269
+ return /* @__PURE__ */ jsx(RabbyWalletIcon, {});
270
+ case "rainbow":
271
+ return /* @__PURE__ */ jsx(RainbowWalletIcon, {});
272
+ case "zerion":
273
+ return /* @__PURE__ */ jsx(ZerionWalletIcon, {});
274
+ case "brave":
275
+ return /* @__PURE__ */ jsx(BraveWalletIcon, {});
276
+ case "bitget":
277
+ return /* @__PURE__ */ jsx(BitgetWalletIcon, {});
278
+ default:
279
+ return /* @__PURE__ */ jsx(WalletPlaceholder, { name });
280
+ }
281
+ };
282
+ var CloseButton = ({ onClick }) => /* @__PURE__ */ jsx(
283
+ "button",
284
+ {
285
+ type: "button",
286
+ onClick,
287
+ "aria-label": "Close",
288
+ style: {
289
+ width: 30,
290
+ height: 30,
291
+ borderRadius: "50%",
292
+ background: colors.card,
293
+ border: "none",
294
+ cursor: "pointer",
295
+ display: "flex",
296
+ alignItems: "center",
297
+ justifyContent: "center",
298
+ padding: 0,
299
+ flexShrink: 0
300
+ },
301
+ children: /* @__PURE__ */ jsx("svg", { width: "17", height: "17", viewBox: "0 0 17 17", fill: "none", children: /* @__PURE__ */ jsx(
302
+ "path",
303
+ {
304
+ d: "M4.25 4.25L12.75 12.75M12.75 4.25L4.25 12.75",
305
+ stroke: colors.textPrimary,
306
+ strokeWidth: "1.5",
307
+ strokeLinecap: "round"
308
+ }
309
+ ) })
310
+ }
311
+ );
312
+ var ModalFrame = ({
313
+ onClose,
314
+ width = 500,
315
+ cardStyle,
316
+ contentStyle,
317
+ children
318
+ }) => /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 14, alignItems: "flex-start" }, children: [
319
+ /* @__PURE__ */ jsx(
320
+ "div",
321
+ {
322
+ style: {
323
+ width,
324
+ background: colors.card,
325
+ borderRadius: radii.card,
326
+ overflow: "hidden",
327
+ ...cardStyle
328
+ },
329
+ children: /* @__PURE__ */ jsx(
330
+ "div",
331
+ {
332
+ style: {
333
+ display: "flex",
334
+ flexDirection: "column",
335
+ minHeight: 0,
336
+ fontFamily: fonts.family,
337
+ color: colors.textPrimary,
338
+ boxSizing: "border-box",
339
+ ...contentStyle
340
+ },
341
+ children
342
+ }
343
+ )
344
+ }
345
+ ),
346
+ /* @__PURE__ */ jsx(CloseButton, { onClick: onClose })
347
+ ] }) });
348
+ async function loadWalletAccount() {
349
+ return import('./account-F5Z2SMJE.js');
350
+ }
351
+ async function loadOidcAuth() {
352
+ return import('./dist-Q2PDXT2F.js');
353
+ }
354
+ var SignInModalFrame = ({
355
+ id,
356
+ title,
357
+ onClose,
358
+ footer,
359
+ children
360
+ }) => /* @__PURE__ */ jsx(
361
+ ModalFrame,
362
+ {
363
+ onClose,
364
+ cardStyle: { padding: "32px 24px" },
365
+ contentStyle: { alignItems: "center" },
366
+ children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24, alignItems: "center" }, id, children: [
367
+ /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: 24, fontWeight: 600, lineHeight: 1.4, textAlign: "center" }, children: title }),
368
+ /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 12, alignItems: "center" }, children }),
369
+ footer
370
+ ] })
371
+ }
372
+ );
373
+ var SignInWithEmailSection = () => {
374
+ const [email, setEmail] = useState("");
375
+ const [partialOidcToken, setPartialOidcToken] = useState("");
376
+ const [emailCode, setEmailCode] = useState("");
377
+ return /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, children: [
378
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: /* @__PURE__ */ jsx("input", { type: "email", placeholder: "Email", value: email, onChange: (e) => setEmail(e.target.value), style: { color: "black" } }) }),
379
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
380
+ /* @__PURE__ */ jsx(
381
+ "input",
382
+ {
383
+ type: "text",
384
+ className: "m-1 bg-[#fff] p-1",
385
+ style: { color: "black" },
386
+ value: emailCode,
387
+ placeholder: "emailCode",
388
+ onChange: (e) => setEmailCode(e.target.value)
389
+ }
390
+ ),
391
+ " "
392
+ ] }),
393
+ /* @__PURE__ */ jsx("button", { disabled: !email, onClick: async () => {
394
+ const { OidcAuth } = await loadOidcAuth();
395
+ const { loginByEmail } = OidcAuth({
396
+ stage: "dev",
397
+ xClientId: clientIds.x ?? "",
398
+ googleClientId: clientIds.google ?? ""
399
+ });
400
+ const { partialOidcToken: partialOidcToken2 } = await loginByEmail(email);
401
+ setPartialOidcToken(partialOidcToken2);
402
+ }, children: "send code" }),
403
+ /* @__PURE__ */ jsx("button", { disabled: !partialOidcToken || !emailCode, onClick: async () => {
404
+ const oidcToken = `${partialOidcToken}${emailCode}`;
405
+ const { default: WalletAccount2 } = await loadWalletAccount();
406
+ await WalletAccount2.getInstance(oidcToken);
407
+ }, children: "sign in" })
408
+ ] });
409
+ };
410
+ var SignInModalSocialSection = ({
411
+ id,
412
+ socialProviders,
413
+ isBusy,
414
+ loadingProvider,
415
+ onSocialClick
416
+ }) => /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, id, children: [
417
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: socialProviders.map((provider) => {
418
+ const isLoading = loadingProvider === provider.id;
419
+ return /* @__PURE__ */ jsxs(
420
+ "button",
421
+ {
422
+ id: `social-provider-${provider.id}`,
423
+ type: "button",
424
+ disabled: isBusy,
425
+ onClick: () => onSocialClick(provider.id),
426
+ style: {
427
+ width: "100%",
428
+ height: 48,
429
+ borderRadius: radii.pill,
430
+ border: `1px solid ${colors.border}`,
431
+ background: "transparent",
432
+ display: "flex",
433
+ alignItems: "center",
434
+ justifyContent: "center",
435
+ gap: 12,
436
+ cursor: isBusy ? "wait" : "pointer",
437
+ padding: 12,
438
+ boxSizing: "border-box",
439
+ opacity: isLoading ? 0.6 : isBusy ? 0.8 : 1,
440
+ transition: "opacity .15s"
441
+ },
442
+ children: [
443
+ isLoading ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : provider.icon,
444
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: isLoading ? "Signing in..." : provider.label })
445
+ ]
446
+ },
447
+ provider.id
448
+ );
449
+ }) }),
450
+ typeof window !== "undefined" && window.location.href.indexOf("emailSignIn") !== -1 && /* @__PURE__ */ jsx(SignInWithEmailSection, {}),
451
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 20, width: "100%" }, children: [
452
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, height: 1, background: colors.border } }),
453
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors.textPrimary, opacity: 0.4, whiteSpace: "nowrap" }, children: "Or connect a wallet" }),
454
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, height: 1, background: colors.border } })
455
+ ] })
456
+ ] });
457
+ var SignInModalWalletGrid = ({
458
+ wallets,
459
+ isBusy,
460
+ loadingWalletId,
461
+ expanded,
462
+ showExpandToggle,
463
+ onWalletClick,
464
+ onToggleExpanded
465
+ }) => /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 8, alignItems: "center", paddingTop: 12 }, children: [
466
+ /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex", flexWrap: "wrap", gap: "14px 0" }, children: wallets.map((wallet) => /* @__PURE__ */ jsxs(
467
+ "button",
468
+ {
469
+ type: "button",
470
+ disabled: isBusy,
471
+ onClick: () => onWalletClick(wallet.id),
472
+ style: {
473
+ width: "25%",
474
+ display: "flex",
475
+ flexDirection: "column",
476
+ alignItems: "center",
477
+ gap: 4,
478
+ background: "transparent",
479
+ border: "none",
480
+ cursor: isBusy ? "wait" : "pointer",
481
+ padding: 0,
482
+ opacity: loadingWalletId === wallet.id ? 0.7 : isBusy ? 0.85 : 1
483
+ },
484
+ children: [
485
+ /* @__PURE__ */ jsx("div", { style: { width: 56, height: 56, display: "flex", alignItems: "center", justifyContent: "center" }, children: loadingWalletId === wallet.id ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : wallet.icon ?? /* @__PURE__ */ jsx(DefaultWalletIcon, { walletId: wallet.id, name: wallet.name }) }),
486
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", width: "100%" }, children: [
487
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 12, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family, textAlign: "center", whiteSpace: "nowrap" }, children: wallet.name }),
488
+ loadingWalletId === wallet.id ? /* @__PURE__ */ jsx("span", { style: { fontSize: 10, lineHeight: 1.4, color: colors.textSecondary, fontFamily: fonts.family }, children: "Connecting..." }) : wallet.installed ? /* @__PURE__ */ jsx("span", { style: { fontSize: 10, lineHeight: 1.4, color: colors.accent, fontFamily: fonts.family }, children: "Installed" }) : wallet.installUrl ? /* @__PURE__ */ jsx(
489
+ "a",
490
+ {
491
+ href: wallet.installUrl,
492
+ target: "_blank",
493
+ rel: "noopener noreferrer",
494
+ onClick: (event) => event.stopPropagation(),
495
+ style: { fontSize: 10, lineHeight: 1.4, color: colors.textSecondary, fontFamily: fonts.family, textDecoration: "underline" },
496
+ children: "Install"
497
+ }
498
+ ) : null
499
+ ] })
500
+ ]
501
+ },
502
+ wallet.id
503
+ )) }),
504
+ showExpandToggle && /* @__PURE__ */ jsx(
505
+ "button",
506
+ {
507
+ type: "button",
508
+ onClick: onToggleExpanded,
509
+ style: {
510
+ background: "transparent",
511
+ border: "none",
512
+ cursor: "pointer",
513
+ display: "flex",
514
+ alignItems: "center",
515
+ justifyContent: "center",
516
+ padding: 4
517
+ },
518
+ children: /* @__PURE__ */ jsx(ExpandIcon, { expanded })
519
+ }
520
+ )
521
+ ] });
522
+ var SignInModalFooter = ({
523
+ privacyPolicyUrl,
524
+ termsOfUseUrl
525
+ }) => /* @__PURE__ */ jsx("div", { style: { padding: "12px 0", display: "flex", justifyContent: "center", width: "100%" }, children: /* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: 14, lineHeight: 1.4, color: colors.textSecondary, fontFamily: fonts.family, textAlign: "center" }, children: [
526
+ "By continuing, I agree to the",
527
+ " ",
528
+ /* @__PURE__ */ jsx("a", { href: privacyPolicyUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }),
529
+ " ",
530
+ "and",
531
+ " ",
532
+ /* @__PURE__ */ jsx("a", { href: termsOfUseUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Terms of Use" })
533
+ ] }) });
534
+ var useSignInModalController = ({
535
+ wallets,
536
+ initialVisibleCount,
537
+ onGoogleLogin: _onGoogleLogin,
538
+ onTwitterLogin: _onTwitterLogin,
539
+ onCubeSignerSession: _onCubeSignerSession,
540
+ onWalletConnected,
541
+ onSocialLogin: _onSocialLogin,
542
+ onWalletSelect
543
+ }) => {
544
+ const [expanded, setExpanded] = useState(false);
545
+ const [loadingProvider, setLoadingProvider] = useState(null);
546
+ const [loadingWalletId, setLoadingWalletId] = useState(null);
547
+ const defaultWalletRegistry = useMemo(() => createDefaultInjectedWalletRegistry(), []);
548
+ const defaultWalletConnector = useMemo(
549
+ () => new WalletConnector(defaultWalletRegistry.map((item) => item.provider)),
550
+ [defaultWalletRegistry]
551
+ );
552
+ const resolvedWallets = useMemo(
553
+ () => resolveWalletItems(wallets, defaultWalletRegistry),
554
+ [defaultWalletRegistry, wallets]
555
+ );
556
+ const showExpandToggle = resolvedWallets.length > initialVisibleCount;
557
+ const visibleWallets = expanded ? resolvedWallets : resolvedWallets.slice(0, initialVisibleCount);
558
+ const isBusy = !!loadingProvider || !!loadingWalletId;
559
+ async function loadOidcAuth2() {
560
+ return import('./dist-Q2PDXT2F.js');
561
+ }
562
+ const handleSocialClick = async (providerId) => {
563
+ setLoadingProvider(providerId);
564
+ const cfg = getSDKConfig();
565
+ const { OidcAuth } = await loadOidcAuth2();
566
+ const { loginByX, loginByGoogle } = OidcAuth({
567
+ stage,
568
+ xClientId: cfg.twitterClientId ?? clientIds.x ?? "",
569
+ googleClientId: cfg.googleClientId ?? clientIds.google ?? ""
570
+ });
571
+ if (providerId === "google") {
572
+ try {
573
+ const oidcToken = await loginByGoogle();
574
+ return oidcToken;
575
+ } catch (error) {
576
+ console.error(`[SDK] Google sign-in failed:`, error);
577
+ }
578
+ }
579
+ if (providerId === "x") {
580
+ const oidcToken = await loginByX();
581
+ return oidcToken;
582
+ }
583
+ };
584
+ const clearSocialLoading = () => setLoadingProvider(null);
585
+ const handleWalletClick = async (walletId) => {
586
+ if (isBusy) return;
587
+ const targetWallet = resolvedWallets.find((wallet) => wallet.id === walletId);
588
+ if (!targetWallet) return;
589
+ if (targetWallet.installed === false && targetWallet.installUrl) return;
590
+ setLoadingWalletId(walletId);
591
+ try {
592
+ if (onWalletSelect) {
593
+ await onWalletSelect(walletId);
594
+ return;
595
+ }
596
+ const builtInWallet = defaultWalletRegistry.find((item) => item.id === walletId);
597
+ if (!builtInWallet || !builtInWallet.installed) return;
598
+ const session = await defaultWalletConnector.connect(walletId);
599
+ onWalletConnected?.(session, walletId);
600
+ } catch (err) {
601
+ console.error(`[SDK] Wallet connect failed for ${walletId}:`, err);
602
+ } finally {
603
+ setLoadingWalletId(null);
604
+ }
605
+ };
606
+ return {
607
+ expanded,
608
+ loadingProvider,
609
+ loadingWalletId,
610
+ visibleWallets,
611
+ showExpandToggle,
612
+ isBusy,
613
+ handleSocialClick,
614
+ handleWalletClick,
615
+ clearSocialLoading,
616
+ toggleExpanded: () => setExpanded((value) => !value)
617
+ };
618
+ };
619
+ var variantStyles = {
620
+ success: { bg: "rgba(41, 255, 155, 0.82)", border: "rgba(41, 255, 155, 0.53)", icon: colors.accent },
621
+ error: { bg: "rgba(255, 107, 107, 0.82)", border: "rgba(255, 107, 107, 0.53)", icon: colors.danger },
622
+ info: { bg: "rgba(126, 135, 162, 0.82)", border: "rgba(126, 135, 162, 0.55)", icon: colors.textSecondary }
623
+ };
624
+ var Toast = ({ message, variant = "info", duration, onClose }) => {
625
+ const style = variantStyles[variant];
626
+ useEffect(() => {
627
+ if (duration != null && duration > 0 && onClose) {
628
+ const t = setTimeout(onClose, duration);
629
+ return () => clearTimeout(t);
630
+ }
631
+ }, [duration, onClose]);
632
+ return /* @__PURE__ */ jsx(
633
+ "div",
634
+ {
635
+ style: {
636
+ position: "fixed",
637
+ top: 0,
638
+ left: 0,
639
+ right: 0,
640
+ display: "flex",
641
+ justifyContent: "center",
642
+ paddingTop: 16,
643
+ zIndex: 1e4,
644
+ pointerEvents: "none"
645
+ },
646
+ children: /* @__PURE__ */ jsxs(
647
+ "div",
648
+ {
649
+ role: "alert",
650
+ style: {
651
+ pointerEvents: "auto",
652
+ display: "flex",
653
+ alignItems: "center",
654
+ gap: 10,
655
+ padding: "12px 16px",
656
+ borderRadius: radii.card,
657
+ background: style.bg,
658
+ border: `1px solid ${style.border}`,
659
+ color: colors.textPrimary,
660
+ fontSize: 14,
661
+ lineHeight: 1.4,
662
+ maxWidth: 360,
663
+ boxSizing: "border-box"
664
+ },
665
+ children: [
666
+ /* @__PURE__ */ jsx("span", { style: { flex: 1 }, children: message }),
667
+ onClose && /* @__PURE__ */ jsx(
668
+ "button",
669
+ {
670
+ type: "button",
671
+ "aria-label": "Dismiss",
672
+ onClick: onClose,
673
+ style: {
674
+ padding: 4,
675
+ margin: -4,
676
+ border: "none",
677
+ background: "transparent",
678
+ color: colors.textSecondary,
679
+ cursor: "pointer",
680
+ borderRadius: 4,
681
+ lineHeight: 1
682
+ },
683
+ children: /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
684
+ "path",
685
+ {
686
+ d: "M3.5 3.5L10.5 10.5M10.5 3.5L3.5 10.5",
687
+ stroke: "currentColor",
688
+ strokeWidth: "1.5",
689
+ strokeLinecap: "round"
690
+ }
691
+ ) })
692
+ }
693
+ )
694
+ ]
695
+ }
696
+ )
697
+ }
698
+ );
699
+ };
700
+ async function loadWalletAccount2() {
701
+ return import('./account-F5Z2SMJE.js');
702
+ }
703
+ var SignInModal = ({
704
+ title = "Welcome to PredicateMarket",
705
+ socialProviders,
706
+ wallets,
707
+ initialVisibleCount,
708
+ privacyPolicyUrl = "#",
709
+ termsOfUseUrl = "#",
710
+ onGoogleLogin,
711
+ onTwitterLogin,
712
+ onCubeSignerSession,
713
+ onWalletConnected,
714
+ onSocialLogin,
715
+ onWalletSelect,
716
+ onDismiss,
717
+ onSuccess
718
+ }) => {
719
+ const sdkConfig = getSDKConfig();
720
+ const effectiveSocialProviders = resolveSocialProviders(
721
+ socialProviders ?? sdkConfig.signIn?.socialProviders
722
+ );
723
+ const effectiveWallets = wallets ?? sdkConfig.signIn?.wallets;
724
+ const effectiveInitialVisibleCount = initialVisibleCount ?? sdkConfig.signIn?.initialVisibleCount ?? 5;
725
+ const [toastError, setToastError] = useState(null);
726
+ const [socialLoadingProvider, setSocialLoadingProvider] = useState(null);
727
+ const {
728
+ expanded,
729
+ loadingProvider,
730
+ loadingWalletId,
731
+ visibleWallets,
732
+ showExpandToggle,
733
+ isBusy,
734
+ handleSocialClick,
735
+ handleWalletClick,
736
+ clearSocialLoading,
737
+ toggleExpanded
738
+ } = useSignInModalController({
739
+ wallets: effectiveWallets,
740
+ initialVisibleCount: effectiveInitialVisibleCount,
741
+ onGoogleLogin,
742
+ onTwitterLogin,
743
+ onCubeSignerSession,
744
+ onWalletConnected,
745
+ onSocialLogin,
746
+ onWalletSelect
747
+ });
748
+ return /* @__PURE__ */ jsxs(
749
+ SignInModalFrame,
750
+ {
751
+ id: "SignInModalFrame",
752
+ title,
753
+ onClose: onDismiss,
754
+ footer: /* @__PURE__ */ jsx(
755
+ SignInModalFooter,
756
+ {
757
+ privacyPolicyUrl,
758
+ termsOfUseUrl
759
+ }
760
+ ),
761
+ children: [
762
+ toastError && /* @__PURE__ */ jsx(
763
+ Toast,
764
+ {
765
+ message: toastError,
766
+ variant: "error",
767
+ duration: 5e3,
768
+ onClose: () => setToastError(null)
769
+ }
770
+ ),
771
+ /* @__PURE__ */ jsx(
772
+ SignInModalSocialSection,
773
+ {
774
+ id: "SignInModalSocialSection",
775
+ socialProviders: effectiveSocialProviders,
776
+ isBusy: isBusy || !!socialLoadingProvider,
777
+ loadingProvider: loadingProvider ?? socialLoadingProvider,
778
+ onSocialClick: async (providerId) => {
779
+ setSocialLoadingProvider(providerId);
780
+ sessionStore.clearSession();
781
+ let walletAccount = null;
782
+ let address = "";
783
+ try {
784
+ const { default: WalletAccount2 } = await loadWalletAccount2();
785
+ WalletAccount2.clearInstance();
786
+ const oidcToken = await handleSocialClick(providerId);
787
+ if (!oidcToken) {
788
+ setToastError("Social login failed, please try again");
789
+ return;
790
+ }
791
+ walletAccount = await WalletAccount2.getInstance(oidcToken);
792
+ onCubeSignerSession?.(walletAccount.getCubeSignerSession());
793
+ cache_exports.set("oidcToken", oidcToken, false);
794
+ const res = await walletAccount.eth_accounts();
795
+ address = res?.[0] || "";
796
+ const authSource = providerId === "x" ? "twitter" : providerId;
797
+ const session = {
798
+ address,
799
+ chain: "BSC",
800
+ provider: walletAccount,
801
+ walletType: "social",
802
+ authSource
803
+ };
804
+ onSuccess?.(session);
805
+ } catch (error) {
806
+ setToastError(error?.message ?? "Failed to get wallet account, please try again");
807
+ return;
808
+ } finally {
809
+ setSocialLoadingProvider(null);
810
+ clearSocialLoading();
811
+ }
812
+ }
813
+ }
814
+ ),
815
+ /* @__PURE__ */ jsx(
816
+ SignInModalWalletGrid,
817
+ {
818
+ wallets: visibleWallets,
819
+ isBusy,
820
+ loadingWalletId,
821
+ expanded,
822
+ showExpandToggle,
823
+ onWalletClick: handleWalletClick,
824
+ onToggleExpanded: toggleExpanded
825
+ }
826
+ )
827
+ ]
828
+ }
829
+ );
830
+ };
831
+
832
+ // src/ui/theme.ts
833
+ var colors2 = {
834
+ background: "#050608",
835
+ card: "#121214",
836
+ cardRaised: "#151821",
837
+ border: "rgba(126,135,162,0.2)",
838
+ borderStrong: "rgba(255,255,255,0.16)",
839
+ borderFocused: "#FFFFFF",
840
+ textPrimary: "#FFFFFF",
841
+ textSecondary: "#737477",
842
+ accent: "#29FF9B",
843
+ accentStrong: "#4AD481",
844
+ warning: "#FFB547",
845
+ danger: "#FF6B6B",
846
+ stepActive: "#FFFFFF",
847
+ stepInactive: "#36383D",
848
+ buttonDisabledBg: "rgba(255,255,255,0.14)",
849
+ buttonDisabledBorder: "#444444"
850
+ };
851
+ var radii2 = {
852
+ xl: "28px",
853
+ lg: "20px",
854
+ pill: "99px",
855
+ full: "9999px",
856
+ card: "12px",
857
+ input: "8px"
858
+ };
859
+ var fonts2 = {
860
+ family: '"Switzer", "Inter", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
861
+ };
862
+ var placeholderIcon = (label) => /* @__PURE__ */ jsx(
863
+ "div",
864
+ {
865
+ style: {
866
+ width: 40,
867
+ height: 40,
868
+ borderRadius: "12px",
869
+ background: colors2.cardRaised,
870
+ display: "flex",
871
+ alignItems: "center",
872
+ justifyContent: "center",
873
+ color: colors2.textSecondary,
874
+ fontWeight: 600
875
+ },
876
+ children: label.slice(0, 2).toUpperCase()
877
+ }
878
+ );
879
+ var WalletSelectionModal = ({
880
+ title = "Connect Wallet",
881
+ options,
882
+ onSelect
883
+ }) => {
884
+ const sections = [
885
+ {
886
+ id: "social",
887
+ label: "Social Wallets",
888
+ items: options.filter((item) => item.category === "social")
889
+ },
890
+ {
891
+ id: "plugin",
892
+ label: "Plugin Wallets",
893
+ items: options.filter((item) => item.category === "plugin")
894
+ }
895
+ ].filter((section) => section.items.length > 0);
896
+ return /* @__PURE__ */ jsxs(
897
+ "div",
898
+ {
899
+ style: {
900
+ width: "min(720px, 90vw)",
901
+ background: colors2.card,
902
+ borderRadius: radii2.xl,
903
+ border: `1px solid ${colors2.border}`,
904
+ padding: "40px",
905
+ display: "flex",
906
+ flexDirection: "column",
907
+ gap: 32,
908
+ color: colors2.textPrimary,
909
+ fontFamily: fonts2.family
910
+ },
911
+ children: [
912
+ /* @__PURE__ */ jsxs("div", { children: [
913
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 26, fontWeight: 600 }, children: title }),
914
+ /* @__PURE__ */ jsx("p", { style: { color: colors2.textSecondary, marginTop: 8 }, children: "Choose social or plugin wallets" })
915
+ ] }),
916
+ sections.map((section) => /* @__PURE__ */ jsxs("section", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
917
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 14, textTransform: "uppercase", letterSpacing: 1.5, color: colors2.textSecondary }, children: section.label }),
918
+ /* @__PURE__ */ jsx(
919
+ "div",
920
+ {
921
+ style: {
922
+ display: "grid",
923
+ gap: 16,
924
+ gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
925
+ },
926
+ children: section.items.map((option) => /* @__PURE__ */ jsxs(
927
+ "button",
928
+ {
929
+ onClick: () => onSelect?.(option.id),
930
+ style: {
931
+ borderRadius: radii2.lg,
932
+ border: `1px solid ${colors2.border}`,
933
+ background: colors2.cardRaised,
934
+ padding: "20px",
935
+ display: "flex",
936
+ gap: 14,
937
+ alignItems: "center",
938
+ textAlign: "left",
939
+ cursor: "pointer",
940
+ color: colors2.textPrimary
941
+ },
942
+ children: [
943
+ option.icon ?? placeholderIcon(option.label),
944
+ /* @__PURE__ */ jsxs("div", { children: [
945
+ /* @__PURE__ */ jsx("div", { style: { fontWeight: 600 }, children: option.label }),
946
+ /* @__PURE__ */ jsx("div", { style: { color: colors2.textSecondary, fontSize: 14 }, children: option.description })
947
+ ] })
948
+ ]
949
+ },
950
+ option.id
951
+ ))
952
+ }
953
+ )
954
+ ] }, section.id))
955
+ ]
956
+ }
957
+ );
958
+ };
959
+ var CloseButton2 = ({ onClick }) => /* @__PURE__ */ jsx(
960
+ "button",
961
+ {
962
+ type: "button",
963
+ onClick,
964
+ "aria-label": "Close",
965
+ style: {
966
+ width: 30,
967
+ height: 30,
968
+ borderRadius: "50%",
969
+ background: colors2.card,
970
+ border: "none",
971
+ cursor: "pointer",
972
+ display: "flex",
973
+ alignItems: "center",
974
+ justifyContent: "center",
975
+ padding: 0,
976
+ flexShrink: 0
977
+ },
978
+ children: /* @__PURE__ */ jsx("svg", { width: "17", height: "17", viewBox: "0 0 17 17", fill: "none", children: /* @__PURE__ */ jsx(
979
+ "path",
980
+ {
981
+ d: "M4.25 4.25L12.75 12.75M12.75 4.25L4.25 12.75",
982
+ stroke: colors2.textPrimary,
983
+ strokeWidth: "1.5",
984
+ strokeLinecap: "round"
985
+ }
986
+ ) })
987
+ }
988
+ );
989
+ var ModalFrame2 = ({
990
+ onClose,
991
+ width = 500,
992
+ cardStyle,
993
+ contentStyle,
994
+ children
995
+ }) => /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 14, alignItems: "flex-start" }, children: [
996
+ /* @__PURE__ */ jsx(
997
+ "div",
998
+ {
999
+ style: {
1000
+ width,
1001
+ background: colors2.card,
1002
+ borderRadius: radii2.card,
1003
+ overflow: "hidden",
1004
+ ...cardStyle
1005
+ },
1006
+ children: /* @__PURE__ */ jsx(
1007
+ "div",
1008
+ {
1009
+ style: {
1010
+ display: "flex",
1011
+ flexDirection: "column",
1012
+ minHeight: 0,
1013
+ fontFamily: fonts2.family,
1014
+ color: colors2.textPrimary,
1015
+ boxSizing: "border-box",
1016
+ ...contentStyle
1017
+ },
1018
+ children
1019
+ }
1020
+ )
1021
+ }
1022
+ ),
1023
+ /* @__PURE__ */ jsx(CloseButton2, { onClick: onClose })
1024
+ ] }) });
1025
+ var StepIndicator = ({ steps, stepActive, activeStep = 0 }) => {
1026
+ return /* @__PURE__ */ jsx(
1027
+ "div",
1028
+ {
1029
+ style: {
1030
+ display: "flex",
1031
+ flexDirection: "column",
1032
+ alignItems: "center",
1033
+ width: 20,
1034
+ paddingTop: 4,
1035
+ flexShrink: 0
1036
+ },
1037
+ children: Array.from({ length: steps }, (_, i) => {
1038
+ const isActive = stepActive && stepActive.length > i ? stepActive[i] : i <= activeStep;
1039
+ const isLast = i === steps - 1;
1040
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
1041
+ /* @__PURE__ */ jsx(
1042
+ "div",
1043
+ {
1044
+ style: {
1045
+ width: 20,
1046
+ height: 20,
1047
+ borderRadius: "50%",
1048
+ border: `2px solid ${isActive ? colors2.stepActive : colors2.stepInactive}`,
1049
+ display: "flex",
1050
+ alignItems: "center",
1051
+ justifyContent: "center",
1052
+ boxSizing: "border-box"
1053
+ },
1054
+ children: /* @__PURE__ */ jsx(
1055
+ "div",
1056
+ {
1057
+ style: {
1058
+ width: 7.5,
1059
+ height: 7.5,
1060
+ borderRadius: "50%",
1061
+ background: isActive ? colors2.stepActive : colors2.stepInactive
1062
+ }
1063
+ }
1064
+ )
1065
+ }
1066
+ ),
1067
+ !isLast && /* @__PURE__ */ jsx(
1068
+ "div",
1069
+ {
1070
+ style: {
1071
+ width: 1,
1072
+ height: 87,
1073
+ background: isActive ? colors2.stepActive : colors2.stepInactive,
1074
+ opacity: 0.3
1075
+ }
1076
+ }
1077
+ )
1078
+ ] }, i);
1079
+ })
1080
+ }
1081
+ );
1082
+ };
1083
+ var Chevron = ({ up }) => /* @__PURE__ */ jsx(
1084
+ "svg",
1085
+ {
1086
+ width: "16",
1087
+ height: "16",
1088
+ viewBox: "0 0 16 16",
1089
+ fill: "none",
1090
+ style: { transition: "transform .2s", transform: up ? "rotate(180deg)" : "none" },
1091
+ children: /* @__PURE__ */ jsx("path", { d: "M4 6L8 10L12 6", stroke: colors2.textSecondary, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1092
+ }
1093
+ );
1094
+ var DropdownField = ({
1095
+ label,
1096
+ placeholder,
1097
+ value,
1098
+ icon,
1099
+ focused,
1100
+ options,
1101
+ onSelect,
1102
+ onClick
1103
+ }) => {
1104
+ const [open, setOpen] = useState(false);
1105
+ const [triggerFocused, setTriggerFocused] = useState(false);
1106
+ const ref = useRef(null);
1107
+ useEffect(() => {
1108
+ if (!open) return;
1109
+ const handler = (e) => {
1110
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
1111
+ };
1112
+ document.addEventListener("mousedown", handler);
1113
+ return () => document.removeEventListener("mousedown", handler);
1114
+ }, [open]);
1115
+ const hasOptions = options && options.length > 0;
1116
+ const handleClick = () => {
1117
+ if (hasOptions) {
1118
+ setOpen((p) => !p);
1119
+ } else {
1120
+ onClick?.();
1121
+ }
1122
+ };
1123
+ const handleSelect = (id) => {
1124
+ onSelect?.(id);
1125
+ setOpen(false);
1126
+ };
1127
+ const selected = hasOptions ? options.find((o) => o.id === value) : void 0;
1128
+ return /* @__PURE__ */ jsxs("div", { ref, style: { display: "flex", flexDirection: "column", gap: 8, width: "100%", position: "relative" }, children: [
1129
+ /* @__PURE__ */ jsx(
1130
+ "span",
1131
+ {
1132
+ style: {
1133
+ fontSize: 14,
1134
+ fontWeight: 400,
1135
+ lineHeight: 1.4,
1136
+ color: colors2.textPrimary,
1137
+ fontFamily: fonts2.family
1138
+ },
1139
+ children: label
1140
+ }
1141
+ ),
1142
+ /* @__PURE__ */ jsxs(
1143
+ "button",
1144
+ {
1145
+ type: "button",
1146
+ onClick: handleClick,
1147
+ onFocus: () => setTriggerFocused(true),
1148
+ onBlur: () => setTriggerFocused(false),
1149
+ style: {
1150
+ display: "flex",
1151
+ alignItems: "center",
1152
+ justifyContent: "space-between",
1153
+ height: 44,
1154
+ padding: "0 16px",
1155
+ borderRadius: radii2.input,
1156
+ border: `1px solid ${open || triggerFocused ? colors2.borderFocused : colors2.border}`,
1157
+ background: "transparent",
1158
+ cursor: "pointer",
1159
+ fontFamily: fonts2.family,
1160
+ width: "100%",
1161
+ boxSizing: "border-box"
1162
+ },
1163
+ children: [
1164
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1165
+ selected?.icon ?? icon,
1166
+ /* @__PURE__ */ jsx(
1167
+ "span",
1168
+ {
1169
+ style: {
1170
+ fontSize: 14,
1171
+ lineHeight: 1.4,
1172
+ color: value ? colors2.textPrimary : colors2.textSecondary,
1173
+ fontFamily: fonts2.family
1174
+ },
1175
+ children: selected?.label ?? value ?? placeholder
1176
+ }
1177
+ )
1178
+ ] }),
1179
+ /* @__PURE__ */ jsx(Chevron, { up: open })
1180
+ ]
1181
+ }
1182
+ ),
1183
+ open && hasOptions && /* @__PURE__ */ jsx(
1184
+ "div",
1185
+ {
1186
+ className: "dropdown-list-item",
1187
+ style: {
1188
+ position: "absolute",
1189
+ top: "calc(100% + 4px)",
1190
+ left: 0,
1191
+ right: 0,
1192
+ zIndex: 10,
1193
+ borderRadius: radii2.input,
1194
+ border: `1px solid ${colors2.border}`,
1195
+ background: colors2.card,
1196
+ overflow: "hidden",
1197
+ boxShadow: "0 8px 24px rgba(0,0,0,0.4)"
1198
+ },
1199
+ children: options.map((opt) => /* @__PURE__ */ jsxs(
1200
+ "button",
1201
+ {
1202
+ type: "button",
1203
+ onClick: () => handleSelect(opt.id),
1204
+ style: {
1205
+ display: "flex",
1206
+ alignItems: "center",
1207
+ gap: 10,
1208
+ width: "100%",
1209
+ padding: "10px 16px",
1210
+ border: "none",
1211
+ background: opt.id === value ? "rgba(255,255,255,0.06)" : "transparent",
1212
+ cursor: "pointer",
1213
+ fontFamily: fonts2.family,
1214
+ textAlign: "left",
1215
+ transition: "background .12s"
1216
+ },
1217
+ onMouseEnter: (e) => {
1218
+ e.currentTarget.style.background = "rgba(255,255,255,0.08)";
1219
+ },
1220
+ onMouseLeave: (e) => {
1221
+ e.currentTarget.style.background = opt.id === value ? "rgba(255,255,255,0.06)" : "transparent";
1222
+ },
1223
+ children: [
1224
+ opt.icon && /* @__PURE__ */ jsx("div", { style: { width: 28, height: 28, flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: opt.icon }),
1225
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 1 }, children: [
1226
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 500, color: colors2.textPrimary }, children: opt.label }),
1227
+ opt.subtitle && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: colors2.textSecondary }, children: opt.subtitle })
1228
+ ] })
1229
+ ]
1230
+ },
1231
+ opt.id
1232
+ ))
1233
+ }
1234
+ )
1235
+ ] });
1236
+ };
1237
+ function getRemaining(expiresAt) {
1238
+ const end = typeof expiresAt === "string" ? new Date(expiresAt).getTime() : expiresAt;
1239
+ return Math.max(0, Math.floor((end - Date.now()) / 1e3));
1240
+ }
1241
+ function formatRemaining(seconds) {
1242
+ const m = Math.floor(seconds / 60);
1243
+ const s = seconds % 60;
1244
+ return `${m}:${s.toString().padStart(2, "0")}`;
1245
+ }
1246
+ function Countdown({
1247
+ expiresAt,
1248
+ expiredLabel = "Expired",
1249
+ style,
1250
+ isExpired = false,
1251
+ onExpired
1252
+ }) {
1253
+ const [remaining, setRemaining] = useState(() => getRemaining(expiresAt));
1254
+ const hasFiredExpired = useRef(false);
1255
+ useEffect(() => {
1256
+ hasFiredExpired.current = false;
1257
+ }, [expiresAt]);
1258
+ useEffect(() => {
1259
+ if (isExpired) {
1260
+ setRemaining(0);
1261
+ return;
1262
+ }
1263
+ const tick = () => {
1264
+ const r = getRemaining(expiresAt);
1265
+ setRemaining(r);
1266
+ if (r <= 0 && onExpired && !hasFiredExpired.current) {
1267
+ hasFiredExpired.current = true;
1268
+ onExpired();
1269
+ }
1270
+ };
1271
+ tick();
1272
+ const id = setInterval(tick, 1e3);
1273
+ return () => clearInterval(id);
1274
+ }, [expiresAt, isExpired, onExpired]);
1275
+ const text = remaining <= 0 ? expiredLabel : formatRemaining(remaining);
1276
+ const color = remaining <= 0 ? colors2.warning : colors2.textSecondary;
1277
+ return /* @__PURE__ */ jsxs("span", { style: { fontSize: 12, color, fontFamily: fonts2.family, ...style }, children: [
1278
+ "Expires in ",
1279
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, color: "#fff" }, children: text })
1280
+ ] });
1281
+ }
1282
+ function generateMatrix(data) {
1283
+ const qr = qrcode(0, "H");
1284
+ qr.addData(data);
1285
+ qr.make();
1286
+ const count = qr.getModuleCount();
1287
+ const matrix = [];
1288
+ for (let r = 0; r < count; r++) {
1289
+ const row = [];
1290
+ for (let c = 0; c < count; c++) {
1291
+ row.push(qr.isDark(r, c));
1292
+ }
1293
+ matrix.push(row);
1294
+ }
1295
+ return matrix;
1296
+ }
1297
+ function isFinderZone(row, col, size) {
1298
+ return row < 7 && col < 7 || row < 7 && col >= size - 7 || row >= size - 7 && col < 7;
1299
+ }
1300
+ var FinderEye = ({ ox, oy, s }) => /* @__PURE__ */ jsxs(Fragment, { children: [
1301
+ /* @__PURE__ */ jsx("rect", { x: ox, y: oy, width: 7 * s, height: 7 * s, rx: s * 1.4, ry: s * 1.4, fill: "#fff" }),
1302
+ /* @__PURE__ */ jsx(
1303
+ "rect",
1304
+ {
1305
+ x: ox + s,
1306
+ y: oy + s,
1307
+ width: 5 * s,
1308
+ height: 5 * s,
1309
+ rx: s * 0.9,
1310
+ ry: s * 0.9,
1311
+ fill: colors2.background
1312
+ }
1313
+ ),
1314
+ /* @__PURE__ */ jsx(
1315
+ "rect",
1316
+ {
1317
+ x: ox + 2 * s,
1318
+ y: oy + 2 * s,
1319
+ width: 3 * s,
1320
+ height: 3 * s,
1321
+ rx: s * 0.7,
1322
+ ry: s * 0.7,
1323
+ fill: "#fff"
1324
+ }
1325
+ )
1326
+ ] });
1327
+ var SVG_SIZE = 220;
1328
+ var QUIET_ZONE = 2;
1329
+ var StyledQR = ({ data }) => {
1330
+ const matrix = useMemo(() => generateMatrix(data), [data]);
1331
+ const n = matrix.length;
1332
+ const total = n + QUIET_ZONE * 2;
1333
+ const cell = SVG_SIZE / total;
1334
+ const off = QUIET_ZONE * cell;
1335
+ const dotR = cell * 0.42;
1336
+ const centerClearR = 3;
1337
+ const cx = n / 2;
1338
+ const cy = n / 2;
1339
+ const dots = [];
1340
+ for (let r = 0; r < n; r++) {
1341
+ for (let c = 0; c < n; c++) {
1342
+ if (!matrix[r][c]) continue;
1343
+ if (isFinderZone(r, c, n)) continue;
1344
+ if (Math.abs(c - cx) < centerClearR && Math.abs(r - cy) < centerClearR) continue;
1345
+ dots.push(
1346
+ /* @__PURE__ */ jsx(
1347
+ "circle",
1348
+ {
1349
+ cx: off + c * cell + cell / 2,
1350
+ cy: off + r * cell + cell / 2,
1351
+ r: dotR,
1352
+ fill: "#fff"
1353
+ },
1354
+ `${r}-${c}`
1355
+ )
1356
+ );
1357
+ }
1358
+ }
1359
+ return /* @__PURE__ */ jsxs(
1360
+ "svg",
1361
+ {
1362
+ width: SVG_SIZE,
1363
+ height: SVG_SIZE,
1364
+ viewBox: `0 0 ${SVG_SIZE} ${SVG_SIZE}`,
1365
+ style: { borderRadius: 12 },
1366
+ children: [
1367
+ /* @__PURE__ */ jsx("rect", { width: SVG_SIZE, height: SVG_SIZE, fill: colors2.background }),
1368
+ /* @__PURE__ */ jsx(FinderEye, { ox: off, oy: off, s: cell }),
1369
+ /* @__PURE__ */ jsx(FinderEye, { ox: off + (n - 7) * cell, oy: off, s: cell }),
1370
+ /* @__PURE__ */ jsx(FinderEye, { ox: off, oy: off + (n - 7) * cell, s: cell }),
1371
+ dots
1372
+ ]
1373
+ }
1374
+ );
1375
+ };
1376
+ var CopyIcon = () => /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: [
1377
+ /* @__PURE__ */ jsx("rect", { x: "4.5", y: "4.5", width: "7", height: "7", rx: "1.5", stroke: colors2.textPrimary, strokeWidth: "1.2" }),
1378
+ /* @__PURE__ */ jsx(
1379
+ "path",
1380
+ {
1381
+ d: "M9.5 4.5V3.5C9.5 2.67 8.83 2 8 2H3.5C2.67 2 2 2.67 2 3.5V8C2 8.83 2.67 9.5 3.5 9.5H4.5",
1382
+ stroke: colors2.textPrimary,
1383
+ strokeWidth: "1.2"
1384
+ }
1385
+ )
1386
+ ] });
1387
+ var DepositDetailsPanel = ({
1388
+ address,
1389
+ tokenIcon,
1390
+ minimumDeposit,
1391
+ onCopyAddress
1392
+ }) => {
1393
+ const canCopy = typeof address === "string" && address.trim().length > 0;
1394
+ const handleCopy = async () => {
1395
+ if (!canCopy) return;
1396
+ try {
1397
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
1398
+ await navigator.clipboard.writeText(address);
1399
+ } else {
1400
+ const el = document.createElement("textarea");
1401
+ el.value = address;
1402
+ el.setAttribute("readonly", "");
1403
+ el.style.position = "absolute";
1404
+ el.style.left = "-9999px";
1405
+ document.body.appendChild(el);
1406
+ el.select();
1407
+ try {
1408
+ document.execCommand("copy");
1409
+ } catch {
1410
+ }
1411
+ document.body.removeChild(el);
1412
+ }
1413
+ } finally {
1414
+ onCopyAddress?.(address);
1415
+ }
1416
+ };
1417
+ return /* @__PURE__ */ jsxs(
1418
+ "div",
1419
+ {
1420
+ style: {
1421
+ display: "flex",
1422
+ flexDirection: "column",
1423
+ alignItems: "center",
1424
+ gap: 16,
1425
+ padding: "20px",
1426
+ borderRadius: radii2.card,
1427
+ border: `1px solid ${colors2.border}`,
1428
+ fontFamily: fonts2.family
1429
+ },
1430
+ children: [
1431
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative", display: "inline-flex" }, children: [
1432
+ /* @__PURE__ */ jsx(StyledQR, { data: address }),
1433
+ tokenIcon && /* @__PURE__ */ jsx(
1434
+ "div",
1435
+ {
1436
+ style: {
1437
+ position: "absolute",
1438
+ top: "50%",
1439
+ left: "50%",
1440
+ transform: "translate(-50%, -50%)",
1441
+ width: 36,
1442
+ height: 36,
1443
+ borderRadius: "50%",
1444
+ background: "#3B5998",
1445
+ display: "flex",
1446
+ alignItems: "center",
1447
+ justifyContent: "center",
1448
+ boxShadow: `0 0 0 3px ${colors2.background}`
1449
+ },
1450
+ children: tokenIcon
1451
+ }
1452
+ )
1453
+ ] }),
1454
+ /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 8 }, children: /* @__PURE__ */ jsx(
1455
+ "div",
1456
+ {
1457
+ style: {
1458
+ padding: "10px 14px",
1459
+ borderRadius: radii2.input,
1460
+ background: "rgba(255,255,255,0.05)",
1461
+ fontSize: 13,
1462
+ color: colors2.textPrimary,
1463
+ wordBreak: "break-all",
1464
+ lineHeight: 1.5
1465
+ },
1466
+ children: address
1467
+ }
1468
+ ) }),
1469
+ minimumDeposit && /* @__PURE__ */ jsxs(
1470
+ "div",
1471
+ {
1472
+ style: {
1473
+ width: "100%",
1474
+ display: "flex",
1475
+ justifyContent: "space-between",
1476
+ fontSize: 13
1477
+ },
1478
+ children: [
1479
+ /* @__PURE__ */ jsx("span", { style: { color: colors2.textSecondary }, children: "Minimum deposit" }),
1480
+ /* @__PURE__ */ jsx("span", { style: { color: colors2.textPrimary, fontWeight: 500 }, children: minimumDeposit })
1481
+ ]
1482
+ }
1483
+ ),
1484
+ /* @__PURE__ */ jsxs(
1485
+ "button",
1486
+ {
1487
+ type: "button",
1488
+ onClick: handleCopy,
1489
+ disabled: !canCopy,
1490
+ style: {
1491
+ display: "flex",
1492
+ alignItems: "center",
1493
+ gap: 6,
1494
+ padding: "10px 28px",
1495
+ borderRadius: radii2.pill,
1496
+ border: `1px solid ${colors2.borderStrong}`,
1497
+ background: "transparent",
1498
+ color: colors2.textPrimary,
1499
+ fontSize: 14,
1500
+ fontWeight: 500,
1501
+ cursor: canCopy ? "pointer" : "not-allowed",
1502
+ opacity: canCopy ? 1 : 0.6,
1503
+ fontFamily: fonts2.family,
1504
+ transition: "background .15s"
1505
+ },
1506
+ onMouseEnter: (e) => {
1507
+ if (!canCopy) return;
1508
+ e.currentTarget.style.background = "rgba(255,255,255,0.06)";
1509
+ },
1510
+ onMouseLeave: (e) => {
1511
+ e.currentTarget.style.background = "transparent";
1512
+ },
1513
+ children: [
1514
+ /* @__PURE__ */ jsx(CopyIcon, {}),
1515
+ "Copy address"
1516
+ ]
1517
+ }
1518
+ )
1519
+ ]
1520
+ }
1521
+ );
1522
+ };
1523
+ var LockIcon = () => /* @__PURE__ */ jsxs("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", children: [
1524
+ /* @__PURE__ */ jsx("rect", { x: "10", y: "22", width: "28", height: "20", rx: "4", stroke: colors2.textSecondary, strokeWidth: "2" }),
1525
+ /* @__PURE__ */ jsx("path", { d: "M16 22V16C16 11.5817 19.5817 8 24 8C28.4183 8 32 11.5817 32 16V22", stroke: colors2.textSecondary, strokeWidth: "2", strokeLinecap: "round" }),
1526
+ /* @__PURE__ */ jsx("circle", { cx: "24", cy: "33", r: "3", fill: colors2.textSecondary })
1527
+ ] });
1528
+ var LoginRequiredOverlay = ({
1529
+ title,
1530
+ onSignIn,
1531
+ onClose
1532
+ }) => /* @__PURE__ */ jsx(ModalFrame2, { onClose, contentStyle: { padding: "48px 24px" }, children: /* @__PURE__ */ jsxs(
1533
+ "div",
1534
+ {
1535
+ style: {
1536
+ display: "flex",
1537
+ flexDirection: "column",
1538
+ alignItems: "center",
1539
+ gap: 24,
1540
+ textAlign: "center"
1541
+ },
1542
+ children: [
1543
+ /* @__PURE__ */ jsx(LockIcon, {}),
1544
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1545
+ /* @__PURE__ */ jsx(
1546
+ "h2",
1547
+ {
1548
+ style: {
1549
+ margin: 0,
1550
+ fontSize: 20,
1551
+ fontWeight: 600,
1552
+ color: colors2.textPrimary
1553
+ },
1554
+ children: title
1555
+ }
1556
+ ),
1557
+ /* @__PURE__ */ jsx(
1558
+ "p",
1559
+ {
1560
+ style: {
1561
+ margin: 0,
1562
+ fontSize: 14,
1563
+ color: colors2.textSecondary,
1564
+ lineHeight: 1.5
1565
+ },
1566
+ children: "Please sign in to continue"
1567
+ }
1568
+ )
1569
+ ] }),
1570
+ onSignIn && /* @__PURE__ */ jsx(
1571
+ "button",
1572
+ {
1573
+ type: "button",
1574
+ onClick: onSignIn,
1575
+ style: {
1576
+ padding: "12px 48px",
1577
+ borderRadius: radii2.full,
1578
+ border: "none",
1579
+ background: colors2.textPrimary,
1580
+ color: "#15181D",
1581
+ fontSize: 16,
1582
+ fontWeight: 500,
1583
+ fontFamily: fonts2.family,
1584
+ cursor: "pointer"
1585
+ },
1586
+ children: "Sign In"
1587
+ }
1588
+ )
1589
+ ]
1590
+ }
1591
+ ) });
1592
+ function useSession() {
1593
+ const [session, setSession] = useState(
1594
+ () => sessionStore.getState().session
1595
+ );
1596
+ useEffect(() => {
1597
+ const unsub = sessionStore.on("session:changed", setSession);
1598
+ return () => {
1599
+ unsub();
1600
+ };
1601
+ }, []);
1602
+ return session;
1603
+ }
1604
+ var BackArrow = () => /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M15 6L9 12L15 18", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
1605
+ var TransferIcon = () => /* @__PURE__ */ jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", children: [
1606
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "18", fill: "rgba(255,255,255,0.08)" }),
1607
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "7", stroke: colors2.textPrimary, strokeWidth: "1.5" }),
1608
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "2.5", fill: colors2.textPrimary }),
1609
+ /* @__PURE__ */ jsx("path", { d: "M18 7V11", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" }),
1610
+ /* @__PURE__ */ jsx("path", { d: "M18 25V29", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" }),
1611
+ /* @__PURE__ */ jsx("path", { d: "M7 18H11", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" }),
1612
+ /* @__PURE__ */ jsx("path", { d: "M25 18H29", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" })
1613
+ ] });
1614
+ var FiatIcon = () => /* @__PURE__ */ jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", children: [
1615
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "18", fill: "rgba(255,255,255,0.06)" }),
1616
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "10", stroke: colors2.textSecondary, strokeWidth: "1.5" }),
1617
+ /* @__PURE__ */ jsx("path", { d: "M18 12V24", stroke: colors2.textSecondary, strokeWidth: "1.5", strokeLinecap: "round" }),
1618
+ /* @__PURE__ */ jsx("path", { d: "M15 15.5C15 14.12 16.34 13 18 13C19.66 13 21 14.12 21 15.5C21 16.88 19.66 18 18 18C16.34 18 15 19.12 15 20.5C15 21.88 16.34 23 18 23C19.66 23 21 21.88 21 20.5", stroke: colors2.textSecondary, strokeWidth: "1.5", strokeLinecap: "round" })
1619
+ ] });
1620
+ var DefaultCryptoIcons = () => {
1621
+ const tokens = [
1622
+ { label: "B", bg: "#F7931A" },
1623
+ { label: "E", bg: "#627EEA" },
1624
+ { label: "\u2261", bg: "#26A17B" },
1625
+ { label: "$", bg: "#2775CA" },
1626
+ { label: "S", bg: "#9945FF" },
1627
+ { label: "A", bg: "#E84142" }
1628
+ ];
1629
+ return /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 0 }, children: tokens.map((t, i) => /* @__PURE__ */ jsx(
1630
+ "div",
1631
+ {
1632
+ style: {
1633
+ width: 24,
1634
+ height: 24,
1635
+ borderRadius: "50%",
1636
+ background: t.bg,
1637
+ display: "flex",
1638
+ alignItems: "center",
1639
+ justifyContent: "center",
1640
+ fontSize: 11,
1641
+ fontWeight: 700,
1642
+ color: "#fff",
1643
+ marginLeft: i > 0 ? -4 : 0,
1644
+ border: `2px solid ${colors2.card}`,
1645
+ boxSizing: "content-box"
1646
+ },
1647
+ children: t.label
1648
+ },
1649
+ i
1650
+ )) });
1651
+ };
1652
+ function chainsToTokenOptions(chains) {
1653
+ const bySymbol = /* @__PURE__ */ new Map();
1654
+ for (const c of chains) {
1655
+ for (const t of c.tokens) {
1656
+ if (!bySymbol.has(t.symbol)) bySymbol.set(t.symbol, { symbol: t.symbol, decimals: t.decimals });
1657
+ }
1658
+ }
1659
+ return Array.from(bySymbol.entries()).map(([id, { symbol }]) => ({
1660
+ id,
1661
+ label: symbol,
1662
+ subtitle: symbol
1663
+ }));
1664
+ }
1665
+ function chainsToChainOptionsForToken(chains, tokenSymbol) {
1666
+ return chains.filter((c) => c.tokens.some((t) => t.symbol === tokenSymbol)).map((c) => ({
1667
+ id: c.chain_id,
1668
+ label: c.network,
1669
+ subtitle: `chainId: ${c.chain_id}`,
1670
+ icon: /* @__PURE__ */ jsx(
1671
+ "span",
1672
+ {
1673
+ style: {
1674
+ display: "inline-flex",
1675
+ alignItems: "center",
1676
+ justifyContent: "center",
1677
+ minWidth: 28,
1678
+ height: 28,
1679
+ padding: "0 6px",
1680
+ borderRadius: radii2.card,
1681
+ background: "rgba(255,255,255,0.08)",
1682
+ fontSize: 12,
1683
+ fontWeight: 600,
1684
+ color: colors2.textPrimary,
1685
+ fontFamily: fonts2.family
1686
+ },
1687
+ children: c.network
1688
+ }
1689
+ )
1690
+ }));
1691
+ }
1692
+ function getTokenAddressForChain(chains, chainId, tokenSymbol) {
1693
+ const chain = chains.find((c) => c.chain_id === chainId);
1694
+ return chain?.tokens.find((t) => t.symbol === tokenSymbol)?.address;
1695
+ }
1696
+ var FUNDING_TOKEN_SYMBOL = getEnv("FUNDING_TOKEN_SYMBOL");
1697
+ var DepositModal = ({
1698
+ token,
1699
+ chain,
1700
+ tokenOptions: tokenOptionsProp,
1701
+ chainOptions: chainOptionsProp,
1702
+ depositAddress,
1703
+ minimumDeposit,
1704
+ qrCenterIcon,
1705
+ cryptoIcons,
1706
+ depositAmount,
1707
+ onShowToast,
1708
+ txHash,
1709
+ explorerTxUrl,
1710
+ onTokenSelect,
1711
+ onChainSelect,
1712
+ onCopyAddress,
1713
+ onBuyCrypto,
1714
+ onSignIn,
1715
+ onBack,
1716
+ onClose
1717
+ }) => {
1718
+ const session = useSession();
1719
+ const [view, setView] = useState("entry");
1720
+ const [copySuccessMessage, setCopySuccessMessage] = useState(null);
1721
+ const [apiChains, setApiChains] = useState(null);
1722
+ const [apiQuote, setApiQuote] = useState(null);
1723
+ const [loadingChains, setLoadingChains] = useState(false);
1724
+ const [loadingQuote, setLoadingQuote] = useState(false);
1725
+ const [quoteRefreshKey, setQuoteRefreshKey] = useState(0);
1726
+ const [internalDepositAddress, setInternalDepositAddress] = useState(void 0);
1727
+ const lastEmittedAddressRef = useRef(void 0);
1728
+ const lastEmittedChainRef = useRef(void 0);
1729
+ const tokenOptions = useMemo(() => {
1730
+ if (tokenOptionsProp?.length) return tokenOptionsProp;
1731
+ if (!apiChains?.length) return void 0;
1732
+ return chainsToTokenOptions(apiChains);
1733
+ }, [tokenOptionsProp, apiChains]);
1734
+ const chainOptions = useMemo(() => {
1735
+ if (chainOptionsProp?.length) return chainOptionsProp;
1736
+ if (!apiChains?.length || !token) return void 0;
1737
+ return chainsToChainOptionsForToken(apiChains, token);
1738
+ }, [chainOptionsProp, apiChains, token]);
1739
+ useEffect(() => {
1740
+ if (chainOptions?.length !== 1 || !onChainSelect) return;
1741
+ const onlyId = chainOptions[0].id;
1742
+ if (chain === onlyId) return;
1743
+ onChainSelect(onlyId);
1744
+ }, [chainOptions, chain, onChainSelect]);
1745
+ useEffect(() => {
1746
+ if (view !== "transfer") return;
1747
+ setLoadingChains(true);
1748
+ getChains().then((res) => setApiChains(res?.chains ?? {})).finally(() => setLoadingChains(false));
1749
+ }, [view]);
1750
+ useEffect(() => {
1751
+ if (view !== "transfer") return;
1752
+ if (!session?.address || !chain) return;
1753
+ registerPlatform({
1754
+ platform_contract_address: session.address,
1755
+ chain_id: chain
1756
+ }).then((res) => {
1757
+ if (res?.deposit_address) {
1758
+ setInternalDepositAddress(res.deposit_address);
1759
+ }
1760
+ }).catch(() => {
1761
+ });
1762
+ }, [view, chain, session?.address]);
1763
+ useEffect(() => {
1764
+ if (!apiChains?.length || !token || !chain) {
1765
+ setApiQuote(null);
1766
+ return;
1767
+ }
1768
+ const tokenAddress = getTokenAddressForChain(apiChains, chain, token);
1769
+ if (!tokenAddress) {
1770
+ setApiQuote(null);
1771
+ return;
1772
+ }
1773
+ setLoadingQuote(true);
1774
+ quote({
1775
+ direction: "deposit",
1776
+ chain_id: chain,
1777
+ token_address: tokenAddress,
1778
+ token_amount: depositAmount || void 0
1779
+ }).then((q) => setApiQuote(q ?? null)).catch((err) => {
1780
+ const message = err?.message ?? String(err);
1781
+ if (onShowToast) onShowToast(message);
1782
+ setApiQuote({
1783
+ token_address: tokenAddress,
1784
+ token_symbol: token,
1785
+ token_decimals: 18,
1786
+ rate: "1",
1787
+ chain_id: Number(chain) || 56,
1788
+ deposit_address: "0x" + "0".repeat(39) + "1",
1789
+ dst_token_amount: depositAmount ?? "0",
1790
+ expires_at: new Date(Date.now() + 6e4).toISOString()
1791
+ });
1792
+ }).finally(() => setLoadingQuote(false));
1793
+ }, [apiChains, token, chain, depositAmount, quoteRefreshKey, onShowToast]);
1794
+ useEffect(() => {
1795
+ if (!chain) return;
1796
+ if (!depositAddress) return;
1797
+ if (lastEmittedAddressRef.current === depositAddress && lastEmittedChainRef.current === chain) {
1798
+ return;
1799
+ }
1800
+ lastEmittedAddressRef.current = depositAddress;
1801
+ lastEmittedChainRef.current = chain;
1802
+ }, [depositAddress, chain]);
1803
+ const handleQuoteExpired = useCallback(() => {
1804
+ setQuoteRefreshKey((k) => k + 1);
1805
+ }, []);
1806
+ useEffect(() => {
1807
+ if (txHash && chain && onShowToast) {
1808
+ onShowToast("Transfer confirmed");
1809
+ }
1810
+ }, [txHash, chain, onShowToast]);
1811
+ if (!session) {
1812
+ return /* @__PURE__ */ jsx(LoginRequiredOverlay, { title: "Deposit", onSignIn, onClose });
1813
+ }
1814
+ const goToEntry = () => {
1815
+ setView("entry");
1816
+ onBack?.();
1817
+ };
1818
+ const handleCopyAddress = useCallback((address) => {
1819
+ onCopyAddress?.(address);
1820
+ onShowToast?.("Address copied");
1821
+ setCopySuccessMessage("Address copied");
1822
+ }, [onCopyAddress, onShowToast]);
1823
+ useEffect(() => {
1824
+ if (!copySuccessMessage) return;
1825
+ const t = setTimeout(() => setCopySuccessMessage(null), 2e3);
1826
+ return () => clearTimeout(t);
1827
+ }, [copySuccessMessage]);
1828
+ return /* @__PURE__ */ jsxs(ModalFrame2, { onClose, contentStyle: { padding: "24px", position: "relative" }, children: [
1829
+ copySuccessMessage && /* @__PURE__ */ jsx(
1830
+ "div",
1831
+ {
1832
+ style: {
1833
+ position: "absolute",
1834
+ top: 12,
1835
+ left: 0,
1836
+ right: 0,
1837
+ display: "flex",
1838
+ justifyContent: "center",
1839
+ pointerEvents: "none",
1840
+ zIndex: 10
1841
+ },
1842
+ children: /* @__PURE__ */ jsx(
1843
+ "div",
1844
+ {
1845
+ style: {
1846
+ pointerEvents: "auto",
1847
+ padding: "10px 20px",
1848
+ borderRadius: 8,
1849
+ background: "var(--pm-colors-card, #1a1a2e)",
1850
+ color: "var(--pm-colors-textPrimary, #fff)",
1851
+ fontSize: 13,
1852
+ fontWeight: 500,
1853
+ boxShadow: "0 4px 12px rgba(0,0,0,.25)"
1854
+ },
1855
+ children: copySuccessMessage
1856
+ }
1857
+ )
1858
+ }
1859
+ ),
1860
+ view === "entry" ? /* @__PURE__ */ jsx(
1861
+ EntryView,
1862
+ {
1863
+ cryptoIcons,
1864
+ onTransferCrypto: () => setView("transfer"),
1865
+ onBuyCrypto
1866
+ }
1867
+ ) : /* @__PURE__ */ jsx(
1868
+ TransferView,
1869
+ {
1870
+ token,
1871
+ chain,
1872
+ tokenOptions,
1873
+ chainOptions,
1874
+ depositAddress: depositAddress ?? internalDepositAddress,
1875
+ minimumDeposit,
1876
+ qrCenterIcon,
1877
+ quote: apiQuote,
1878
+ quoteLoading: loadingQuote,
1879
+ txHash,
1880
+ chainIdForExplorer: chain,
1881
+ explorerTxUrl,
1882
+ loadingChains,
1883
+ onTokenSelect,
1884
+ onChainSelect,
1885
+ onCopyAddress: handleCopyAddress,
1886
+ onQuoteExpired: handleQuoteExpired,
1887
+ onRefreshQuote: () => {
1888
+ if (!apiChains?.length || !token || !chain) return;
1889
+ const tokenAddress = getTokenAddressForChain(apiChains, chain, token);
1890
+ if (tokenAddress) {
1891
+ setLoadingQuote(true);
1892
+ quote({ direction: "deposit", chain_id: chain, token_address: tokenAddress, token_amount: depositAmount }).then((q) => setApiQuote(q ?? null)).catch(() => {
1893
+ setApiQuote({
1894
+ token_address: tokenAddress,
1895
+ token_symbol: token,
1896
+ token_decimals: 18,
1897
+ rate: "1",
1898
+ chain_id: Number(chain) || 56,
1899
+ deposit_address: "0x" + "0".repeat(39) + "1",
1900
+ dst_token_amount: depositAmount ?? "0",
1901
+ expires_at: new Date(Date.now() + 6e4).toISOString()
1902
+ });
1903
+ }).finally(() => setLoadingQuote(false));
1904
+ }
1905
+ },
1906
+ onShowToast,
1907
+ onBack: goToEntry
1908
+ }
1909
+ )
1910
+ ] });
1911
+ };
1912
+ var EntryView = ({
1913
+ cryptoIcons,
1914
+ onTransferCrypto,
1915
+ onBuyCrypto: _onBuyCrypto
1916
+ }) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 24 }, children: [
1917
+ /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: 24, fontWeight: 600, lineHeight: 1.4 }, children: "Deposit" }),
1918
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
1919
+ /* @__PURE__ */ jsxs(
1920
+ "button",
1921
+ {
1922
+ type: "button",
1923
+ onClick: onTransferCrypto,
1924
+ style: {
1925
+ display: "flex",
1926
+ alignItems: "center",
1927
+ gap: 14,
1928
+ padding: "18px 20px",
1929
+ borderRadius: radii2.card,
1930
+ border: `1px solid ${colors2.border}`,
1931
+ background: "transparent",
1932
+ cursor: "pointer",
1933
+ textAlign: "left",
1934
+ fontFamily: fonts2.family,
1935
+ width: "100%",
1936
+ transition: "border-color .15s"
1937
+ },
1938
+ onMouseEnter: (e) => {
1939
+ e.target.closest("button").style.borderColor = colors2.borderStrong;
1940
+ },
1941
+ onMouseLeave: (e) => {
1942
+ e.target.closest("button").style.borderColor = colors2.border;
1943
+ },
1944
+ children: [
1945
+ /* @__PURE__ */ jsx(TransferIcon, {}),
1946
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: 2 }, children: [
1947
+ /* @__PURE__ */ jsx("span", { style: { color: colors2.textPrimary, fontSize: 16, fontWeight: 600 }, children: "Transfer Crypto" }),
1948
+ /* @__PURE__ */ jsx("span", { style: { color: colors2.textSecondary, fontSize: 13 }, children: "No limit \xB7 Instant" })
1949
+ ] }),
1950
+ cryptoIcons ?? /* @__PURE__ */ jsx(DefaultCryptoIcons, {})
1951
+ ]
1952
+ }
1953
+ ),
1954
+ /* @__PURE__ */ jsxs(
1955
+ "div",
1956
+ {
1957
+ style: {
1958
+ display: "flex",
1959
+ alignItems: "center",
1960
+ gap: 14,
1961
+ padding: "18px 20px",
1962
+ borderRadius: radii2.card,
1963
+ border: `1px solid ${colors2.border}`,
1964
+ opacity: 0.55
1965
+ },
1966
+ children: [
1967
+ /* @__PURE__ */ jsx(FiatIcon, {}),
1968
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: 2 }, children: [
1969
+ /* @__PURE__ */ jsx("span", { style: { color: colors2.textSecondary, fontSize: 16, fontWeight: 600 }, children: "Buy Crypto" }),
1970
+ /* @__PURE__ */ jsx("span", { style: { color: colors2.textSecondary, fontSize: 13 }, children: "Debit card, credit card, ACH" })
1971
+ ] }),
1972
+ /* @__PURE__ */ jsx(
1973
+ "span",
1974
+ {
1975
+ style: {
1976
+ padding: "5px 12px",
1977
+ borderRadius: radii2.pill,
1978
+ border: `1px solid ${colors2.border}`,
1979
+ fontSize: 12,
1980
+ fontWeight: 500,
1981
+ color: colors2.textSecondary,
1982
+ whiteSpace: "nowrap"
1983
+ },
1984
+ children: "Coming Soon"
1985
+ }
1986
+ )
1987
+ ]
1988
+ }
1989
+ )
1990
+ ] })
1991
+ ] });
1992
+ var TransferView = ({
1993
+ token,
1994
+ chain,
1995
+ tokenOptions,
1996
+ chainOptions,
1997
+ depositAddress,
1998
+ minimumDeposit,
1999
+ qrCenterIcon,
2000
+ quote: quoteData,
2001
+ quoteLoading,
2002
+ txHash,
2003
+ chainIdForExplorer,
2004
+ explorerTxUrl,
2005
+ loadingChains,
2006
+ onTokenSelect,
2007
+ onChainSelect,
2008
+ onCopyAddress,
2009
+ onQuoteExpired,
2010
+ onRefreshQuote,
2011
+ onShowToast,
2012
+ onBack
2013
+ }) => {
2014
+ const activeStep = chain ? 2 : token ? 1 : 0;
2015
+ const stepActive = [!!token, !!chain, !!quoteData];
2016
+ const quoteExpired = useMemo(() => {
2017
+ if (!quoteData?.expires_at) return false;
2018
+ try {
2019
+ return new Date(quoteData.expires_at).getTime() < Date.now();
2020
+ } catch {
2021
+ return false;
2022
+ }
2023
+ }, [quoteData?.expires_at]);
2024
+ const didToastWait = useRef(false);
2025
+ useEffect(() => {
2026
+ if (!depositAddress || !onShowToast || didToastWait.current) return;
2027
+ didToastWait.current = true;
2028
+ onShowToast("Please wait for deposit-address balance to update");
2029
+ }, [depositAddress, onShowToast]);
2030
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 24 }, children: [
2031
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
2032
+ onBack && /* @__PURE__ */ jsx(
2033
+ "button",
2034
+ {
2035
+ type: "button",
2036
+ onClick: onBack,
2037
+ style: {
2038
+ background: "transparent",
2039
+ border: "none",
2040
+ cursor: "pointer",
2041
+ padding: 0,
2042
+ display: "flex",
2043
+ alignItems: "center"
2044
+ },
2045
+ children: /* @__PURE__ */ jsx(BackArrow, {})
2046
+ }
2047
+ ),
2048
+ /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: 24, fontWeight: 600, lineHeight: 1.4 }, children: "Transfer Crypto" })
2049
+ ] }) }),
2050
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 16, position: "relative" }, children: [
2051
+ /* @__PURE__ */ jsx(StepIndicator, { steps: 3, stepActive, activeStep }),
2052
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: 40 }, children: [
2053
+ /* @__PURE__ */ jsx(
2054
+ DropdownField,
2055
+ {
2056
+ label: "Select token",
2057
+ placeholder: loadingChains ? "Loading\u2026" : "Token",
2058
+ value: token,
2059
+ options: tokenOptions,
2060
+ onSelect: onTokenSelect
2061
+ }
2062
+ ),
2063
+ /* @__PURE__ */ jsx(
2064
+ DropdownField,
2065
+ {
2066
+ label: "Select chain",
2067
+ placeholder: loadingChains ? "Loading\u2026" : "Chain",
2068
+ value: chain,
2069
+ options: chainOptions,
2070
+ onSelect: onChainSelect
2071
+ }
2072
+ ),
2073
+ quoteData && token && chain && /* @__PURE__ */ jsx(
2074
+ "div",
2075
+ {
2076
+ id: "quote-panel",
2077
+ style: {
2078
+ padding: "12px 16px",
2079
+ borderRadius: radii2.card,
2080
+ margin: "-10px 0",
2081
+ border: `1px solid ${colors2.border}`,
2082
+ display: "flex",
2083
+ flexDirection: "column",
2084
+ gap: 8
2085
+ },
2086
+ children: quoteLoading ? /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: colors2.textSecondary }, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2087
+ /* @__PURE__ */ jsxs("span", { style: { fontSize: 13, color: colors2.textSecondary }, children: [
2088
+ "1 ",
2089
+ quoteData.token_symbol,
2090
+ " = ",
2091
+ quoteData.rate,
2092
+ " ",
2093
+ FUNDING_TOKEN_SYMBOL
2094
+ ] }),
2095
+ quoteData.expires_at && /* @__PURE__ */ jsx(
2096
+ Countdown,
2097
+ {
2098
+ expiresAt: quoteData.expires_at,
2099
+ isExpired: quoteExpired,
2100
+ onExpired: onQuoteExpired
2101
+ }
2102
+ ),
2103
+ quoteExpired && /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
2104
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#f59e0b" }, children: "Quote expired, please refresh" }),
2105
+ onRefreshQuote && /* @__PURE__ */ jsx(
2106
+ "button",
2107
+ {
2108
+ type: "button",
2109
+ onClick: onRefreshQuote,
2110
+ style: {
2111
+ padding: "4px 12px",
2112
+ fontSize: 12,
2113
+ borderRadius: radii2.pill,
2114
+ border: `1px solid ${colors2.border}`,
2115
+ background: "transparent",
2116
+ color: colors2.textPrimary,
2117
+ cursor: "pointer",
2118
+ fontFamily: fonts2.family
2119
+ },
2120
+ children: "Refresh"
2121
+ }
2122
+ )
2123
+ ] })
2124
+ ] })
2125
+ }
2126
+ ),
2127
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8, marginTop: "-5px" }, id: "deposit-details", children: [
2128
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: "Deposit details" }),
2129
+ depositAddress ? /* @__PURE__ */ jsxs(Fragment, { children: [
2130
+ /* @__PURE__ */ jsx(
2131
+ DepositDetailsPanel,
2132
+ {
2133
+ address: depositAddress,
2134
+ tokenIcon: qrCenterIcon,
2135
+ minimumDeposit,
2136
+ onCopyAddress
2137
+ }
2138
+ ),
2139
+ txHash && chainIdForExplorer && explorerTxUrl && /* @__PURE__ */ jsx(
2140
+ "a",
2141
+ {
2142
+ href: explorerTxUrl(chainIdForExplorer, txHash),
2143
+ target: "_blank",
2144
+ rel: "noopener noreferrer",
2145
+ style: {
2146
+ fontSize: 13,
2147
+ color: colors2.textPrimary,
2148
+ textDecoration: "underline"
2149
+ },
2150
+ children: "View on explorer"
2151
+ }
2152
+ )
2153
+ ] }) : /* @__PURE__ */ jsx(
2154
+ "div",
2155
+ {
2156
+ style: {
2157
+ padding: "20px",
2158
+ borderRadius: radii2.card,
2159
+ border: `1px solid ${colors2.border}`,
2160
+ color: colors2.textSecondary,
2161
+ fontSize: 13,
2162
+ textAlign: "center"
2163
+ },
2164
+ children: "Select token and chain to view deposit details"
2165
+ }
2166
+ )
2167
+ ] })
2168
+ ] })
2169
+ ] })
2170
+ ] });
2171
+ };
2172
+ var SuccessIcon = () => {
2173
+ return /* @__PURE__ */ jsxs("svg", { width: "80", height: "81", viewBox: "0 0 80 81", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2174
+ /* @__PURE__ */ jsx(
2175
+ "path",
2176
+ {
2177
+ d: "M40 80.5C62.0914 80.5 80 62.5914 80 40.5C80 18.4086 62.0914 0.5 40 0.5C17.9086 0.5 0 18.4086 0 40.5C0 62.5914 17.9086 80.5 40 80.5Z",
2178
+ fill: "#627EEA"
2179
+ }
2180
+ ),
2181
+ /* @__PURE__ */ jsx(
2182
+ "path",
2183
+ {
2184
+ d: "M38.999 16.5V34.2437L53.9962 40.9451L38.999 16.5Z",
2185
+ fill: "white",
2186
+ fillOpacity: "0.602"
2187
+ }
2188
+ ),
2189
+ /* @__PURE__ */ jsx("path", { d: "M38.9991 16.5L24 40.9451L38.9991 34.2437V16.5Z", fill: "white" }),
2190
+ /* @__PURE__ */ jsx(
2191
+ "path",
2192
+ {
2193
+ d: "M38.999 52.4434V64.4999L54.0061 43.7376L38.999 52.4434Z",
2194
+ fill: "white",
2195
+ fillOpacity: "0.602"
2196
+ }
2197
+ ),
2198
+ /* @__PURE__ */ jsx("path", { d: "M38.9991 64.4999V52.4414L24 43.7376L38.9991 64.4999Z", fill: "white" }),
2199
+ /* @__PURE__ */ jsx(
2200
+ "path",
2201
+ {
2202
+ d: "M38.999 49.653L53.9962 40.9451L38.999 34.2477V49.653Z",
2203
+ fill: "white",
2204
+ fillOpacity: "0.2"
2205
+ }
2206
+ ),
2207
+ /* @__PURE__ */ jsx(
2208
+ "path",
2209
+ {
2210
+ d: "M24 40.9451L38.9991 49.653V34.2477L24 40.9451Z",
2211
+ fill: "white",
2212
+ fillOpacity: "0.602"
2213
+ }
2214
+ ),
2215
+ /* @__PURE__ */ jsx("g", { filter: "url(#filter0_ii_34_1690)", children: /* @__PURE__ */ jsx("circle", { cx: "40", cy: "40", r: "40", fill: "url(#paint0_linear_34_1690)" }) }),
2216
+ /* @__PURE__ */ jsx(
2217
+ "path",
2218
+ {
2219
+ d: "M25.8057 35.9858L38.7921 49.0324L56.7734 30.9678",
2220
+ stroke: "#58AE36",
2221
+ strokeWidth: "5.16129",
2222
+ fill: "none"
2223
+ }
2224
+ ),
2225
+ /* @__PURE__ */ jsxs("defs", { children: [
2226
+ /* @__PURE__ */ jsxs(
2227
+ "filter",
2228
+ {
2229
+ id: "filter0_ii_34_1690",
2230
+ x: "0",
2231
+ y: "0",
2232
+ width: "80",
2233
+ height: "80",
2234
+ filterUnits: "userSpaceOnUse",
2235
+ colorInterpolationFilters: "sRGB",
2236
+ children: [
2237
+ /* @__PURE__ */ jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
2238
+ /* @__PURE__ */ jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }),
2239
+ /* @__PURE__ */ jsx(
2240
+ "feColorMatrix",
2241
+ {
2242
+ in: "SourceAlpha",
2243
+ type: "matrix",
2244
+ values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
2245
+ result: "hardAlpha"
2246
+ }
2247
+ ),
2248
+ /* @__PURE__ */ jsx("feOffset", { dx: "-1.29032", dy: "-1.29032" }),
2249
+ /* @__PURE__ */ jsx("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
2250
+ /* @__PURE__ */ jsx(
2251
+ "feColorMatrix",
2252
+ {
2253
+ type: "matrix",
2254
+ values: "0 0 0 0 0.584745 0 0 0 0 1 0 0 0 0 0.420982 0 0 0 1 0"
2255
+ }
2256
+ ),
2257
+ /* @__PURE__ */ jsx("feBlend", { mode: "multiply", in2: "shape", result: "effect1_innerShadow_34_1690" }),
2258
+ /* @__PURE__ */ jsx(
2259
+ "feColorMatrix",
2260
+ {
2261
+ in: "SourceAlpha",
2262
+ type: "matrix",
2263
+ values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
2264
+ result: "hardAlpha"
2265
+ }
2266
+ ),
2267
+ /* @__PURE__ */ jsx("feOffset", { dx: "1.29032", dy: "1.29032" }),
2268
+ /* @__PURE__ */ jsx("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
2269
+ /* @__PURE__ */ jsx("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" }),
2270
+ /* @__PURE__ */ jsx("feBlend", { mode: "normal", in2: "effect1_innerShadow_34_1690", result: "effect2_innerShadow_34_1690" })
2271
+ ]
2272
+ }
2273
+ ),
2274
+ /* @__PURE__ */ jsxs(
2275
+ "linearGradient",
2276
+ {
2277
+ id: "paint0_linear_34_1690",
2278
+ x1: "27.4722",
2279
+ y1: "7.62951",
2280
+ x2: "70.4313",
2281
+ y2: "26.563",
2282
+ gradientUnits: "userSpaceOnUse",
2283
+ children: [
2284
+ /* @__PURE__ */ jsx("stop", { stopColor: "#BBFFA1" }),
2285
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#ACFE8B" })
2286
+ ]
2287
+ }
2288
+ )
2289
+ ] })
2290
+ ] });
2291
+ };
2292
+ function CopyIcon2() {
2293
+ return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, children: [
2294
+ /* @__PURE__ */ jsx("rect", { x: "5", y: "5", width: "9", height: "9", rx: "1", stroke: "currentColor", strokeWidth: "1.2", fill: "none" }),
2295
+ /* @__PURE__ */ jsx("path", { d: "M3 11V3a1 1 0 0 1 1-1h8", stroke: "currentColor", strokeWidth: "1.2", fill: "none" })
2296
+ ] });
2297
+ }
2298
+ var FUNDING_TOKEN_SYMBOL2 = getEnv("FUNDING_TOKEN_SYMBOL");
2299
+ function chainsToTokenOptions2(chains) {
2300
+ const bySymbol = /* @__PURE__ */ new Map();
2301
+ for (const c of chains) {
2302
+ for (const t of c.tokens) {
2303
+ if (!bySymbol.has(t.symbol)) bySymbol.set(t.symbol, t.symbol);
2304
+ }
2305
+ }
2306
+ return Array.from(bySymbol.entries()).map(([id, symbol]) => ({
2307
+ id,
2308
+ label: symbol,
2309
+ subtitle: symbol
2310
+ }));
2311
+ }
2312
+ function chainsToChainOptionsForToken2(chains, tokenSymbol) {
2313
+ return chains.filter((c) => c.tokens.some((t) => t.symbol === tokenSymbol)).map((c) => ({ id: c.chain_id, label: c.network, subtitle: c.chain_id }));
2314
+ }
2315
+ function getTokenAddressForChain2(chains, chainId, tokenSymbol) {
2316
+ const chain = chains.find((c) => c.chain_id === chainId);
2317
+ return chain?.tokens.find((t) => t.symbol === tokenSymbol)?.address;
2318
+ }
2319
+ function parseBalanceNumber(balance) {
2320
+ const match = balance.trim().match(/^(\d*\.?\d*)/);
2321
+ if (!match) return null;
2322
+ const n = Number(match[1]);
2323
+ return Number.isNaN(n) ? null : n;
2324
+ }
2325
+ function formatBalanceTo2Decimals(balance) {
2326
+ const match = balance.trim().match(/^(\d*\.?\d*)(.*)$/);
2327
+ if (!match) return balance;
2328
+ const numPart = match[1];
2329
+ const suffix = match[2].trim() ? " " + match[2].trim() : "";
2330
+ const n = Number(numPart);
2331
+ if (Number.isNaN(n)) return balance;
2332
+ const formatted = n.toFixed(2);
2333
+ return formatted + suffix;
2334
+ }
2335
+ function weiToEtherDisplay(wei) {
2336
+ const s = (wei || "0").trim().replace(/^0+/, "") || "0";
2337
+ if (s === "0") return "0";
2338
+ const padded = s.padStart(19, "0");
2339
+ const intPart = padded.slice(0, Math.max(0, padded.length - 18));
2340
+ const decPart = padded.slice(-18).replace(/0+$/, "");
2341
+ const combined = decPart ? `${intPart}.${decPart}` : intPart;
2342
+ const num = Number(combined);
2343
+ if (Number.isNaN(num)) return wei;
2344
+ const fixed = num.toFixed(6).replace(/\.?0+$/, "");
2345
+ return fixed;
2346
+ }
2347
+ var POLL_INTERVAL_MS = 4e3;
2348
+ var WithdrawModal = ({
2349
+ address = "",
2350
+ token,
2351
+ tokenSymbol,
2352
+ chain,
2353
+ amount = "",
2354
+ balance,
2355
+ status = "idle",
2356
+ receiveAmount: receiveAmountProp,
2357
+ txHash,
2358
+ tokenOptions: tokenOptionsProp,
2359
+ chainOptions: chainOptionsProp,
2360
+ useMerchantApi = false,
2361
+ orderId,
2362
+ withdrawMode,
2363
+ withdrawDirectResult,
2364
+ feeDisplay,
2365
+ fundingChainId,
2366
+ onShowToast,
2367
+ onAddressChange,
2368
+ onTokenSelect,
2369
+ onChainSelect,
2370
+ onAmountChange,
2371
+ onMaxClick,
2372
+ onSubmit,
2373
+ onWithdrawCompleted,
2374
+ onStartAnotherWithdrawal,
2375
+ onSignIn,
2376
+ onClose
2377
+ }) => {
2378
+ const session = useSession();
2379
+ const addressInputRef = useRef(null);
2380
+ const [addressInputFocused, setAddressInputFocused] = useState(false);
2381
+ const [amountInputFocused, setAmountInputFocused] = useState(false);
2382
+ const [apiChains, setApiChains] = useState(null);
2383
+ const [apiQuote, setApiQuote] = useState(null);
2384
+ const [withdrawOrder, setWithdrawOrder] = useState(null);
2385
+ const [loadingChains, setLoadingChains] = useState(false);
2386
+ const [loadingQuote, setLoadingQuote] = useState(false);
2387
+ const tokenOptions = useMemo(() => {
2388
+ const raw = tokenOptionsProp?.length ? tokenOptionsProp : apiChains?.length ? chainsToTokenOptions2(apiChains) : void 0;
2389
+ if (!raw?.length) return void 0;
2390
+ return raw;
2391
+ }, [tokenOptionsProp, apiChains]);
2392
+ const chainOptions = useMemo(() => {
2393
+ if (chainOptionsProp?.length) return chainOptionsProp;
2394
+ if (!apiChains?.length || !token) return void 0;
2395
+ return chainsToChainOptionsForToken2(apiChains, token);
2396
+ }, [chainOptionsProp, apiChains, token]);
2397
+ const resolvedTokenAddress = useMemo(() => {
2398
+ if (!apiChains?.length || !token || !chain) return void 0;
2399
+ return getTokenAddressForChain2(apiChains, chain, token);
2400
+ }, [apiChains, token, chain]);
2401
+ const [directActive, setDirectActive] = useState(false);
2402
+ useEffect(() => {
2403
+ setDirectActive(withdrawMode === "direct" && Boolean(withdrawDirectResult));
2404
+ }, [withdrawMode, withdrawDirectResult]);
2405
+ const trackingWithdraw = useMemo(
2406
+ () => Boolean(orderId) || directActive,
2407
+ [orderId, directActive]
2408
+ );
2409
+ useEffect(() => {
2410
+ if (trackingWithdraw) return;
2411
+ const t = requestAnimationFrame(() => {
2412
+ addressInputRef.current?.focus();
2413
+ });
2414
+ return () => cancelAnimationFrame(t);
2415
+ }, [trackingWithdraw]);
2416
+ const shouldLoadChains = useMerchantApi || Boolean(token && chain);
2417
+ useEffect(() => {
2418
+ if (!shouldLoadChains) return;
2419
+ setLoadingChains(true);
2420
+ getChains().then((res) => setApiChains(res?.chains ?? [])).finally(() => setLoadingChains(false));
2421
+ }, [shouldLoadChains]);
2422
+ useEffect(() => {
2423
+ if (!apiChains?.length || !token || !chain) {
2424
+ setApiQuote(null);
2425
+ return;
2426
+ }
2427
+ const tokenAddress = getTokenAddressForChain2(apiChains, chain, token);
2428
+ if (!tokenAddress) {
2429
+ setApiQuote(null);
2430
+ return;
2431
+ }
2432
+ const amountNum = amount && Number(amount) > 0 ? Number(amount) : 1;
2433
+ const amountWei = String(BigInt(Math.floor(amountNum * 1e18)));
2434
+ setLoadingQuote(true);
2435
+ quote({
2436
+ direction: "withdraw",
2437
+ chain_id: chain,
2438
+ token_address: tokenAddress,
2439
+ dst_token_amount: amountWei
2440
+ }).then((q) => setApiQuote(q ?? null)).catch(() => {
2441
+ setApiQuote({
2442
+ token_address: tokenAddress,
2443
+ token_symbol: token,
2444
+ token_decimals: 18,
2445
+ rate: "1",
2446
+ chain_id: Number(chain) || 56,
2447
+ token_amount: amountWei,
2448
+ expires_at: new Date(Date.now() + 6e4).toISOString()
2449
+ });
2450
+ }).finally(() => setLoadingQuote(false));
2451
+ }, [apiChains, token, chain, amount]);
2452
+ useEffect(() => {
2453
+ if (tokenOptions?.length !== 1 || !onTokenSelect) return;
2454
+ const onlyId = tokenOptions[0].id;
2455
+ if (token === onlyId) return;
2456
+ onTokenSelect(onlyId);
2457
+ }, [tokenOptions, token, onTokenSelect]);
2458
+ useEffect(() => {
2459
+ if (chainOptions?.length !== 1 || !onChainSelect) return;
2460
+ const onlyId = chainOptions[0].id;
2461
+ if (chain === onlyId) return;
2462
+ onChainSelect(onlyId);
2463
+ }, [chainOptions, chain, onChainSelect]);
2464
+ const mockWithdrawOrderState = useMemo(
2465
+ () => ({
2466
+ order_id: orderId ?? "",
2467
+ status: "pending",
2468
+ chain_id: "56",
2469
+ dst_token_amount: "0",
2470
+ target_chain_id: chain ?? "1",
2471
+ target_address: address ?? "0x",
2472
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2473
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
2474
+ }),
2475
+ [orderId, chain, address]
2476
+ );
2477
+ useEffect(() => {
2478
+ if (orderId) {
2479
+ const t = setInterval(() => {
2480
+ getWithdrawOrder(orderId).then((order) => {
2481
+ setWithdrawOrder(order);
2482
+ }).catch(() => setWithdrawOrder(mockWithdrawOrderState));
2483
+ }, POLL_INTERVAL_MS);
2484
+ getWithdrawOrder(orderId).then(setWithdrawOrder).catch(() => setWithdrawOrder(mockWithdrawOrderState));
2485
+ return () => clearInterval(t);
2486
+ }
2487
+ if (!orderId && directActive) {
2488
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2489
+ const inferredAmountWei = (() => {
2490
+ if (withdrawDirectResult?.dst_token_amount) return withdrawDirectResult.dst_token_amount;
2491
+ const n = Number(amount || "0");
2492
+ return String(n > 0 ? BigInt(Math.floor(n * 1e18)) : 0n);
2493
+ })();
2494
+ const synthetic = {
2495
+ order_id: withdrawDirectResult?.order_id ?? `direct-${Date.now()}`,
2496
+ status: withdrawDirectResult?.status ?? "pending",
2497
+ chain_id: withdrawDirectResult?.chain_id ?? String(fundingChainId ?? "3131"),
2498
+ dst_token_amount: inferredAmountWei,
2499
+ fee: withdrawDirectResult?.fee ?? feeDisplay,
2500
+ target_chain_id: withdrawDirectResult?.target_chain_id ?? (chain ?? ""),
2501
+ target_address: withdrawDirectResult?.target_address ?? (address ?? ""),
2502
+ funding_tx_hash: withdrawDirectResult?.funding_tx_hash ?? txHash,
2503
+ dst_tx_hash: withdrawDirectResult?.dst_tx_hash,
2504
+ out_tx_hash: withdrawDirectResult?.out_tx_hash,
2505
+ created_at: withdrawDirectResult?.created_at ?? now,
2506
+ updated_at: withdrawDirectResult?.updated_at ?? now,
2507
+ one_time_address: withdrawDirectResult?.one_time_address
2508
+ };
2509
+ setWithdrawOrder(synthetic);
2510
+ return;
2511
+ }
2512
+ setWithdrawOrder(null);
2513
+ }, [orderId, directActive, withdrawDirectResult, amount, feeDisplay, chain, address, txHash, fundingChainId, onShowToast, mockWithdrawOrderState]);
2514
+ const completedKeyRef = useRef(null);
2515
+ const successToastKeyRef = useRef(null);
2516
+ useEffect(() => {
2517
+ if (withdrawOrder?.status !== "completed") return;
2518
+ const key = orderId ?? withdrawOrder.order_id;
2519
+ if (key && completedKeyRef.current !== key) {
2520
+ completedKeyRef.current = key;
2521
+ onWithdrawCompleted?.();
2522
+ }
2523
+ if (!trackingWithdraw) completedKeyRef.current = null;
2524
+ }, [withdrawOrder?.status, orderId, trackingWithdraw, onWithdrawCompleted]);
2525
+ useEffect(() => {
2526
+ if (!withdrawOrder || withdrawOrder.status !== "completed") return;
2527
+ const key = orderId ?? withdrawOrder.order_id;
2528
+ if (!key) return;
2529
+ if (successToastKeyRef.current === key) return;
2530
+ successToastKeyRef.current = key;
2531
+ onShowToast?.("Withdrawal completed");
2532
+ }, [withdrawOrder, orderId, onShowToast]);
2533
+ useEffect(() => {
2534
+ if (!trackingWithdraw) successToastKeyRef.current = null;
2535
+ }, [trackingWithdraw]);
2536
+ const receiveAmount = useMemo(() => {
2537
+ if (receiveAmountProp) {
2538
+ const n = Number(receiveAmountProp);
2539
+ if (!Number.isNaN(n)) return n.toFixed(2);
2540
+ return receiveAmountProp;
2541
+ }
2542
+ if (!apiQuote?.token_amount || !apiQuote?.token_symbol) return void 0;
2543
+ const amount2 = Number(apiQuote.token_amount);
2544
+ const formatted = Number.isNaN(amount2) ? apiQuote.token_amount : amount2.toFixed(2);
2545
+ return `\u2248 ${formatted} (wei) ${apiQuote.token_symbol}`;
2546
+ }, [receiveAmountProp, apiQuote]);
2547
+ const quoteExpired = useMemo(() => {
2548
+ if (!apiQuote?.expires_at) return false;
2549
+ try {
2550
+ return new Date(apiQuote.expires_at).getTime() < Date.now();
2551
+ } catch {
2552
+ return false;
2553
+ }
2554
+ }, [apiQuote?.expires_at]);
2555
+ const handleRefreshQuote = useCallback(() => {
2556
+ if (!apiChains?.length || !token || !chain) return;
2557
+ const tokenAddress = getTokenAddressForChain2(apiChains, chain, token);
2558
+ if (!tokenAddress) return;
2559
+ const amountNum = amount && Number(amount) > 0 ? Number(amount) : 1;
2560
+ const amountWei = String(BigInt(Math.floor(amountNum * 1e18)));
2561
+ setLoadingQuote(true);
2562
+ quote({
2563
+ direction: "withdraw",
2564
+ chain_id: chain,
2565
+ token_address: tokenAddress,
2566
+ dst_token_amount: amountWei
2567
+ }).then((q) => setApiQuote(q ?? null)).catch(() => {
2568
+ setApiQuote({
2569
+ token_address: tokenAddress,
2570
+ token_symbol: token,
2571
+ token_decimals: 18,
2572
+ rate: "1",
2573
+ chain_id: Number(chain) || 56,
2574
+ token_amount: amountWei,
2575
+ expires_at: new Date(Date.now() + 6e4).toISOString()
2576
+ });
2577
+ }).finally(() => setLoadingQuote(false));
2578
+ }, [apiChains, token, chain, amount]);
2579
+ const handleAmountChange = useCallback(
2580
+ (e) => {
2581
+ const raw = e.target.value;
2582
+ const maxNum = balance ? parseBalanceNumber(balance) : null;
2583
+ if (maxNum != null && raw !== "" && raw !== ".") {
2584
+ const num = Number(raw);
2585
+ if (!Number.isNaN(num) && num > maxNum) {
2586
+ onAmountChange?.({
2587
+ ...e,
2588
+ target: { ...e.target, value: String(maxNum) }
2589
+ });
2590
+ return;
2591
+ }
2592
+ }
2593
+ onAmountChange?.(e);
2594
+ },
2595
+ [balance, onAmountChange]
2596
+ );
2597
+ if (!session) {
2598
+ return /* @__PURE__ */ jsx(LoginRequiredOverlay, { title: "Withdraw", onSignIn, onClose });
2599
+ }
2600
+ const activeStep = amount ? 3 : chain ? 2 : token ? 1 : address ? 0 : 0;
2601
+ const canSubmit = address && token && chain && amount;
2602
+ const isSubmitting = status !== "idle";
2603
+ const orderInProgress = trackingWithdraw && (!withdrawOrder || withdrawOrder.status !== "completed");
2604
+ const orderSucceeded = trackingWithdraw && withdrawOrder?.status === "completed";
2605
+ return /* @__PURE__ */ jsxs(
2606
+ ModalFrame2,
2607
+ {
2608
+ onClose,
2609
+ contentStyle: {
2610
+ justifyContent: "space-between",
2611
+ padding: "24px"
2612
+ },
2613
+ children: [
2614
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 32 }, children: [
2615
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: 24, fontWeight: 600, lineHeight: 1.4 }, children: "Withdraw" }) }),
2616
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 16 }, children: [
2617
+ /* @__PURE__ */ jsx(
2618
+ "div",
2619
+ {
2620
+ style: {
2621
+ opacity: trackingWithdraw ? 0 : 1,
2622
+ maxWidth: trackingWithdraw ? 0 : 48,
2623
+ overflow: "hidden",
2624
+ transition: "opacity 0.3s ease, max-width 0.35s ease"
2625
+ },
2626
+ children: /* @__PURE__ */ jsx(
2627
+ StepIndicator,
2628
+ {
2629
+ steps: 4,
2630
+ stepActive: [!!address, !!token, !!chain, !!apiQuote],
2631
+ activeStep
2632
+ }
2633
+ )
2634
+ }
2635
+ ),
2636
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, position: "relative", minHeight: 400 }, children: [
2637
+ /* @__PURE__ */ jsxs(
2638
+ "div",
2639
+ {
2640
+ style: {
2641
+ position: "absolute",
2642
+ inset: 0,
2643
+ display: "flex",
2644
+ flexDirection: "column",
2645
+ alignItems: "center",
2646
+ justifyContent: "center",
2647
+ gap: 12,
2648
+ padding: "0 16px",
2649
+ opacity: trackingWithdraw ? 1 : 0,
2650
+ maxHeight: trackingWithdraw ? 400 : 0,
2651
+ overflow: "hidden",
2652
+ pointerEvents: trackingWithdraw ? "auto" : "none",
2653
+ transition: "opacity 0.3s ease, max-height 0.35s ease"
2654
+ },
2655
+ children: [
2656
+ orderInProgress && /* @__PURE__ */ jsxs(
2657
+ "div",
2658
+ {
2659
+ style: {
2660
+ display: "flex",
2661
+ flexDirection: "column",
2662
+ alignItems: "center",
2663
+ justifyContent: "center",
2664
+ gap: 32
2665
+ },
2666
+ children: [
2667
+ /* @__PURE__ */ jsx(
2668
+ "span",
2669
+ {
2670
+ style: {
2671
+ display: "inline-block",
2672
+ width: 60,
2673
+ height: 60,
2674
+ border: `3px solid ${colors2.border}`,
2675
+ borderTopColor: colors2.textPrimary,
2676
+ borderRadius: "50%",
2677
+ animation: "withdraw-modal-spin 0.8s linear infinite"
2678
+ },
2679
+ "aria-hidden": true
2680
+ }
2681
+ ),
2682
+ /* @__PURE__ */ jsx(
2683
+ "span",
2684
+ {
2685
+ style: {
2686
+ fontSize: 20,
2687
+ fontWeight: 600,
2688
+ color: colors2.textPrimary,
2689
+ textAlign: "center",
2690
+ fontFamily: fonts2.family,
2691
+ lineHeight: 1.4
2692
+ },
2693
+ children: "Processing withdrawal..."
2694
+ }
2695
+ )
2696
+ ]
2697
+ }
2698
+ ),
2699
+ orderSucceeded && (() => {
2700
+ const destTxHash = withdrawOrder.dst_tx_hash ?? withdrawOrder.out_tx_hash;
2701
+ const targetChainName = apiChains?.find((c) => c.chain_id === withdrawOrder.target_chain_id)?.network ?? withdrawOrder.target_chain_id ?? "\u2014";
2702
+ const explorerUrl = destTxHash && withdrawOrder.target_chain_id ? getExplorerUrl(withdrawOrder.target_chain_id, { txId: destTxHash }) : null;
2703
+ const copyHash = () => {
2704
+ if (destTxHash && typeof navigator?.clipboard?.writeText === "function") {
2705
+ navigator.clipboard.writeText(destTxHash);
2706
+ onShowToast?.("Copied");
2707
+ }
2708
+ };
2709
+ return /* @__PURE__ */ jsxs(
2710
+ "div",
2711
+ {
2712
+ style: {
2713
+ display: "flex",
2714
+ flexDirection: "column",
2715
+ alignItems: "center",
2716
+ gap: 20,
2717
+ width: "100%",
2718
+ maxWidth: 412
2719
+ },
2720
+ children: [
2721
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 24 }, children: [
2722
+ /* @__PURE__ */ jsx(
2723
+ "span",
2724
+ {
2725
+ style: {
2726
+ display: "flex",
2727
+ alignItems: "center",
2728
+ justifyContent: "center",
2729
+ width: 60,
2730
+ height: 60,
2731
+ borderRadius: "50%",
2732
+ color: "#22c55e",
2733
+ fontSize: 40,
2734
+ lineHeight: 1,
2735
+ fontWeight: 700
2736
+ },
2737
+ "aria-hidden": true,
2738
+ children: /* @__PURE__ */ jsx(SuccessIcon, {})
2739
+ }
2740
+ ),
2741
+ /* @__PURE__ */ jsx(
2742
+ "span",
2743
+ {
2744
+ style: {
2745
+ fontSize: 20,
2746
+ fontWeight: 600,
2747
+ color: colors2.textPrimary,
2748
+ textAlign: "center",
2749
+ fontFamily: fonts2.family,
2750
+ lineHeight: 1.4
2751
+ },
2752
+ children: "Withdrawal successful"
2753
+ }
2754
+ )
2755
+ ] }),
2756
+ /* @__PURE__ */ jsxs(
2757
+ "div",
2758
+ {
2759
+ style: {
2760
+ display: "flex",
2761
+ flexDirection: "column",
2762
+ gap: 4,
2763
+ width: "100%"
2764
+ },
2765
+ children: [
2766
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "8px 0", height: 36 }, children: [
2767
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Amount" }),
2768
+ /* @__PURE__ */ jsxs("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: [
2769
+ weiToEtherDisplay(withdrawOrder.dst_token_amount),
2770
+ " ",
2771
+ tokenSymbol
2772
+ ] })
2773
+ ] }),
2774
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "8px 0", height: 36 }, children: [
2775
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Fee" }),
2776
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: withdrawOrder.fee ?? feeDisplay ?? "\u2014" })
2777
+ ] }),
2778
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "8px 0", height: 36 }, children: [
2779
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Network" }),
2780
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: targetChainName })
2781
+ ] }),
2782
+ destTxHash && /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "8px 0", minHeight: 38 }, children: [
2783
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Transaction Hash" }),
2784
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
2785
+ explorerUrl ? /* @__PURE__ */ jsxs(
2786
+ "a",
2787
+ {
2788
+ href: explorerUrl,
2789
+ target: "_blank",
2790
+ rel: "noopener noreferrer",
2791
+ style: { fontSize: 14, color: colors2.textPrimary, textDecoration: "underline" },
2792
+ children: [
2793
+ destTxHash.slice(0, 10),
2794
+ "...",
2795
+ destTxHash.slice(-8)
2796
+ ]
2797
+ }
2798
+ ) : /* @__PURE__ */ jsxs("span", { style: { fontSize: 14, color: colors2.textPrimary }, children: [
2799
+ destTxHash.slice(0, 10),
2800
+ "...",
2801
+ destTxHash.slice(-8)
2802
+ ] }),
2803
+ /* @__PURE__ */ jsx(
2804
+ "button",
2805
+ {
2806
+ type: "button",
2807
+ onClick: copyHash,
2808
+ "aria-label": "Copy hash",
2809
+ style: {
2810
+ padding: 0,
2811
+ border: "none",
2812
+ background: "transparent",
2813
+ color: colors2.textPrimary,
2814
+ cursor: "pointer",
2815
+ display: "flex",
2816
+ alignItems: "center",
2817
+ justifyContent: "center",
2818
+ width: 16,
2819
+ height: 16
2820
+ },
2821
+ children: /* @__PURE__ */ jsx(CopyIcon2, {})
2822
+ }
2823
+ )
2824
+ ] })
2825
+ ] })
2826
+ ]
2827
+ }
2828
+ ),
2829
+ /* @__PURE__ */ jsx("div", { style: { paddingTop: 24, width: "100%", display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsx(
2830
+ "button",
2831
+ {
2832
+ type: "button",
2833
+ onClick: () => {
2834
+ setDirectActive(false);
2835
+ setWithdrawOrder(null);
2836
+ (onStartAnotherWithdrawal ?? onClose)?.();
2837
+ },
2838
+ style: {
2839
+ width: 274,
2840
+ padding: "12px 0",
2841
+ borderRadius: radii2.full,
2842
+ border: `1px solid ${colors2.buttonDisabledBorder}`,
2843
+ background: colors2.textPrimary,
2844
+ color: "#121214",
2845
+ fontSize: 16,
2846
+ fontWeight: 500,
2847
+ lineHeight: 1.4,
2848
+ fontFamily: fonts2.family,
2849
+ cursor: "pointer",
2850
+ textAlign: "center"
2851
+ },
2852
+ children: "Start another withdrawal"
2853
+ }
2854
+ ) })
2855
+ ]
2856
+ }
2857
+ );
2858
+ })()
2859
+ ]
2860
+ }
2861
+ ),
2862
+ /* @__PURE__ */ jsx(
2863
+ "div",
2864
+ {
2865
+ style: {
2866
+ opacity: trackingWithdraw ? 0 : 1,
2867
+ maxHeight: trackingWithdraw ? 0 : 1200,
2868
+ overflow: "hidden",
2869
+ pointerEvents: trackingWithdraw ? "none" : "auto",
2870
+ transition: "opacity 0.3s ease, max-height 0.35s ease"
2871
+ },
2872
+ children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 40 }, children: [
2873
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8, width: "100%" }, children: [
2874
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: "Recipient address" }),
2875
+ /* @__PURE__ */ jsx(
2876
+ "div",
2877
+ {
2878
+ style: {
2879
+ display: "flex",
2880
+ alignItems: "center",
2881
+ height: 44,
2882
+ padding: "0 16px",
2883
+ borderRadius: radii2.input,
2884
+ border: `1px solid ${addressInputFocused ? colors2.borderFocused : colors2.border}`,
2885
+ boxSizing: "border-box"
2886
+ },
2887
+ children: /* @__PURE__ */ jsx(
2888
+ "input",
2889
+ {
2890
+ ref: addressInputRef,
2891
+ value: address,
2892
+ onChange: onAddressChange,
2893
+ readOnly: !onAddressChange,
2894
+ onFocus: () => setAddressInputFocused(true),
2895
+ onBlur: () => setAddressInputFocused(false),
2896
+ spellCheck: false,
2897
+ placeholder: "0x",
2898
+ style: {
2899
+ flex: 1,
2900
+ border: "none",
2901
+ outline: "none",
2902
+ background: "transparent",
2903
+ color: colors2.textPrimary,
2904
+ fontSize: 14,
2905
+ fontFamily: fonts2.family,
2906
+ lineHeight: 1.4,
2907
+ padding: 0
2908
+ }
2909
+ }
2910
+ )
2911
+ }
2912
+ )
2913
+ ] }),
2914
+ /* @__PURE__ */ jsx(
2915
+ DropdownField,
2916
+ {
2917
+ label: "Select token",
2918
+ placeholder: loadingChains ? "Loading\u2026" : "Token",
2919
+ value: token,
2920
+ options: tokenOptions,
2921
+ onSelect: onTokenSelect
2922
+ }
2923
+ ),
2924
+ /* @__PURE__ */ jsx(
2925
+ DropdownField,
2926
+ {
2927
+ label: "Select chain",
2928
+ placeholder: loadingChains ? "Loading\u2026" : "Chain",
2929
+ value: chain,
2930
+ options: chainOptions,
2931
+ onSelect: onChainSelect
2932
+ }
2933
+ ),
2934
+ apiQuote && token && chain && /* @__PURE__ */ jsx(
2935
+ "div",
2936
+ {
2937
+ style: {
2938
+ padding: "12px 16px",
2939
+ borderRadius: radii2.card,
2940
+ border: `1px solid ${colors2.border}`,
2941
+ display: "flex",
2942
+ flexDirection: "column",
2943
+ gap: 8
2944
+ },
2945
+ children: loadingQuote ? /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: colors2.textSecondary }, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2946
+ /* @__PURE__ */ jsxs("span", { style: { fontSize: 13, color: colors2.textSecondary }, children: [
2947
+ "Rate: 1 ",
2948
+ FUNDING_TOKEN_SYMBOL2,
2949
+ " = ",
2950
+ apiQuote.rate,
2951
+ " ",
2952
+ apiQuote.token_symbol
2953
+ ] }),
2954
+ apiQuote.expires_at && /* @__PURE__ */ jsx(
2955
+ Countdown,
2956
+ {
2957
+ expiresAt: apiQuote.expires_at,
2958
+ isExpired: quoteExpired,
2959
+ onExpired: handleRefreshQuote
2960
+ }
2961
+ ),
2962
+ quoteExpired && /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
2963
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#f59e0b" }, children: "Quote expired, please refresh" }),
2964
+ /* @__PURE__ */ jsx(
2965
+ "button",
2966
+ {
2967
+ type: "button",
2968
+ onClick: handleRefreshQuote,
2969
+ style: {
2970
+ padding: "4px 12px",
2971
+ fontSize: 12,
2972
+ borderRadius: radii2.pill,
2973
+ border: `1px solid ${colors2.border}`,
2974
+ background: "transparent",
2975
+ color: colors2.textPrimary,
2976
+ cursor: "pointer",
2977
+ fontFamily: fonts2.family
2978
+ },
2979
+ children: "Refresh"
2980
+ }
2981
+ )
2982
+ ] })
2983
+ ] })
2984
+ }
2985
+ ),
2986
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
2987
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
2988
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: "Amount" }),
2989
+ balance && /* @__PURE__ */ jsxs("span", { style: { fontSize: 13, lineHeight: 1.2, color: colors2.textSecondary }, children: [
2990
+ "Balance: \xA0",
2991
+ formatBalanceTo2Decimals(balance),
2992
+ " ",
2993
+ FUNDING_TOKEN_SYMBOL2
2994
+ ] })
2995
+ ] }),
2996
+ /* @__PURE__ */ jsxs(
2997
+ "div",
2998
+ {
2999
+ style: {
3000
+ display: "flex",
3001
+ alignItems: "center",
3002
+ justifyContent: "space-between",
3003
+ height: 48,
3004
+ padding: "0 16px",
3005
+ borderRadius: radii2.input,
3006
+ border: `1px solid ${amountInputFocused ? colors2.borderFocused : colors2.border}`,
3007
+ boxSizing: "border-box"
3008
+ },
3009
+ children: [
3010
+ /* @__PURE__ */ jsx(
3011
+ "input",
3012
+ {
3013
+ value: amount,
3014
+ onChange: handleAmountChange,
3015
+ onFocus: () => setAmountInputFocused(true),
3016
+ onBlur: () => setAmountInputFocused(false),
3017
+ placeholder: "0.00",
3018
+ type: "text",
3019
+ inputMode: "decimal",
3020
+ style: {
3021
+ flex: 1,
3022
+ border: "none",
3023
+ outline: "none",
3024
+ background: "transparent",
3025
+ color: amount ? colors2.textPrimary : colors2.textSecondary,
3026
+ fontSize: 14,
3027
+ fontFamily: fonts2.family,
3028
+ lineHeight: 1.4,
3029
+ padding: 0
3030
+ }
3031
+ }
3032
+ ),
3033
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: /* @__PURE__ */ jsx(
3034
+ "button",
3035
+ {
3036
+ type: "button",
3037
+ onClick: onMaxClick,
3038
+ style: {
3039
+ background: colors2.textPrimary,
3040
+ border: "none",
3041
+ borderRadius: radii2.pill,
3042
+ padding: "2px 8px",
3043
+ fontSize: 12,
3044
+ lineHeight: 1.4,
3045
+ fontWeight: 400,
3046
+ color: "#15181D",
3047
+ fontFamily: fonts2.family,
3048
+ cursor: "pointer"
3049
+ },
3050
+ children: "Max"
3051
+ }
3052
+ ) })
3053
+ ]
3054
+ }
3055
+ )
3056
+ ] }) })
3057
+ ] })
3058
+ }
3059
+ )
3060
+ ] })
3061
+ ] })
3062
+ ] }),
3063
+ /* @__PURE__ */ jsxs("div", { style: { padding: "20px 20px 0", display: "flex", flexDirection: "column", gap: 10, alignItems: "center" }, id: "WithdrawModalReceiveAmount", children: [
3064
+ !trackingWithdraw && amount && Number(amount) > 0 && /* @__PURE__ */ jsxs("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: [
3065
+ "You will receive : ",
3066
+ receiveAmount
3067
+ ] }),
3068
+ orderInProgress && withdrawOrder && (() => {
3069
+ const fundingHash = txHash ?? withdrawOrder?.funding_tx_hash;
3070
+ const showFundingLink = fundingHash && fundingChainId;
3071
+ try {
3072
+ return /* @__PURE__ */ jsx("div", { style: { display: "none", flexDirection: "column", gap: 6, alignItems: "center" }, children: showFundingLink && /* @__PURE__ */ jsx(
3073
+ "a",
3074
+ {
3075
+ href: getExplorerUrl(fundingChainId, { txId: fundingHash }),
3076
+ target: "_blank",
3077
+ rel: "noopener noreferrer",
3078
+ style: { fontSize: 13, color: colors2.textPrimary, textDecoration: "underline" },
3079
+ children: "Withdraw request transaction on explorer"
3080
+ }
3081
+ ) });
3082
+ } catch {
3083
+ return /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: colors2.textPrimary }, children: "Withdraw in progress." });
3084
+ }
3085
+ })(),
3086
+ orderInProgress && withdrawOrder && /* @__PURE__ */ jsxs("span", { style: { fontSize: 13, color: colors2.textSecondary, display: "none", alignItems: "center", gap: 6 }, children: [
3087
+ "Order status: ",
3088
+ withdrawOrder.status,
3089
+ /* @__PURE__ */ jsx(
3090
+ "span",
3091
+ {
3092
+ style: {
3093
+ display: "inline-block",
3094
+ width: 10,
3095
+ height: 10,
3096
+ border: `2px solid ${colors2.textSecondary}`,
3097
+ borderTopColor: "transparent",
3098
+ borderRadius: "50%",
3099
+ animation: "withdraw-modal-spin 0.7s linear infinite"
3100
+ },
3101
+ "aria-hidden": true
3102
+ }
3103
+ )
3104
+ ] }),
3105
+ /* @__PURE__ */ jsx("style", { children: `@keyframes withdraw-modal-spin { to { transform: rotate(360deg); } }` }),
3106
+ orderSucceeded || trackingWithdraw ? null : /* @__PURE__ */ jsx(
3107
+ SubmitButton,
3108
+ {
3109
+ disabled: !canSubmit || isSubmitting,
3110
+ status,
3111
+ onClick: () => {
3112
+ try {
3113
+ const ret = onSubmit?.({
3114
+ toAddress: address,
3115
+ amount: amount ?? "",
3116
+ token: token ?? "",
3117
+ tokenAddress: resolvedTokenAddress ?? apiQuote?.token_address ?? "",
3118
+ chain: chain ?? ""
3119
+ });
3120
+ if (ret && typeof ret.then === "function") {
3121
+ ret.catch((err) => {
3122
+ const msg = err instanceof Error ? err.message : "Transaction failed";
3123
+ onShowToast?.(msg);
3124
+ });
3125
+ }
3126
+ } catch (err) {
3127
+ const msg = err instanceof Error ? err.message : "Transaction failed";
3128
+ onShowToast?.(msg);
3129
+ }
3130
+ }
3131
+ }
3132
+ )
3133
+ ] })
3134
+ ]
3135
+ }
3136
+ );
3137
+ };
3138
+ var SubmitButton = ({ disabled, status, onClick }) => {
3139
+ const labels = {
3140
+ idle: disabled ? "Please fill in withdrawal information" : "Submit",
3141
+ pending: "Processing...",
3142
+ success: "Withdrawal successful",
3143
+ manual_review: "Under manual review"
3144
+ };
3145
+ const isDisabled = disabled || status !== "idle";
3146
+ return /* @__PURE__ */ jsx(
3147
+ "button",
3148
+ {
3149
+ type: "button",
3150
+ disabled: isDisabled,
3151
+ onClick,
3152
+ style: {
3153
+ width: 364,
3154
+ padding: "12px 0",
3155
+ borderRadius: radii2.full,
3156
+ border: isDisabled ? `1px solid ${colors2.buttonDisabledBorder}` : "none",
3157
+ background: isDisabled ? colors2.buttonDisabledBg : colors2.textPrimary,
3158
+ color: isDisabled ? colors2.textSecondary : "#15181D",
3159
+ fontSize: 16,
3160
+ fontWeight: 500,
3161
+ lineHeight: 1.4,
3162
+ fontFamily: fonts2.family,
3163
+ cursor: isDisabled ? "not-allowed" : "pointer",
3164
+ textAlign: "center"
3165
+ },
3166
+ children: labels[status]
3167
+ }
3168
+ );
3169
+ };
3170
+
3171
+ // src/react.ts
3172
+ async function loadWalletAccountModule() {
3173
+ return import('./account-F5Z2SMJE.js');
3174
+ }
3175
+ var WalletAccount = {
3176
+ async getInstance(oidcToken) {
3177
+ const { default: WalletAccount2 } = await loadWalletAccountModule();
3178
+ return WalletAccount2.getInstance(oidcToken);
3179
+ },
3180
+ clearInstance() {
3181
+ void loadWalletAccountModule().then(({ default: WalletAccount2 }) => {
3182
+ WalletAccount2.clearInstance();
3183
+ });
3184
+ }
3185
+ };
3186
+ function clearSocialAccountInstance() {
3187
+ void loadWalletAccountModule().then(({ clearSocialAccountInstance: clearSocialAccountInstance2 }) => {
3188
+ clearSocialAccountInstance2();
3189
+ });
3190
+ }
3191
+
3192
+ export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance };