astra-modal-test 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.github/workflows/code-quality.yml +43 -0
  2. package/.github/workflows/publish.yml +64 -0
  3. package/README.md +204 -0
  4. package/dist/SwapController-CsNqEWIM.js +447 -0
  5. package/dist/add-Dm_oSEbv.js +19 -0
  6. package/dist/all-wallets-DfLlzQJ3.js +10 -0
  7. package/dist/app-store-BMdJkp6P.js +21 -0
  8. package/dist/apple-BetlVMKw.js +22 -0
  9. package/dist/arrow-bottom-BddPptxy.js +12 -0
  10. package/dist/arrow-bottom-circle-CvdJJniv.js +15 -0
  11. package/dist/arrow-left-Bbq-z1nQ.js +12 -0
  12. package/dist/arrow-right-Bu4_SVLC.js +12 -0
  13. package/dist/arrow-top-CynlXB-M.js +12 -0
  14. package/dist/astra-sdk.es.js +4 -4
  15. package/dist/bank-B9QscNnS.js +18 -0
  16. package/dist/bin-v-tshf8_.js +8 -0
  17. package/dist/bitcoin-C01gkYyN.js +17 -0
  18. package/dist/browser-9uNaCY31.js +18 -0
  19. package/dist/card-hKR9lRzU.js +18 -0
  20. package/dist/{ccip-oZOrZYR9.js → ccip-CUCziAPw.js} +52 -49
  21. package/dist/checkmark-D1M40aM5.js +15 -0
  22. package/dist/checkmark-bold-1_UGl24m.js +12 -0
  23. package/dist/chevron-bottom-BleoRNRL.js +12 -0
  24. package/dist/chevron-left-C9JMU-3B.js +12 -0
  25. package/dist/chevron-right-Daue4WBx.js +12 -0
  26. package/dist/chevron-top-yuXekbUC.js +12 -0
  27. package/dist/chrome-store-BsUFRR7F.js +65 -0
  28. package/dist/circle-BCxdhM5X.js +8 -0
  29. package/dist/clock-7a-DWZQa.js +12 -0
  30. package/dist/close-DMQYuJ0z.js +12 -0
  31. package/dist/clsx.m-DCYaa4RU.js +20 -0
  32. package/dist/coinPlaceholder-DjQ-HnSH.js +12 -0
  33. package/dist/compass-AMecXNVm.js +12 -0
  34. package/dist/copy-CgIPGYbU.js +19 -0
  35. package/dist/cursor-DpYbTNcO.js +7 -0
  36. package/dist/cursor-transparent-C8iPJkn8.js +16 -0
  37. package/dist/desktop-BWVQVGng.js +13 -0
  38. package/dist/disconnect-C6IQRrtF.js +12 -0
  39. package/dist/discord-gH3i-QsC.js +21 -0
  40. package/dist/email-BxYwJC5T.js +10 -0
  41. package/dist/embedded-wallet-DCcVNgkc.js +464 -0
  42. package/dist/ethereum-CGWsmZaC.js +14 -0
  43. package/dist/etherscan-D4EFsAJ4.js +10 -0
  44. package/dist/exclamation-triangle-DNwQ1Xq6.js +8 -0
  45. package/dist/extension-DxQPsN2z.js +12 -0
  46. package/dist/external-link-BeEzrdgR.js +12 -0
  47. package/dist/facebook-B2Ix8_d3.js +30 -0
  48. package/dist/farcaster-BB83p8dC.js +16 -0
  49. package/dist/filters-PzdIomB1.js +12 -0
  50. package/dist/github-gcp1rxX0.js +22 -0
  51. package/dist/google-Qv9lTZcz.js +22 -0
  52. package/dist/help-circle-BLXTMjzX.js +16 -0
  53. package/dist/id-BHg2CRhj.js +16 -0
  54. package/dist/image-DWi1V30x.js +8 -0
  55. package/dist/index-4lbsZ6RQ.js +33 -0
  56. package/dist/index-64U3D9_n.js +21034 -0
  57. package/dist/index-CRU49I0g.js +15911 -0
  58. package/dist/index-ChxXyuZj.js +572 -0
  59. package/dist/index-ClS956E1.js +74511 -0
  60. package/dist/index-Cs4fWw01.js +386 -0
  61. package/dist/index-DfWqgW4h.js +709 -0
  62. package/dist/index-VYNI76FM.js +315 -0
  63. package/dist/index-qfkTLN90.js +10785 -0
  64. package/dist/index-r2ztgVN2.js +1060 -0
  65. package/dist/index-wvh7Yd5J.js +70 -0
  66. package/dist/info-Bl5tmiBJ.js +7 -0
  67. package/dist/info-circle-D2uYywg-.js +16 -0
  68. package/dist/lightbulb-HvXH2AVF.js +7 -0
  69. package/dist/mail-DXOPfnog.js +12 -0
  70. package/dist/mobile-Dd0Gj4vZ.js +13 -0
  71. package/dist/more-DYcnClbB.js +15 -0
  72. package/dist/network-placeholder-CfRZGQfi.js +18 -0
  73. package/dist/nftPlaceholder-DHmFkY55.js +12 -0
  74. package/dist/off-CG2Y30qN.js +8 -0
  75. package/dist/onramp-DoAMTeNm.js +917 -0
  76. package/dist/play-store-B5EYBQto.js +36 -0
  77. package/dist/plus-DPo25_zL.js +17 -0
  78. package/dist/qr-code-BRTO19PL.js +10 -0
  79. package/dist/receive-BvclNdV_.js +179 -0
  80. package/dist/recycle-horizontal-ng_b2eJV.js +13 -0
  81. package/dist/refresh-3kiwRV0w.js +12 -0
  82. package/dist/reown-logo-_9cuIfJD.js +16 -0
  83. package/dist/search-CoJvIxpi.js +12 -0
  84. package/dist/secp256k1-wZyK2iIX.js +1257 -0
  85. package/dist/send-BVKGSR-Z.js +19 -0
  86. package/dist/send-Bkj5YtHe.js +1039 -0
  87. package/dist/socials-DL42HlL5.js +589 -0
  88. package/dist/solana-BjP-_Ioa.js +17 -0
  89. package/dist/swapHorizontal-Do3uBbum.js +12 -0
  90. package/dist/swapHorizontalBold-D7N75BE-.js +12 -0
  91. package/dist/swapHorizontalMedium-BahEVO2x.js +20 -0
  92. package/dist/swapHorizontalRoundedBold-D6Hoi132.js +12 -0
  93. package/dist/swapVertical-P-fnrADh.js +12 -0
  94. package/dist/swaps-DZgbVJZ2.js +1713 -0
  95. package/dist/telegram-DmaL2iB8.js +20 -0
  96. package/dist/three-dots-oXyAsUA6.js +9 -0
  97. package/dist/transactions-BjB5yZN7.js +35 -0
  98. package/dist/twitch-0UGrMr2K.js +22 -0
  99. package/dist/twitterIcon-B97KAbaJ.js +10 -0
  100. package/dist/ui-r6nnVhBA.js +812 -0
  101. package/dist/user-BG1yp56Q.js +7 -0
  102. package/dist/verify-CgzkMSuV.js +12 -0
  103. package/dist/verify-filled-D-TRpWtN.js +12 -0
  104. package/dist/w3m-modal-Drsibcs0.js +1041 -0
  105. package/dist/wallet-CAHsZdfj.js +12 -0
  106. package/dist/wallet-placeholder-agbbreqw.js +18 -0
  107. package/dist/walletconnect-Yd8iXqY9.js +36 -0
  108. package/dist/warning-circle-C0hqC6h_.js +16 -0
  109. package/dist/x-mark-D9_ai2sI.js +7 -0
  110. package/dist/x-z6v1Jegg.js +16 -0
  111. package/eslint.config.mjs +1 -1
  112. package/package.json +14 -13
  113. package/src/apis/lspApi.js +47 -24
  114. package/src/assets/ln.png +0 -0
  115. package/src/assets/network/Arbitrum.png +0 -0
  116. package/src/assets/network/Polygon.png +0 -0
  117. package/src/assets/network/Solana.png +0 -0
  118. package/src/assets/network/botanix.png +0 -0
  119. package/src/assets/network/bsc.svg +13 -0
  120. package/src/assets/pay.png +0 -0
  121. package/src/assets/tokens/usdc.png +0 -0
  122. package/src/assets/tokens/usdt.png +0 -0
  123. package/src/comps/AstraImage.jsx +17 -3
  124. package/src/comps/AstraModal.jsx +22 -16
  125. package/src/comps/AstraModalLogo.jsx +9 -9
  126. package/src/comps/AstraNetwork.jsx +174 -45
  127. package/src/comps/CheckErc20Button.jsx +1 -1
  128. package/src/comps/CommonStyle.jsx +4 -0
  129. package/src/comps/ConnectButton.jsx +16 -33
  130. package/src/comps/ResultModal.jsx +45 -39
  131. package/src/comps/ToLightning.jsx +207 -80
  132. package/src/comps/ToToken.jsx +278 -217
  133. package/src/constants/index.js +20 -4
  134. package/src/hooks/useContract.js +164 -125
  135. package/src/hooks/useGetMinAndMax.js +48 -0
  136. package/src/hooks/useLspApi.js +56 -39
  137. package/src/hooks/useParseInvoice.js +82 -72
  138. package/src/index.jsx +43 -10
  139. package/src/main.jsx +36 -5
  140. package/src/utils/index.js +136 -24
  141. package/vite.config.js +7 -1
  142. package/dist/astra-sdk.umd.js +0 -12578
  143. package/dist/hooks.module-BBZfodGH.js +0 -506
  144. package/dist/index-BKKAfRrw.js +0 -87520
  145. package/dist/index-C2MAIRET.js +0 -2929
  146. package/dist/index-CsRxokSv.js +0 -445
  147. package/dist/index-DQ6iiHxJ.js +0 -13720
  148. package/dist/index-SJhlkSif.js +0 -133
  149. package/dist/w3m-modal-CYJpmgnf.js +0 -267
  150. package/src/constants/contracts/abi/bridge.js +0 -1281
  151. package/src/constants/contracts/abi/index.js +0 -3
  152. package/src/constants/contracts/abi/usdt.js +0 -130
  153. package/src/constants/contracts/abi/watcher.js +0 -437
  154. package/src/constants/contracts/index.js +0 -37
@@ -0,0 +1,812 @@
1
+ import { V as g, aJ as j, aK as b, aL as K, P as O, aM as m, X as U, _ as L, aN as M, aO as x, E as z, J as N, K as c, H as T, I as $, R as f, aB as w, S as v, as as V, av as u } from "./index-ClS956E1.js";
2
+ import { f as R } from "./index-DfWqgW4h.js";
3
+ class X {
4
+ constructor(e) {
5
+ this.expiration = e.expiration, this.getNonce = e.getNonce, this.getRequestId = e.getRequestId, this.domain = e.domain, this.uri = e.uri, this.statement = e.statement, this.resources = e.resources;
6
+ }
7
+ /**
8
+ * This is the default method to create a SIWXMessage object.
9
+ * It will call the `getNonce`, `getRequestId`, `getExpirationTime`, `getIssuedAt`, and `getNotBefore` methods.
10
+ * It appends the `stringify` method to the object as `toString`.
11
+ *
12
+ * @param input SIWXMessage.Input
13
+ * @returns
14
+ */
15
+ async createMessage(e) {
16
+ var s;
17
+ const t = {
18
+ accountAddress: e.accountAddress,
19
+ chainId: e.chainId,
20
+ version: this.version,
21
+ domain: this.domain,
22
+ uri: this.uri,
23
+ statement: this.statement,
24
+ resources: this.resources,
25
+ nonce: await this.getNonce(e),
26
+ requestId: await ((s = this.getRequestId) == null ? void 0 : s.call(this)),
27
+ expirationTime: this.getExpirationTime(e),
28
+ issuedAt: this.getIssuedAt(),
29
+ notBefore: this.getNotBefore(e)
30
+ };
31
+ return Object.assign(t, {
32
+ toString: () => this.stringify(t)
33
+ });
34
+ }
35
+ /**
36
+ * This method generates the expiration time based on the `notBefore` value and the `expiration` value.
37
+ * You may override this method to provide a custom expiration time.
38
+ *
39
+ * @param Pick<SIWXMessage.Input, 'notBefore'>
40
+ * @returns string | undefined - The expiration time in `stringifyDate` format or undefined if not available
41
+ */
42
+ getExpirationTime({ notBefore: e }) {
43
+ if (typeof this.expiration > "u")
44
+ return;
45
+ const t = e ? new Date(e).getTime() : Date.now();
46
+ return this.stringifyDate(new Date(t + this.expiration));
47
+ }
48
+ /**
49
+ * This method generates the `notBefore` formatted value based on the `notBefore` input.
50
+ * You may override this method to provide a custom `notBefore` value.
51
+ *
52
+ * @param Pick<SIWXMessage.Input, 'notBefore'>
53
+ * @returns string | undefined - The `notBefore` value in `stringifyDate` format or undefined if not available
54
+ */
55
+ getNotBefore({ notBefore: e }) {
56
+ return e ? this.stringifyDate(new Date(e)) : void 0;
57
+ }
58
+ /**
59
+ * This method generates the `issuedAt` formatted value based on the current date.
60
+ * You may override this method to provide a custom `issuedAt` value.
61
+ *
62
+ * @returns string - The `issuedAt` value in `stringifyDate` format
63
+ */
64
+ getIssuedAt() {
65
+ return this.stringifyDate(/* @__PURE__ */ new Date());
66
+ }
67
+ /**
68
+ * This method converts a date object to a formatted string.
69
+ * You may override this method to provide a custom date format.
70
+ *
71
+ * @param date Date
72
+ * @returns string - The date in ISO format
73
+ */
74
+ stringifyDate(e) {
75
+ return e.toISOString();
76
+ }
77
+ }
78
+ class B extends X {
79
+ constructor({ clearChainIdNamespace: e, ...t }) {
80
+ super(t), this.version = "1", this.clearChainIdNamespace = e || !1;
81
+ }
82
+ /**
83
+ * Get the blockchain name for a given chain ID
84
+ * @param chainId The chain ID to get the blockchain name for
85
+ * @returns The blockchain name
86
+ */
87
+ getNetworkName(e) {
88
+ const t = g.getAllRequestedCaipNetworks();
89
+ return j.getNetworkNameByCaipNetworkId(t, e);
90
+ }
91
+ stringify(e) {
92
+ var s;
93
+ const t = this.clearChainIdNamespace ? e.chainId.split(":")[1] : e.chainId, i = this.getNetworkName(e.chainId);
94
+ return [
95
+ `${e.domain} wants you to sign in with your ${i} account:`,
96
+ e.accountAddress,
97
+ e.statement ? `
98
+ ${e.statement}
99
+ ` : "",
100
+ `URI: ${e.uri}`,
101
+ `Version: ${e.version}`,
102
+ `Chain ID: ${t}`,
103
+ `Nonce: ${e.nonce}`,
104
+ e.issuedAt && `Issued At: ${e.issuedAt}`,
105
+ e.expirationTime && `Expiration Time: ${e.expirationTime}`,
106
+ e.notBefore && `Not Before: ${e.notBefore}`,
107
+ e.requestId && `Request ID: ${e.requestId}`,
108
+ ((s = e.resources) == null ? void 0 : s.length) && e.resources.reduce((n, a) => `${n}
109
+ - ${a}`, "Resources:")
110
+ ].filter((n) => typeof n == "string").join(`
111
+ `).trim();
112
+ }
113
+ }
114
+ class _ {
115
+ constructor(e = {}) {
116
+ this.otpUuid = null, this.listeners = {
117
+ sessionChanged: []
118
+ }, this.localAuthStorageKey = e.localAuthStorageKey || b.SIWX_AUTH_TOKEN, this.localNonceStorageKey = e.localNonceStorageKey || b.SIWX_NONCE_TOKEN, this.required = e.required ?? !0, this.messenger = new B({
119
+ domain: typeof document > "u" ? "Unknown Domain" : document.location.host,
120
+ uri: typeof document > "u" ? "Unknown URI" : document.location.href,
121
+ getNonce: this.getNonce.bind(this),
122
+ clearChainIdNamespace: !1
123
+ });
124
+ }
125
+ async createMessage(e) {
126
+ return this.messenger.createMessage(e);
127
+ }
128
+ async addSession(e) {
129
+ const t = await this.request({
130
+ method: "POST",
131
+ key: "authenticate",
132
+ body: {
133
+ data: e.data,
134
+ message: e.message,
135
+ signature: e.signature,
136
+ clientId: this.getClientId(),
137
+ walletInfo: this.getWalletInfo()
138
+ },
139
+ headers: ["nonce", "otp"]
140
+ });
141
+ this.setStorageToken(t.token, this.localAuthStorageKey), this.emit("sessionChanged", e), this.setAppKitAccountUser(H(t.token)), this.otpUuid = null;
142
+ }
143
+ async getSessions(e, t) {
144
+ try {
145
+ if (!this.getStorageToken(this.localAuthStorageKey))
146
+ return [];
147
+ const i = await this.request({
148
+ method: "GET",
149
+ key: "me",
150
+ query: {},
151
+ headers: ["auth"]
152
+ });
153
+ if (!i)
154
+ return [];
155
+ const s = i.address.toLowerCase() === t.toLowerCase(), n = i.caip2Network === e;
156
+ if (!s || !n)
157
+ return [];
158
+ const a = {
159
+ data: {
160
+ accountAddress: i.address,
161
+ chainId: i.caip2Network
162
+ },
163
+ message: "",
164
+ signature: ""
165
+ };
166
+ return this.emit("sessionChanged", a), this.setAppKitAccountUser(i), [a];
167
+ } catch {
168
+ return [];
169
+ }
170
+ }
171
+ async revokeSession(e, t) {
172
+ return Promise.resolve(this.clearStorageTokens());
173
+ }
174
+ async setSessions(e) {
175
+ if (e.length === 0)
176
+ this.clearStorageTokens();
177
+ else {
178
+ const t = e.find((i) => {
179
+ var s;
180
+ return i.data.chainId === ((s = K()) == null ? void 0 : s.caipNetworkId);
181
+ }) || e[0];
182
+ await this.addSession(t);
183
+ }
184
+ }
185
+ getRequired() {
186
+ return this.required;
187
+ }
188
+ async getSessionAccount() {
189
+ if (!this.getStorageToken(this.localAuthStorageKey))
190
+ throw new Error("Not authenticated");
191
+ return this.request({
192
+ method: "GET",
193
+ key: "me",
194
+ body: void 0,
195
+ query: {
196
+ includeAppKitAccount: !0
197
+ },
198
+ headers: ["auth"]
199
+ });
200
+ }
201
+ async setSessionAccountMetadata(e = null) {
202
+ if (!this.getStorageToken(this.localAuthStorageKey))
203
+ throw new Error("Not authenticated");
204
+ return this.request({
205
+ method: "PUT",
206
+ key: "account-metadata",
207
+ body: { metadata: e },
208
+ headers: ["auth"]
209
+ });
210
+ }
211
+ on(e, t) {
212
+ return this.listeners[e].push(t), () => {
213
+ this.listeners[e] = this.listeners[e].filter((i) => i !== t);
214
+ };
215
+ }
216
+ removeAllListeners() {
217
+ Object.keys(this.listeners).forEach((t) => {
218
+ this.listeners[t] = [];
219
+ });
220
+ }
221
+ async requestEmailOtp({ email: e, account: t }) {
222
+ const i = await this.request({
223
+ method: "POST",
224
+ key: "otp",
225
+ body: { email: e, account: t }
226
+ });
227
+ return this.otpUuid = i.uuid, this.messenger.resources = [`email:${e}`], i;
228
+ }
229
+ confirmEmailOtp({ code: e }) {
230
+ return this.request({
231
+ method: "PUT",
232
+ key: "otp",
233
+ body: { code: e },
234
+ headers: ["otp"]
235
+ });
236
+ }
237
+ async request({ method: e, key: t, query: i, body: s, headers: n }) {
238
+ var k;
239
+ const { projectId: a, st: o, sv: P } = this.getSDKProperties(), p = new URL(`${O.W3M_API_URL}/auth/v1/${String(t)}`);
240
+ p.searchParams.set("projectId", a), p.searchParams.set("st", o), p.searchParams.set("sv", P), i && Object.entries(i).forEach(([h, C]) => p.searchParams.set(h, String(C)));
241
+ const y = await fetch(p, {
242
+ method: e,
243
+ body: s ? JSON.stringify(s) : void 0,
244
+ headers: Array.isArray(n) ? n.reduce((h, C) => {
245
+ switch (C) {
246
+ case "nonce":
247
+ h["x-nonce-jwt"] = `Bearer ${this.getStorageToken(this.localNonceStorageKey)}`;
248
+ break;
249
+ case "auth":
250
+ h.Authorization = `Bearer ${this.getStorageToken(this.localAuthStorageKey)}`;
251
+ break;
252
+ case "otp":
253
+ this.otpUuid && (h["x-otp"] = this.otpUuid);
254
+ break;
255
+ }
256
+ return h;
257
+ }, {}) : void 0
258
+ });
259
+ if (!y.ok)
260
+ throw new Error(await y.text());
261
+ return (k = y.headers.get("content-type")) != null && k.includes("application/json") ? y.json() : null;
262
+ }
263
+ getStorageToken(e) {
264
+ return m.getItem(e);
265
+ }
266
+ setStorageToken(e, t) {
267
+ m.setItem(t, e);
268
+ }
269
+ clearStorageTokens() {
270
+ this.otpUuid = null, m.removeItem(this.localAuthStorageKey), m.removeItem(this.localNonceStorageKey), this.emit("sessionChanged", void 0);
271
+ }
272
+ async getNonce() {
273
+ const { nonce: e, token: t } = await this.request({
274
+ method: "GET",
275
+ key: "nonce"
276
+ });
277
+ return this.setStorageToken(t, this.localNonceStorageKey), e;
278
+ }
279
+ getClientId() {
280
+ return U.state.clientId;
281
+ }
282
+ getWalletInfo() {
283
+ const { connectedWalletInfo: e } = L.state;
284
+ if (!e)
285
+ return;
286
+ if ("social" in e) {
287
+ const n = e.social, a = e.identifier;
288
+ return { type: "social", social: n, identifier: a };
289
+ }
290
+ const { name: t, icon: i } = e;
291
+ let s = "unknown";
292
+ switch (e.type) {
293
+ case x.CONNECTOR_TYPE_EXTERNAL:
294
+ case x.CONNECTOR_TYPE_INJECTED:
295
+ case x.CONNECTOR_TYPE_ANNOUNCED:
296
+ s = "extension";
297
+ break;
298
+ case x.CONNECTOR_TYPE_WALLET_CONNECT:
299
+ s = "walletconnect";
300
+ break;
301
+ default:
302
+ s = "unknown";
303
+ }
304
+ return {
305
+ type: s,
306
+ name: t,
307
+ icon: i
308
+ };
309
+ }
310
+ getSDKProperties() {
311
+ return M._getSdkProperties();
312
+ }
313
+ emit(e, t) {
314
+ this.listeners[e].forEach((i) => i(t));
315
+ }
316
+ setAppKitAccountUser(e) {
317
+ const { email: t } = e;
318
+ t && Object.values(O.CHAIN).forEach((i) => {
319
+ g.setAccountProp("user", { email: t }, i);
320
+ });
321
+ }
322
+ }
323
+ function H(r) {
324
+ const e = r.split(".");
325
+ if (e.length !== 3)
326
+ throw new Error("Invalid token");
327
+ const t = e[1];
328
+ if (typeof t != "string")
329
+ throw new Error("Invalid token");
330
+ const i = t.replace(/-/gu, "+").replace(/_/gu, "/"), s = i.padEnd(i.length + (4 - i.length % 4) % 4, "=");
331
+ return JSON.parse(atob(s));
332
+ }
333
+ const A = z`
334
+ .hero {
335
+ display: flex;
336
+ flex-direction: column;
337
+ align-items: center;
338
+ justify-content: center;
339
+ gap: var(--wui-spacing-3xs);
340
+
341
+ transition-property: margin, height;
342
+ transition-duration: var(--wui-duration-md);
343
+ transition-timing-function: var(--wui-ease-out-power-1);
344
+ margin-top: -100px;
345
+
346
+ &[data-state='loading'] {
347
+ margin-top: 0px;
348
+ }
349
+
350
+ position: relative;
351
+ &:after {
352
+ content: '';
353
+ position: absolute;
354
+ bottom: 0;
355
+ height: 252px;
356
+ width: 360px;
357
+ background: radial-gradient(
358
+ 96.11% 53.95% at 50% 51.28%,
359
+ transparent 0%,
360
+ color-mix(in srgb, var(--wui-color-bg-100) 5%, transparent) 49%,
361
+ color-mix(in srgb, var(--wui-color-bg-100) 65%, transparent) 99.43%
362
+ );
363
+ }
364
+ }
365
+
366
+ .hero-main-icon {
367
+ width: 176px;
368
+ transition-property: background-color;
369
+ transition-duration: var(--wui-duration-lg);
370
+ transition-timing-function: var(--wui-ease-out-power-1);
371
+
372
+ &[data-state='loading'] {
373
+ width: 56px;
374
+ }
375
+ }
376
+
377
+ .hero-row {
378
+ display: flex;
379
+ flex-direction: row;
380
+ align-items: center;
381
+ justify-content: center;
382
+ gap: var(--wui-spacing-3xs);
383
+ flex-wrap: nowrap;
384
+ min-width: fit-content;
385
+
386
+ &:nth-child(1) {
387
+ transform: translateX(-30px);
388
+ }
389
+
390
+ &:nth-child(2) {
391
+ transform: translateX(30px);
392
+ }
393
+
394
+ &:nth-child(4) {
395
+ transform: translateX(40px);
396
+ }
397
+
398
+ transition-property: height;
399
+ transition-duration: var(--wui-duration-md);
400
+ transition-timing-function: var(--wui-ease-out-power-1);
401
+ height: 68px;
402
+
403
+ &[data-state='loading'] {
404
+ height: 0px;
405
+ }
406
+ }
407
+
408
+ .hero-row-icon {
409
+ opacity: 0.1;
410
+ transition-property: opacity;
411
+ transition-duration: var(--wui-duration-md);
412
+ transition-timing-function: var(--wui-ease-out-power-1);
413
+
414
+ &[data-state='loading'] {
415
+ opacity: 0;
416
+ }
417
+ }
418
+
419
+ .email-sufixes {
420
+ display: flex;
421
+ flex-direction: row;
422
+ gap: var(--wui-spacing-3xs);
423
+ overflow-x: auto;
424
+ max-width: 100%;
425
+ margin-top: var(--wui-spacing-s);
426
+ margin-bottom: calc(-1 * var(--wui-spacing-m));
427
+ padding-bottom: var(--wui-spacing-m);
428
+ margin-left: calc(-1 * var(--wui-spacing-m));
429
+ margin-right: calc(-1 * var(--wui-spacing-m));
430
+ padding-left: var(--wui-spacing-m);
431
+ padding-right: var(--wui-spacing-m);
432
+
433
+ &::-webkit-scrollbar {
434
+ display: none;
435
+ }
436
+ }
437
+
438
+ .recent-emails {
439
+ display: flex;
440
+ flex-direction: column;
441
+ padding: var(--wui-spacing-s) 0;
442
+ border-top: 1px solid var(--wui-color-gray-glass-005);
443
+ border-bottom: 1px solid var(--wui-color-gray-glass-005);
444
+ }
445
+
446
+ .recent-emails-heading {
447
+ margin-bottom: var(--wui-spacing-s);
448
+ }
449
+
450
+ .recent-emails-list-item {
451
+ --wui-color-gray-glass-002: transparent;
452
+ }
453
+ `;
454
+ var q = function(r, e, t, i) {
455
+ var s = arguments.length, n = s < 3 ? e : i === null ? i = Object.getOwnPropertyDescriptor(e, t) : i, a;
456
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(r, e, t, i);
457
+ else for (var o = r.length - 1; o >= 0; o--) (a = r[o]) && (n = (s < 3 ? a(n) : s > 3 ? a(e, t, n) : a(e, t)) || n);
458
+ return s > 3 && n && Object.defineProperty(e, t, n), n;
459
+ };
460
+ const J = [
461
+ "@gmail.com",
462
+ "@outlook.com",
463
+ "@yahoo.com",
464
+ "@hotmail.com",
465
+ "@aol.com",
466
+ "@icloud.com",
467
+ "@zoho.com"
468
+ ];
469
+ let E = class extends N {
470
+ constructor() {
471
+ super(...arguments), this.email = "";
472
+ }
473
+ render() {
474
+ const e = J.filter(this.filter.bind(this)).map(this.item.bind(this));
475
+ return e.length === 0 ? null : c`<div class="email-sufixes">${e}</div>`;
476
+ }
477
+ filter(e) {
478
+ if (!this.email)
479
+ return !1;
480
+ const t = this.email.split("@");
481
+ if (t.length < 2)
482
+ return !0;
483
+ const i = t.pop();
484
+ return e.includes(i) && e !== `@${i}`;
485
+ }
486
+ item(e) {
487
+ return c`<wui-button variant="neutral" size="sm" @click=${() => {
488
+ const i = this.email.split("@");
489
+ i.length > 1 && i.pop();
490
+ const s = i[0] + e;
491
+ this.dispatchEvent(new CustomEvent("change", {
492
+ detail: s,
493
+ bubbles: !0,
494
+ composed: !0
495
+ }));
496
+ }}
497
+ >${e}</wui-button
498
+ >`;
499
+ }
500
+ };
501
+ E.styles = [A];
502
+ q([
503
+ T()
504
+ ], E.prototype, "email", void 0);
505
+ E = q([
506
+ $("w3m-email-suffixes-widget")
507
+ ], E);
508
+ var D = function(r, e, t, i) {
509
+ var s = arguments.length, n = s < 3 ? e : i === null ? i = Object.getOwnPropertyDescriptor(e, t) : i, a;
510
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(r, e, t, i);
511
+ else for (var o = r.length - 1; o >= 0; o--) (a = r[o]) && (n = (s < 3 ? a(n) : s > 3 ? a(e, t, n) : a(e, t)) || n);
512
+ return s > 3 && n && Object.defineProperty(e, t, n), n;
513
+ };
514
+ let S = class extends N {
515
+ constructor() {
516
+ super(...arguments), this.emails = [];
517
+ }
518
+ render() {
519
+ return this.emails.length === 0 ? null : c`<div class="recent-emails">
520
+ <wui-text variant="micro-600" color="fg-200" class="recent-emails-heading"
521
+ >Recently used emails</wui-text
522
+ >
523
+ ${this.emails.map(this.item.bind(this))}
524
+ </div>`;
525
+ }
526
+ item(e) {
527
+ return c`<wui-list-item
528
+ @click=${() => {
529
+ this.dispatchEvent(new CustomEvent("select", {
530
+ detail: e,
531
+ bubbles: !0,
532
+ composed: !0
533
+ }));
534
+ }}
535
+ ?chevron=${!0}
536
+ icon="mail"
537
+ iconVariant="overlay"
538
+ class="recent-emails-list-item"
539
+ >
540
+ <wui-text variant="paragraph-500" color="fg-100">${e}</wui-text>
541
+ </wui-list-item>`;
542
+ }
543
+ };
544
+ S.styles = [A];
545
+ D([
546
+ T()
547
+ ], S.prototype, "emails", void 0);
548
+ S = D([
549
+ $("w3m-recent-emails-widget")
550
+ ], S);
551
+ var d = function(r, e, t, i) {
552
+ var s = arguments.length, n = s < 3 ? e : i === null ? i = Object.getOwnPropertyDescriptor(e, t) : i, a;
553
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(r, e, t, i);
554
+ else for (var o = r.length - 1; o >= 0; o--) (a = r[o]) && (n = (s < 3 ? a(n) : s > 3 ? a(e, t, n) : a(e, t)) || n);
555
+ return s > 3 && n && Object.defineProperty(e, t, n), n;
556
+ };
557
+ let l = class extends N {
558
+ constructor() {
559
+ var e, t, i, s, n, a, o;
560
+ super(...arguments), this.email = ((e = f.state.data) == null ? void 0 : e.email) ?? ((i = (t = g.getAccountData()) == null ? void 0 : t.user) == null ? void 0 : i.email) ?? "", this.address = ((s = g.getAccountData()) == null ? void 0 : s.address) ?? "", this.loading = !1, this.appName = ((n = w.state.metadata) == null ? void 0 : n.name) ?? "AppKit", this.siwx = w.state.siwx, this.isRequired = Array.isArray((a = w.state.remoteFeatures) == null ? void 0 : a.emailCapture) && ((o = w.state.remoteFeatures) == null ? void 0 : o.emailCapture.includes("required")), this.recentEmails = this.getRecentEmails();
561
+ }
562
+ connectedCallback() {
563
+ (!this.siwx || !(this.siwx instanceof _)) && v.showError("ReownAuthentication is not initialized."), super.connectedCallback();
564
+ }
565
+ firstUpdated() {
566
+ this.loading = !1, this.recentEmails = this.getRecentEmails(), this.email && this.onSubmit();
567
+ }
568
+ render() {
569
+ return c`
570
+ <wui-flex flexDirection="column" .padding=${["3xs", "m", "m", "m"]} gap="l">
571
+ ${this.hero()} ${this.paragraph()} ${this.emailInput()} ${this.recentEmailsWidget()}
572
+ ${this.footerActions()}
573
+ </wui-flex>
574
+ `;
575
+ }
576
+ hero() {
577
+ return c`
578
+ <div class="hero" data-state=${this.loading ? "loading" : "default"}>
579
+ ${this.heroRow(["id", "mail", "wallet", "x", "solana", "qrCode"])}
580
+ ${this.heroRow(["mail", "farcaster", "wallet", "discord", "mobile", "qrCode"])}
581
+ <div class="hero-row">
582
+ ${this.heroIcon("github")} ${this.heroIcon("bank")}
583
+ <wui-icon-box
584
+ size="xl"
585
+ iconSize="xxl"
586
+ iconColor=${this.loading ? "fg-100" : "accent-100"}
587
+ backgroundColor=${this.loading ? "fg-100" : "accent-100"}
588
+ icon=${this.loading ? "id" : "user"}
589
+ isOpaque
590
+ class="hero-main-icon"
591
+ data-state=${this.loading ? "loading" : "default"}
592
+ >
593
+ </wui-icon-box>
594
+ ${this.heroIcon("id")} ${this.heroIcon("card")}
595
+ </div>
596
+ ${this.heroRow(["google", "id", "github", "verify", "apple", "mobile"])}
597
+ </div>
598
+ `;
599
+ }
600
+ heroRow(e) {
601
+ return c`
602
+ <div class="hero-row" data-state=${this.loading ? "loading" : "default"}>
603
+ ${e.map(this.heroIcon.bind(this))}
604
+ </div>
605
+ `;
606
+ }
607
+ heroIcon(e) {
608
+ return c`
609
+ <wui-icon-box
610
+ size="xl"
611
+ iconSize="xxl"
612
+ iconColor="fg-100"
613
+ backgroundColor="fg-100"
614
+ icon=${e}
615
+ data-state=${this.loading ? "loading" : "default"}
616
+ isOpaque
617
+ class="hero-row-icon"
618
+ >
619
+ </wui-icon-box>
620
+ `;
621
+ }
622
+ paragraph() {
623
+ return this.loading ? c`
624
+ <wui-text variant="paragraph-400" color="fg-200" align="center"
625
+ >We are verifying your account with email
626
+ <wui-text variant="paragraph-600" color="accent-100">${this.email}</wui-text> and address
627
+ <wui-text variant="paragraph-600" color="fg-100">
628
+ ${V.getTruncateString({
629
+ string: this.address,
630
+ charsEnd: 4,
631
+ charsStart: 4,
632
+ truncate: "middle"
633
+ })} </wui-text
634
+ >, please wait a moment.</wui-text
635
+ >
636
+ ` : this.isRequired ? c`
637
+ <wui-text variant="paragraph-600" color="fg-100" align="center">
638
+ ${this.appName} requires your email for authentication.
639
+ </wui-text>
640
+ ` : c`
641
+ <wui-flex flexDirection="column" gap="xs" alignItems="center">
642
+ <wui-text variant="paragraph-600" color="fg-100" align="center" size>
643
+ ${this.appName} would like to collect your email.
644
+ </wui-text>
645
+
646
+ <wui-text variant="small-400" color="fg-200" align="center">
647
+ Don't worry, it's optional&mdash;you can skip this step.
648
+ </wui-text>
649
+ </wui-flex>
650
+ `;
651
+ }
652
+ emailInput() {
653
+ if (this.loading)
654
+ return null;
655
+ const e = (i) => {
656
+ i.key === "Enter" && this.onSubmit();
657
+ }, t = (i) => {
658
+ this.email = i.detail;
659
+ };
660
+ return c`
661
+ <wui-flex flexDirection="column">
662
+ <wui-email-input
663
+ .value=${this.email}
664
+ .disabled=${this.loading}
665
+ @inputChange=${t}
666
+ @keydown=${e}
667
+ ></wui-email-input>
668
+
669
+ <w3m-email-suffixes-widget
670
+ .email=${this.email}
671
+ @change=${t}
672
+ ></w3m-email-suffixes-widget>
673
+ </wui-flex>
674
+ `;
675
+ }
676
+ recentEmailsWidget() {
677
+ if (this.recentEmails.length === 0 || this.loading)
678
+ return null;
679
+ const e = (t) => {
680
+ this.email = t.detail, this.onSubmit();
681
+ };
682
+ return c`
683
+ <w3m-recent-emails-widget
684
+ .emails=${this.recentEmails}
685
+ @select=${e}
686
+ ></w3m-recent-emails-widget>
687
+ `;
688
+ }
689
+ footerActions() {
690
+ return c`
691
+ <wui-flex flexDirection="row" fullWidth gap="s">
692
+ ${this.isRequired ? null : c`<wui-button
693
+ size="lg"
694
+ variant="neutral"
695
+ fullWidth
696
+ .disabled=${this.loading}
697
+ @click=${this.onSkip.bind(this)}
698
+ >Skip this step</wui-button
699
+ >`}
700
+
701
+ <wui-button
702
+ size="lg"
703
+ variant="main"
704
+ type="submit"
705
+ fullWidth
706
+ .disabled=${!this.email || !this.isValidEmail(this.email)}
707
+ .loading=${this.loading}
708
+ @click=${this.onSubmit.bind(this)}
709
+ >
710
+ Continue
711
+ </wui-button>
712
+ </wui-flex>
713
+ `;
714
+ }
715
+ async onSubmit() {
716
+ const e = g.getActiveCaipAddress();
717
+ if (!e)
718
+ throw new Error("Account is not connected.");
719
+ if (!this.isValidEmail(this.email)) {
720
+ v.showError("Please provide a valid email.");
721
+ return;
722
+ }
723
+ try {
724
+ this.loading = !0;
725
+ const t = await this.siwx.requestEmailOtp({
726
+ email: this.email,
727
+ account: e
728
+ });
729
+ this.pushRecentEmail(this.email), t.uuid === null ? f.replace("SIWXSignMessage") : f.replace("DataCaptureOtpConfirm", { email: this.email });
730
+ } catch {
731
+ v.showError("Failed to send email OTP"), this.loading = !1;
732
+ }
733
+ }
734
+ onSkip() {
735
+ f.replace("SIWXSignMessage");
736
+ }
737
+ getRecentEmails() {
738
+ const e = m.getItem(b.RECENT_EMAILS);
739
+ return (e ? e.split(",") : []).filter(this.isValidEmail.bind(this)).slice(0, 3);
740
+ }
741
+ pushRecentEmail(e) {
742
+ const t = this.getRecentEmails(), i = Array.from(/* @__PURE__ */ new Set([e, ...t])).slice(0, 3);
743
+ m.setItem(b.RECENT_EMAILS, i.join(","));
744
+ }
745
+ isValidEmail(e) {
746
+ return /^\S+@\S+\.\S+$/u.test(e);
747
+ }
748
+ };
749
+ l.styles = [A];
750
+ d([
751
+ u()
752
+ ], l.prototype, "email", void 0);
753
+ d([
754
+ u()
755
+ ], l.prototype, "address", void 0);
756
+ d([
757
+ u()
758
+ ], l.prototype, "loading", void 0);
759
+ d([
760
+ u()
761
+ ], l.prototype, "appName", void 0);
762
+ d([
763
+ u()
764
+ ], l.prototype, "siwx", void 0);
765
+ d([
766
+ u()
767
+ ], l.prototype, "isRequired", void 0);
768
+ d([
769
+ u()
770
+ ], l.prototype, "recentEmails", void 0);
771
+ l = d([
772
+ $("w3m-data-capture-view")
773
+ ], l);
774
+ var W = function(r, e, t, i) {
775
+ var s = arguments.length, n = s < 3 ? e : i === null ? i = Object.getOwnPropertyDescriptor(e, t) : i, a;
776
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(r, e, t, i);
777
+ else for (var o = r.length - 1; o >= 0; o--) (a = r[o]) && (n = (s < 3 ? a(n) : s > 3 ? a(e, t, n) : a(e, t)) || n);
778
+ return s > 3 && n && Object.defineProperty(e, t, n), n;
779
+ };
780
+ let I = class extends R {
781
+ constructor() {
782
+ super(...arguments), this.siwx = w.state.siwx, this.onOtpSubmit = async (e) => {
783
+ await this.siwx.confirmEmailOtp({ code: e }), f.replace("SIWXSignMessage");
784
+ }, this.onOtpResend = async (e) => {
785
+ const t = g.getAccountData();
786
+ if (!(t != null && t.caipAddress))
787
+ throw new Error("No account data found");
788
+ await this.siwx.requestEmailOtp({
789
+ email: e,
790
+ account: t.caipAddress
791
+ });
792
+ };
793
+ }
794
+ connectedCallback() {
795
+ (!this.siwx || !(this.siwx instanceof _)) && v.showError("ReownAuthentication is not initialized."), super.connectedCallback();
796
+ }
797
+ shouldSubmitOnOtpChange() {
798
+ return this.otp.length === R.OTP_LENGTH;
799
+ }
800
+ };
801
+ W([
802
+ u()
803
+ ], I.prototype, "siwx", void 0);
804
+ I = W([
805
+ $("w3m-data-capture-otp-confirm-view")
806
+ ], I);
807
+ export {
808
+ I as W3mDataCaptureOtpConfirmView,
809
+ l as W3mDataCaptureView,
810
+ E as W3mEmailSuffixesWidget,
811
+ S as W3mRecentEmailsWidget
812
+ };