@ab-org/predicate-market-sdk 2.1.2 → 2.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3750 @@
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
+ className: "absdk-predicate-close-button",
286
+ type: "button",
287
+ onClick,
288
+ "aria-label": "Close",
289
+ style: {
290
+ width: 30,
291
+ height: 30,
292
+ borderRadius: "50%",
293
+ background: colors.card,
294
+ border: "none",
295
+ cursor: "pointer",
296
+ display: "flex",
297
+ alignItems: "center",
298
+ justifyContent: "center",
299
+ padding: 0,
300
+ flexShrink: 0
301
+ },
302
+ children: /* @__PURE__ */ jsx("svg", { className: "absdk-predicate-close-button__icon", width: "17", height: "17", viewBox: "0 0 17 17", fill: "none", children: /* @__PURE__ */ jsx(
303
+ "path",
304
+ {
305
+ className: "absdk-predicate-close-button__icon-path",
306
+ d: "M4.25 4.25L12.75 12.75M12.75 4.25L4.25 12.75",
307
+ stroke: colors.textPrimary,
308
+ strokeWidth: "1.5",
309
+ strokeLinecap: "round"
310
+ }
311
+ ) })
312
+ }
313
+ );
314
+ var MOBILE_BREAKPOINT_PX = 720;
315
+ var MOBILE_MODAL_WIDTH_PX = 375;
316
+ var MOBILE_MODAL_GUTTER_PX = 16;
317
+ function isMobileViewport(width) {
318
+ return width < MOBILE_BREAKPOINT_PX;
319
+ }
320
+ function useIsMobileViewport() {
321
+ const [isMobile, setIsMobile] = useState(
322
+ () => typeof window !== "undefined" ? isMobileViewport(window.innerWidth) : false
323
+ );
324
+ useEffect(() => {
325
+ if (typeof window === "undefined") return;
326
+ const handleResize = () => {
327
+ setIsMobile(isMobileViewport(window.innerWidth));
328
+ };
329
+ handleResize();
330
+ window.addEventListener("resize", handleResize);
331
+ return () => window.removeEventListener("resize", handleResize);
332
+ }, []);
333
+ return isMobile;
334
+ }
335
+ var ModalFrame = ({
336
+ onClose,
337
+ width = 500,
338
+ cardStyle,
339
+ contentStyle,
340
+ children
341
+ }) => {
342
+ const isMobile = useIsMobileViewport();
343
+ return /* @__PURE__ */ jsx(
344
+ "div",
345
+ {
346
+ className: `absdk-predicate-modal-frame ${isMobile ? "absdk-predicate-modal-frame--mobile" : "absdk-predicate-modal-frame--desktop"}`,
347
+ style: {
348
+ display: "flex",
349
+ flexDirection: "column",
350
+ alignItems: "center",
351
+ justifyContent: "center",
352
+ width: "100%",
353
+ maxHeight: isMobile ? "90vh" : void 0
354
+ },
355
+ children: /* @__PURE__ */ jsxs(
356
+ "div",
357
+ {
358
+ className: "absdk-predicate-modal-frame__layout",
359
+ style: {
360
+ display: "flex",
361
+ flexDirection: isMobile ? "column" : "row",
362
+ gap: isMobile ? 10 : 14,
363
+ alignItems: isMobile ? "stretch" : "flex-start",
364
+ width: isMobile ? `min(${MOBILE_MODAL_WIDTH_PX}px, calc(100vw - ${MOBILE_MODAL_GUTTER_PX * 2}px))` : "auto"
365
+ },
366
+ children: [
367
+ onClose ? /* @__PURE__ */ jsx(
368
+ "div",
369
+ {
370
+ className: "absdk-predicate-modal-frame__close",
371
+ style: {
372
+ display: "flex",
373
+ justifyContent: isMobile ? "flex-end" : "flex-start",
374
+ order: isMobile ? -1 : 1,
375
+ paddingTop: isMobile ? 13 : 0,
376
+ paddingRight: isMobile ? 2 : 0
377
+ },
378
+ children: /* @__PURE__ */ jsx(CloseButton, { onClick: onClose })
379
+ }
380
+ ) : null,
381
+ /* @__PURE__ */ jsx(
382
+ "div",
383
+ {
384
+ className: "absdk-predicate-modal-frame__card",
385
+ style: {
386
+ width: isMobile ? "100%" : width,
387
+ maxWidth: "100%",
388
+ maxHeight: isMobile ? "90vh" : void 0,
389
+ background: colors.card,
390
+ borderRadius: radii.card,
391
+ overflow: "hidden",
392
+ ...cardStyle
393
+ },
394
+ children: /* @__PURE__ */ jsx(
395
+ "div",
396
+ {
397
+ className: "absdk-predicate-modal-frame__content",
398
+ style: {
399
+ display: "flex",
400
+ flexDirection: "column",
401
+ minHeight: 0,
402
+ maxHeight: isMobile ? "90vh" : void 0,
403
+ overflowY: isMobile ? "auto" : void 0,
404
+ overflowX: "hidden",
405
+ WebkitOverflowScrolling: "touch",
406
+ fontFamily: fonts.family,
407
+ color: colors.textPrimary,
408
+ boxSizing: "border-box",
409
+ ...contentStyle
410
+ },
411
+ children
412
+ }
413
+ )
414
+ }
415
+ )
416
+ ]
417
+ }
418
+ )
419
+ }
420
+ );
421
+ };
422
+ async function loadWalletAccount() {
423
+ return import('./account-F5Z2SMJE.js');
424
+ }
425
+ async function loadOidcAuth() {
426
+ return import('./dist-Q2PDXT2F.js');
427
+ }
428
+ var SignInModalFrame = ({
429
+ id,
430
+ title,
431
+ onClose,
432
+ footer,
433
+ children
434
+ }) => {
435
+ const isMobile = useIsMobileViewport();
436
+ return /* @__PURE__ */ jsx(
437
+ ModalFrame,
438
+ {
439
+ onClose,
440
+ cardStyle: { padding: isMobile ? "24px 16px" : "32px 24px" },
441
+ contentStyle: { alignItems: "center" },
442
+ children: /* @__PURE__ */ jsxs(
443
+ "div",
444
+ {
445
+ style: { width: "100%", display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24, alignItems: "center" },
446
+ id,
447
+ className: `absdk-predicate-signin-modal ${isMobile ? "absdk-predicate-signin-modal--mobile" : "absdk-predicate-signin-modal--desktop"}`,
448
+ children: [
449
+ /* @__PURE__ */ jsx(
450
+ "h2",
451
+ {
452
+ className: "absdk-predicate-signin-modal__title",
453
+ style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4, textAlign: "center" },
454
+ children: title
455
+ }
456
+ ),
457
+ /* @__PURE__ */ jsx("div", { className: "absdk-predicate-signin-modal__content", style: { width: "100%", display: "flex", flexDirection: "column", gap: 12, alignItems: "center" }, children }),
458
+ footer
459
+ ]
460
+ }
461
+ )
462
+ }
463
+ );
464
+ };
465
+ var SignInWithEmailSection = () => {
466
+ const [email, setEmail] = useState("");
467
+ const [partialOidcToken, setPartialOidcToken] = useState("");
468
+ const [emailCode, setEmailCode] = useState("");
469
+ return /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, children: [
470
+ /* @__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" } }) }),
471
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
472
+ /* @__PURE__ */ jsx(
473
+ "input",
474
+ {
475
+ type: "text",
476
+ className: "absdk-predicate-signin-modal__email-code-input",
477
+ style: { color: "black" },
478
+ value: emailCode,
479
+ placeholder: "emailCode",
480
+ onChange: (e) => setEmailCode(e.target.value)
481
+ }
482
+ ),
483
+ " "
484
+ ] }),
485
+ /* @__PURE__ */ jsx("button", { disabled: !email, onClick: async () => {
486
+ const { OidcAuth } = await loadOidcAuth();
487
+ const { loginByEmail } = OidcAuth({
488
+ stage: "dev",
489
+ xClientId: clientIds.x ?? "",
490
+ googleClientId: clientIds.google ?? ""
491
+ });
492
+ const { partialOidcToken: partialOidcToken2 } = await loginByEmail(email);
493
+ setPartialOidcToken(partialOidcToken2);
494
+ }, children: "send code" }),
495
+ /* @__PURE__ */ jsx("button", { disabled: !partialOidcToken || !emailCode, onClick: async () => {
496
+ const oidcToken = `${partialOidcToken}${emailCode}`;
497
+ const { default: WalletAccount2 } = await loadWalletAccount();
498
+ await WalletAccount2.getInstance(oidcToken);
499
+ }, children: "sign in" })
500
+ ] });
501
+ };
502
+ var SignInModalSocialSection = ({
503
+ id,
504
+ socialProviders,
505
+ isBusy,
506
+ loadingProvider,
507
+ onSocialClick
508
+ }) => /* @__PURE__ */ jsxs(
509
+ "div",
510
+ {
511
+ style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 },
512
+ id,
513
+ className: "absdk-predicate-signin-modal__social",
514
+ children: [
515
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: socialProviders.map((provider) => {
516
+ const isLoading = loadingProvider === provider.id;
517
+ return /* @__PURE__ */ jsxs(
518
+ "button",
519
+ {
520
+ id: `absdk-predicate-signin-modal-social-provider-${provider.id}`,
521
+ className: `absdk-predicate-signin-modal__social-button absdk-predicate-signin-modal__social-button--${provider.id}`,
522
+ type: "button",
523
+ disabled: isBusy,
524
+ onClick: () => onSocialClick(provider.id),
525
+ style: {
526
+ width: "100%",
527
+ height: 48,
528
+ borderRadius: radii.pill,
529
+ border: `1px solid ${colors.border}`,
530
+ background: "transparent",
531
+ display: "flex",
532
+ alignItems: "center",
533
+ justifyContent: "center",
534
+ gap: 12,
535
+ cursor: isBusy ? "wait" : "pointer",
536
+ padding: 12,
537
+ boxSizing: "border-box",
538
+ opacity: isLoading ? 0.6 : isBusy ? 0.8 : 1,
539
+ transition: "opacity .15s"
540
+ },
541
+ children: [
542
+ isLoading ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : provider.icon,
543
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: isLoading ? "Signing in..." : provider.label })
544
+ ]
545
+ },
546
+ provider.id
547
+ );
548
+ }) }),
549
+ typeof window !== "undefined" && window.location.href.indexOf("emailSignIn") !== -1 && /* @__PURE__ */ jsx(SignInWithEmailSection, {}),
550
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 20, width: "100%" }, children: [
551
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, height: 1, background: colors.border } }),
552
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors.textPrimary, opacity: 0.4, whiteSpace: "nowrap" }, children: "Or connect a wallet" }),
553
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, height: 1, background: colors.border } })
554
+ ] })
555
+ ]
556
+ }
557
+ );
558
+ var SignInModalWalletGrid = ({
559
+ wallets,
560
+ isBusy,
561
+ loadingWalletId,
562
+ expanded,
563
+ showExpandToggle,
564
+ onWalletClick,
565
+ onToggleExpanded
566
+ }) => {
567
+ const isMobile = useIsMobileViewport();
568
+ return /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-signin-modal__wallets", style: { width: "100%", display: "flex", flexDirection: "column", gap: 8, alignItems: "center", paddingTop: 12 }, children: [
569
+ /* @__PURE__ */ jsx("div", { className: "absdk-predicate-signin-modal__wallet-grid", style: { width: "100%", display: "flex", flexWrap: "wrap", gap: "14px 0" }, children: wallets.map((wallet) => /* @__PURE__ */ jsxs(
570
+ "button",
571
+ {
572
+ id: `absdk-predicate-signin-modal-wallet-${wallet.id}`,
573
+ className: `absdk-predicate-signin-modal__wallet-button absdk-predicate-signin-modal__wallet-button--${wallet.id}`,
574
+ type: "button",
575
+ disabled: isBusy,
576
+ onClick: () => onWalletClick(wallet.id),
577
+ style: {
578
+ width: isMobile ? "33.3333%" : "25%",
579
+ display: "flex",
580
+ flexDirection: "column",
581
+ alignItems: "center",
582
+ gap: 4,
583
+ background: "transparent",
584
+ border: "none",
585
+ cursor: isBusy ? "wait" : "pointer",
586
+ padding: 0,
587
+ opacity: loadingWalletId === wallet.id ? 0.7 : isBusy ? 0.85 : 1
588
+ },
589
+ children: [
590
+ /* @__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 }) }),
591
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", width: "100%" }, children: [
592
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 12, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family, textAlign: "center", whiteSpace: "nowrap" }, children: wallet.name }),
593
+ 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(
594
+ "a",
595
+ {
596
+ href: wallet.installUrl,
597
+ target: "_blank",
598
+ rel: "noopener noreferrer",
599
+ onClick: (event) => event.stopPropagation(),
600
+ style: { fontSize: 10, lineHeight: 1.4, color: colors.textSecondary, fontFamily: fonts.family, textDecoration: "underline" },
601
+ children: "Install"
602
+ }
603
+ ) : null
604
+ ] })
605
+ ]
606
+ },
607
+ wallet.id
608
+ )) }),
609
+ showExpandToggle && /* @__PURE__ */ jsx(
610
+ "button",
611
+ {
612
+ id: "absdk-predicate-signin-modal-expand-button",
613
+ className: "absdk-predicate-signin-modal__expand-button",
614
+ type: "button",
615
+ onClick: onToggleExpanded,
616
+ style: {
617
+ background: "transparent",
618
+ border: "none",
619
+ cursor: "pointer",
620
+ display: "flex",
621
+ alignItems: "center",
622
+ justifyContent: "center",
623
+ padding: 4
624
+ },
625
+ children: /* @__PURE__ */ jsx(ExpandIcon, { expanded })
626
+ }
627
+ )
628
+ ] });
629
+ };
630
+ var SignInModalFooter = ({
631
+ privacyPolicyUrl,
632
+ termsOfUseUrl
633
+ }) => /* @__PURE__ */ jsx("div", { className: "absdk-predicate-signin-modal__footer", 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: [
634
+ "By continuing, I agree to the",
635
+ " ",
636
+ /* @__PURE__ */ jsx("a", { href: privacyPolicyUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }),
637
+ " ",
638
+ "and",
639
+ " ",
640
+ /* @__PURE__ */ jsx("a", { href: termsOfUseUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Terms of Use" })
641
+ ] }) });
642
+ var useSignInModalController = ({
643
+ wallets,
644
+ initialVisibleCount,
645
+ onGoogleLogin: _onGoogleLogin,
646
+ onTwitterLogin: _onTwitterLogin,
647
+ onCubeSignerSession: _onCubeSignerSession,
648
+ onWalletConnected,
649
+ onSocialLogin: _onSocialLogin,
650
+ onWalletSelect
651
+ }) => {
652
+ const [expanded, setExpanded] = useState(false);
653
+ const [loadingProvider, setLoadingProvider] = useState(null);
654
+ const [loadingWalletId, setLoadingWalletId] = useState(null);
655
+ const defaultWalletRegistry = useMemo(() => createDefaultInjectedWalletRegistry(), []);
656
+ const defaultWalletConnector = useMemo(
657
+ () => new WalletConnector(defaultWalletRegistry.map((item) => item.provider)),
658
+ [defaultWalletRegistry]
659
+ );
660
+ const resolvedWallets = useMemo(
661
+ () => resolveWalletItems(wallets, defaultWalletRegistry),
662
+ [defaultWalletRegistry, wallets]
663
+ );
664
+ const showExpandToggle = resolvedWallets.length > initialVisibleCount;
665
+ const visibleWallets = expanded ? resolvedWallets : resolvedWallets.slice(0, initialVisibleCount);
666
+ const isBusy = !!loadingProvider || !!loadingWalletId;
667
+ async function loadOidcAuth2() {
668
+ return import('./dist-Q2PDXT2F.js');
669
+ }
670
+ const handleSocialClick = async (providerId) => {
671
+ setLoadingProvider(providerId);
672
+ const cfg = getSDKConfig();
673
+ const { OidcAuth } = await loadOidcAuth2();
674
+ const { loginByX, loginByGoogle } = OidcAuth({
675
+ stage,
676
+ xClientId: cfg.twitterClientId ?? clientIds.x ?? "",
677
+ googleClientId: cfg.googleClientId ?? clientIds.google ?? ""
678
+ });
679
+ if (providerId === "google") {
680
+ try {
681
+ const oidcToken = await loginByGoogle();
682
+ return oidcToken;
683
+ } catch (error) {
684
+ console.error(`[SDK] Google sign-in failed:`, error);
685
+ }
686
+ }
687
+ if (providerId === "x") {
688
+ const oidcToken = await loginByX();
689
+ return oidcToken;
690
+ }
691
+ };
692
+ const clearSocialLoading = () => setLoadingProvider(null);
693
+ const handleWalletClick = async (walletId) => {
694
+ if (isBusy) return;
695
+ const targetWallet = resolvedWallets.find((wallet) => wallet.id === walletId);
696
+ if (!targetWallet) return;
697
+ if (targetWallet.installed === false && targetWallet.installUrl) return;
698
+ setLoadingWalletId(walletId);
699
+ try {
700
+ if (onWalletSelect) {
701
+ await onWalletSelect(walletId);
702
+ return;
703
+ }
704
+ const builtInWallet = defaultWalletRegistry.find((item) => item.id === walletId);
705
+ if (!builtInWallet || !builtInWallet.installed) return;
706
+ const session = await defaultWalletConnector.connect(walletId);
707
+ onWalletConnected?.(session, walletId);
708
+ } catch (err) {
709
+ console.error(`[SDK] Wallet connect failed for ${walletId}:`, err);
710
+ } finally {
711
+ setLoadingWalletId(null);
712
+ }
713
+ };
714
+ return {
715
+ expanded,
716
+ loadingProvider,
717
+ loadingWalletId,
718
+ visibleWallets,
719
+ showExpandToggle,
720
+ isBusy,
721
+ handleSocialClick,
722
+ handleWalletClick,
723
+ clearSocialLoading,
724
+ toggleExpanded: () => setExpanded((value) => !value)
725
+ };
726
+ };
727
+ var variantStyles = {
728
+ success: { bg: "rgba(41, 255, 155, 0.82)", border: "rgba(41, 255, 155, 0.53)", icon: colors.accent },
729
+ error: { bg: "rgba(255, 107, 107, 0.82)", border: "rgba(255, 107, 107, 0.53)", icon: colors.danger },
730
+ info: { bg: "rgba(126, 135, 162, 0.82)", border: "rgba(126, 135, 162, 0.55)", icon: colors.textSecondary }
731
+ };
732
+ var Toast = ({ message, variant = "info", duration, onClose }) => {
733
+ const style = variantStyles[variant];
734
+ useEffect(() => {
735
+ if (duration != null && duration > 0 && onClose) {
736
+ const t = setTimeout(onClose, duration);
737
+ return () => clearTimeout(t);
738
+ }
739
+ }, [duration, onClose]);
740
+ return /* @__PURE__ */ jsx(
741
+ "div",
742
+ {
743
+ className: "absdk-predicate-toast",
744
+ style: {
745
+ position: "fixed",
746
+ top: 0,
747
+ left: 0,
748
+ right: 0,
749
+ display: "flex",
750
+ justifyContent: "center",
751
+ paddingTop: 16,
752
+ zIndex: 1e4,
753
+ pointerEvents: "none"
754
+ },
755
+ children: /* @__PURE__ */ jsxs(
756
+ "div",
757
+ {
758
+ className: `absdk-predicate-toast__content absdk-predicate-toast__content--${variant}`,
759
+ role: "alert",
760
+ style: {
761
+ pointerEvents: "auto",
762
+ display: "flex",
763
+ alignItems: "center",
764
+ gap: 10,
765
+ padding: "12px 16px",
766
+ borderRadius: radii.card,
767
+ background: style.bg,
768
+ border: `1px solid ${style.border}`,
769
+ color: colors.textPrimary,
770
+ fontSize: 14,
771
+ lineHeight: 1.4,
772
+ maxWidth: 360,
773
+ boxSizing: "border-box"
774
+ },
775
+ children: [
776
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-toast__message", style: { flex: 1 }, children: message }),
777
+ onClose && /* @__PURE__ */ jsx(
778
+ "button",
779
+ {
780
+ className: "absdk-predicate-toast__dismiss",
781
+ type: "button",
782
+ "aria-label": "Dismiss",
783
+ onClick: onClose,
784
+ style: {
785
+ padding: 4,
786
+ margin: -4,
787
+ border: "none",
788
+ background: "transparent",
789
+ color: colors.textSecondary,
790
+ cursor: "pointer",
791
+ borderRadius: 4,
792
+ lineHeight: 1
793
+ },
794
+ children: /* @__PURE__ */ jsx("svg", { className: "absdk-predicate-toast__dismiss-icon", width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
795
+ "path",
796
+ {
797
+ className: "absdk-predicate-toast__dismiss-icon-path",
798
+ d: "M3.5 3.5L10.5 10.5M10.5 3.5L3.5 10.5",
799
+ stroke: "currentColor",
800
+ strokeWidth: "1.5",
801
+ strokeLinecap: "round"
802
+ }
803
+ ) })
804
+ }
805
+ )
806
+ ]
807
+ }
808
+ )
809
+ }
810
+ );
811
+ };
812
+ async function loadWalletAccount2() {
813
+ return import('./account-F5Z2SMJE.js');
814
+ }
815
+ var SignInModal = ({
816
+ title = "Welcome to PredicateMarket",
817
+ socialProviders,
818
+ wallets,
819
+ initialVisibleCount,
820
+ privacyPolicyUrl = "#",
821
+ termsOfUseUrl = "#",
822
+ onGoogleLogin,
823
+ onTwitterLogin,
824
+ onCubeSignerSession,
825
+ onWalletConnected,
826
+ onSocialLogin,
827
+ onWalletSelect,
828
+ onDismiss,
829
+ onSuccess
830
+ }) => {
831
+ const sdkConfig = getSDKConfig();
832
+ const effectiveSocialProviders = resolveSocialProviders(
833
+ socialProviders ?? sdkConfig.signIn?.socialProviders
834
+ );
835
+ const effectiveWallets = wallets ?? sdkConfig.signIn?.wallets;
836
+ const effectiveInitialVisibleCount = initialVisibleCount ?? sdkConfig.signIn?.initialVisibleCount ?? 5;
837
+ const [toastError, setToastError] = useState(null);
838
+ const [socialLoadingProvider, setSocialLoadingProvider] = useState(null);
839
+ const {
840
+ expanded,
841
+ loadingProvider,
842
+ loadingWalletId,
843
+ visibleWallets,
844
+ showExpandToggle,
845
+ isBusy,
846
+ handleSocialClick,
847
+ handleWalletClick,
848
+ clearSocialLoading,
849
+ toggleExpanded
850
+ } = useSignInModalController({
851
+ wallets: effectiveWallets,
852
+ initialVisibleCount: effectiveInitialVisibleCount,
853
+ onGoogleLogin,
854
+ onTwitterLogin,
855
+ onCubeSignerSession,
856
+ onWalletConnected,
857
+ onSocialLogin,
858
+ onWalletSelect
859
+ });
860
+ return /* @__PURE__ */ jsxs(
861
+ SignInModalFrame,
862
+ {
863
+ id: "absdk-predicate-signin-modal-frame",
864
+ title,
865
+ onClose: onDismiss,
866
+ footer: /* @__PURE__ */ jsx(
867
+ SignInModalFooter,
868
+ {
869
+ privacyPolicyUrl,
870
+ termsOfUseUrl
871
+ }
872
+ ),
873
+ children: [
874
+ toastError && /* @__PURE__ */ jsx(
875
+ Toast,
876
+ {
877
+ message: toastError,
878
+ variant: "error",
879
+ duration: 5e3,
880
+ onClose: () => setToastError(null)
881
+ }
882
+ ),
883
+ /* @__PURE__ */ jsx(
884
+ SignInModalSocialSection,
885
+ {
886
+ id: "absdk-predicate-signin-modal-social",
887
+ socialProviders: effectiveSocialProviders,
888
+ isBusy: isBusy || !!socialLoadingProvider,
889
+ loadingProvider: loadingProvider ?? socialLoadingProvider,
890
+ onSocialClick: async (providerId) => {
891
+ setSocialLoadingProvider(providerId);
892
+ sessionStore.clearSession();
893
+ let walletAccount = null;
894
+ let address = "";
895
+ try {
896
+ const { default: WalletAccount2 } = await loadWalletAccount2();
897
+ WalletAccount2.clearInstance();
898
+ const oidcToken = await handleSocialClick(providerId);
899
+ if (!oidcToken) {
900
+ setToastError("Social login failed, please try again");
901
+ return;
902
+ }
903
+ walletAccount = await WalletAccount2.getInstance(oidcToken);
904
+ onCubeSignerSession?.(walletAccount.getCubeSignerSession());
905
+ cache_exports.set("oidcToken", oidcToken, false);
906
+ const res = await walletAccount.eth_accounts();
907
+ address = res?.[0] || "";
908
+ const authSource = providerId === "x" ? "twitter" : providerId;
909
+ const session = {
910
+ address,
911
+ chain: "BSC",
912
+ provider: walletAccount,
913
+ walletType: "social",
914
+ authSource
915
+ };
916
+ onSuccess?.(session);
917
+ } catch (error) {
918
+ setToastError(error?.message ?? "Failed to get wallet account, please try again");
919
+ return;
920
+ } finally {
921
+ setSocialLoadingProvider(null);
922
+ clearSocialLoading();
923
+ }
924
+ }
925
+ }
926
+ ),
927
+ /* @__PURE__ */ jsx(
928
+ SignInModalWalletGrid,
929
+ {
930
+ wallets: visibleWallets,
931
+ isBusy,
932
+ loadingWalletId,
933
+ expanded,
934
+ showExpandToggle,
935
+ onWalletClick: handleWalletClick,
936
+ onToggleExpanded: toggleExpanded
937
+ }
938
+ )
939
+ ]
940
+ }
941
+ );
942
+ };
943
+
944
+ // src/ui/theme.ts
945
+ var colors2 = {
946
+ background: "#050608",
947
+ card: "#121214",
948
+ cardRaised: "#151821",
949
+ border: "rgba(126,135,162,0.2)",
950
+ borderStrong: "rgba(255,255,255,0.16)",
951
+ borderFocused: "#FFFFFF",
952
+ textPrimary: "#FFFFFF",
953
+ textSecondary: "#737477",
954
+ accent: "#29FF9B",
955
+ accentStrong: "#4AD481",
956
+ warning: "#FFB547",
957
+ danger: "#FF6B6B",
958
+ stepActive: "#FFFFFF",
959
+ stepInactive: "#36383D",
960
+ buttonDisabledBg: "rgba(255,255,255,0.14)",
961
+ buttonDisabledBorder: "#444444"
962
+ };
963
+ var radii2 = {
964
+ xl: "28px",
965
+ lg: "20px",
966
+ pill: "99px",
967
+ full: "9999px",
968
+ card: "12px",
969
+ input: "8px"
970
+ };
971
+ var fonts2 = {
972
+ family: '"Switzer", "Inter", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
973
+ };
974
+ var placeholderIcon = (label) => /* @__PURE__ */ jsx(
975
+ "div",
976
+ {
977
+ style: {
978
+ width: 40,
979
+ height: 40,
980
+ borderRadius: "12px",
981
+ background: colors2.cardRaised,
982
+ display: "flex",
983
+ alignItems: "center",
984
+ justifyContent: "center",
985
+ color: colors2.textSecondary,
986
+ fontWeight: 600
987
+ },
988
+ children: label.slice(0, 2).toUpperCase()
989
+ }
990
+ );
991
+ var WalletSelectionModal = ({
992
+ title = "Connect Wallet",
993
+ options,
994
+ onSelect
995
+ }) => {
996
+ const sections = [
997
+ {
998
+ id: "social",
999
+ label: "Social Wallets",
1000
+ items: options.filter((item) => item.category === "social")
1001
+ },
1002
+ {
1003
+ id: "plugin",
1004
+ label: "Plugin Wallets",
1005
+ items: options.filter((item) => item.category === "plugin")
1006
+ }
1007
+ ].filter((section) => section.items.length > 0);
1008
+ return /* @__PURE__ */ jsxs(
1009
+ "div",
1010
+ {
1011
+ style: {
1012
+ width: "min(720px, 90vw)",
1013
+ background: colors2.card,
1014
+ borderRadius: radii2.xl,
1015
+ border: `1px solid ${colors2.border}`,
1016
+ padding: "40px",
1017
+ display: "flex",
1018
+ flexDirection: "column",
1019
+ gap: 32,
1020
+ color: colors2.textPrimary,
1021
+ fontFamily: fonts2.family
1022
+ },
1023
+ children: [
1024
+ /* @__PURE__ */ jsxs("div", { children: [
1025
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 26, fontWeight: 600 }, children: title }),
1026
+ /* @__PURE__ */ jsx("p", { style: { color: colors2.textSecondary, marginTop: 8 }, children: "Choose social or plugin wallets" })
1027
+ ] }),
1028
+ sections.map((section) => /* @__PURE__ */ jsxs("section", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
1029
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 14, textTransform: "uppercase", letterSpacing: 1.5, color: colors2.textSecondary }, children: section.label }),
1030
+ /* @__PURE__ */ jsx(
1031
+ "div",
1032
+ {
1033
+ style: {
1034
+ display: "grid",
1035
+ gap: 16,
1036
+ gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
1037
+ },
1038
+ children: section.items.map((option) => /* @__PURE__ */ jsxs(
1039
+ "button",
1040
+ {
1041
+ onClick: () => onSelect?.(option.id),
1042
+ style: {
1043
+ borderRadius: radii2.lg,
1044
+ border: `1px solid ${colors2.border}`,
1045
+ background: colors2.cardRaised,
1046
+ padding: "20px",
1047
+ display: "flex",
1048
+ gap: 14,
1049
+ alignItems: "center",
1050
+ textAlign: "left",
1051
+ cursor: "pointer",
1052
+ color: colors2.textPrimary
1053
+ },
1054
+ children: [
1055
+ option.icon ?? placeholderIcon(option.label),
1056
+ /* @__PURE__ */ jsxs("div", { children: [
1057
+ /* @__PURE__ */ jsx("div", { style: { fontWeight: 600 }, children: option.label }),
1058
+ /* @__PURE__ */ jsx("div", { style: { color: colors2.textSecondary, fontSize: 14 }, children: option.description })
1059
+ ] })
1060
+ ]
1061
+ },
1062
+ option.id
1063
+ ))
1064
+ }
1065
+ )
1066
+ ] }, section.id))
1067
+ ]
1068
+ }
1069
+ );
1070
+ };
1071
+ var CloseButton2 = ({ onClick }) => /* @__PURE__ */ jsx(
1072
+ "button",
1073
+ {
1074
+ className: "absdk-predicate-close-button",
1075
+ type: "button",
1076
+ onClick,
1077
+ "aria-label": "Close",
1078
+ style: {
1079
+ width: 30,
1080
+ height: 30,
1081
+ borderRadius: "50%",
1082
+ background: colors2.card,
1083
+ border: "none",
1084
+ cursor: "pointer",
1085
+ display: "flex",
1086
+ alignItems: "center",
1087
+ justifyContent: "center",
1088
+ padding: 0,
1089
+ flexShrink: 0
1090
+ },
1091
+ children: /* @__PURE__ */ jsx("svg", { className: "absdk-predicate-close-button__icon", width: "17", height: "17", viewBox: "0 0 17 17", fill: "none", children: /* @__PURE__ */ jsx(
1092
+ "path",
1093
+ {
1094
+ className: "absdk-predicate-close-button__icon-path",
1095
+ d: "M4.25 4.25L12.75 12.75M12.75 4.25L4.25 12.75",
1096
+ stroke: colors2.textPrimary,
1097
+ strokeWidth: "1.5",
1098
+ strokeLinecap: "round"
1099
+ }
1100
+ ) })
1101
+ }
1102
+ );
1103
+ var MOBILE_BREAKPOINT_PX2 = 720;
1104
+ var MOBILE_MODAL_WIDTH_PX2 = 375;
1105
+ var MOBILE_MODAL_GUTTER_PX2 = 16;
1106
+ function isMobileViewport2(width) {
1107
+ return width < MOBILE_BREAKPOINT_PX2;
1108
+ }
1109
+ function useIsMobileViewport2() {
1110
+ const [isMobile, setIsMobile] = useState(
1111
+ () => typeof window !== "undefined" ? isMobileViewport2(window.innerWidth) : false
1112
+ );
1113
+ useEffect(() => {
1114
+ if (typeof window === "undefined") return;
1115
+ const handleResize = () => {
1116
+ setIsMobile(isMobileViewport2(window.innerWidth));
1117
+ };
1118
+ handleResize();
1119
+ window.addEventListener("resize", handleResize);
1120
+ return () => window.removeEventListener("resize", handleResize);
1121
+ }, []);
1122
+ return isMobile;
1123
+ }
1124
+ var ModalFrame2 = ({
1125
+ onClose,
1126
+ width = 500,
1127
+ cardStyle,
1128
+ contentStyle,
1129
+ children
1130
+ }) => {
1131
+ const isMobile = useIsMobileViewport2();
1132
+ return /* @__PURE__ */ jsx(
1133
+ "div",
1134
+ {
1135
+ className: `absdk-predicate-modal-frame ${isMobile ? "absdk-predicate-modal-frame--mobile" : "absdk-predicate-modal-frame--desktop"}`,
1136
+ style: {
1137
+ display: "flex",
1138
+ flexDirection: "column",
1139
+ alignItems: "center",
1140
+ justifyContent: "center",
1141
+ width: "100%",
1142
+ maxHeight: isMobile ? "90vh" : void 0
1143
+ },
1144
+ children: /* @__PURE__ */ jsxs(
1145
+ "div",
1146
+ {
1147
+ className: "absdk-predicate-modal-frame__layout",
1148
+ style: {
1149
+ display: "flex",
1150
+ flexDirection: isMobile ? "column" : "row",
1151
+ gap: isMobile ? 10 : 14,
1152
+ alignItems: isMobile ? "stretch" : "flex-start",
1153
+ width: isMobile ? `min(${MOBILE_MODAL_WIDTH_PX2}px, calc(100vw - ${MOBILE_MODAL_GUTTER_PX2 * 2}px))` : "auto"
1154
+ },
1155
+ children: [
1156
+ onClose ? /* @__PURE__ */ jsx(
1157
+ "div",
1158
+ {
1159
+ className: "absdk-predicate-modal-frame__close",
1160
+ style: {
1161
+ display: "flex",
1162
+ justifyContent: isMobile ? "flex-end" : "flex-start",
1163
+ order: isMobile ? -1 : 1,
1164
+ paddingTop: isMobile ? 13 : 0,
1165
+ paddingRight: isMobile ? 2 : 0
1166
+ },
1167
+ children: /* @__PURE__ */ jsx(CloseButton2, { onClick: onClose })
1168
+ }
1169
+ ) : null,
1170
+ /* @__PURE__ */ jsx(
1171
+ "div",
1172
+ {
1173
+ className: "absdk-predicate-modal-frame__card",
1174
+ style: {
1175
+ width: isMobile ? "100%" : width,
1176
+ maxWidth: "100%",
1177
+ maxHeight: isMobile ? "90vh" : void 0,
1178
+ background: colors2.card,
1179
+ borderRadius: radii2.card,
1180
+ overflow: "hidden",
1181
+ ...cardStyle
1182
+ },
1183
+ children: /* @__PURE__ */ jsx(
1184
+ "div",
1185
+ {
1186
+ className: "absdk-predicate-modal-frame__content",
1187
+ style: {
1188
+ display: "flex",
1189
+ flexDirection: "column",
1190
+ minHeight: 0,
1191
+ maxHeight: isMobile ? "90vh" : void 0,
1192
+ overflowY: isMobile ? "auto" : void 0,
1193
+ overflowX: "hidden",
1194
+ WebkitOverflowScrolling: "touch",
1195
+ fontFamily: fonts2.family,
1196
+ color: colors2.textPrimary,
1197
+ boxSizing: "border-box",
1198
+ ...contentStyle
1199
+ },
1200
+ children
1201
+ }
1202
+ )
1203
+ }
1204
+ )
1205
+ ]
1206
+ }
1207
+ )
1208
+ }
1209
+ );
1210
+ };
1211
+ var StepIndicator = ({
1212
+ steps,
1213
+ stepActive,
1214
+ activeStep = 0,
1215
+ orientation = "vertical"
1216
+ }) => {
1217
+ const isHorizontal = orientation === "horizontal";
1218
+ return /* @__PURE__ */ jsx(
1219
+ "div",
1220
+ {
1221
+ className: `absdk-predicate-step-indicator absdk-predicate-step-indicator--${orientation}`,
1222
+ style: {
1223
+ display: "flex",
1224
+ flexDirection: isHorizontal ? "row" : "column",
1225
+ alignItems: "center",
1226
+ justifyContent: "center",
1227
+ width: isHorizontal ? "100%" : 20,
1228
+ paddingTop: isHorizontal ? 0 : 4,
1229
+ flexShrink: 0,
1230
+ gap: isHorizontal ? 0 : void 0
1231
+ },
1232
+ children: Array.from({ length: steps }, (_, i) => {
1233
+ const isActive = stepActive && stepActive.length > i ? stepActive[i] : i <= activeStep;
1234
+ const isLast = i === steps - 1;
1235
+ return /* @__PURE__ */ jsxs(
1236
+ "div",
1237
+ {
1238
+ className: "absdk-predicate-step-indicator__item",
1239
+ style: {
1240
+ display: "flex",
1241
+ flexDirection: isHorizontal ? "row" : "column",
1242
+ alignItems: "center",
1243
+ width: isHorizontal ? "100%" : void 0,
1244
+ flex: isHorizontal ? void 0 : void 0
1245
+ },
1246
+ children: [
1247
+ /* @__PURE__ */ jsx(
1248
+ "div",
1249
+ {
1250
+ className: "absdk-predicate-step-indicator__dot",
1251
+ style: {
1252
+ width: 20,
1253
+ height: 20,
1254
+ minWidth: 20,
1255
+ minHeight: 20,
1256
+ flexShrink: 0,
1257
+ borderRadius: "50%",
1258
+ border: `2px solid ${isActive ? colors2.stepActive : colors2.stepInactive}`,
1259
+ display: "flex",
1260
+ alignItems: "center",
1261
+ justifyContent: "center",
1262
+ boxSizing: "border-box"
1263
+ },
1264
+ children: /* @__PURE__ */ jsx(
1265
+ "div",
1266
+ {
1267
+ className: "absdk-predicate-step-indicator__dot-inner",
1268
+ style: {
1269
+ width: 7.5,
1270
+ height: 7.5,
1271
+ borderRadius: "50%",
1272
+ background: isActive ? colors2.stepActive : colors2.stepInactive
1273
+ }
1274
+ }
1275
+ )
1276
+ }
1277
+ ),
1278
+ !isLast && /* @__PURE__ */ jsx(
1279
+ "div",
1280
+ {
1281
+ className: "absdk-predicate-step-indicator__line",
1282
+ style: {
1283
+ width: isHorizontal ? "100%" : 1,
1284
+ height: isHorizontal ? 1 : 87,
1285
+ flex: isHorizontal ? 1 : void 0,
1286
+ flexShrink: 1,
1287
+ background: isActive ? colors2.stepActive : colors2.stepInactive,
1288
+ opacity: 0.3,
1289
+ margin: isHorizontal ? "0 8px" : "8px 0"
1290
+ }
1291
+ }
1292
+ )
1293
+ ]
1294
+ },
1295
+ i
1296
+ );
1297
+ })
1298
+ }
1299
+ );
1300
+ };
1301
+ var Chevron = ({ up }) => /* @__PURE__ */ jsx(
1302
+ "svg",
1303
+ {
1304
+ className: `absdk-predicate-dropdown-field__chevron ${up ? "absdk-predicate-dropdown-field__chevron--open" : "absdk-predicate-dropdown-field__chevron--closed"}`,
1305
+ width: "16",
1306
+ height: "16",
1307
+ viewBox: "0 0 16 16",
1308
+ fill: "none",
1309
+ style: { transition: "transform .2s", transform: up ? "rotate(180deg)" : "none" },
1310
+ children: /* @__PURE__ */ jsx("path", { className: "absdk-predicate-dropdown-field__chevron-path", d: "M4 6L8 10L12 6", stroke: colors2.textSecondary, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1311
+ }
1312
+ );
1313
+ var DropdownField = ({
1314
+ label,
1315
+ placeholder,
1316
+ value,
1317
+ icon,
1318
+ focused,
1319
+ options,
1320
+ onSelect,
1321
+ wrapperClassName,
1322
+ triggerClassName,
1323
+ triggerId,
1324
+ onClick
1325
+ }) => {
1326
+ const [open, setOpen] = useState(false);
1327
+ const [triggerFocused, setTriggerFocused] = useState(false);
1328
+ const ref = useRef(null);
1329
+ useEffect(() => {
1330
+ if (!open) return;
1331
+ const handler = (e) => {
1332
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
1333
+ };
1334
+ document.addEventListener("mousedown", handler);
1335
+ return () => document.removeEventListener("mousedown", handler);
1336
+ }, [open]);
1337
+ const hasOptions = options && options.length > 0;
1338
+ const handleClick = () => {
1339
+ if (hasOptions) {
1340
+ setOpen((p) => !p);
1341
+ } else {
1342
+ onClick?.();
1343
+ }
1344
+ };
1345
+ const handleSelect = (id) => {
1346
+ onSelect?.(id);
1347
+ setOpen(false);
1348
+ };
1349
+ const selected = hasOptions ? options.find((o) => o.id === value) : void 0;
1350
+ return /* @__PURE__ */ jsxs(
1351
+ "div",
1352
+ {
1353
+ ref,
1354
+ className: wrapperClassName ? `absdk-predicate-dropdown-field ${wrapperClassName}` : "absdk-predicate-dropdown-field",
1355
+ style: { display: "flex", flexDirection: "column", gap: 8, width: "100%", position: "relative" },
1356
+ children: [
1357
+ /* @__PURE__ */ jsx(
1358
+ "span",
1359
+ {
1360
+ className: "absdk-predicate-dropdown-field__label",
1361
+ style: {
1362
+ fontSize: 14,
1363
+ fontWeight: 400,
1364
+ lineHeight: 1.4,
1365
+ color: colors2.textPrimary,
1366
+ fontFamily: fonts2.family
1367
+ },
1368
+ children: label
1369
+ }
1370
+ ),
1371
+ /* @__PURE__ */ jsxs(
1372
+ "button",
1373
+ {
1374
+ id: triggerId,
1375
+ className: triggerClassName ? `absdk-predicate-dropdown-field__trigger ${triggerClassName}` : "absdk-predicate-dropdown-field__trigger",
1376
+ type: "button",
1377
+ onClick: handleClick,
1378
+ onFocus: () => setTriggerFocused(true),
1379
+ onBlur: () => setTriggerFocused(false),
1380
+ style: {
1381
+ display: "flex",
1382
+ alignItems: "center",
1383
+ justifyContent: "space-between",
1384
+ height: 44,
1385
+ padding: "0 16px",
1386
+ borderRadius: radii2.input,
1387
+ border: `1px solid ${open || triggerFocused ? colors2.borderFocused : colors2.border}`,
1388
+ background: "transparent",
1389
+ cursor: "pointer",
1390
+ fontFamily: fonts2.family,
1391
+ width: "100%",
1392
+ boxSizing: "border-box"
1393
+ },
1394
+ children: [
1395
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-dropdown-field__trigger-content", style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1396
+ selected?.icon ?? icon ? /* @__PURE__ */ jsx("span", { className: "absdk-predicate-dropdown-field__trigger-icon", children: selected?.icon ?? icon }) : null,
1397
+ /* @__PURE__ */ jsx(
1398
+ "span",
1399
+ {
1400
+ className: "absdk-predicate-dropdown-field__trigger-text",
1401
+ style: {
1402
+ fontSize: 14,
1403
+ lineHeight: 1.4,
1404
+ color: value ? colors2.textPrimary : colors2.textSecondary,
1405
+ fontFamily: fonts2.family
1406
+ },
1407
+ children: selected?.label ?? value ?? placeholder
1408
+ }
1409
+ )
1410
+ ] }),
1411
+ /* @__PURE__ */ jsx(Chevron, { up: open })
1412
+ ]
1413
+ }
1414
+ ),
1415
+ open && hasOptions && /* @__PURE__ */ jsx(
1416
+ "div",
1417
+ {
1418
+ className: "absdk-predicate-dropdown-field__list",
1419
+ style: {
1420
+ position: "absolute",
1421
+ top: "calc(100% + 4px)",
1422
+ left: 0,
1423
+ right: 0,
1424
+ zIndex: 10,
1425
+ borderRadius: radii2.input,
1426
+ border: `1px solid ${colors2.border}`,
1427
+ background: colors2.card,
1428
+ overflow: "hidden",
1429
+ boxShadow: "0 8px 24px rgba(0,0,0,0.4)"
1430
+ },
1431
+ children: options.map((opt) => /* @__PURE__ */ jsxs(
1432
+ "button",
1433
+ {
1434
+ className: "absdk-predicate-dropdown-field__option",
1435
+ type: "button",
1436
+ onClick: () => handleSelect(opt.id),
1437
+ style: {
1438
+ display: "flex",
1439
+ alignItems: "center",
1440
+ gap: 10,
1441
+ width: "100%",
1442
+ padding: "10px 16px",
1443
+ border: "none",
1444
+ background: opt.id === value ? "rgba(255,255,255,0.06)" : "transparent",
1445
+ cursor: "pointer",
1446
+ fontFamily: fonts2.family,
1447
+ textAlign: "left",
1448
+ transition: "background .12s"
1449
+ },
1450
+ onMouseEnter: (e) => {
1451
+ e.currentTarget.style.background = "rgba(255,255,255,0.08)";
1452
+ },
1453
+ onMouseLeave: (e) => {
1454
+ e.currentTarget.style.background = opt.id === value ? "rgba(255,255,255,0.06)" : "transparent";
1455
+ },
1456
+ children: [
1457
+ opt.icon && /* @__PURE__ */ jsx("div", { className: "absdk-predicate-dropdown-field__option-icon", style: { width: 28, height: 28, flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: opt.icon }),
1458
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-dropdown-field__option-copy", style: { display: "flex", flexDirection: "column", gap: 1 }, children: [
1459
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-dropdown-field__option-label", style: { fontSize: 14, fontWeight: 500, color: colors2.textPrimary }, children: opt.label }),
1460
+ opt.subtitle && /* @__PURE__ */ jsx("span", { className: "absdk-predicate-dropdown-field__option-subtitle", style: { fontSize: 12, color: colors2.textSecondary }, children: opt.subtitle })
1461
+ ] })
1462
+ ]
1463
+ },
1464
+ opt.id
1465
+ ))
1466
+ }
1467
+ )
1468
+ ]
1469
+ }
1470
+ );
1471
+ };
1472
+ function getRemaining(expiresAt) {
1473
+ const end = typeof expiresAt === "string" ? new Date(expiresAt).getTime() : expiresAt;
1474
+ return Math.max(0, Math.floor((end - Date.now()) / 1e3));
1475
+ }
1476
+ function formatRemaining(seconds) {
1477
+ const m = Math.floor(seconds / 60);
1478
+ const s = seconds % 60;
1479
+ return `${m}:${s.toString().padStart(2, "0")}`;
1480
+ }
1481
+ function Countdown({
1482
+ expiresAt,
1483
+ expiredLabel = "Expired",
1484
+ style,
1485
+ isExpired = false,
1486
+ onExpired
1487
+ }) {
1488
+ const [remaining, setRemaining] = useState(() => getRemaining(expiresAt));
1489
+ const hasFiredExpired = useRef(false);
1490
+ useEffect(() => {
1491
+ hasFiredExpired.current = false;
1492
+ }, [expiresAt]);
1493
+ useEffect(() => {
1494
+ if (isExpired) {
1495
+ setRemaining(0);
1496
+ return;
1497
+ }
1498
+ const tick = () => {
1499
+ const r = getRemaining(expiresAt);
1500
+ setRemaining(r);
1501
+ if (r <= 0 && onExpired && !hasFiredExpired.current) {
1502
+ hasFiredExpired.current = true;
1503
+ onExpired();
1504
+ }
1505
+ };
1506
+ tick();
1507
+ const id = setInterval(tick, 1e3);
1508
+ return () => clearInterval(id);
1509
+ }, [expiresAt, isExpired, onExpired]);
1510
+ const text = remaining <= 0 ? expiredLabel : formatRemaining(remaining);
1511
+ const color = remaining <= 0 ? colors2.warning : colors2.textSecondary;
1512
+ return /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-countdown", style: { fontSize: 12, color, fontFamily: fonts2.family, ...style }, children: [
1513
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-countdown__label", children: "Expires in " }),
1514
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-countdown__value", style: { fontWeight: 600, color: "#fff" }, children: text })
1515
+ ] });
1516
+ }
1517
+ function generateMatrix(data) {
1518
+ const qr = qrcode(0, "H");
1519
+ qr.addData(data);
1520
+ qr.make();
1521
+ const count = qr.getModuleCount();
1522
+ const matrix = [];
1523
+ for (let r = 0; r < count; r++) {
1524
+ const row = [];
1525
+ for (let c = 0; c < count; c++) {
1526
+ row.push(qr.isDark(r, c));
1527
+ }
1528
+ matrix.push(row);
1529
+ }
1530
+ return matrix;
1531
+ }
1532
+ function isFinderZone(row, col, size) {
1533
+ return row < 7 && col < 7 || row < 7 && col >= size - 7 || row >= size - 7 && col < 7;
1534
+ }
1535
+ var FinderEye = ({ ox, oy, s }) => /* @__PURE__ */ jsxs(Fragment, { children: [
1536
+ /* @__PURE__ */ jsx("rect", { x: ox, y: oy, width: 7 * s, height: 7 * s, rx: s * 1.4, ry: s * 1.4, fill: "#fff" }),
1537
+ /* @__PURE__ */ jsx(
1538
+ "rect",
1539
+ {
1540
+ x: ox + s,
1541
+ y: oy + s,
1542
+ width: 5 * s,
1543
+ height: 5 * s,
1544
+ rx: s * 0.9,
1545
+ ry: s * 0.9,
1546
+ fill: colors2.background
1547
+ }
1548
+ ),
1549
+ /* @__PURE__ */ jsx(
1550
+ "rect",
1551
+ {
1552
+ x: ox + 2 * s,
1553
+ y: oy + 2 * s,
1554
+ width: 3 * s,
1555
+ height: 3 * s,
1556
+ rx: s * 0.7,
1557
+ ry: s * 0.7,
1558
+ fill: "#fff"
1559
+ }
1560
+ )
1561
+ ] });
1562
+ var SVG_SIZE = 176;
1563
+ var QUIET_ZONE = 2;
1564
+ var StyledQR = ({ data }) => {
1565
+ const matrix = useMemo(() => generateMatrix(data), [data]);
1566
+ const n = matrix.length;
1567
+ const total = n + QUIET_ZONE * 2;
1568
+ const cell = SVG_SIZE / total;
1569
+ const off = QUIET_ZONE * cell;
1570
+ const dotR = cell * 0.42;
1571
+ const centerClearR = 3;
1572
+ const cx = n / 2;
1573
+ const cy = n / 2;
1574
+ const dots = [];
1575
+ for (let r = 0; r < n; r++) {
1576
+ for (let c = 0; c < n; c++) {
1577
+ if (!matrix[r][c]) continue;
1578
+ if (isFinderZone(r, c, n)) continue;
1579
+ if (Math.abs(c - cx) < centerClearR && Math.abs(r - cy) < centerClearR) continue;
1580
+ dots.push(
1581
+ /* @__PURE__ */ jsx(
1582
+ "circle",
1583
+ {
1584
+ cx: off + c * cell + cell / 2,
1585
+ cy: off + r * cell + cell / 2,
1586
+ r: dotR,
1587
+ fill: "#fff"
1588
+ },
1589
+ `${r}-${c}`
1590
+ )
1591
+ );
1592
+ }
1593
+ }
1594
+ return /* @__PURE__ */ jsxs(
1595
+ "svg",
1596
+ {
1597
+ className: "absdk-predicate-deposit-details__qr-svg",
1598
+ width: SVG_SIZE,
1599
+ height: SVG_SIZE,
1600
+ viewBox: `0 0 ${SVG_SIZE} ${SVG_SIZE}`,
1601
+ style: { borderRadius: 12 },
1602
+ children: [
1603
+ /* @__PURE__ */ jsx("rect", { className: "absdk-predicate-deposit-details__qr-background", width: SVG_SIZE, height: SVG_SIZE, fill: colors2.background }),
1604
+ /* @__PURE__ */ jsx(FinderEye, { ox: off, oy: off, s: cell }),
1605
+ /* @__PURE__ */ jsx(FinderEye, { ox: off + (n - 7) * cell, oy: off, s: cell }),
1606
+ /* @__PURE__ */ jsx(FinderEye, { ox: off, oy: off + (n - 7) * cell, s: cell }),
1607
+ dots
1608
+ ]
1609
+ }
1610
+ );
1611
+ };
1612
+ var CopyIcon = () => /* @__PURE__ */ jsxs("svg", { className: "absdk-predicate-deposit-details__copy-icon", width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: [
1613
+ /* @__PURE__ */ jsx("rect", { className: "absdk-predicate-deposit-details__copy-icon-body", x: "4.5", y: "4.5", width: "7", height: "7", rx: "1.5", stroke: colors2.textPrimary, strokeWidth: "1.2" }),
1614
+ /* @__PURE__ */ jsx(
1615
+ "path",
1616
+ {
1617
+ className: "absdk-predicate-deposit-details__copy-icon-path",
1618
+ 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",
1619
+ stroke: colors2.textPrimary,
1620
+ strokeWidth: "1.2"
1621
+ }
1622
+ )
1623
+ ] });
1624
+ var DepositDetailsPanel = ({
1625
+ address,
1626
+ tokenIcon,
1627
+ minimumDeposit,
1628
+ onCopyAddress
1629
+ }) => {
1630
+ const isMobile = useIsMobileViewport2();
1631
+ const canCopy = typeof address === "string" && address.trim().length > 0;
1632
+ const handleCopy = async () => {
1633
+ if (!canCopy) return;
1634
+ try {
1635
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
1636
+ await navigator.clipboard.writeText(address);
1637
+ } else {
1638
+ const el = document.createElement("textarea");
1639
+ el.value = address;
1640
+ el.setAttribute("readonly", "");
1641
+ el.style.position = "absolute";
1642
+ el.style.left = "-9999px";
1643
+ document.body.appendChild(el);
1644
+ el.select();
1645
+ try {
1646
+ document.execCommand("copy");
1647
+ } catch {
1648
+ }
1649
+ document.body.removeChild(el);
1650
+ }
1651
+ } finally {
1652
+ onCopyAddress?.(address);
1653
+ }
1654
+ };
1655
+ return /* @__PURE__ */ jsxs(
1656
+ "div",
1657
+ {
1658
+ className: `absdk-predicate-deposit-details ${isMobile ? "absdk-predicate-deposit-details--mobile" : "absdk-predicate-deposit-details--desktop"}`,
1659
+ style: {
1660
+ display: "flex",
1661
+ flexDirection: "column",
1662
+ alignItems: "center",
1663
+ gap: 16,
1664
+ padding: isMobile ? "16px" : "20px",
1665
+ borderRadius: radii2.card,
1666
+ border: `1px solid ${colors2.border}`,
1667
+ fontFamily: fonts2.family
1668
+ },
1669
+ children: [
1670
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-deposit-details__qr", style: { position: "relative", display: "inline-flex" }, children: [
1671
+ /* @__PURE__ */ jsx(StyledQR, { data: address }),
1672
+ tokenIcon && /* @__PURE__ */ jsx(
1673
+ "div",
1674
+ {
1675
+ className: "absdk-predicate-deposit-details__token-icon-shell",
1676
+ style: {
1677
+ position: "absolute",
1678
+ top: "50%",
1679
+ left: "50%",
1680
+ transform: "translate(-50%, -50%)",
1681
+ width: 30,
1682
+ height: 30,
1683
+ borderRadius: "50%",
1684
+ background: "#3B5998",
1685
+ display: "flex",
1686
+ alignItems: "center",
1687
+ justifyContent: "center",
1688
+ boxShadow: `0 0 0 3px ${colors2.background}`
1689
+ },
1690
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-details__token-icon", children: tokenIcon })
1691
+ }
1692
+ )
1693
+ ] }),
1694
+ /* @__PURE__ */ jsx("div", { className: "absdk-predicate-deposit-details__address-group", style: { width: "100%", display: "flex", flexDirection: "column", gap: 8 }, children: /* @__PURE__ */ jsx(
1695
+ "div",
1696
+ {
1697
+ id: "absdk-predicate-deposit-details-address",
1698
+ className: "absdk-predicate-deposit-details__address",
1699
+ style: {
1700
+ padding: "10px 14px",
1701
+ borderRadius: radii2.input,
1702
+ background: "rgba(255,255,255,0.05)",
1703
+ fontSize: 13,
1704
+ color: colors2.textPrimary,
1705
+ wordBreak: "break-all",
1706
+ lineHeight: 1.5
1707
+ },
1708
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-details__address-text", children: address })
1709
+ }
1710
+ ) }),
1711
+ minimumDeposit && /* @__PURE__ */ jsxs(
1712
+ "div",
1713
+ {
1714
+ className: "absdk-predicate-deposit-details__minimum",
1715
+ style: {
1716
+ width: "100%",
1717
+ display: "flex",
1718
+ justifyContent: "space-between",
1719
+ fontSize: 13
1720
+ },
1721
+ children: [
1722
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-details__minimum-label", style: { color: colors2.textSecondary }, children: "Minimum deposit" }),
1723
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-details__minimum-value", style: { color: colors2.textPrimary, fontWeight: 500 }, children: minimumDeposit })
1724
+ ]
1725
+ }
1726
+ ),
1727
+ /* @__PURE__ */ jsxs(
1728
+ "button",
1729
+ {
1730
+ id: "absdk-predicate-deposit-details-copy-button",
1731
+ className: "absdk-predicate-deposit-details__copy-button",
1732
+ type: "button",
1733
+ onClick: handleCopy,
1734
+ disabled: !canCopy,
1735
+ style: {
1736
+ display: "flex",
1737
+ alignItems: "center",
1738
+ gap: 6,
1739
+ padding: "10px 28px",
1740
+ borderRadius: radii2.pill,
1741
+ border: `1px solid ${colors2.borderStrong}`,
1742
+ background: "transparent",
1743
+ color: colors2.textPrimary,
1744
+ fontSize: 14,
1745
+ fontWeight: 500,
1746
+ cursor: canCopy ? "pointer" : "not-allowed",
1747
+ opacity: canCopy ? 1 : 0.6,
1748
+ fontFamily: fonts2.family,
1749
+ transition: "background .15s"
1750
+ },
1751
+ onMouseEnter: (e) => {
1752
+ if (!canCopy) return;
1753
+ e.currentTarget.style.background = "rgba(255,255,255,0.06)";
1754
+ },
1755
+ onMouseLeave: (e) => {
1756
+ e.currentTarget.style.background = "transparent";
1757
+ },
1758
+ children: [
1759
+ /* @__PURE__ */ jsx(CopyIcon, {}),
1760
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-details__copy-button-label", children: "Copy address" })
1761
+ ]
1762
+ }
1763
+ )
1764
+ ]
1765
+ }
1766
+ );
1767
+ };
1768
+ var LockIcon = () => /* @__PURE__ */ jsxs("svg", { className: "absdk-predicate-login-required__icon", width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", children: [
1769
+ /* @__PURE__ */ jsx("rect", { className: "absdk-predicate-login-required__icon-body", x: "10", y: "22", width: "28", height: "20", rx: "4", stroke: colors2.textSecondary, strokeWidth: "2" }),
1770
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-login-required__icon-shackle", d: "M16 22V16C16 11.5817 19.5817 8 24 8C28.4183 8 32 11.5817 32 16V22", stroke: colors2.textSecondary, strokeWidth: "2", strokeLinecap: "round" }),
1771
+ /* @__PURE__ */ jsx("circle", { className: "absdk-predicate-login-required__icon-core", cx: "24", cy: "33", r: "3", fill: colors2.textSecondary })
1772
+ ] });
1773
+ var LoginRequiredOverlay = ({
1774
+ title,
1775
+ onSignIn,
1776
+ onClose
1777
+ }) => {
1778
+ const isMobile = useIsMobileViewport2();
1779
+ return /* @__PURE__ */ jsx(ModalFrame2, { onClose, contentStyle: { padding: isMobile ? "32px 16px" : "48px 24px" }, children: /* @__PURE__ */ jsxs(
1780
+ "div",
1781
+ {
1782
+ className: `absdk-predicate-login-required ${isMobile ? "absdk-predicate-login-required--mobile" : "absdk-predicate-login-required--desktop"}`,
1783
+ style: {
1784
+ display: "flex",
1785
+ flexDirection: "column",
1786
+ alignItems: "center",
1787
+ gap: isMobile ? 20 : 24,
1788
+ textAlign: "center"
1789
+ },
1790
+ children: [
1791
+ /* @__PURE__ */ jsx(LockIcon, {}),
1792
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-login-required__copy", style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1793
+ /* @__PURE__ */ jsx(
1794
+ "h2",
1795
+ {
1796
+ className: "absdk-predicate-login-required__title",
1797
+ style: {
1798
+ margin: 0,
1799
+ fontSize: isMobile ? 18 : 20,
1800
+ fontWeight: 600,
1801
+ color: colors2.textPrimary
1802
+ },
1803
+ children: title
1804
+ }
1805
+ ),
1806
+ /* @__PURE__ */ jsx(
1807
+ "p",
1808
+ {
1809
+ className: "absdk-predicate-login-required__description",
1810
+ style: {
1811
+ margin: 0,
1812
+ fontSize: 14,
1813
+ color: colors2.textSecondary,
1814
+ lineHeight: 1.5
1815
+ },
1816
+ children: "Please sign in to continue"
1817
+ }
1818
+ )
1819
+ ] }),
1820
+ onSignIn && /* @__PURE__ */ jsx(
1821
+ "button",
1822
+ {
1823
+ id: "absdk-predicate-login-required-signin-button",
1824
+ className: "absdk-predicate-login-required__signin-button",
1825
+ type: "button",
1826
+ onClick: onSignIn,
1827
+ style: {
1828
+ width: isMobile ? "100%" : void 0,
1829
+ padding: "12px 48px",
1830
+ borderRadius: radii2.full,
1831
+ border: "none",
1832
+ background: colors2.textPrimary,
1833
+ color: "#15181D",
1834
+ fontSize: 16,
1835
+ fontWeight: 500,
1836
+ fontFamily: fonts2.family,
1837
+ cursor: "pointer"
1838
+ },
1839
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-login-required__signin-button-label", children: "Sign In" })
1840
+ }
1841
+ )
1842
+ ]
1843
+ }
1844
+ ) });
1845
+ };
1846
+ function useSession() {
1847
+ const [session, setSession] = useState(
1848
+ () => sessionStore.getState().session
1849
+ );
1850
+ useEffect(() => {
1851
+ const unsub = sessionStore.on("session:changed", setSession);
1852
+ return () => {
1853
+ unsub();
1854
+ };
1855
+ }, []);
1856
+ return session;
1857
+ }
1858
+ var BackArrow = () => /* @__PURE__ */ jsx("svg", { className: "absdk-predicate-deposit-modal__back-icon", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__back-icon-path", d: "M15 6L9 12L15 18", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
1859
+ var TransferIcon = () => /* @__PURE__ */ jsxs("svg", { className: "absdk-predicate-deposit-modal__transfer-icon", width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", children: [
1860
+ /* @__PURE__ */ jsx("circle", { className: "absdk-predicate-deposit-modal__transfer-icon-circle absdk-predicate-deposit-modal__transfer-icon-circle--outer", cx: "18", cy: "18", r: "18", fill: "rgba(255,255,255,0.08)" }),
1861
+ /* @__PURE__ */ jsx("circle", { className: "absdk-predicate-deposit-modal__transfer-icon-circle absdk-predicate-deposit-modal__transfer-icon-circle--middle", cx: "18", cy: "18", r: "7", stroke: colors2.textPrimary, strokeWidth: "1.5" }),
1862
+ /* @__PURE__ */ jsx("circle", { className: "absdk-predicate-deposit-modal__transfer-icon-circle absdk-predicate-deposit-modal__transfer-icon-circle--inner", cx: "18", cy: "18", r: "2.5", fill: colors2.textPrimary }),
1863
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__transfer-icon-path", d: "M18 7V11", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" }),
1864
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__transfer-icon-path", d: "M18 25V29", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" }),
1865
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__transfer-icon-path", d: "M7 18H11", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" }),
1866
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__transfer-icon-path", d: "M25 18H29", stroke: colors2.textPrimary, strokeWidth: "1.5", strokeLinecap: "round" })
1867
+ ] });
1868
+ var FiatIcon = () => /* @__PURE__ */ jsxs("svg", { className: "absdk-predicate-deposit-modal__fiat-icon", width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", children: [
1869
+ /* @__PURE__ */ jsx("circle", { className: "absdk-predicate-deposit-modal__fiat-icon-circle absdk-predicate-deposit-modal__fiat-icon-circle--outer", cx: "18", cy: "18", r: "18", fill: "rgba(255,255,255,0.06)" }),
1870
+ /* @__PURE__ */ jsx("circle", { className: "absdk-predicate-deposit-modal__fiat-icon-circle absdk-predicate-deposit-modal__fiat-icon-circle--inner", cx: "18", cy: "18", r: "10", stroke: colors2.textSecondary, strokeWidth: "1.5" }),
1871
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__fiat-icon-path", d: "M18 12V24", stroke: colors2.textSecondary, strokeWidth: "1.5", strokeLinecap: "round" }),
1872
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-deposit-modal__fiat-icon-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" })
1873
+ ] });
1874
+ var DefaultCryptoIcons = ({ isMobile }) => {
1875
+ const tokens = [
1876
+ { label: "B", bg: "#F7931A" },
1877
+ { label: "E", bg: "#627EEA" },
1878
+ { label: "\u2261", bg: "#26A17B" },
1879
+ { label: "$", bg: "#2775CA" },
1880
+ { label: "S", bg: "#9945FF" },
1881
+ { label: "A", bg: "#E84142" }
1882
+ ];
1883
+ return /* @__PURE__ */ jsx(
1884
+ "div",
1885
+ {
1886
+ className: "absdk-predicate-deposit-modal__crypto-icons",
1887
+ style: {
1888
+ display: "flex",
1889
+ gap: 0,
1890
+ flexWrap: isMobile ? "wrap" : "nowrap",
1891
+ width: isMobile ? 84 : void 0,
1892
+ justifyContent: isMobile ? "flex-end" : "flex-start",
1893
+ rowGap: isMobile ? 4 : 0,
1894
+ padding: "10px 0 0 4px"
1895
+ },
1896
+ children: tokens.map((t, i) => /* @__PURE__ */ jsx(
1897
+ "div",
1898
+ {
1899
+ className: `absdk-predicate-deposit-modal__crypto-icon absdk-predicate-deposit-modal__crypto-icon--${i + 1}`,
1900
+ style: {
1901
+ width: 24,
1902
+ height: 24,
1903
+ borderRadius: "50%",
1904
+ background: t.bg,
1905
+ display: "flex",
1906
+ alignItems: "center",
1907
+ justifyContent: "center",
1908
+ fontSize: 11,
1909
+ fontWeight: 700,
1910
+ color: "#fff",
1911
+ marginLeft: -4,
1912
+ marginTop: -10,
1913
+ border: `2px solid ${colors2.card}`,
1914
+ boxSizing: "content-box"
1915
+ },
1916
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__crypto-icon-label", children: t.label })
1917
+ },
1918
+ i
1919
+ ))
1920
+ }
1921
+ );
1922
+ };
1923
+ function chainsToTokenOptions(chains) {
1924
+ const bySymbol = /* @__PURE__ */ new Map();
1925
+ for (const c of chains) {
1926
+ for (const t of c.tokens) {
1927
+ if (!bySymbol.has(t.symbol)) bySymbol.set(t.symbol, { symbol: t.symbol, decimals: t.decimals });
1928
+ }
1929
+ }
1930
+ return Array.from(bySymbol.entries()).map(([id, { symbol }]) => ({
1931
+ id,
1932
+ label: symbol,
1933
+ subtitle: symbol
1934
+ }));
1935
+ }
1936
+ function chainsToChainOptionsForToken(chains, tokenSymbol) {
1937
+ return chains.filter((c) => c.tokens.some((t) => t.symbol === tokenSymbol)).map((c) => ({
1938
+ id: c.chain_id,
1939
+ label: c.network,
1940
+ subtitle: `chainId: ${c.chain_id}`,
1941
+ icon: /* @__PURE__ */ jsx(
1942
+ "span",
1943
+ {
1944
+ style: {
1945
+ display: "inline-flex",
1946
+ alignItems: "center",
1947
+ justifyContent: "center",
1948
+ minWidth: 28,
1949
+ height: 28,
1950
+ padding: "0 6px",
1951
+ borderRadius: radii2.card,
1952
+ background: "rgba(255,255,255,0.08)",
1953
+ fontSize: 12,
1954
+ fontWeight: 600,
1955
+ color: colors2.textPrimary,
1956
+ fontFamily: fonts2.family
1957
+ },
1958
+ children: c.network
1959
+ }
1960
+ )
1961
+ }));
1962
+ }
1963
+ function getTokenAddressForChain(chains, chainId, tokenSymbol) {
1964
+ const chain = chains.find((c) => c.chain_id === chainId);
1965
+ return chain?.tokens.find((t) => t.symbol === tokenSymbol)?.address;
1966
+ }
1967
+ var FUNDING_TOKEN_SYMBOL = getEnv("FUNDING_TOKEN_SYMBOL");
1968
+ var DepositModal = ({
1969
+ token,
1970
+ chain,
1971
+ tokenOptions: tokenOptionsProp,
1972
+ chainOptions: chainOptionsProp,
1973
+ depositAddress,
1974
+ minimumDeposit,
1975
+ qrCenterIcon,
1976
+ cryptoIcons,
1977
+ depositAmount,
1978
+ onShowToast,
1979
+ txHash,
1980
+ explorerTxUrl,
1981
+ onTokenSelect,
1982
+ onChainSelect,
1983
+ onCopyAddress,
1984
+ onBuyCrypto,
1985
+ onSignIn,
1986
+ onBack,
1987
+ onClose
1988
+ }) => {
1989
+ const isMobile = useIsMobileViewport2();
1990
+ const session = useSession();
1991
+ const [view, setView] = useState("entry");
1992
+ const [copySuccessMessage, setCopySuccessMessage] = useState(null);
1993
+ const [apiChains, setApiChains] = useState(null);
1994
+ const [apiQuote, setApiQuote] = useState(null);
1995
+ const [loadingChains, setLoadingChains] = useState(false);
1996
+ const [loadingQuote, setLoadingQuote] = useState(false);
1997
+ const [quoteRefreshKey, setQuoteRefreshKey] = useState(0);
1998
+ const [internalDepositAddress, setInternalDepositAddress] = useState(void 0);
1999
+ const lastEmittedAddressRef = useRef(void 0);
2000
+ const lastEmittedChainRef = useRef(void 0);
2001
+ const tokenOptions = useMemo(() => {
2002
+ if (tokenOptionsProp?.length) return tokenOptionsProp;
2003
+ if (!apiChains?.length) return void 0;
2004
+ return chainsToTokenOptions(apiChains);
2005
+ }, [tokenOptionsProp, apiChains]);
2006
+ const chainOptions = useMemo(() => {
2007
+ if (chainOptionsProp?.length) return chainOptionsProp;
2008
+ if (!apiChains?.length || !token) return void 0;
2009
+ return chainsToChainOptionsForToken(apiChains, token);
2010
+ }, [chainOptionsProp, apiChains, token]);
2011
+ useEffect(() => {
2012
+ if (chainOptions?.length !== 1 || !onChainSelect) return;
2013
+ const onlyId = chainOptions[0].id;
2014
+ if (chain === onlyId) return;
2015
+ onChainSelect(onlyId);
2016
+ }, [chainOptions, chain, onChainSelect]);
2017
+ useEffect(() => {
2018
+ if (view !== "transfer") return;
2019
+ setLoadingChains(true);
2020
+ getChains().then((res) => setApiChains(res?.chains ?? {})).finally(() => setLoadingChains(false));
2021
+ }, [view]);
2022
+ useEffect(() => {
2023
+ if (view !== "transfer") return;
2024
+ if (!session?.address || !chain) return;
2025
+ const platform_contract_address = getEnv("PLATFORM_CONTRACT_ADDRESS") || session.address;
2026
+ registerPlatform({
2027
+ platform_contract_address,
2028
+ chain_id: chain
2029
+ }).then((res) => {
2030
+ if (res?.deposit_address) {
2031
+ setInternalDepositAddress(res.deposit_address);
2032
+ }
2033
+ }).catch(() => {
2034
+ });
2035
+ }, [view, chain, session?.address]);
2036
+ useEffect(() => {
2037
+ if (!apiChains?.length || !token || !chain) {
2038
+ setApiQuote(null);
2039
+ return;
2040
+ }
2041
+ const tokenAddress = getTokenAddressForChain(apiChains, chain, token);
2042
+ if (!tokenAddress) {
2043
+ setApiQuote(null);
2044
+ return;
2045
+ }
2046
+ setLoadingQuote(true);
2047
+ quote({
2048
+ direction: "deposit",
2049
+ chain_id: chain,
2050
+ token_address: tokenAddress,
2051
+ token_amount: depositAmount || void 0
2052
+ }).then((q) => setApiQuote(q ?? null)).catch((err) => {
2053
+ const message = err?.message ?? String(err);
2054
+ if (onShowToast) onShowToast(message);
2055
+ setApiQuote({
2056
+ token_address: tokenAddress,
2057
+ token_symbol: token,
2058
+ token_decimals: 18,
2059
+ rate: "1",
2060
+ chain_id: Number(chain) || 56,
2061
+ deposit_address: "0x" + "0".repeat(39) + "1",
2062
+ dst_token_amount: depositAmount ?? "0",
2063
+ expires_at: new Date(Date.now() + 6e4).toISOString()
2064
+ });
2065
+ }).finally(() => setLoadingQuote(false));
2066
+ }, [apiChains, token, chain, depositAmount, quoteRefreshKey, onShowToast]);
2067
+ useEffect(() => {
2068
+ if (!chain) return;
2069
+ if (!depositAddress) return;
2070
+ if (lastEmittedAddressRef.current === depositAddress && lastEmittedChainRef.current === chain) {
2071
+ return;
2072
+ }
2073
+ lastEmittedAddressRef.current = depositAddress;
2074
+ lastEmittedChainRef.current = chain;
2075
+ }, [depositAddress, chain]);
2076
+ const handleQuoteExpired = useCallback(() => {
2077
+ setQuoteRefreshKey((k) => k + 1);
2078
+ }, []);
2079
+ useEffect(() => {
2080
+ if (txHash && chain && onShowToast) {
2081
+ onShowToast("Transfer confirmed");
2082
+ }
2083
+ }, [txHash, chain, onShowToast]);
2084
+ if (!session) {
2085
+ return /* @__PURE__ */ jsx(LoginRequiredOverlay, { title: "Deposit", onSignIn, onClose });
2086
+ }
2087
+ const goToEntry = () => {
2088
+ setView("entry");
2089
+ onBack?.();
2090
+ };
2091
+ const handleCopyAddress = useCallback((address) => {
2092
+ onCopyAddress?.(address);
2093
+ onShowToast?.("Address copied");
2094
+ setCopySuccessMessage("Address copied");
2095
+ }, [onCopyAddress, onShowToast]);
2096
+ useEffect(() => {
2097
+ if (!copySuccessMessage) return;
2098
+ const t = setTimeout(() => setCopySuccessMessage(null), 2e3);
2099
+ return () => clearTimeout(t);
2100
+ }, [copySuccessMessage]);
2101
+ return /* @__PURE__ */ jsxs(
2102
+ ModalFrame2,
2103
+ {
2104
+ onClose,
2105
+ contentStyle: { padding: isMobile ? "20px 16px" : "24px", position: "relative" },
2106
+ children: [
2107
+ copySuccessMessage && /* @__PURE__ */ jsx(
2108
+ "div",
2109
+ {
2110
+ className: "absdk-predicate-deposit-modal__toast",
2111
+ style: {
2112
+ position: "absolute",
2113
+ top: 12,
2114
+ left: 0,
2115
+ right: 0,
2116
+ display: "flex",
2117
+ justifyContent: "center",
2118
+ pointerEvents: "none",
2119
+ zIndex: 10
2120
+ },
2121
+ children: /* @__PURE__ */ jsx(
2122
+ "div",
2123
+ {
2124
+ className: "absdk-predicate-deposit-modal__toast-content",
2125
+ style: {
2126
+ pointerEvents: "auto",
2127
+ padding: "10px 20px",
2128
+ borderRadius: 8,
2129
+ background: "var(--pm-colors-card, #1a1a2e)",
2130
+ color: "var(--pm-colors-textPrimary, #fff)",
2131
+ fontSize: 13,
2132
+ fontWeight: 500,
2133
+ boxShadow: "0 4px 12px rgba(0,0,0,.25)"
2134
+ },
2135
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__toast-message", children: copySuccessMessage })
2136
+ }
2137
+ )
2138
+ }
2139
+ ),
2140
+ /* @__PURE__ */ jsx(
2141
+ "div",
2142
+ {
2143
+ id: "absdk-predicate-deposit-modal",
2144
+ className: `absdk-predicate-deposit-modal ${isMobile ? "absdk-predicate-deposit-modal--mobile" : "absdk-predicate-deposit-modal--desktop"}`,
2145
+ children: view === "entry" ? /* @__PURE__ */ jsx(
2146
+ EntryView,
2147
+ {
2148
+ isMobile,
2149
+ cryptoIcons,
2150
+ onTransferCrypto: () => setView("transfer"),
2151
+ onBuyCrypto
2152
+ }
2153
+ ) : /* @__PURE__ */ jsx(
2154
+ TransferView,
2155
+ {
2156
+ isMobile,
2157
+ token,
2158
+ chain,
2159
+ tokenOptions,
2160
+ chainOptions,
2161
+ depositAddress: depositAddress ?? internalDepositAddress,
2162
+ minimumDeposit,
2163
+ qrCenterIcon,
2164
+ quote: apiQuote,
2165
+ quoteLoading: loadingQuote,
2166
+ txHash,
2167
+ chainIdForExplorer: chain,
2168
+ explorerTxUrl,
2169
+ loadingChains,
2170
+ onTokenSelect,
2171
+ onChainSelect,
2172
+ onCopyAddress: handleCopyAddress,
2173
+ onQuoteExpired: handleQuoteExpired,
2174
+ onRefreshQuote: () => {
2175
+ if (!apiChains?.length || !token || !chain) return;
2176
+ const tokenAddress = getTokenAddressForChain(apiChains, chain, token);
2177
+ if (tokenAddress) {
2178
+ setLoadingQuote(true);
2179
+ quote({ direction: "deposit", chain_id: chain, token_address: tokenAddress, token_amount: depositAmount }).then((q) => setApiQuote(q ?? null)).catch(() => {
2180
+ setApiQuote({
2181
+ token_address: tokenAddress,
2182
+ token_symbol: token,
2183
+ token_decimals: 18,
2184
+ rate: "1",
2185
+ chain_id: Number(chain) || 56,
2186
+ deposit_address: "0x" + "0".repeat(39) + "1",
2187
+ dst_token_amount: depositAmount ?? "0",
2188
+ expires_at: new Date(Date.now() + 6e4).toISOString()
2189
+ });
2190
+ }).finally(() => setLoadingQuote(false));
2191
+ }
2192
+ },
2193
+ onShowToast,
2194
+ onBack: goToEntry
2195
+ }
2196
+ )
2197
+ }
2198
+ )
2199
+ ]
2200
+ }
2201
+ );
2202
+ };
2203
+ var EntryView = ({
2204
+ isMobile,
2205
+ cryptoIcons,
2206
+ onTransferCrypto,
2207
+ onBuyCrypto: _onBuyCrypto
2208
+ }) => /* @__PURE__ */ jsxs(
2209
+ "div",
2210
+ {
2211
+ className: "absdk-predicate-deposit-modal__entry",
2212
+ style: { display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24 },
2213
+ children: [
2214
+ /* @__PURE__ */ jsx(
2215
+ "h2",
2216
+ {
2217
+ className: "absdk-predicate-deposit-modal__title",
2218
+ style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4 },
2219
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__title-text", children: "Deposit" })
2220
+ }
2221
+ ),
2222
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-deposit-modal__actions", style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
2223
+ /* @__PURE__ */ jsxs(
2224
+ "button",
2225
+ {
2226
+ id: "absdk-predicate-deposit-modal-transfer-button",
2227
+ className: "absdk-predicate-deposit-modal__action absdk-predicate-deposit-modal__action--primary",
2228
+ type: "button",
2229
+ onClick: onTransferCrypto,
2230
+ style: {
2231
+ display: "flex",
2232
+ alignItems: "center",
2233
+ gap: isMobile ? 12 : 14,
2234
+ padding: isMobile ? "16px" : "18px 20px",
2235
+ borderRadius: radii2.card,
2236
+ border: `1px solid ${colors2.border}`,
2237
+ background: "transparent",
2238
+ cursor: "pointer",
2239
+ textAlign: "left",
2240
+ fontFamily: fonts2.family,
2241
+ width: "100%",
2242
+ transition: "border-color .15s"
2243
+ },
2244
+ onMouseEnter: (e) => {
2245
+ e.target.closest("button").style.borderColor = colors2.borderStrong;
2246
+ },
2247
+ onMouseLeave: (e) => {
2248
+ e.target.closest("button").style.borderColor = colors2.border;
2249
+ },
2250
+ children: [
2251
+ /* @__PURE__ */ jsx(TransferIcon, {}),
2252
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-deposit-modal__action-copy", style: { flex: 1, display: "flex", flexDirection: "column", gap: 2 }, children: [
2253
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__action-title", style: { color: colors2.textPrimary, fontSize: 16, fontWeight: 600 }, children: "Transfer Crypto" }),
2254
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__action-subtitle", style: { color: colors2.textSecondary, fontSize: 13 }, children: "No limit \xB7 Instant" })
2255
+ ] }),
2256
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__action-trailing", children: cryptoIcons ?? /* @__PURE__ */ jsx(DefaultCryptoIcons, { isMobile }) })
2257
+ ]
2258
+ }
2259
+ ),
2260
+ /* @__PURE__ */ jsxs(
2261
+ "div",
2262
+ {
2263
+ className: "absdk-predicate-deposit-modal__action absdk-predicate-deposit-modal__action--secondary",
2264
+ style: {
2265
+ display: "flex",
2266
+ alignItems: "center",
2267
+ gap: isMobile ? 12 : 14,
2268
+ padding: isMobile ? "16px" : "18px 20px",
2269
+ borderRadius: radii2.card,
2270
+ border: `1px solid ${colors2.border}`,
2271
+ opacity: 0.55
2272
+ },
2273
+ children: [
2274
+ /* @__PURE__ */ jsx(FiatIcon, {}),
2275
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-deposit-modal__action-copy", style: { flex: 1, display: "flex", flexDirection: "column", gap: 2 }, children: [
2276
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__action-title", style: { color: colors2.textSecondary, fontSize: 16, fontWeight: 600 }, children: "Buy Crypto" }),
2277
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__action-subtitle", style: { color: colors2.textSecondary, fontSize: 13 }, children: "Debit card, credit card, ACH" })
2278
+ ] }),
2279
+ /* @__PURE__ */ jsx(
2280
+ "span",
2281
+ {
2282
+ className: "absdk-predicate-deposit-modal__action-badge",
2283
+ style: {
2284
+ padding: "5px 12px",
2285
+ borderRadius: radii2.pill,
2286
+ border: `1px solid ${colors2.border}`,
2287
+ fontSize: 12,
2288
+ fontWeight: 500,
2289
+ color: colors2.textSecondary,
2290
+ whiteSpace: "nowrap"
2291
+ },
2292
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__action-badge-text", children: "Coming Soon" })
2293
+ }
2294
+ )
2295
+ ]
2296
+ }
2297
+ )
2298
+ ] })
2299
+ ]
2300
+ }
2301
+ );
2302
+ var TransferView = ({
2303
+ isMobile,
2304
+ token,
2305
+ chain,
2306
+ tokenOptions,
2307
+ chainOptions,
2308
+ depositAddress,
2309
+ minimumDeposit,
2310
+ qrCenterIcon,
2311
+ quote: quoteData,
2312
+ quoteLoading,
2313
+ txHash,
2314
+ chainIdForExplorer,
2315
+ explorerTxUrl,
2316
+ loadingChains,
2317
+ onTokenSelect,
2318
+ onChainSelect,
2319
+ onCopyAddress,
2320
+ onQuoteExpired,
2321
+ onRefreshQuote,
2322
+ onShowToast,
2323
+ onBack
2324
+ }) => {
2325
+ const activeStep = chain ? 2 : token ? 1 : 0;
2326
+ const stepActive = [!!token, !!chain, !!quoteData];
2327
+ const quoteExpired = useMemo(() => {
2328
+ if (!quoteData?.expires_at) return false;
2329
+ try {
2330
+ return new Date(quoteData.expires_at).getTime() < Date.now();
2331
+ } catch {
2332
+ return false;
2333
+ }
2334
+ }, [quoteData?.expires_at]);
2335
+ const didToastWait = useRef(false);
2336
+ useEffect(() => {
2337
+ if (!depositAddress || !onShowToast || didToastWait.current) return;
2338
+ didToastWait.current = true;
2339
+ onShowToast("Please wait for deposit-address balance to update");
2340
+ }, [depositAddress, onShowToast]);
2341
+ return /* @__PURE__ */ jsxs(
2342
+ "div",
2343
+ {
2344
+ className: "absdk-predicate-deposit-modal__transfer",
2345
+ style: { display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24 },
2346
+ children: [
2347
+ /* @__PURE__ */ jsx(
2348
+ "div",
2349
+ {
2350
+ className: "absdk-predicate-deposit-modal__header",
2351
+ style: { display: "flex", alignItems: "center", justifyContent: "space-between" },
2352
+ children: /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-deposit-modal__header-main", style: { display: "flex", alignItems: "center", gap: 12 }, children: [
2353
+ onBack && /* @__PURE__ */ jsx(
2354
+ "button",
2355
+ {
2356
+ id: "absdk-predicate-deposit-modal-back-button",
2357
+ className: "absdk-predicate-deposit-modal__back-button",
2358
+ type: "button",
2359
+ onClick: onBack,
2360
+ style: {
2361
+ background: "transparent",
2362
+ border: "none",
2363
+ cursor: "pointer",
2364
+ padding: 0,
2365
+ display: "flex",
2366
+ alignItems: "center"
2367
+ },
2368
+ children: /* @__PURE__ */ jsx(BackArrow, {})
2369
+ }
2370
+ ),
2371
+ /* @__PURE__ */ jsx(
2372
+ "h2",
2373
+ {
2374
+ className: "absdk-predicate-deposit-modal__title",
2375
+ style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4 },
2376
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__title-text", children: "Transfer Crypto" })
2377
+ }
2378
+ )
2379
+ ] })
2380
+ }
2381
+ ),
2382
+ /* @__PURE__ */ jsxs(
2383
+ "div",
2384
+ {
2385
+ className: "absdk-predicate-deposit-modal__body",
2386
+ style: { display: "flex", flexDirection: isMobile ? "column" : "row", gap: 16, position: "relative" },
2387
+ children: [
2388
+ /* @__PURE__ */ jsx(
2389
+ StepIndicator,
2390
+ {
2391
+ steps: 3,
2392
+ stepActive,
2393
+ activeStep,
2394
+ orientation: isMobile ? "horizontal" : "vertical"
2395
+ }
2396
+ ),
2397
+ /* @__PURE__ */ jsxs(
2398
+ "div",
2399
+ {
2400
+ className: "absdk-predicate-deposit-modal__form",
2401
+ style: { flex: 1, display: "flex", flexDirection: "column", gap: isMobile ? 24 : 40 },
2402
+ children: [
2403
+ /* @__PURE__ */ jsx(
2404
+ DropdownField,
2405
+ {
2406
+ wrapperClassName: "absdk-predicate-deposit-modal__field absdk-predicate-deposit-modal__field--token",
2407
+ triggerId: "absdk-predicate-deposit-modal-token-select",
2408
+ label: "Select token",
2409
+ placeholder: loadingChains ? "Loading\u2026" : "Token",
2410
+ value: token,
2411
+ options: tokenOptions,
2412
+ onSelect: onTokenSelect
2413
+ }
2414
+ ),
2415
+ /* @__PURE__ */ jsx(
2416
+ DropdownField,
2417
+ {
2418
+ wrapperClassName: "absdk-predicate-deposit-modal__field absdk-predicate-deposit-modal__field--chain",
2419
+ triggerId: "absdk-predicate-deposit-modal-chain-select",
2420
+ label: "Select chain",
2421
+ placeholder: loadingChains ? "Loading\u2026" : "Chain",
2422
+ value: chain,
2423
+ options: chainOptions,
2424
+ onSelect: onChainSelect
2425
+ }
2426
+ ),
2427
+ quoteData && token && chain && /* @__PURE__ */ jsxs(
2428
+ "div",
2429
+ {
2430
+ id: "absdk-predicate-deposit-modal-quote-panel",
2431
+ className: "absdk-predicate-deposit-modal__quote-panel",
2432
+ style: {
2433
+ padding: "12px 16px",
2434
+ borderRadius: radii2.card,
2435
+ margin: "-10px 0",
2436
+ border: `1px solid ${colors2.border}`,
2437
+ display: "flex",
2438
+ flexDirection: "column",
2439
+ gap: 8
2440
+ },
2441
+ children: [
2442
+ /* @__PURE__ */ jsx(
2443
+ "div",
2444
+ {
2445
+ className: "absdk-predicate-deposit-modal__quote-rate-row",
2446
+ style: { minHeight: 18, display: "flex", alignItems: "center" },
2447
+ children: quoteLoading ? /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__quote-loading", style: { fontSize: 13, color: colors2.textSecondary }, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-deposit-modal__quote-rate", style: { fontSize: 13, color: colors2.textSecondary }, children: [
2448
+ "1 ",
2449
+ quoteData.token_symbol,
2450
+ " = ",
2451
+ quoteData.rate,
2452
+ " ",
2453
+ FUNDING_TOKEN_SYMBOL
2454
+ ] })
2455
+ }
2456
+ ),
2457
+ !quoteLoading && /* @__PURE__ */ jsxs(Fragment, { children: [
2458
+ quoteData.expires_at && /* @__PURE__ */ jsx(
2459
+ Countdown,
2460
+ {
2461
+ expiresAt: quoteData.expires_at,
2462
+ isExpired: quoteExpired,
2463
+ onExpired: onQuoteExpired
2464
+ }
2465
+ ),
2466
+ quoteExpired && /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-deposit-modal__quote-expired", style: { display: "flex", alignItems: "center", gap: 8 }, children: [
2467
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__quote-expired-text", style: { fontSize: 13, color: "#f59e0b" }, children: "Quote expired, please refresh" }),
2468
+ onRefreshQuote && /* @__PURE__ */ jsx(
2469
+ "button",
2470
+ {
2471
+ className: "absdk-predicate-deposit-modal__quote-refresh-button",
2472
+ type: "button",
2473
+ onClick: onRefreshQuote,
2474
+ style: {
2475
+ padding: "4px 12px",
2476
+ fontSize: 12,
2477
+ borderRadius: radii2.pill,
2478
+ border: `1px solid ${colors2.border}`,
2479
+ background: "transparent",
2480
+ color: colors2.textPrimary,
2481
+ cursor: "pointer",
2482
+ fontFamily: fonts2.family
2483
+ },
2484
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__quote-refresh-button-label", children: "Refresh" })
2485
+ }
2486
+ )
2487
+ ] })
2488
+ ] })
2489
+ ]
2490
+ }
2491
+ ),
2492
+ /* @__PURE__ */ jsxs(
2493
+ "div",
2494
+ {
2495
+ id: "absdk-predicate-deposit-modal-details",
2496
+ className: "absdk-predicate-deposit-modal__details",
2497
+ style: { display: "flex", flexDirection: "column", gap: 8, marginTop: isMobile ? 0 : "-5px" },
2498
+ children: [
2499
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__details-title", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: "Deposit details" }),
2500
+ depositAddress ? /* @__PURE__ */ jsxs(Fragment, { children: [
2501
+ /* @__PURE__ */ jsx(
2502
+ DepositDetailsPanel,
2503
+ {
2504
+ address: depositAddress,
2505
+ tokenIcon: qrCenterIcon,
2506
+ minimumDeposit,
2507
+ onCopyAddress
2508
+ }
2509
+ ),
2510
+ txHash && chainIdForExplorer && explorerTxUrl && /* @__PURE__ */ jsx(
2511
+ "a",
2512
+ {
2513
+ className: "absdk-predicate-deposit-modal__explorer-link",
2514
+ href: explorerTxUrl(chainIdForExplorer, txHash),
2515
+ target: "_blank",
2516
+ rel: "noopener noreferrer",
2517
+ style: {
2518
+ fontSize: 13,
2519
+ color: colors2.textPrimary,
2520
+ textDecoration: "underline"
2521
+ },
2522
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__explorer-link-text", children: "View on explorer" })
2523
+ }
2524
+ )
2525
+ ] }) : /* @__PURE__ */ jsx(
2526
+ "div",
2527
+ {
2528
+ className: "absdk-predicate-deposit-modal__details-empty",
2529
+ style: {
2530
+ padding: "20px",
2531
+ borderRadius: radii2.card,
2532
+ border: `1px solid ${colors2.border}`,
2533
+ color: colors2.textSecondary,
2534
+ fontSize: 13,
2535
+ textAlign: "center"
2536
+ },
2537
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-deposit-modal__details-empty-text", children: "Select token and chain to view deposit details" })
2538
+ }
2539
+ )
2540
+ ]
2541
+ }
2542
+ )
2543
+ ]
2544
+ }
2545
+ )
2546
+ ]
2547
+ }
2548
+ )
2549
+ ]
2550
+ }
2551
+ );
2552
+ };
2553
+ var SuccessIcon = () => {
2554
+ return /* @__PURE__ */ jsxs("svg", { width: "80", height: "81", viewBox: "0 0 80 81", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2555
+ /* @__PURE__ */ jsx(
2556
+ "path",
2557
+ {
2558
+ 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",
2559
+ fill: "#627EEA"
2560
+ }
2561
+ ),
2562
+ /* @__PURE__ */ jsx(
2563
+ "path",
2564
+ {
2565
+ d: "M38.999 16.5V34.2437L53.9962 40.9451L38.999 16.5Z",
2566
+ fill: "white",
2567
+ fillOpacity: "0.602"
2568
+ }
2569
+ ),
2570
+ /* @__PURE__ */ jsx("path", { d: "M38.9991 16.5L24 40.9451L38.9991 34.2437V16.5Z", fill: "white" }),
2571
+ /* @__PURE__ */ jsx(
2572
+ "path",
2573
+ {
2574
+ d: "M38.999 52.4434V64.4999L54.0061 43.7376L38.999 52.4434Z",
2575
+ fill: "white",
2576
+ fillOpacity: "0.602"
2577
+ }
2578
+ ),
2579
+ /* @__PURE__ */ jsx("path", { d: "M38.9991 64.4999V52.4414L24 43.7376L38.9991 64.4999Z", fill: "white" }),
2580
+ /* @__PURE__ */ jsx(
2581
+ "path",
2582
+ {
2583
+ d: "M38.999 49.653L53.9962 40.9451L38.999 34.2477V49.653Z",
2584
+ fill: "white",
2585
+ fillOpacity: "0.2"
2586
+ }
2587
+ ),
2588
+ /* @__PURE__ */ jsx(
2589
+ "path",
2590
+ {
2591
+ d: "M24 40.9451L38.9991 49.653V34.2477L24 40.9451Z",
2592
+ fill: "white",
2593
+ fillOpacity: "0.602"
2594
+ }
2595
+ ),
2596
+ /* @__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)" }) }),
2597
+ /* @__PURE__ */ jsx(
2598
+ "path",
2599
+ {
2600
+ d: "M25.8057 35.9858L38.7921 49.0324L56.7734 30.9678",
2601
+ stroke: "#58AE36",
2602
+ strokeWidth: "5.16129",
2603
+ fill: "none"
2604
+ }
2605
+ ),
2606
+ /* @__PURE__ */ jsxs("defs", { children: [
2607
+ /* @__PURE__ */ jsxs(
2608
+ "filter",
2609
+ {
2610
+ id: "filter0_ii_34_1690",
2611
+ x: "0",
2612
+ y: "0",
2613
+ width: "80",
2614
+ height: "80",
2615
+ filterUnits: "userSpaceOnUse",
2616
+ colorInterpolationFilters: "sRGB",
2617
+ children: [
2618
+ /* @__PURE__ */ jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
2619
+ /* @__PURE__ */ jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }),
2620
+ /* @__PURE__ */ jsx(
2621
+ "feColorMatrix",
2622
+ {
2623
+ in: "SourceAlpha",
2624
+ type: "matrix",
2625
+ values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
2626
+ result: "hardAlpha"
2627
+ }
2628
+ ),
2629
+ /* @__PURE__ */ jsx("feOffset", { dx: "-1.29032", dy: "-1.29032" }),
2630
+ /* @__PURE__ */ jsx("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
2631
+ /* @__PURE__ */ jsx(
2632
+ "feColorMatrix",
2633
+ {
2634
+ type: "matrix",
2635
+ values: "0 0 0 0 0.584745 0 0 0 0 1 0 0 0 0 0.420982 0 0 0 1 0"
2636
+ }
2637
+ ),
2638
+ /* @__PURE__ */ jsx("feBlend", { mode: "multiply", in2: "shape", result: "effect1_innerShadow_34_1690" }),
2639
+ /* @__PURE__ */ jsx(
2640
+ "feColorMatrix",
2641
+ {
2642
+ in: "SourceAlpha",
2643
+ type: "matrix",
2644
+ values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
2645
+ result: "hardAlpha"
2646
+ }
2647
+ ),
2648
+ /* @__PURE__ */ jsx("feOffset", { dx: "1.29032", dy: "1.29032" }),
2649
+ /* @__PURE__ */ jsx("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
2650
+ /* @__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" }),
2651
+ /* @__PURE__ */ jsx("feBlend", { mode: "normal", in2: "effect1_innerShadow_34_1690", result: "effect2_innerShadow_34_1690" })
2652
+ ]
2653
+ }
2654
+ ),
2655
+ /* @__PURE__ */ jsxs(
2656
+ "linearGradient",
2657
+ {
2658
+ id: "paint0_linear_34_1690",
2659
+ x1: "27.4722",
2660
+ y1: "7.62951",
2661
+ x2: "70.4313",
2662
+ y2: "26.563",
2663
+ gradientUnits: "userSpaceOnUse",
2664
+ children: [
2665
+ /* @__PURE__ */ jsx("stop", { stopColor: "#BBFFA1" }),
2666
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#ACFE8B" })
2667
+ ]
2668
+ }
2669
+ )
2670
+ ] })
2671
+ ] });
2672
+ };
2673
+ function CopyIcon2() {
2674
+ return /* @__PURE__ */ jsxs("svg", { className: "absdk-predicate-withdraw-modal__copy-icon", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, children: [
2675
+ /* @__PURE__ */ jsx("rect", { className: "absdk-predicate-withdraw-modal__copy-icon-rect", x: "5", y: "5", width: "9", height: "9", rx: "1", stroke: "currentColor", strokeWidth: "1.2", fill: "none" }),
2676
+ /* @__PURE__ */ jsx("path", { className: "absdk-predicate-withdraw-modal__copy-icon-path", d: "M3 11V3a1 1 0 0 1 1-1h8", stroke: "currentColor", strokeWidth: "1.2", fill: "none" })
2677
+ ] });
2678
+ }
2679
+ var FUNDING_TOKEN_SYMBOL2 = getEnv("FUNDING_TOKEN_SYMBOL");
2680
+ function chainsToTokenOptions2(chains) {
2681
+ const bySymbol = /* @__PURE__ */ new Map();
2682
+ for (const c of chains) {
2683
+ for (const t of c.tokens) {
2684
+ if (!bySymbol.has(t.symbol)) bySymbol.set(t.symbol, t.symbol);
2685
+ }
2686
+ }
2687
+ return Array.from(bySymbol.entries()).map(([id, symbol]) => ({
2688
+ id,
2689
+ label: symbol,
2690
+ subtitle: symbol
2691
+ }));
2692
+ }
2693
+ function chainsToChainOptionsForToken2(chains, tokenSymbol) {
2694
+ return chains.filter((c) => c.tokens.some((t) => t.symbol === tokenSymbol)).map((c) => ({ id: c.chain_id, label: c.network, subtitle: c.chain_id }));
2695
+ }
2696
+ function getTokenAddressForChain2(chains, chainId, tokenSymbol) {
2697
+ const chain = chains.find((c) => c.chain_id === chainId);
2698
+ return chain?.tokens.find((t) => t.symbol === tokenSymbol)?.address;
2699
+ }
2700
+ function parseBalanceNumber(balance) {
2701
+ const match = balance.trim().match(/^(\d*\.?\d*)/);
2702
+ if (!match) return null;
2703
+ const n = Number(match[1]);
2704
+ return Number.isNaN(n) ? null : n;
2705
+ }
2706
+ function formatBalanceTo2Decimals(balance) {
2707
+ const match = balance.trim().match(/^(\d*\.?\d*)(.*)$/);
2708
+ if (!match) return balance;
2709
+ const numPart = match[1];
2710
+ const suffix = match[2].trim() ? " " + match[2].trim() : "";
2711
+ const n = Number(numPart);
2712
+ if (Number.isNaN(n)) return balance;
2713
+ const formatted = n.toFixed(2);
2714
+ return formatted + suffix;
2715
+ }
2716
+ function weiToEtherDisplay(wei) {
2717
+ const s = (wei || "0").trim().replace(/^0+/, "") || "0";
2718
+ if (s === "0") return "0";
2719
+ const padded = s.padStart(19, "0");
2720
+ const intPart = padded.slice(0, Math.max(0, padded.length - 18));
2721
+ const decPart = padded.slice(-18).replace(/0+$/, "");
2722
+ const combined = decPart ? `${intPart}.${decPart}` : intPart;
2723
+ const num = Number(combined);
2724
+ if (Number.isNaN(num)) return wei;
2725
+ const fixed = num.toFixed(6).replace(/\.?0+$/, "");
2726
+ return fixed;
2727
+ }
2728
+ function findScrollableAncestor(node) {
2729
+ let current = node?.parentElement ?? null;
2730
+ while (current) {
2731
+ if (current.scrollHeight > current.clientHeight + 1) {
2732
+ return current;
2733
+ }
2734
+ current = current.parentElement;
2735
+ }
2736
+ return null;
2737
+ }
2738
+ var POLL_INTERVAL_MS = 4e3;
2739
+ var WithdrawModal = ({
2740
+ address = "",
2741
+ token,
2742
+ tokenSymbol,
2743
+ chain,
2744
+ amount = "",
2745
+ balance,
2746
+ status = "idle",
2747
+ receiveAmount: receiveAmountProp,
2748
+ txHash,
2749
+ tokenOptions: tokenOptionsProp,
2750
+ chainOptions: chainOptionsProp,
2751
+ useMerchantApi = false,
2752
+ orderId,
2753
+ withdrawMode,
2754
+ withdrawDirectResult,
2755
+ feeDisplay,
2756
+ fundingChainId,
2757
+ onShowToast,
2758
+ onAddressChange,
2759
+ onTokenSelect,
2760
+ onChainSelect,
2761
+ onAmountChange,
2762
+ onMaxClick,
2763
+ onSubmit,
2764
+ onWithdrawCompleted,
2765
+ onStartAnotherWithdrawal,
2766
+ onSignIn,
2767
+ onClose
2768
+ }) => {
2769
+ const isMobile = useIsMobileViewport2();
2770
+ const session = useSession();
2771
+ const addressInputRef = useRef(null);
2772
+ const footerRef = useRef(null);
2773
+ const [addressInputFocused, setAddressInputFocused] = useState(false);
2774
+ const [amountInputFocused, setAmountInputFocused] = useState(false);
2775
+ const [apiChains, setApiChains] = useState(null);
2776
+ const [apiQuote, setApiQuote] = useState(null);
2777
+ const [withdrawOrder, setWithdrawOrder] = useState(null);
2778
+ const [loadingChains, setLoadingChains] = useState(false);
2779
+ const [loadingQuote, setLoadingQuote] = useState(false);
2780
+ const tokenOptions = useMemo(() => {
2781
+ const raw = tokenOptionsProp?.length ? tokenOptionsProp : apiChains?.length ? chainsToTokenOptions2(apiChains) : void 0;
2782
+ if (!raw?.length) return void 0;
2783
+ return raw;
2784
+ }, [tokenOptionsProp, apiChains]);
2785
+ const chainOptions = useMemo(() => {
2786
+ if (chainOptionsProp?.length) return chainOptionsProp;
2787
+ if (!apiChains?.length || !token) return void 0;
2788
+ return chainsToChainOptionsForToken2(apiChains, token);
2789
+ }, [chainOptionsProp, apiChains, token]);
2790
+ const resolvedTokenAddress = useMemo(() => {
2791
+ if (!apiChains?.length || !token || !chain) return void 0;
2792
+ return getTokenAddressForChain2(apiChains, chain, token);
2793
+ }, [apiChains, token, chain]);
2794
+ const [directActive, setDirectActive] = useState(false);
2795
+ useEffect(() => {
2796
+ setDirectActive(withdrawMode === "direct" && Boolean(withdrawDirectResult));
2797
+ }, [withdrawMode, withdrawDirectResult]);
2798
+ const trackingWithdraw = useMemo(
2799
+ () => Boolean(orderId) || directActive,
2800
+ [orderId, directActive]
2801
+ );
2802
+ useEffect(() => {
2803
+ if (trackingWithdraw) return;
2804
+ const t = requestAnimationFrame(() => {
2805
+ addressInputRef.current?.focus();
2806
+ });
2807
+ return () => cancelAnimationFrame(t);
2808
+ }, [trackingWithdraw]);
2809
+ const shouldLoadChains = useMerchantApi || Boolean(token && chain);
2810
+ useEffect(() => {
2811
+ if (!shouldLoadChains) return;
2812
+ setLoadingChains(true);
2813
+ getChains().then((res) => setApiChains(res?.chains ?? [])).finally(() => setLoadingChains(false));
2814
+ }, [shouldLoadChains]);
2815
+ useEffect(() => {
2816
+ if (!apiChains?.length || !token || !chain) {
2817
+ setApiQuote(null);
2818
+ return;
2819
+ }
2820
+ const tokenAddress = getTokenAddressForChain2(apiChains, chain, token);
2821
+ if (!tokenAddress) {
2822
+ setApiQuote(null);
2823
+ return;
2824
+ }
2825
+ const amountNum = amount && Number(amount) > 0 ? Number(amount) : 1;
2826
+ const amountWei = String(BigInt(Math.floor(amountNum * 1e18)));
2827
+ setLoadingQuote(true);
2828
+ quote({
2829
+ direction: "withdraw",
2830
+ chain_id: chain,
2831
+ token_address: tokenAddress,
2832
+ dst_token_amount: amountWei
2833
+ }).then((q) => setApiQuote(q ?? null)).catch(() => {
2834
+ setApiQuote({
2835
+ token_address: tokenAddress,
2836
+ token_symbol: token,
2837
+ token_decimals: 18,
2838
+ rate: "1",
2839
+ chain_id: Number(chain) || 56,
2840
+ token_amount: amountWei,
2841
+ expires_at: new Date(Date.now() + 6e4).toISOString()
2842
+ });
2843
+ }).finally(() => setLoadingQuote(false));
2844
+ }, [apiChains, token, chain, amount]);
2845
+ useEffect(() => {
2846
+ if (tokenOptions?.length !== 1 || !onTokenSelect) return;
2847
+ const onlyId = tokenOptions[0].id;
2848
+ if (token === onlyId) return;
2849
+ onTokenSelect(onlyId);
2850
+ }, [tokenOptions, token, onTokenSelect]);
2851
+ useEffect(() => {
2852
+ if (chainOptions?.length !== 1 || !onChainSelect) return;
2853
+ const onlyId = chainOptions[0].id;
2854
+ if (chain === onlyId) return;
2855
+ onChainSelect(onlyId);
2856
+ }, [chainOptions, chain, onChainSelect]);
2857
+ const mockWithdrawOrderState = useMemo(
2858
+ () => ({
2859
+ order_id: orderId ?? "",
2860
+ status: "pending",
2861
+ chain_id: "56",
2862
+ dst_token_amount: "0",
2863
+ target_chain_id: chain ?? "1",
2864
+ target_address: address ?? "0x",
2865
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2866
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
2867
+ }),
2868
+ [orderId, chain, address]
2869
+ );
2870
+ useEffect(() => {
2871
+ if (orderId) {
2872
+ const t = setInterval(() => {
2873
+ getWithdrawOrder(orderId).then((order) => {
2874
+ setWithdrawOrder(order);
2875
+ }).catch(() => setWithdrawOrder(mockWithdrawOrderState));
2876
+ }, POLL_INTERVAL_MS);
2877
+ getWithdrawOrder(orderId).then(setWithdrawOrder).catch(() => setWithdrawOrder(mockWithdrawOrderState));
2878
+ return () => clearInterval(t);
2879
+ }
2880
+ if (!orderId && directActive) {
2881
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2882
+ const inferredAmountWei = (() => {
2883
+ if (withdrawDirectResult?.dst_token_amount) return withdrawDirectResult.dst_token_amount;
2884
+ const n = Number(amount || "0");
2885
+ return String(n > 0 ? BigInt(Math.floor(n * 1e18)) : 0n);
2886
+ })();
2887
+ const synthetic = {
2888
+ order_id: withdrawDirectResult?.order_id ?? `direct-${Date.now()}`,
2889
+ status: withdrawDirectResult?.status ?? "pending",
2890
+ chain_id: withdrawDirectResult?.chain_id ?? String(fundingChainId ?? "3131"),
2891
+ dst_token_amount: inferredAmountWei,
2892
+ fee: withdrawDirectResult?.fee ?? feeDisplay,
2893
+ target_chain_id: withdrawDirectResult?.target_chain_id ?? (chain ?? ""),
2894
+ target_address: withdrawDirectResult?.target_address ?? (address ?? ""),
2895
+ funding_tx_hash: withdrawDirectResult?.funding_tx_hash ?? txHash,
2896
+ dst_tx_hash: withdrawDirectResult?.dst_tx_hash,
2897
+ out_tx_hash: withdrawDirectResult?.out_tx_hash,
2898
+ created_at: withdrawDirectResult?.created_at ?? now,
2899
+ updated_at: withdrawDirectResult?.updated_at ?? now,
2900
+ one_time_address: withdrawDirectResult?.one_time_address
2901
+ };
2902
+ setWithdrawOrder(synthetic);
2903
+ return;
2904
+ }
2905
+ setWithdrawOrder(null);
2906
+ }, [orderId, directActive, withdrawDirectResult, amount, feeDisplay, chain, address, txHash, fundingChainId, onShowToast, mockWithdrawOrderState]);
2907
+ const completedKeyRef = useRef(null);
2908
+ const successToastKeyRef = useRef(null);
2909
+ useEffect(() => {
2910
+ if (withdrawOrder?.status !== "completed") return;
2911
+ const key = orderId ?? withdrawOrder.order_id;
2912
+ if (key && completedKeyRef.current !== key) {
2913
+ completedKeyRef.current = key;
2914
+ onWithdrawCompleted?.();
2915
+ }
2916
+ if (!trackingWithdraw) completedKeyRef.current = null;
2917
+ }, [withdrawOrder?.status, orderId, trackingWithdraw, onWithdrawCompleted]);
2918
+ useEffect(() => {
2919
+ if (!withdrawOrder || withdrawOrder.status !== "completed") return;
2920
+ const key = orderId ?? withdrawOrder.order_id;
2921
+ if (!key) return;
2922
+ if (successToastKeyRef.current === key) return;
2923
+ successToastKeyRef.current = key;
2924
+ onShowToast?.("Withdrawal completed");
2925
+ }, [withdrawOrder, orderId, onShowToast]);
2926
+ useEffect(() => {
2927
+ if (!trackingWithdraw) successToastKeyRef.current = null;
2928
+ }, [trackingWithdraw]);
2929
+ const receiveAmount = useMemo(() => {
2930
+ if (receiveAmountProp) {
2931
+ const n = Number(receiveAmountProp);
2932
+ if (!Number.isNaN(n)) return n.toFixed(2);
2933
+ return receiveAmountProp;
2934
+ }
2935
+ if (!apiQuote?.token_amount || !apiQuote?.token_symbol) return void 0;
2936
+ const amount2 = Number(apiQuote.token_amount);
2937
+ const formatted = Number.isNaN(amount2) ? apiQuote.token_amount : amount2.toFixed(2);
2938
+ return `\u2248 ${formatted} (wei) ${apiQuote.token_symbol}`;
2939
+ }, [receiveAmountProp, apiQuote]);
2940
+ const quoteExpired = useMemo(() => {
2941
+ if (!apiQuote?.expires_at) return false;
2942
+ try {
2943
+ return new Date(apiQuote.expires_at).getTime() < Date.now();
2944
+ } catch {
2945
+ return false;
2946
+ }
2947
+ }, [apiQuote?.expires_at]);
2948
+ const handleRefreshQuote = useCallback(() => {
2949
+ if (!apiChains?.length || !token || !chain) return;
2950
+ const tokenAddress = getTokenAddressForChain2(apiChains, chain, token);
2951
+ if (!tokenAddress) return;
2952
+ const amountNum = amount && Number(amount) > 0 ? Number(amount) : 1;
2953
+ const amountWei = String(BigInt(Math.floor(amountNum * 1e18)));
2954
+ setLoadingQuote(true);
2955
+ quote({
2956
+ direction: "withdraw",
2957
+ chain_id: chain,
2958
+ token_address: tokenAddress,
2959
+ dst_token_amount: amountWei
2960
+ }).then((q) => setApiQuote(q ?? null)).catch(() => {
2961
+ setApiQuote({
2962
+ token_address: tokenAddress,
2963
+ token_symbol: token,
2964
+ token_decimals: 18,
2965
+ rate: "1",
2966
+ chain_id: Number(chain) || 56,
2967
+ token_amount: amountWei,
2968
+ expires_at: new Date(Date.now() + 6e4).toISOString()
2969
+ });
2970
+ }).finally(() => setLoadingQuote(false));
2971
+ }, [apiChains, token, chain, amount]);
2972
+ const handleAmountChange = useCallback(
2973
+ (e) => {
2974
+ const raw = e.target.value;
2975
+ const maxNum = balance ? parseBalanceNumber(balance) : null;
2976
+ if (maxNum != null && raw !== "" && raw !== ".") {
2977
+ const num = Number(raw);
2978
+ if (!Number.isNaN(num) && num > maxNum) {
2979
+ onAmountChange?.({
2980
+ ...e,
2981
+ target: { ...e.target, value: String(maxNum) }
2982
+ });
2983
+ return;
2984
+ }
2985
+ }
2986
+ onAmountChange?.(e);
2987
+ },
2988
+ [balance, onAmountChange]
2989
+ );
2990
+ if (!session) {
2991
+ return /* @__PURE__ */ jsx(LoginRequiredOverlay, { title: "Withdraw", onSignIn, onClose });
2992
+ }
2993
+ const activeStep = amount ? 3 : chain ? 2 : token ? 1 : address ? 0 : 0;
2994
+ const canSubmit = address && token && chain && amount;
2995
+ const isSubmitting = status !== "idle";
2996
+ const orderInProgress = trackingWithdraw && (!withdrawOrder || withdrawOrder.status !== "completed");
2997
+ const orderSucceeded = trackingWithdraw && withdrawOrder?.status === "completed";
2998
+ useEffect(() => {
2999
+ if (trackingWithdraw) return;
3000
+ if (!amount || Number(amount) <= 0) return;
3001
+ const frame = requestAnimationFrame(() => {
3002
+ const footer = footerRef.current;
3003
+ if (!footer) return;
3004
+ const scrollableAncestor = findScrollableAncestor(footer);
3005
+ if (!scrollableAncestor) return;
3006
+ scrollableAncestor.scrollTo({
3007
+ top: scrollableAncestor.scrollHeight,
3008
+ behavior: "smooth"
3009
+ });
3010
+ });
3011
+ return () => cancelAnimationFrame(frame);
3012
+ }, [amount, receiveAmount, trackingWithdraw]);
3013
+ return /* @__PURE__ */ jsxs(
3014
+ ModalFrame2,
3015
+ {
3016
+ onClose,
3017
+ contentStyle: {
3018
+ justifyContent: "space-between",
3019
+ padding: isMobile ? "20px 16px" : "24px"
3020
+ },
3021
+ children: [
3022
+ /* @__PURE__ */ jsxs(
3023
+ "div",
3024
+ {
3025
+ id: "absdk-predicate-withdraw-modal",
3026
+ className: `absdk-predicate-withdraw-modal ${isMobile ? "absdk-predicate-withdraw-modal--mobile" : "absdk-predicate-withdraw-modal--desktop"}`,
3027
+ style: { display: "flex", flexDirection: "column", gap: isMobile ? 24 : 32 },
3028
+ children: [
3029
+ /* @__PURE__ */ jsx(
3030
+ "div",
3031
+ {
3032
+ className: "absdk-predicate-withdraw-modal__header",
3033
+ style: { display: "flex", alignItems: "center", justifyContent: "space-between" },
3034
+ children: /* @__PURE__ */ jsx(
3035
+ "h2",
3036
+ {
3037
+ className: "absdk-predicate-withdraw-modal__title",
3038
+ style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4 },
3039
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__title-text", children: "Withdraw" })
3040
+ }
3041
+ )
3042
+ }
3043
+ ),
3044
+ /* @__PURE__ */ jsxs(
3045
+ "div",
3046
+ {
3047
+ className: "absdk-predicate-withdraw-modal__body",
3048
+ style: { display: "flex", flexDirection: isMobile ? "column" : "row", gap: 16 },
3049
+ children: [
3050
+ /* @__PURE__ */ jsx(
3051
+ "div",
3052
+ {
3053
+ className: "absdk-predicate-withdraw-modal__steps",
3054
+ style: {
3055
+ opacity: trackingWithdraw ? 0 : 1,
3056
+ maxWidth: trackingWithdraw ? 0 : isMobile ? 999 : 48,
3057
+ overflow: "hidden",
3058
+ transition: "opacity 0.3s ease, max-width 0.35s ease"
3059
+ },
3060
+ children: /* @__PURE__ */ jsx(
3061
+ StepIndicator,
3062
+ {
3063
+ steps: 4,
3064
+ stepActive: [!!address, !!token, !!chain, !!apiQuote],
3065
+ activeStep,
3066
+ orientation: isMobile ? "horizontal" : "vertical"
3067
+ }
3068
+ )
3069
+ }
3070
+ ),
3071
+ /* @__PURE__ */ jsxs(
3072
+ "div",
3073
+ {
3074
+ className: "absdk-predicate-withdraw-modal__content",
3075
+ style: { flex: 1, position: "relative", minHeight: isMobile ? 320 : 400 },
3076
+ children: [
3077
+ /* @__PURE__ */ jsxs(
3078
+ "div",
3079
+ {
3080
+ className: "absdk-predicate-withdraw-modal__tracking",
3081
+ style: {
3082
+ position: "absolute",
3083
+ inset: 0,
3084
+ display: "flex",
3085
+ flexDirection: "column",
3086
+ alignItems: "center",
3087
+ justifyContent: "center",
3088
+ gap: 12,
3089
+ padding: "0 16px",
3090
+ opacity: trackingWithdraw ? 1 : 0,
3091
+ maxHeight: trackingWithdraw ? 400 : 0,
3092
+ overflow: "hidden",
3093
+ pointerEvents: trackingWithdraw ? "auto" : "none",
3094
+ transition: "opacity 0.3s ease, max-height 0.35s ease"
3095
+ },
3096
+ children: [
3097
+ orderInProgress && /* @__PURE__ */ jsxs(
3098
+ "div",
3099
+ {
3100
+ id: "absdk-predicate-withdraw-modal-processing",
3101
+ className: "absdk-predicate-withdraw-modal__processing",
3102
+ style: {
3103
+ display: "flex",
3104
+ flexDirection: "column",
3105
+ alignItems: "center",
3106
+ justifyContent: "center",
3107
+ gap: 32
3108
+ },
3109
+ children: [
3110
+ /* @__PURE__ */ jsx(
3111
+ "span",
3112
+ {
3113
+ className: "absdk-predicate-withdraw-modal__processing-spinner",
3114
+ style: {
3115
+ display: "inline-block",
3116
+ width: 60,
3117
+ height: 60,
3118
+ border: `3px solid ${colors2.border}`,
3119
+ borderTopColor: colors2.textPrimary,
3120
+ borderRadius: "50%",
3121
+ animation: "withdraw-modal-spin 0.8s linear infinite"
3122
+ },
3123
+ "aria-hidden": true
3124
+ }
3125
+ ),
3126
+ /* @__PURE__ */ jsx(
3127
+ "span",
3128
+ {
3129
+ className: "absdk-predicate-withdraw-modal__processing-text",
3130
+ style: {
3131
+ fontSize: 20,
3132
+ fontWeight: 600,
3133
+ color: colors2.textPrimary,
3134
+ textAlign: "center",
3135
+ fontFamily: fonts2.family,
3136
+ lineHeight: 1.4
3137
+ },
3138
+ children: "Processing withdrawal..."
3139
+ }
3140
+ )
3141
+ ]
3142
+ }
3143
+ ),
3144
+ orderSucceeded && (() => {
3145
+ const destTxHash = withdrawOrder.dst_tx_hash ?? withdrawOrder.out_tx_hash;
3146
+ const targetChainName = apiChains?.find((c) => c.chain_id === withdrawOrder.target_chain_id)?.network ?? withdrawOrder.target_chain_id ?? "\u2014";
3147
+ const explorerUrl = destTxHash && withdrawOrder.target_chain_id ? getExplorerUrl(withdrawOrder.target_chain_id, { txId: destTxHash }) : null;
3148
+ const copyHash = () => {
3149
+ if (destTxHash && typeof navigator?.clipboard?.writeText === "function") {
3150
+ navigator.clipboard.writeText(destTxHash);
3151
+ onShowToast?.("Copied");
3152
+ }
3153
+ };
3154
+ return /* @__PURE__ */ jsxs(
3155
+ "div",
3156
+ {
3157
+ id: "absdk-predicate-withdraw-modal-success",
3158
+ className: "absdk-predicate-withdraw-modal__success",
3159
+ style: {
3160
+ display: "flex",
3161
+ flexDirection: "column",
3162
+ alignItems: "center",
3163
+ gap: 20,
3164
+ width: "100%",
3165
+ maxWidth: 412
3166
+ },
3167
+ children: [
3168
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__success-header", style: { display: "flex", flexDirection: "column", alignItems: "center", gap: isMobile ? 6 : 24 }, children: [
3169
+ /* @__PURE__ */ jsx(
3170
+ "span",
3171
+ {
3172
+ className: "absdk-predicate-withdraw-modal__success-icon",
3173
+ style: {
3174
+ display: "flex",
3175
+ alignItems: "center",
3176
+ justifyContent: "center",
3177
+ width: isMobile ? 48 : 60,
3178
+ height: isMobile ? 48 : 60,
3179
+ borderRadius: "50%",
3180
+ color: "#22c55e",
3181
+ fontSize: isMobile ? 32 : 40,
3182
+ lineHeight: 1,
3183
+ fontWeight: 700
3184
+ },
3185
+ "aria-hidden": true,
3186
+ children: /* @__PURE__ */ jsx(SuccessIcon, {})
3187
+ }
3188
+ ),
3189
+ /* @__PURE__ */ jsx(
3190
+ "span",
3191
+ {
3192
+ className: "absdk-predicate-withdraw-modal__success-title",
3193
+ style: {
3194
+ fontSize: 20,
3195
+ fontWeight: 600,
3196
+ color: colors2.textPrimary,
3197
+ textAlign: "center",
3198
+ fontFamily: fonts2.family,
3199
+ lineHeight: 1.4
3200
+ },
3201
+ children: "Withdrawal successful"
3202
+ }
3203
+ )
3204
+ ] }),
3205
+ /* @__PURE__ */ jsxs(
3206
+ "div",
3207
+ {
3208
+ className: "absdk-predicate-withdraw-modal__summary",
3209
+ style: {
3210
+ display: "flex",
3211
+ flexDirection: "column",
3212
+ gap: isMobile ? 2 : 4,
3213
+ width: "100%"
3214
+ },
3215
+ children: [
3216
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__summary-row absdk-predicate-withdraw-modal__summary-row--amount", style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: isMobile ? "6px 0" : "8px 0", height: isMobile ? 29 : 36 }, children: [
3217
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__summary-label", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Amount" }),
3218
+ /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-withdraw-modal__summary-value", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: [
3219
+ weiToEtherDisplay(withdrawOrder.dst_token_amount),
3220
+ " ",
3221
+ tokenSymbol
3222
+ ] })
3223
+ ] }),
3224
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__summary-row absdk-predicate-withdraw-modal__summary-row--fee", style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: isMobile ? "6px 0" : "8px 0", height: isMobile ? 29 : 36 }, children: [
3225
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__summary-label", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Fee" }),
3226
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__summary-value", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: withdrawOrder.fee ?? feeDisplay ?? "\u2014" })
3227
+ ] }),
3228
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__summary-row absdk-predicate-withdraw-modal__summary-row--network", style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: isMobile ? "6px 0" : "8px 0", height: isMobile ? 29 : 36 }, children: [
3229
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__summary-label", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Network" }),
3230
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__summary-value", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: targetChainName })
3231
+ ] }),
3232
+ destTxHash && /* @__PURE__ */ jsxs(
3233
+ "div",
3234
+ {
3235
+ className: "absdk-predicate-withdraw-modal__summary-row absdk-predicate-withdraw-modal__summary-row--hash",
3236
+ style: {
3237
+ display: "flex",
3238
+ justifyContent: "space-between",
3239
+ alignItems: isMobile ? "flex-start" : "center",
3240
+ flexDirection: "row",
3241
+ gap: isMobile ? 8 : 0,
3242
+ padding: isMobile ? "6px 0" : "8px 0",
3243
+ minHeight: 38
3244
+ },
3245
+ children: [
3246
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__summary-label", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textSecondary }, children: "Transaction" }),
3247
+ /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__transaction", style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }, children: [
3248
+ explorerUrl ? /* @__PURE__ */ jsx(
3249
+ "a",
3250
+ {
3251
+ className: "absdk-predicate-withdraw-modal__transaction-link",
3252
+ href: explorerUrl,
3253
+ target: "_blank",
3254
+ rel: "noopener noreferrer",
3255
+ style: {
3256
+ fontSize: 14,
3257
+ color: colors2.textPrimary,
3258
+ textDecoration: "underline",
3259
+ whiteSpace: "nowrap"
3260
+ },
3261
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__transaction-text", children: isMobile ? `${destTxHash.slice(0, 6)}...${destTxHash.slice(-4)}` : `${destTxHash.slice(0, 10)}...${destTxHash.slice(-8)}` })
3262
+ }
3263
+ ) : /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__transaction-text", style: { fontSize: 14, color: colors2.textPrimary, whiteSpace: "nowrap" }, children: isMobile ? `${destTxHash.slice(0, 6)}...${destTxHash.slice(-4)}` : `${destTxHash.slice(0, 10)}...${destTxHash.slice(-8)}` }),
3264
+ /* @__PURE__ */ jsx(
3265
+ "button",
3266
+ {
3267
+ className: "absdk-predicate-withdraw-modal__transaction-copy-button",
3268
+ type: "button",
3269
+ onClick: copyHash,
3270
+ "aria-label": "Copy hash",
3271
+ style: {
3272
+ padding: 0,
3273
+ border: "none",
3274
+ background: "transparent",
3275
+ color: colors2.textPrimary,
3276
+ cursor: "pointer",
3277
+ display: "flex",
3278
+ alignItems: "center",
3279
+ justifyContent: "center",
3280
+ width: 16,
3281
+ height: 16
3282
+ },
3283
+ children: /* @__PURE__ */ jsx(CopyIcon2, {})
3284
+ }
3285
+ )
3286
+ ] })
3287
+ ]
3288
+ }
3289
+ )
3290
+ ]
3291
+ }
3292
+ ),
3293
+ /* @__PURE__ */ jsx("div", { style: { paddingTop: isMobile ? 14 : 24, width: "100%", display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsx(
3294
+ "button",
3295
+ {
3296
+ id: "absdk-predicate-withdraw-modal-reset-button",
3297
+ className: "absdk-predicate-withdraw-modal__reset-button",
3298
+ type: "button",
3299
+ onClick: () => {
3300
+ setDirectActive(false);
3301
+ setWithdrawOrder(null);
3302
+ (onStartAnotherWithdrawal ?? onClose)?.();
3303
+ },
3304
+ style: {
3305
+ width: isMobile ? "100%" : 274,
3306
+ padding: "12px 0",
3307
+ borderRadius: radii2.full,
3308
+ border: `1px solid ${colors2.buttonDisabledBorder}`,
3309
+ background: colors2.textPrimary,
3310
+ color: "#121214",
3311
+ fontSize: 16,
3312
+ fontWeight: 500,
3313
+ lineHeight: 1.4,
3314
+ fontFamily: fonts2.family,
3315
+ cursor: "pointer",
3316
+ textAlign: "center"
3317
+ },
3318
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__reset-button-label", children: "Start another withdrawal" })
3319
+ }
3320
+ ) })
3321
+ ]
3322
+ }
3323
+ );
3324
+ })()
3325
+ ]
3326
+ }
3327
+ ),
3328
+ /* @__PURE__ */ jsx(
3329
+ "div",
3330
+ {
3331
+ className: "absdk-predicate-withdraw-modal__form-state",
3332
+ style: {
3333
+ opacity: trackingWithdraw ? 0 : 1,
3334
+ maxHeight: trackingWithdraw ? 0 : 1200,
3335
+ overflow: "hidden",
3336
+ pointerEvents: trackingWithdraw ? "none" : "auto",
3337
+ transition: "opacity 0.3s ease, max-height 0.35s ease"
3338
+ },
3339
+ children: /* @__PURE__ */ jsxs(
3340
+ "div",
3341
+ {
3342
+ className: "absdk-predicate-withdraw-modal__form",
3343
+ style: { display: "flex", flexDirection: "column", gap: isMobile ? 24 : 40 },
3344
+ children: [
3345
+ /* @__PURE__ */ jsxs(
3346
+ "div",
3347
+ {
3348
+ className: "absdk-predicate-withdraw-modal__field absdk-predicate-withdraw-modal__field--address",
3349
+ style: { display: "flex", flexDirection: "column", gap: 8, width: "100%" },
3350
+ children: [
3351
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__field-label", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: "Recipient address" }),
3352
+ /* @__PURE__ */ jsx(
3353
+ "div",
3354
+ {
3355
+ className: "absdk-predicate-withdraw-modal__input-shell absdk-predicate-withdraw-modal__input-shell--address",
3356
+ style: {
3357
+ display: "flex",
3358
+ alignItems: "center",
3359
+ height: 44,
3360
+ padding: "0 16px",
3361
+ borderRadius: radii2.input,
3362
+ border: `1px solid ${addressInputFocused ? colors2.borderFocused : colors2.border}`,
3363
+ boxSizing: "border-box"
3364
+ },
3365
+ children: /* @__PURE__ */ jsx(
3366
+ "input",
3367
+ {
3368
+ id: "absdk-predicate-withdraw-modal-address-input",
3369
+ className: "absdk-predicate-withdraw-modal__input absdk-predicate-withdraw-modal__input--address",
3370
+ ref: addressInputRef,
3371
+ value: address,
3372
+ onChange: onAddressChange,
3373
+ readOnly: !onAddressChange,
3374
+ onFocus: () => setAddressInputFocused(true),
3375
+ onBlur: () => setAddressInputFocused(false),
3376
+ spellCheck: false,
3377
+ placeholder: "0x",
3378
+ style: {
3379
+ flex: 1,
3380
+ border: "none",
3381
+ outline: "none",
3382
+ background: "transparent",
3383
+ color: colors2.textPrimary,
3384
+ fontSize: 14,
3385
+ fontFamily: fonts2.family,
3386
+ lineHeight: 1.4,
3387
+ padding: 0
3388
+ }
3389
+ }
3390
+ )
3391
+ }
3392
+ )
3393
+ ]
3394
+ }
3395
+ ),
3396
+ /* @__PURE__ */ jsx(
3397
+ DropdownField,
3398
+ {
3399
+ wrapperClassName: "absdk-predicate-withdraw-modal__field absdk-predicate-withdraw-modal__field--token",
3400
+ triggerClassName: "absdk-predicate-withdraw-modal__select-trigger absdk-predicate-withdraw-modal__select-trigger--token",
3401
+ triggerId: "absdk-predicate-withdraw-modal-token-select",
3402
+ label: "Select token",
3403
+ placeholder: loadingChains ? "Loading\u2026" : "Token",
3404
+ value: token,
3405
+ options: tokenOptions,
3406
+ onSelect: onTokenSelect
3407
+ }
3408
+ ),
3409
+ /* @__PURE__ */ jsx(
3410
+ DropdownField,
3411
+ {
3412
+ wrapperClassName: "absdk-predicate-withdraw-modal__field absdk-predicate-withdraw-modal__field--chain",
3413
+ triggerClassName: "absdk-predicate-withdraw-modal__select-trigger absdk-predicate-withdraw-modal__select-trigger--chain",
3414
+ triggerId: "absdk-predicate-withdraw-modal-chain-select",
3415
+ label: "Select chain",
3416
+ placeholder: loadingChains ? "Loading\u2026" : "Chain",
3417
+ value: chain,
3418
+ options: chainOptions,
3419
+ onSelect: onChainSelect
3420
+ }
3421
+ ),
3422
+ apiQuote && token && chain && /* @__PURE__ */ jsxs(
3423
+ "div",
3424
+ {
3425
+ id: "absdk-predicate-withdraw-modal-quote-panel",
3426
+ className: "absdk-predicate-withdraw-modal__quote-panel",
3427
+ style: {
3428
+ padding: "12px 16px",
3429
+ borderRadius: radii2.card,
3430
+ border: `1px solid ${colors2.border}`,
3431
+ display: "flex",
3432
+ flexDirection: "column",
3433
+ gap: 8
3434
+ },
3435
+ children: [
3436
+ /* @__PURE__ */ jsx(
3437
+ "div",
3438
+ {
3439
+ className: "absdk-predicate-withdraw-modal__quote-rate-row",
3440
+ style: { minHeight: 18, display: "flex", alignItems: "center" },
3441
+ children: loadingQuote ? /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__quote-loading", style: { fontSize: 13, color: colors2.textSecondary }, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-withdraw-modal__quote-rate", style: { fontSize: 13, color: colors2.textSecondary }, children: [
3442
+ "Rate: 1 ",
3443
+ FUNDING_TOKEN_SYMBOL2,
3444
+ " = ",
3445
+ apiQuote.rate,
3446
+ " ",
3447
+ apiQuote.token_symbol
3448
+ ] })
3449
+ }
3450
+ ),
3451
+ !loadingQuote && /* @__PURE__ */ jsxs(Fragment, { children: [
3452
+ apiQuote.expires_at && /* @__PURE__ */ jsx(
3453
+ Countdown,
3454
+ {
3455
+ expiresAt: apiQuote.expires_at,
3456
+ isExpired: quoteExpired,
3457
+ onExpired: handleRefreshQuote
3458
+ }
3459
+ ),
3460
+ quoteExpired && /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__quote-expired", style: { display: "flex", alignItems: "center", gap: 8 }, children: [
3461
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__quote-expired-text", style: { fontSize: 13, color: "#f59e0b" }, children: "Quote expired, please refresh" }),
3462
+ /* @__PURE__ */ jsx(
3463
+ "button",
3464
+ {
3465
+ className: "absdk-predicate-withdraw-modal__quote-refresh-button",
3466
+ type: "button",
3467
+ onClick: handleRefreshQuote,
3468
+ style: {
3469
+ padding: "4px 12px",
3470
+ fontSize: 12,
3471
+ borderRadius: radii2.pill,
3472
+ border: `1px solid ${colors2.border}`,
3473
+ background: "transparent",
3474
+ color: colors2.textPrimary,
3475
+ cursor: "pointer",
3476
+ fontFamily: fonts2.family
3477
+ },
3478
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__quote-refresh-button-label", children: "Refresh" })
3479
+ }
3480
+ )
3481
+ ] })
3482
+ ] })
3483
+ ]
3484
+ }
3485
+ ),
3486
+ /* @__PURE__ */ jsx("div", { className: "absdk-predicate-withdraw-modal__amount-section", style: { display: "flex", flexDirection: "column", gap: 16 }, children: /* @__PURE__ */ jsxs("div", { className: "absdk-predicate-withdraw-modal__amount-field", style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
3487
+ /* @__PURE__ */ jsxs(
3488
+ "div",
3489
+ {
3490
+ className: "absdk-predicate-withdraw-modal__amount-header",
3491
+ style: {
3492
+ display: "flex",
3493
+ justifyContent: "space-between",
3494
+ alignItems: isMobile ? "flex-start" : "center",
3495
+ flexDirection: isMobile ? "column" : "row",
3496
+ gap: isMobile ? 4 : 0
3497
+ },
3498
+ children: [
3499
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__field-label", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary }, children: "Amount" }),
3500
+ balance && /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-withdraw-modal__balance", style: { fontSize: 13, lineHeight: 1.2, color: colors2.textSecondary }, children: [
3501
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__balance-label", children: "Balance:" }),
3502
+ " ",
3503
+ /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-withdraw-modal__balance-value", children: [
3504
+ formatBalanceTo2Decimals(balance),
3505
+ " ",
3506
+ FUNDING_TOKEN_SYMBOL2
3507
+ ] })
3508
+ ] })
3509
+ ]
3510
+ }
3511
+ ),
3512
+ /* @__PURE__ */ jsxs(
3513
+ "div",
3514
+ {
3515
+ className: "absdk-predicate-withdraw-modal__input-shell absdk-predicate-withdraw-modal__input-shell--amount",
3516
+ style: {
3517
+ display: "flex",
3518
+ alignItems: "center",
3519
+ justifyContent: "space-between",
3520
+ height: 48,
3521
+ padding: "0 16px",
3522
+ borderRadius: radii2.input,
3523
+ border: `1px solid ${amountInputFocused ? colors2.borderFocused : colors2.border}`,
3524
+ boxSizing: "border-box"
3525
+ },
3526
+ children: [
3527
+ /* @__PURE__ */ jsx(
3528
+ "input",
3529
+ {
3530
+ id: "absdk-predicate-withdraw-modal-amount-input",
3531
+ className: "absdk-predicate-withdraw-modal__input absdk-predicate-withdraw-modal__input--amount",
3532
+ value: amount,
3533
+ onChange: handleAmountChange,
3534
+ onFocus: () => setAmountInputFocused(true),
3535
+ onBlur: () => setAmountInputFocused(false),
3536
+ placeholder: "0.00",
3537
+ type: "text",
3538
+ inputMode: "decimal",
3539
+ style: {
3540
+ flex: 1,
3541
+ border: "none",
3542
+ outline: "none",
3543
+ background: "transparent",
3544
+ color: amount ? colors2.textPrimary : colors2.textSecondary,
3545
+ fontSize: 14,
3546
+ fontFamily: fonts2.family,
3547
+ lineHeight: 1.4,
3548
+ padding: 0
3549
+ }
3550
+ }
3551
+ ),
3552
+ /* @__PURE__ */ jsx("div", { className: "absdk-predicate-withdraw-modal__input-actions", style: { display: "flex", alignItems: "center", gap: 8 }, children: /* @__PURE__ */ jsx(
3553
+ "button",
3554
+ {
3555
+ id: "absdk-predicate-withdraw-modal-max-button",
3556
+ className: "absdk-predicate-withdraw-modal__max-button",
3557
+ type: "button",
3558
+ onClick: onMaxClick,
3559
+ style: {
3560
+ background: colors2.textPrimary,
3561
+ border: "none",
3562
+ borderRadius: radii2.pill,
3563
+ padding: "2px 8px",
3564
+ fontSize: 12,
3565
+ lineHeight: 1.4,
3566
+ fontWeight: 400,
3567
+ color: "#15181D",
3568
+ fontFamily: fonts2.family,
3569
+ cursor: "pointer"
3570
+ },
3571
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__max-button-label", children: "Max" })
3572
+ }
3573
+ ) })
3574
+ ]
3575
+ }
3576
+ )
3577
+ ] }) })
3578
+ ]
3579
+ }
3580
+ )
3581
+ }
3582
+ )
3583
+ ]
3584
+ }
3585
+ )
3586
+ ]
3587
+ }
3588
+ ),
3589
+ !orderSucceeded && /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-withdraw-modal__receive-amount", style: { fontSize: 14, lineHeight: 1.4, color: colors2.textPrimary, opacity: !trackingWithdraw && amount && Number(amount) > 0 ? 1 : 0 }, children: [
3590
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__receive-amount-label", children: "You will receive :" }),
3591
+ " ",
3592
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__receive-amount-value", children: receiveAmount })
3593
+ ] })
3594
+ ]
3595
+ }
3596
+ ),
3597
+ /* @__PURE__ */ jsxs(
3598
+ "div",
3599
+ {
3600
+ id: "absdk-predicate-withdraw-modal-receive-amount",
3601
+ className: "absdk-predicate-withdraw-modal__footer",
3602
+ ref: footerRef,
3603
+ style: {
3604
+ padding: isMobile ? "12px 0 0" : "20px 20px 0",
3605
+ display: "flex",
3606
+ flexDirection: "column",
3607
+ gap: 10,
3608
+ alignItems: "center",
3609
+ position: isMobile ? "sticky" : "static",
3610
+ bottom: 0,
3611
+ background: isMobile ? colors2.card : "transparent",
3612
+ zIndex: isMobile ? 1 : void 0,
3613
+ marginTop: "auto"
3614
+ },
3615
+ children: [
3616
+ orderInProgress && withdrawOrder && (() => {
3617
+ const fundingHash = txHash ?? withdrawOrder?.funding_tx_hash;
3618
+ const showFundingLink = fundingHash && fundingChainId;
3619
+ try {
3620
+ return /* @__PURE__ */ jsx("div", { className: "absdk-predicate-withdraw-modal__funding-link-group", style: { display: "none", flexDirection: "column", gap: 6, alignItems: "center" }, children: showFundingLink && /* @__PURE__ */ jsx(
3621
+ "a",
3622
+ {
3623
+ className: "absdk-predicate-withdraw-modal__funding-link",
3624
+ href: getExplorerUrl(fundingChainId, { txId: fundingHash }),
3625
+ target: "_blank",
3626
+ rel: "noopener noreferrer",
3627
+ style: { fontSize: 13, color: colors2.textPrimary, textDecoration: "underline" },
3628
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__funding-link-text", children: "Withdraw request transaction on explorer" })
3629
+ }
3630
+ ) });
3631
+ } catch {
3632
+ return /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__funding-status", style: { fontSize: 13, color: colors2.textPrimary }, children: "Withdraw in progress." });
3633
+ }
3634
+ })(),
3635
+ orderInProgress && withdrawOrder && /* @__PURE__ */ jsxs("span", { className: "absdk-predicate-withdraw-modal__order-status", style: { fontSize: 13, color: colors2.textSecondary, display: "none", alignItems: "center", gap: 6 }, children: [
3636
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__order-status-label", children: "Order status:" }),
3637
+ " ",
3638
+ /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__order-status-value", children: withdrawOrder.status }),
3639
+ /* @__PURE__ */ jsx(
3640
+ "span",
3641
+ {
3642
+ className: "absdk-predicate-withdraw-modal__order-status-spinner",
3643
+ style: {
3644
+ display: "inline-block",
3645
+ width: 10,
3646
+ height: 10,
3647
+ border: `2px solid ${colors2.textSecondary}`,
3648
+ borderTopColor: "transparent",
3649
+ borderRadius: "50%",
3650
+ animation: "withdraw-modal-spin 0.7s linear infinite"
3651
+ },
3652
+ "aria-hidden": true
3653
+ }
3654
+ )
3655
+ ] }),
3656
+ /* @__PURE__ */ jsx("style", { children: `@keyframes withdraw-modal-spin { to { transform: rotate(360deg); } }` }),
3657
+ orderSucceeded || trackingWithdraw ? null : /* @__PURE__ */ jsx(
3658
+ SubmitButton,
3659
+ {
3660
+ id: "absdk-predicate-withdraw-modal-submit-button",
3661
+ className: "absdk-predicate-withdraw-modal__submit-button",
3662
+ disabled: !canSubmit || isSubmitting,
3663
+ status,
3664
+ onClick: () => {
3665
+ try {
3666
+ const ret = onSubmit?.({
3667
+ toAddress: address,
3668
+ amount: amount ?? "",
3669
+ token: token ?? "",
3670
+ tokenAddress: resolvedTokenAddress ?? apiQuote?.token_address ?? "",
3671
+ chain: chain ?? ""
3672
+ });
3673
+ if (ret && typeof ret.then === "function") {
3674
+ ret.catch((err) => {
3675
+ const msg = err instanceof Error ? err.message : "Transaction failed";
3676
+ onShowToast?.(msg);
3677
+ });
3678
+ }
3679
+ } catch (err) {
3680
+ const msg = err instanceof Error ? err.message : "Transaction failed";
3681
+ onShowToast?.(msg);
3682
+ }
3683
+ }
3684
+ }
3685
+ )
3686
+ ]
3687
+ }
3688
+ )
3689
+ ]
3690
+ }
3691
+ );
3692
+ };
3693
+ var SubmitButton = ({ id, className, disabled, status, onClick }) => {
3694
+ const isMobile = useIsMobileViewport2();
3695
+ const labels = {
3696
+ idle: disabled ? "Please fill in withdrawal information" : "Submit",
3697
+ pending: "Processing...",
3698
+ success: "Withdrawal successful",
3699
+ manual_review: "Under manual review"
3700
+ };
3701
+ const isDisabled = disabled || status !== "idle";
3702
+ return /* @__PURE__ */ jsx(
3703
+ "button",
3704
+ {
3705
+ id,
3706
+ className,
3707
+ type: "button",
3708
+ disabled: isDisabled,
3709
+ onClick,
3710
+ style: {
3711
+ width: isMobile ? "100%" : 364,
3712
+ padding: "12px 0",
3713
+ borderRadius: radii2.full,
3714
+ border: isDisabled ? `1px solid ${colors2.buttonDisabledBorder}` : "none",
3715
+ background: isDisabled ? colors2.buttonDisabledBg : colors2.textPrimary,
3716
+ color: isDisabled ? colors2.textSecondary : "#15181D",
3717
+ fontSize: 16,
3718
+ fontWeight: 500,
3719
+ lineHeight: 1.4,
3720
+ fontFamily: fonts2.family,
3721
+ cursor: isDisabled ? "not-allowed" : "pointer",
3722
+ textAlign: "center"
3723
+ },
3724
+ children: /* @__PURE__ */ jsx("span", { className: "absdk-predicate-withdraw-modal__submit-button-label", children: labels[status] })
3725
+ }
3726
+ );
3727
+ };
3728
+
3729
+ // src/react.ts
3730
+ async function loadWalletAccountModule() {
3731
+ return import('./account-F5Z2SMJE.js');
3732
+ }
3733
+ var WalletAccount = {
3734
+ async getInstance(oidcToken) {
3735
+ const { default: WalletAccount2 } = await loadWalletAccountModule();
3736
+ return WalletAccount2.getInstance(oidcToken);
3737
+ },
3738
+ clearInstance() {
3739
+ void loadWalletAccountModule().then(({ default: WalletAccount2 }) => {
3740
+ WalletAccount2.clearInstance();
3741
+ });
3742
+ }
3743
+ };
3744
+ function clearSocialAccountInstance() {
3745
+ void loadWalletAccountModule().then(({ clearSocialAccountInstance: clearSocialAccountInstance2 }) => {
3746
+ clearSocialAccountInstance2();
3747
+ });
3748
+ }
3749
+
3750
+ export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance };