@algobright/solana-connector-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/Avatar.module-P7KEBP7R.module.css +42 -0
  2. package/dist/Button.module-7TPMDOJN.module.css +145 -0
  3. package/dist/Collapsible.module-NXSN3MGI.module.css +24 -0
  4. package/dist/ConnectButton.d.mts +14 -0
  5. package/dist/ConnectButton.d.ts +14 -0
  6. package/dist/ConnectButton.js +1248 -0
  7. package/dist/ConnectButton.js.map +1 -0
  8. package/dist/ConnectButton.mjs +1216 -0
  9. package/dist/ConnectButton.mjs.map +1 -0
  10. package/dist/ConnectButton.module-UWQKSVTP.module.css +8 -0
  11. package/dist/CustomQRCode.module-FOXENMZG.module.css +176 -0
  12. package/dist/Dialog.module-HCRT743N.module.css +136 -0
  13. package/dist/Menu.module-GV627ZLI.module.css +79 -0
  14. package/dist/Spinner.module-G7GUQJZJ.module.css +16 -0
  15. package/dist/WalletDropdown.d.mts +14 -0
  16. package/dist/WalletDropdown.d.ts +14 -0
  17. package/dist/WalletDropdown.js +346 -0
  18. package/dist/WalletDropdown.js.map +1 -0
  19. package/dist/WalletDropdown.mjs +314 -0
  20. package/dist/WalletDropdown.mjs.map +1 -0
  21. package/dist/WalletDropdown.module-342MM7XM.module.css +220 -0
  22. package/dist/WalletModal.d.mts +13 -0
  23. package/dist/WalletModal.d.ts +13 -0
  24. package/dist/WalletModal.js +838 -0
  25. package/dist/WalletModal.js.map +1 -0
  26. package/dist/WalletModal.mjs +806 -0
  27. package/dist/WalletModal.mjs.map +1 -0
  28. package/dist/WalletModal.module-PVV5PRXU.module.css +341 -0
  29. package/dist/index.d.mts +70 -0
  30. package/dist/index.d.ts +70 -0
  31. package/dist/index.js +242 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/index.mjs +222 -0
  34. package/dist/index.mjs.map +1 -0
  35. package/package.json +70 -0
@@ -0,0 +1,1216 @@
1
+ "use client";
2
+
3
+ // src/components/ConnectButton/ConnectButton.tsx
4
+ import { useState as useState4 } from "react";
5
+ import styles9 from "./ConnectButton.module-UWQKSVTP.module.css";
6
+ import { useConnector as useConnector2 } from "@solana/connector";
7
+
8
+ // src/components/shared/Button/Button.tsx
9
+ import * as React from "react";
10
+ import { Button as BaseButton } from "@base-ui/react/button";
11
+ import styles from "./Button.module-7TPMDOJN.module.css";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var Button = React.forwardRef(
14
+ ({ className, variant = "default", size = "default", ...props }, ref) => {
15
+ return /* @__PURE__ */ jsx(
16
+ BaseButton,
17
+ {
18
+ ref,
19
+ className: `${styles.button} ${className || ""}`,
20
+ "data-variant": variant,
21
+ "data-size": size,
22
+ ...props
23
+ }
24
+ );
25
+ }
26
+ );
27
+ Button.displayName = "Button";
28
+ var Button_default = Button;
29
+
30
+ // src/components/shared/Button/index.ts
31
+ var Button_default2 = Button_default;
32
+
33
+ // src/components/shared/Spinner/Spinner.tsx
34
+ import classes from "./Spinner.module-G7GUQJZJ.module.css";
35
+ import { jsx as jsx2 } from "react/jsx-runtime";
36
+ var Spinner = () => {
37
+ return /* @__PURE__ */ jsx2("div", { className: classes.spinner });
38
+ };
39
+ var Spinner_default = Spinner;
40
+
41
+ // src/components/shared/Spinner/index.ts
42
+ var Spinner_default2 = Spinner_default;
43
+
44
+ // src/components/WalletModal/WalletModal.tsx
45
+ import { useConnector } from "@solana/connector";
46
+ import { Check, ChevronLeft, Copy, ExternalLink, Wallet as Wallet2, X as X2 } from "lucide-react";
47
+ import { useEffect, useState as useState2, useSyncExternalStore } from "react";
48
+ import styles6 from "./WalletModal.module-PVV5PRXU.module.css";
49
+
50
+ // src/components/shared/Dialog/Dialog.tsx
51
+ import * as React2 from "react";
52
+ import { Dialog as BaseDialog } from "@base-ui/react/dialog";
53
+ import { X } from "lucide-react";
54
+ import styles2 from "./Dialog.module-HCRT743N.module.css";
55
+ import clsx from "clsx";
56
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
57
+ var Dialog = BaseDialog.Root;
58
+ var DialogTrigger = BaseDialog.Trigger;
59
+ var DialogPortal = BaseDialog.Portal;
60
+ var DialogClose = BaseDialog.Close;
61
+ var DialogBackdrop = React2.forwardRef(
62
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
63
+ BaseDialog.Backdrop,
64
+ {
65
+ ref,
66
+ className: `${styles2.backdrop} ${className || ""}`,
67
+ ...props
68
+ }
69
+ )
70
+ );
71
+ DialogBackdrop.displayName = "DialogBackdrop";
72
+ var DialogContent = React2.forwardRef(
73
+ ({ className, children, theme, showCloseButton = true, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
74
+ /* @__PURE__ */ jsx3(DialogBackdrop, { "data-theme": theme }),
75
+ /* @__PURE__ */ jsxs(
76
+ BaseDialog.Popup,
77
+ {
78
+ ref,
79
+ "data-theme": theme,
80
+ className: clsx(styles2.content, className),
81
+ ...props,
82
+ children: [
83
+ children,
84
+ showCloseButton && /* @__PURE__ */ jsx3(DialogClose, { className: styles2.closeButton, children: /* @__PURE__ */ jsx3(X, {}) })
85
+ ]
86
+ }
87
+ )
88
+ ] })
89
+ );
90
+ DialogContent.displayName = "DialogContent";
91
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx3("div", { className: `${styles2.header} ${className || ""}`, ...props });
92
+ DialogHeader.displayName = "DialogHeader";
93
+ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsx3("div", { className: `${styles2.footer} ${className || ""}`, ...props });
94
+ DialogFooter.displayName = "DialogFooter";
95
+ var DialogTitle = React2.forwardRef(
96
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
97
+ BaseDialog.Title,
98
+ {
99
+ ref,
100
+ className: `${styles2.title} ${className || ""}`,
101
+ ...props
102
+ }
103
+ )
104
+ );
105
+ DialogTitle.displayName = "DialogTitle";
106
+ var DialogDescription = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
107
+ BaseDialog.Description,
108
+ {
109
+ ref,
110
+ className: `${styles2.description} ${className || ""}`,
111
+ ...props
112
+ }
113
+ ));
114
+ DialogDescription.displayName = "DialogDescription";
115
+
116
+ // src/components/shared/CustomQRCode/CustomQRCode.tsx
117
+ import { useMemo } from "react";
118
+ import QRCodeUtil from "qrcode";
119
+ import styles3 from "./CustomQRCode.module-FOXENMZG.module.css";
120
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
121
+ function generateMatrix(value, errorCorrectionLevel) {
122
+ const arr = Array.prototype.slice.call(QRCodeUtil.create(value, { errorCorrectionLevel }).modules.data, 0);
123
+ const sqrt = Math.sqrt(arr.length);
124
+ return arr.reduce(
125
+ (rows, key, index) => (index % sqrt === 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) && rows,
126
+ []
127
+ );
128
+ }
129
+ function QRCodeSVG({
130
+ value,
131
+ size: sizeProp = 200,
132
+ ecl = "M",
133
+ clearArea = false,
134
+ dotColor = "currentColor",
135
+ backgroundColor = "#ffffff"
136
+ }) {
137
+ const logoSize = clearArea ? 76 : 0;
138
+ const size = sizeProp - 10 * 2;
139
+ const dots = useMemo(() => {
140
+ const dots2 = [];
141
+ const matrix = generateMatrix(value, ecl);
142
+ const cellSize = size / matrix.length;
143
+ const qrList = [
144
+ { x: 0, y: 0 },
145
+ { x: 1, y: 0 },
146
+ { x: 0, y: 1 }
147
+ ];
148
+ qrList.forEach(({ x, y }) => {
149
+ const x1 = (matrix.length - 7) * cellSize * x;
150
+ const y1 = (matrix.length - 7) * cellSize * y;
151
+ for (let i = 0; i < 3; i++) {
152
+ dots2.push(
153
+ /* @__PURE__ */ jsx4(
154
+ "rect",
155
+ {
156
+ fill: i % 2 !== 0 ? backgroundColor : dotColor,
157
+ rx: (i - 2) * -5 + (i === 0 ? 2 : 3),
158
+ ry: (i - 2) * -5 + (i === 0 ? 2 : 3),
159
+ width: cellSize * (7 - i * 2),
160
+ height: cellSize * (7 - i * 2),
161
+ x: x1 + cellSize * i,
162
+ y: y1 + cellSize * i
163
+ },
164
+ `finder-${i}-${x}-${y}`
165
+ )
166
+ );
167
+ }
168
+ });
169
+ const clearArenaSize = Math.floor((logoSize + 25) / cellSize);
170
+ const matrixMiddleStart = matrix.length / 2 - clearArenaSize / 2;
171
+ const matrixMiddleEnd = matrix.length / 2 + clearArenaSize / 2 - 1;
172
+ matrix.forEach((row, i) => {
173
+ row.forEach((_, j) => {
174
+ if (matrix[i][j]) {
175
+ if (!(i < 7 && j < 7 || i > matrix.length - 8 && j < 7 || i < 7 && j > matrix.length - 8)) {
176
+ if (!clearArea || !(i > matrixMiddleStart && i < matrixMiddleEnd && j > matrixMiddleStart && j < matrixMiddleEnd)) {
177
+ dots2.push(
178
+ /* @__PURE__ */ jsx4(
179
+ "circle",
180
+ {
181
+ cx: j * cellSize + cellSize / 2,
182
+ cy: i * cellSize + cellSize / 2,
183
+ fill: dotColor,
184
+ r: cellSize / 3
185
+ },
186
+ `dot-${i}-${j}`
187
+ )
188
+ );
189
+ }
190
+ }
191
+ }
192
+ });
193
+ });
194
+ return dots2;
195
+ }, [value, ecl, size, clearArea, logoSize, dotColor, backgroundColor]);
196
+ return /* @__PURE__ */ jsxs2(
197
+ "svg",
198
+ {
199
+ height: size,
200
+ width: size,
201
+ viewBox: `0 0 ${size} ${size}`,
202
+ className: styles3.svgFull,
203
+ style: { maxWidth: size, maxHeight: size },
204
+ children: [
205
+ /* @__PURE__ */ jsx4("rect", { fill: "transparent", height: size, width: size }),
206
+ dots
207
+ ]
208
+ }
209
+ );
210
+ }
211
+ function ViewfinderFrame({
212
+ size,
213
+ color = "#2D2D2D",
214
+ opacity = 0.01
215
+ }) {
216
+ return /* @__PURE__ */ jsx4(
217
+ "svg",
218
+ {
219
+ width: size,
220
+ height: size,
221
+ viewBox: "0 0 283 283",
222
+ fill: "none",
223
+ xmlns: "http://www.w3.org/2000/svg",
224
+ className: styles3.viewfinder,
225
+ children: /* @__PURE__ */ jsx4(
226
+ "path",
227
+ {
228
+ d: "M3.5 264.06C3.5 272.587 10.4127 279.5 18.9399 279.5H32.8799C33.7083 279.5 34.3799 280.172 34.3799 281V281C34.3799 281.828 33.7083 282.5 32.8799 282.5H17.4399C8.08427 282.5 0.5 274.916 0.5 265.56V250.12C0.5 249.292 1.17157 248.62 2 248.62V248.62C2.82843 248.62 3.5 249.292 3.5 250.12V264.06ZM282.5 266.058C282.5 275.139 275.139 282.5 266.058 282.5H251.116C250.288 282.5 249.616 281.828 249.616 281V281C249.616 280.172 250.288 279.5 251.116 279.5H264.558C272.81 279.5 279.5 272.81 279.5 264.558V250.12C279.5 249.292 280.172 248.62 281 248.62V248.62C281.828 248.62 282.5 249.292 282.5 250.12V266.058ZM34.3799 2C34.3799 2.82843 33.7083 3.5 32.8799 3.5H18.9399C10.4127 3.5 3.5 10.4127 3.5 18.9399V32.8799C3.5 33.7083 2.82843 34.3799 2 34.3799V34.3799C1.17157 34.3799 0.5 33.7083 0.5 32.8799V17.4399C0.5 8.08427 8.08427 0.5 17.4399 0.5H32.8799C33.7083 0.5 34.3799 1.17157 34.3799 2V2ZM282.5 32.8799C282.5 33.7083 281.828 34.3799 281 34.3799V34.3799C280.172 34.3799 279.5 33.7083 279.5 32.8799V18.4419C279.5 10.1897 272.81 3.5 264.558 3.5H251.116C250.288 3.5 249.616 2.82843 249.616 2V2C249.616 1.17157 250.288 0.5 251.116 0.5H266.058C275.139 0.5 282.5 7.86129 282.5 16.9419V32.8799Z",
229
+ fill: color,
230
+ fillOpacity: opacity
231
+ }
232
+ )
233
+ }
234
+ );
235
+ }
236
+ function CustomQRCode({
237
+ value,
238
+ size = 280,
239
+ ecl = "M",
240
+ clearArea = false,
241
+ image,
242
+ imageBackground = "transparent",
243
+ dotColor,
244
+ backgroundColor,
245
+ className,
246
+ style,
247
+ loading = false,
248
+ scanning = true,
249
+ error = false,
250
+ frameColor
251
+ }) {
252
+ const showPlaceholder = loading || !value;
253
+ const resolvedBackground = backgroundColor || "#ffffff";
254
+ const resolvedDotColor = dotColor || "#000000";
255
+ const resolvedFrameColor = error ? "#FF0000" : frameColor || "#2D2D2D";
256
+ const frameOpacity = error ? 0.56 : 0.01;
257
+ return /* @__PURE__ */ jsxs2(
258
+ "div",
259
+ {
260
+ className: `${styles3.container} ${className || ""}`,
261
+ style: {
262
+ width: size,
263
+ height: size,
264
+ ...style
265
+ },
266
+ children: [
267
+ /* @__PURE__ */ jsx4(ViewfinderFrame, { size, color: resolvedFrameColor, opacity: frameOpacity }),
268
+ /* @__PURE__ */ jsxs2(
269
+ "div",
270
+ {
271
+ className: styles3.contentArea,
272
+ style: { background: resolvedBackground },
273
+ "data-error": error,
274
+ children: [
275
+ /* @__PURE__ */ jsx4("div", { className: styles3.glow, "data-error": error }),
276
+ scanning && !showPlaceholder && !error && /* @__PURE__ */ jsx4("div", { className: styles3.shine }),
277
+ /* @__PURE__ */ jsx4("div", { className: styles3.qrWrapper, children: showPlaceholder ? /* @__PURE__ */ jsx4(QRPlaceholder, { size, dotColor: resolvedDotColor, backgroundColor: resolvedBackground }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
278
+ /* @__PURE__ */ jsx4(
279
+ QRCodeSVG,
280
+ {
281
+ value,
282
+ size: size - 40,
283
+ ecl,
284
+ clearArea: clearArea || !!image,
285
+ dotColor: resolvedDotColor,
286
+ backgroundColor: resolvedBackground
287
+ }
288
+ ),
289
+ image && /* @__PURE__ */ jsx4(
290
+ "div",
291
+ {
292
+ className: styles3.logoWrapper,
293
+ style: {
294
+ width: "28%",
295
+ height: "28%",
296
+ background: imageBackground || resolvedBackground
297
+ },
298
+ children: image
299
+ }
300
+ )
301
+ ] }) })
302
+ ]
303
+ }
304
+ )
305
+ ]
306
+ }
307
+ );
308
+ }
309
+ function QRPlaceholder({
310
+ size,
311
+ dotColor,
312
+ backgroundColor
313
+ }) {
314
+ return /* @__PURE__ */ jsxs2("div", { className: styles3.placeholderContainer, style: { width: size - 40, height: size - 40 }, children: [
315
+ /* @__PURE__ */ jsx4(
316
+ "div",
317
+ {
318
+ className: styles3.placeholderPattern,
319
+ style: {
320
+ backgroundImage: `radial-gradient(${dotColor} 41%, transparent 41%)`
321
+ }
322
+ }
323
+ ),
324
+ [
325
+ { top: 0, left: 0 },
326
+ { top: 0, right: 0 },
327
+ { bottom: 0, left: 0 }
328
+ ].map((pos, i) => /* @__PURE__ */ jsx4(
329
+ "span",
330
+ {
331
+ className: styles3.cornerSquare,
332
+ style: {
333
+ ...pos,
334
+ background: dotColor
335
+ }
336
+ },
337
+ i
338
+ )),
339
+ /* @__PURE__ */ jsx4(
340
+ "div",
341
+ {
342
+ className: styles3.centerArea,
343
+ style: {
344
+ background: backgroundColor,
345
+ boxShadow: `0 0 0 7px ${backgroundColor}`
346
+ }
347
+ }
348
+ ),
349
+ /* @__PURE__ */ jsxs2("div", { className: styles3.loaderWrapper, children: [
350
+ /* @__PURE__ */ jsx4(
351
+ "div",
352
+ {
353
+ className: styles3.spinner,
354
+ style: { color: `${dotColor}40` }
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsx4("span", { className: styles3.loadingText, style: { color: `${dotColor}70` }, children: "Generating QR code..." })
358
+ ] })
359
+ ] });
360
+ }
361
+ CustomQRCode.displayName = "CustomQRCode";
362
+
363
+ // src/components/shared/CustomQRCode/index.ts
364
+ var CustomQRCode_default = CustomQRCode;
365
+
366
+ // src/components/WalletModal/WalletModal.tsx
367
+ import { SiWalletconnect } from "react-icons/si";
368
+
369
+ // src/components/shared/Collapsible/Collapsible.tsx
370
+ import * as React3 from "react";
371
+ import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
372
+ import styles4 from "./Collapsible.module-NXSN3MGI.module.css";
373
+ import { jsx as jsx5 } from "react/jsx-runtime";
374
+ var Collapsible = BaseCollapsible.Root;
375
+ var CollapsibleTrigger = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
376
+ BaseCollapsible.Trigger,
377
+ {
378
+ ref,
379
+ className: `${styles4.trigger} ${className || ""}`,
380
+ ...props
381
+ }
382
+ ));
383
+ CollapsibleTrigger.displayName = "CollapsibleTrigger";
384
+ var CollapsibleContent = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
385
+ BaseCollapsible.Panel,
386
+ {
387
+ ref,
388
+ className: `${styles4.content} ${className || ""}`,
389
+ ...props
390
+ }
391
+ ));
392
+ CollapsibleContent.displayName = "CollapsibleContent";
393
+
394
+ // src/components/shared/Avatar/Avatar.tsx
395
+ import { useState } from "react";
396
+ import styles5 from "./Avatar.module-P7KEBP7R.module.css";
397
+ import { Wallet } from "lucide-react";
398
+ import { jsx as jsx6 } from "react/jsx-runtime";
399
+ function Avatar({
400
+ height,
401
+ width,
402
+ src,
403
+ alt,
404
+ theme = "light"
405
+ }) {
406
+ const [hasError, setHasError] = useState(false);
407
+ return /* @__PURE__ */ jsx6("div", { className: styles5.avatar, "data-theme": theme, children: src && !hasError ? /* @__PURE__ */ jsx6(
408
+ "img",
409
+ {
410
+ height,
411
+ width,
412
+ src,
413
+ alt: alt || "Avatar",
414
+ onError: () => setHasError(true)
415
+ }
416
+ ) : /* @__PURE__ */ jsx6("div", { className: styles5.fallback, style: { height, width }, children: /* @__PURE__ */ jsx6(Wallet, {}) }) });
417
+ }
418
+
419
+ // src/components/shared/Avatar/index.ts
420
+ var Avatar_default = Avatar;
421
+
422
+ // src/components/WalletModal/WalletModal.tsx
423
+ import { clsx as clsx2 } from "clsx";
424
+ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
425
+ function WalletModal(props) {
426
+ var _a;
427
+ const {
428
+ CN_Modal,
429
+ theme = "light",
430
+ open,
431
+ onOpenChange,
432
+ walletConnectUri,
433
+ onClearWalletConnectUri
434
+ } = props;
435
+ const { walletStatus: { status }, isConnecting, connectorId, connectors, connectWallet, disconnectWallet } = useConnector();
436
+ const [connectingConnectorId, setConnectingConnectorId] = useState2(null);
437
+ const [isOtherWalletsOpen, setIsOtherWalletsOpen] = useState2(false);
438
+ const [errorConnectorId, setErrorConnectorId] = useState2(null);
439
+ const [errorMessage, setErrorMessage] = useState2(null);
440
+ const [copied, setCopied] = useState2(false);
441
+ const isClient = useSyncExternalStore(
442
+ () => () => {
443
+ },
444
+ () => true,
445
+ () => false
446
+ );
447
+ const recentlyConnectedConnectorId = useSyncExternalStore(
448
+ () => () => {
449
+ },
450
+ () => localStorage.getItem("recentlyConnectedConnectorId"),
451
+ () => null
452
+ );
453
+ useEffect(() => {
454
+ if (status === "connected" && connectorId) {
455
+ localStorage.setItem("recentlyConnectedConnectorId", connectorId);
456
+ }
457
+ }, [status, connectorId]);
458
+ const walletConnectConnector = (_a = connectors.find((c) => c.name === "WalletConnect")) != null ? _a : null;
459
+ const isWalletConnectFlow = !!walletConnectConnector && (connectingConnectorId === walletConnectConnector.id || status === "connecting" && connectorId === walletConnectConnector.id) || !!walletConnectUri;
460
+ function cancelConnection() {
461
+ onClearWalletConnectUri == null ? void 0 : onClearWalletConnectUri();
462
+ setConnectingConnectorId(null);
463
+ disconnectWallet().catch(() => {
464
+ });
465
+ }
466
+ const clearError = () => {
467
+ setErrorConnectorId(null);
468
+ setErrorMessage(null);
469
+ };
470
+ const handleSelectWallet = async (connector) => {
471
+ clearError();
472
+ setConnectingConnectorId(connector.id);
473
+ try {
474
+ if (connector.name === "WalletConnect") {
475
+ onClearWalletConnectUri == null ? void 0 : onClearWalletConnectUri();
476
+ }
477
+ await connectWallet(connector.id);
478
+ localStorage.setItem("recentlyConnectedConnectorId", connector.id);
479
+ if (connector.name !== "WalletConnect") {
480
+ onOpenChange(false);
481
+ }
482
+ } catch (error) {
483
+ const message = error instanceof Error ? error.message : "An unexpected error occurred";
484
+ if (message.includes("Connection cancelled")) return;
485
+ setErrorConnectorId(connector.id);
486
+ setErrorMessage(message);
487
+ console.error("Failed to connect wallet:", {
488
+ wallet: connector.name,
489
+ connectorId: connector.id,
490
+ error,
491
+ message,
492
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
493
+ });
494
+ } finally {
495
+ setConnectingConnectorId(null);
496
+ }
497
+ };
498
+ const handleCopyUri = async () => {
499
+ if (!walletConnectUri) return;
500
+ try {
501
+ await navigator.clipboard.writeText(walletConnectUri);
502
+ setCopied(true);
503
+ setTimeout(() => setCopied(false), 2e3);
504
+ } catch (err) {
505
+ console.error("Failed to copy URI:", err);
506
+ }
507
+ };
508
+ const handleBackFromWalletConnect = () => {
509
+ cancelConnection();
510
+ };
511
+ const readyConnectors = connectors.filter((c) => c.ready);
512
+ const notReadyConnectors = connectors.filter((c) => !c.ready);
513
+ const sortedReadyConnectors = [...readyConnectors].sort((a, b) => {
514
+ const aIsRecent = recentlyConnectedConnectorId === a.id;
515
+ const bIsRecent = recentlyConnectedConnectorId === b.id;
516
+ if (aIsRecent && !bIsRecent) return -1;
517
+ if (!aIsRecent && bIsRecent) return 1;
518
+ return 0;
519
+ });
520
+ const primaryWallets = sortedReadyConnectors.slice(0, 3);
521
+ const otherWallets = sortedReadyConnectors.slice(3);
522
+ const primayOuterHr = otherWallets.length > 0 && primaryWallets.length > 0;
523
+ const getInstallUrl = (walletName, walletUrl) => {
524
+ if (walletUrl) return walletUrl;
525
+ const name = walletName.toLowerCase();
526
+ if (name.includes("phantom")) return "https://phantom.app";
527
+ if (name.includes("solflare")) return "https://solflare.com";
528
+ if (name.includes("backpack")) return "https://backpack.app";
529
+ if (name.includes("glow")) return "https://glow.app";
530
+ if (name.includes("coinbase")) return "https://www.coinbase.com/wallet";
531
+ if (name.includes("ledger")) return "https://www.ledger.com";
532
+ if (name.includes("trust")) return "https://trustwallet.com";
533
+ if (name.includes("exodus")) return "https://www.exodus.com";
534
+ return void 0;
535
+ };
536
+ const handleOpenChange = (isOpen) => {
537
+ if (!isOpen) {
538
+ clearError();
539
+ if (isConnecting || connectingConnectorId || walletConnectUri) {
540
+ cancelConnection();
541
+ }
542
+ }
543
+ onOpenChange(isOpen);
544
+ };
545
+ const walletLinkOpen = (walletName) => {
546
+ const installUrl = getInstallUrl(walletName);
547
+ if (installUrl) {
548
+ window.open(installUrl, "_blank");
549
+ }
550
+ };
551
+ return /* @__PURE__ */ jsx7(Dialog, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs3(
552
+ DialogContent,
553
+ {
554
+ showCloseButton: false,
555
+ className: clsx2(styles6.dialogContent, CN_Modal),
556
+ theme,
557
+ children: [
558
+ /* @__PURE__ */ jsxs3("div", { className: styles6.dialogHeader, children: [
559
+ isWalletConnectFlow ? /* @__PURE__ */ jsx7(
560
+ "button",
561
+ {
562
+ onClick: handleBackFromWalletConnect,
563
+ className: styles6.iconButton,
564
+ children: /* @__PURE__ */ jsx7(ChevronLeft, {})
565
+ }
566
+ ) : null,
567
+ /* @__PURE__ */ jsx7(DialogTitle, { className: styles6.dialogTitle, children: isWalletConnectFlow ? "WalletConnect" : "Connect your wallet" }),
568
+ /* @__PURE__ */ jsx7(DialogClose, { className: styles6.iconButton, children: /* @__PURE__ */ jsx7(X2, {}) })
569
+ ] }),
570
+ isWalletConnectFlow && /* @__PURE__ */ jsxs3("div", { className: styles6.walletsContainer, children: [
571
+ /* @__PURE__ */ jsxs3("div", { className: styles6.tooltipBubble, children: [
572
+ /* @__PURE__ */ jsx7("span", { children: "Use a WalletConnect" }),
573
+ /* @__PURE__ */ jsxs3("div", { className: styles6.tooltipIconWrapper, children: [
574
+ /* @__PURE__ */ jsx7(SiWalletconnect, { className: styles6.tooltipIcon }),
575
+ /* @__PURE__ */ jsx7("div", { className: styles6.tooltipCaret })
576
+ ] }),
577
+ /* @__PURE__ */ jsx7("span", { children: "supported wallet to scan" })
578
+ ] }),
579
+ /* @__PURE__ */ jsx7("div", { className: styles6.qrWrapper, children: /* @__PURE__ */ jsx7(
580
+ CustomQRCode_default,
581
+ {
582
+ value: walletConnectUri != null ? walletConnectUri : "",
583
+ size: 280,
584
+ ecl: "M",
585
+ loading: !walletConnectUri,
586
+ scanning: !!walletConnectUri
587
+ }
588
+ ) }),
589
+ /* @__PURE__ */ jsx7(
590
+ Button_default2,
591
+ {
592
+ variant: "outline",
593
+ onClick: handleCopyUri,
594
+ disabled: !walletConnectUri,
595
+ className: styles6.copyButton,
596
+ "data-theme": theme,
597
+ children: copied ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
598
+ /* @__PURE__ */ jsx7(Check, { className: `${styles6.icon} ${styles6.successIcon}` }),
599
+ "Copy to Clipboard"
600
+ ] }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
601
+ /* @__PURE__ */ jsx7(Copy, { className: styles6.icon }),
602
+ "Copy to Clipboard"
603
+ ] })
604
+ }
605
+ )
606
+ ] }),
607
+ !isWalletConnectFlow && /* @__PURE__ */ jsxs3("div", { className: styles6.walletsContainer, children: [
608
+ !isClient && /* @__PURE__ */ jsxs3("div", { className: styles6.detectingWallets, children: [
609
+ /* @__PURE__ */ jsx7(Spinner_default2, {}),
610
+ /* @__PURE__ */ jsx7("p", { children: "Detecting wallets..." })
611
+ ] }),
612
+ connectors.length === 0 && /* @__PURE__ */ jsxs3("div", { className: styles6.emptyStateContainer, children: [
613
+ /* @__PURE__ */ jsx7(Wallet2, { className: styles6.emptyStateIcon }),
614
+ /* @__PURE__ */ jsx7("h3", { className: styles6.emptyStateTitle, children: "No Wallets Detected" }),
615
+ /* @__PURE__ */ jsx7("p", { className: styles6.emptyStateDesc, children: "Install a Solana wallet extension to get started" }),
616
+ /* @__PURE__ */ jsxs3("div", { className: styles6.emptyStateActions, children: [
617
+ /* @__PURE__ */ jsx7(
618
+ Button_default2,
619
+ {
620
+ variant: "outline",
621
+ "data-theme": theme,
622
+ onClick: () => walletLinkOpen("Phantom"),
623
+ children: "Get Phantom"
624
+ }
625
+ ),
626
+ /* @__PURE__ */ jsx7(
627
+ Button_default2,
628
+ {
629
+ "data-theme": theme,
630
+ variant: "outline",
631
+ onClick: () => walletLinkOpen("Backpack"),
632
+ children: "Get Backpack"
633
+ }
634
+ )
635
+ ] })
636
+ ] }),
637
+ /* @__PURE__ */ jsx7("div", { className: styles6.allWallets, children: primaryWallets.map((connector) => /* @__PURE__ */ jsx7(
638
+ WalletButton,
639
+ {
640
+ theme,
641
+ connector,
642
+ isThisConnecting: isConnecting && connectingConnectorId === connector.id,
643
+ hasError: errorConnectorId === connector.id,
644
+ isRecent: recentlyConnectedConnectorId === connector.id,
645
+ onSelect: () => handleSelectWallet(connector),
646
+ getInstallUrl
647
+ },
648
+ connector.id
649
+ )) }),
650
+ otherWallets.length > 0 && /* @__PURE__ */ jsxs3(Fragment2, { children: [
651
+ primayOuterHr && /* @__PURE__ */ jsx7("div", { className: styles6.seprator }),
652
+ /* @__PURE__ */ jsxs3(
653
+ Collapsible,
654
+ {
655
+ open: isOtherWalletsOpen,
656
+ onOpenChange: setIsOtherWalletsOpen,
657
+ className: styles6.Collapsible,
658
+ children: [
659
+ /* @__PURE__ */ jsxs3(CollapsibleTrigger, { className: styles6.hiddenExpand, children: [
660
+ /* @__PURE__ */ jsx7("span", { className: styles6.textContainer, children: "Other Wallets" }),
661
+ /* @__PURE__ */ jsx7(HiddenWalletIcons, { wallets: otherWallets, className: "shrink-0" })
662
+ ] }),
663
+ /* @__PURE__ */ jsx7(CollapsibleContent, { className: styles6.allWallets, children: otherWallets.map((connector) => /* @__PURE__ */ jsx7(
664
+ WalletButton,
665
+ {
666
+ theme,
667
+ connector,
668
+ isThisConnecting: isConnecting && connectingConnectorId === connector.id,
669
+ hasError: errorConnectorId === connector.id,
670
+ isRecent: recentlyConnectedConnectorId === connector.id,
671
+ onSelect: () => handleSelectWallet(connector),
672
+ getInstallUrl
673
+ },
674
+ connector.id
675
+ )) })
676
+ ]
677
+ }
678
+ )
679
+ ] }),
680
+ notReadyConnectors.length > 0 && /* @__PURE__ */ jsxs3(Fragment2, { children: [
681
+ (primaryWallets.length > 0 || otherWallets.length > 0) && /* @__PURE__ */ jsx7("div", { className: styles6.seprator }),
682
+ /* @__PURE__ */ jsxs3("div", { className: "space-y-2", children: [
683
+ /* @__PURE__ */ jsx7("h3", { className: styles6.sectionHeader, children: readyConnectors.length > 0 ? "Unavailable Wallets" : "Wallets" }),
684
+ /* @__PURE__ */ jsx7("div", { className: styles6.grid, children: notReadyConnectors.slice(0, 3).map((connector) => {
685
+ const installUrl = getInstallUrl(connector.name);
686
+ return /* @__PURE__ */ jsxs3("div", { className: styles6.unavailableRow, children: [
687
+ /* @__PURE__ */ jsxs3("div", { className: styles6.walletInfo, children: [
688
+ /* @__PURE__ */ jsx7(
689
+ Avatar_default,
690
+ {
691
+ width: 40,
692
+ height: 40,
693
+ src: connector.icon,
694
+ alt: connector.name,
695
+ theme
696
+ }
697
+ ),
698
+ /* @__PURE__ */ jsxs3("div", { className: "text-left", children: [
699
+ /* @__PURE__ */ jsx7("div", { className: styles6.walletName, children: connector.name }),
700
+ /* @__PURE__ */ jsx7("div", { className: styles6.unavailableLabel, children: "Not available" })
701
+ ] })
702
+ ] }),
703
+ installUrl && /* @__PURE__ */ jsx7(
704
+ Button_default2,
705
+ {
706
+ "data-theme": theme,
707
+ variant: "ghost",
708
+ size: "sm",
709
+ className: styles6.installButton,
710
+ onClick: () => window.open(installUrl, "_blank"),
711
+ children: /* @__PURE__ */ jsx7(ExternalLink, {})
712
+ }
713
+ )
714
+ ] }, connector.id);
715
+ }) })
716
+ ] })
717
+ ] })
718
+ ] })
719
+ ]
720
+ }
721
+ ) });
722
+ }
723
+ var WalletModal_default = WalletModal;
724
+ function WalletButton(props) {
725
+ const { connector, isThisConnecting, hasError, isRecent, theme, onSelect, getInstallUrl } = props;
726
+ const handleSelectWallet = () => {
727
+ onSelect();
728
+ };
729
+ return /* @__PURE__ */ jsxs3(
730
+ Button_default2,
731
+ {
732
+ variant: "outline",
733
+ "data-error": hasError,
734
+ "data-theme": theme,
735
+ className: styles6.walletButton,
736
+ onClick: handleSelectWallet,
737
+ disabled: isThisConnecting,
738
+ children: [
739
+ /* @__PURE__ */ jsxs3("div", { className: styles6.textContainer, children: [
740
+ /* @__PURE__ */ jsxs3("div", { className: styles6.nameRow, children: [
741
+ /* @__PURE__ */ jsx7("span", { children: connector.name }),
742
+ isRecent && /* @__PURE__ */ jsx7("span", { className: styles6.recentBadge, children: "Recent" })
743
+ ] }),
744
+ isThisConnecting && /* @__PURE__ */ jsx7("div", { className: styles6.statusText, children: "Connecting..." }),
745
+ hasError && !isThisConnecting && /* @__PURE__ */ jsx7("div", { className: styles6.statusText, "data-type": "error", children: "Click to retry" })
746
+ ] }),
747
+ /* @__PURE__ */ jsxs3("div", { className: styles6.iconContainer, children: [
748
+ isThisConnecting && /* @__PURE__ */ jsx7(Spinner_default2, {}),
749
+ /* @__PURE__ */ jsx7(
750
+ Avatar_default,
751
+ {
752
+ width: 40,
753
+ height: 40,
754
+ src: connector.icon,
755
+ alt: connector.name,
756
+ theme
757
+ }
758
+ )
759
+ ] })
760
+ ]
761
+ },
762
+ connector.id
763
+ );
764
+ }
765
+ function HiddenWalletIcons({ wallets, maxIcons = 4, className }) {
766
+ const previewWallets = wallets.slice(0, maxIcons);
767
+ const placeholderCount = Math.max(0, maxIcons - previewWallets.length);
768
+ return /* @__PURE__ */ jsxs3(
769
+ "div",
770
+ {
771
+ className: `${styles6.hiddenWalletGrid} ${className || ""}`,
772
+ "aria-hidden": "true",
773
+ children: [
774
+ previewWallets.map((wallet) => /* @__PURE__ */ jsx7(
775
+ "div",
776
+ {
777
+ className: styles6.hiddenWalletIconWrapper,
778
+ children: wallet.icon && /* @__PURE__ */ jsx7(
779
+ "img",
780
+ {
781
+ height: 10,
782
+ width: 10,
783
+ src: wallet.icon,
784
+ alt: wallet.name,
785
+ draggable: false,
786
+ onError: (e) => {
787
+ e.currentTarget.style.display = "none";
788
+ }
789
+ }
790
+ )
791
+ },
792
+ wallet.id
793
+ )),
794
+ Array.from({ length: placeholderCount }).map((_, index) => /* @__PURE__ */ jsx7(
795
+ "div",
796
+ {
797
+ className: styles6.hiddenWalletIconWrapper
798
+ },
799
+ `placeholder-${index}`
800
+ ))
801
+ ]
802
+ }
803
+ );
804
+ }
805
+
806
+ // src/components/WalletModal/index.ts
807
+ var WalletModal_default2 = WalletModal_default;
808
+
809
+ // src/components/ConnectButton/ConnectButton.tsx
810
+ import clsx4 from "clsx";
811
+
812
+ // src/components/shared/Menu/Menu.tsx
813
+ import * as React4 from "react";
814
+ import { Menu as BaseMenu } from "@base-ui/react/menu";
815
+ import styles7 from "./Menu.module-GV627ZLI.module.css";
816
+ import { jsx as jsx8 } from "react/jsx-runtime";
817
+ var Menu = BaseMenu.Root;
818
+ var MenuPortal = BaseMenu.Portal;
819
+ var MenuGroup = BaseMenu.Group;
820
+ var MenuTrigger = React4.forwardRef(
821
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx8(
822
+ BaseMenu.Trigger,
823
+ {
824
+ ref,
825
+ className: `${className || ""}`,
826
+ ...props
827
+ }
828
+ )
829
+ );
830
+ MenuTrigger.displayName = "MenuTrigger";
831
+ var MenuPositioner = React4.forwardRef(
832
+ ({ sideOffset = 8, ...props }, ref) => /* @__PURE__ */ jsx8(BaseMenu.Positioner, { ref, sideOffset, ...props })
833
+ );
834
+ MenuPositioner.displayName = "MenuPositioner";
835
+ var MenuPopup = React4.forwardRef(
836
+ ({ className, theme, ...props }, ref) => /* @__PURE__ */ jsx8(
837
+ BaseMenu.Popup,
838
+ {
839
+ ref,
840
+ "data-theme": theme,
841
+ className: `${styles7.popup} ${className || ""}`,
842
+ ...props
843
+ }
844
+ )
845
+ );
846
+ MenuPopup.displayName = "MenuPopup";
847
+ var MenuItem = React4.forwardRef(
848
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx8(
849
+ BaseMenu.Item,
850
+ {
851
+ ref,
852
+ className: `${styles7.item} ${className || ""}`,
853
+ ...props
854
+ }
855
+ )
856
+ );
857
+ MenuItem.displayName = "MenuItem";
858
+ var MenuSeparator = React4.forwardRef(
859
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx8(BaseMenu.Separator, { ref, className: `${styles7.separator} ${className || ""}`, ...props })
860
+ );
861
+ MenuSeparator.displayName = "MenuSeparator";
862
+ var MenuGroupLabel = React4.forwardRef(
863
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx8(BaseMenu.GroupLabel, { ref, className: `${styles7.groupLabel} ${className || ""}`, ...props })
864
+ );
865
+ MenuGroupLabel.displayName = "MenuGroupLabel";
866
+
867
+ // src/components/ConnectButton/ConnectButton.tsx
868
+ import { ChevronDown } from "lucide-react";
869
+
870
+ // src/components/WalletDropdown/WalletDropdown.tsx
871
+ import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
872
+ import styles8 from "./WalletDropdown.module-342MM7XM.module.css";
873
+ import { motion } from "motion/react";
874
+ import { Check as Check2, ChevronLeft as ChevronLeft2, Copy as Copy2, Globe, LogOut, RefreshCw } from "lucide-react";
875
+ import { address, ClusterElement, DisconnectElement, lamportsToSol, useConnectorClient } from "@solana/connector";
876
+ import { createSolanaRpc } from "@solana/kit";
877
+ import { clsx as clsx3 } from "clsx";
878
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
879
+ var networkColor = {
880
+ "solana:mainnet": "#00c950",
881
+ "solana:devnet": "#2b7fff",
882
+ "solana:testnet": "#f0b100",
883
+ "solana:localnet": "#ff3b3b"
884
+ };
885
+ function WalletDropdown(props) {
886
+ const client = useConnectorClient();
887
+ const { CN_ConnectButton, selectedAccount, walletIcon, walletName, theme, allowNetworkSwitch, showSolBalance } = props;
888
+ const [view, setView] = useState3("wallet");
889
+ const [copied, setCopied] = useState3(false);
890
+ const fetching = useRef(false);
891
+ const [isFetchingBalance, setIsFetchingBalance] = useState3(false);
892
+ const [solBalance, setSolBalance] = useState3(null);
893
+ const shortAddress = `${selectedAccount.slice(0, 4)}...${selectedAccount.slice(-4)}`;
894
+ async function handleCopy() {
895
+ try {
896
+ await navigator.clipboard.writeText(selectedAccount);
897
+ setCopied(true);
898
+ setTimeout(() => setCopied(false), 2e3);
899
+ } catch (error) {
900
+ setCopied(false);
901
+ console.error("Failed to copy to clipboard:", error);
902
+ }
903
+ }
904
+ async function fetchSolBalance() {
905
+ if (!client || fetching.current) return;
906
+ setIsFetchingBalance(true);
907
+ fetching.current = true;
908
+ try {
909
+ const rpcUrl = client.getRpcUrl();
910
+ const pubkey = address(selectedAccount);
911
+ if (!rpcUrl) throw new Error("No RPC endpoint configured");
912
+ const rpc = createSolanaRpc(rpcUrl);
913
+ const solLamports = (await rpc.getBalance(pubkey).send()).value || 0;
914
+ const sol = lamportsToSol(solLamports);
915
+ setSolBalance(sol);
916
+ } catch (error) {
917
+ setSolBalance(0);
918
+ } finally {
919
+ setIsFetchingBalance(false);
920
+ fetching.current = false;
921
+ }
922
+ }
923
+ useEffect2(() => {
924
+ if (showSolBalance && selectedAccount && client) {
925
+ fetchSolBalance();
926
+ }
927
+ }, [selectedAccount, client, showSolBalance]);
928
+ if (view === "wallet") {
929
+ return /* @__PURE__ */ jsxs4(
930
+ motion.div,
931
+ {
932
+ initial: { opacity: 0 },
933
+ animate: { opacity: 1 },
934
+ exit: { opacity: 0 },
935
+ transition: { duration: 0.2 },
936
+ className: clsx3(styles8.WalletDropdown, CN_ConnectButton),
937
+ "data-theme": theme,
938
+ children: [
939
+ /* @__PURE__ */ jsxs4("div", { className: styles8.Header, children: [
940
+ /* @__PURE__ */ jsxs4("div", { className: styles8.addressAndAvatar, children: [
941
+ /* @__PURE__ */ jsx9(
942
+ Avatar_default,
943
+ {
944
+ width: 48,
945
+ height: 48,
946
+ src: walletIcon,
947
+ alt: walletName
948
+ }
949
+ ),
950
+ /* @__PURE__ */ jsxs4("div", { className: styles8.address, children: [
951
+ /* @__PURE__ */ jsx9("span", { className: styles8.shortAddress, children: shortAddress }),
952
+ /* @__PURE__ */ jsx9("span", { className: styles8.walletName, children: walletName })
953
+ ] })
954
+ ] }),
955
+ /* @__PURE__ */ jsxs4("div", { className: styles8.actions, children: [
956
+ /* @__PURE__ */ jsx9(
957
+ Button_default2,
958
+ {
959
+ type: "button",
960
+ onClick: handleCopy,
961
+ variant: "outline",
962
+ size: "icon",
963
+ className: "rounded-full",
964
+ title: copied ? "Copied!" : "Copy address",
965
+ children: copied ? /* @__PURE__ */ jsx9(Check2, { className: styles8.checkIcon }) : /* @__PURE__ */ jsx9(Copy2, {})
966
+ }
967
+ ),
968
+ allowNetworkSwitch && /* @__PURE__ */ jsx9(
969
+ ClusterElement,
970
+ {
971
+ render: ({ cluster }) => /* @__PURE__ */ jsxs4(
972
+ Button_default2,
973
+ {
974
+ type: "button",
975
+ variant: "outline",
976
+ size: "icon",
977
+ onClick: () => setView("network"),
978
+ title: `Network: ${(cluster == null ? void 0 : cluster.label) || "Unknown"}`,
979
+ children: [
980
+ /* @__PURE__ */ jsx9(Globe, {}),
981
+ /* @__PURE__ */ jsx9(
982
+ "span",
983
+ {
984
+ className: styles8.networkIndicator,
985
+ style: { background: networkColor[(cluster == null ? void 0 : cluster.id) || "solana:mainnet"] }
986
+ }
987
+ )
988
+ ]
989
+ }
990
+ )
991
+ }
992
+ )
993
+ ] })
994
+ ] }),
995
+ showSolBalance && /* @__PURE__ */ jsxs4("div", { className: styles8.balanceSection, children: [
996
+ /* @__PURE__ */ jsxs4(
997
+ "div",
998
+ {
999
+ className: styles8.balanceHeader,
1000
+ children: [
1001
+ /* @__PURE__ */ jsx9("span", { className: styles8.balanceLabel, children: "Balance" }),
1002
+ /* @__PURE__ */ jsx9(
1003
+ "button",
1004
+ {
1005
+ onClick: () => fetchSolBalance(),
1006
+ disabled: isFetchingBalance,
1007
+ title: "Refresh balance",
1008
+ className: styles8.refreshButton,
1009
+ "data-loading": isFetchingBalance,
1010
+ children: /* @__PURE__ */ jsx9(
1011
+ RefreshCw,
1012
+ {
1013
+ className: styles8.refreshIcon
1014
+ }
1015
+ )
1016
+ }
1017
+ )
1018
+ ]
1019
+ }
1020
+ ),
1021
+ /* @__PURE__ */ jsx9("div", { className: styles8.balanceValue, children: isFetchingBalance ? /* @__PURE__ */ jsx9("div", { className: styles8.balanceLoading }) : solBalance !== null ? `${solBalance.toFixed(4)} SOL` : "-- SOL" })
1022
+ ] }),
1023
+ /* @__PURE__ */ jsx9(
1024
+ DisconnectElement,
1025
+ {
1026
+ render: ({ disconnect, disconnecting }) => /* @__PURE__ */ jsxs4(
1027
+ Button_default2,
1028
+ {
1029
+ variant: "default",
1030
+ className: styles8.disconnectButton,
1031
+ onClick: disconnect,
1032
+ disabled: disconnecting,
1033
+ children: [
1034
+ /* @__PURE__ */ jsx9(LogOut, { className: styles8.disconnectIcon }),
1035
+ disconnecting ? "Disconnecting..." : "Disconnect"
1036
+ ]
1037
+ }
1038
+ )
1039
+ }
1040
+ )
1041
+ ]
1042
+ }
1043
+ );
1044
+ }
1045
+ if (view === "network") {
1046
+ console.count("Network view rendered");
1047
+ return /* @__PURE__ */ jsxs4(
1048
+ motion.div,
1049
+ {
1050
+ initial: { opacity: 0 },
1051
+ animate: { opacity: 1 },
1052
+ exit: { opacity: 0 },
1053
+ transition: { duration: 0.2 },
1054
+ className: clsx3(styles8.WalletDropdown, CN_ConnectButton),
1055
+ "data-theme": theme,
1056
+ children: [
1057
+ /* @__PURE__ */ jsxs4("div", { className: styles8.NetworkHeader, children: [
1058
+ /* @__PURE__ */ jsx9(
1059
+ Button_default2,
1060
+ {
1061
+ type: "button",
1062
+ variant: "outline",
1063
+ size: "icon",
1064
+ onClick: () => setView("wallet"),
1065
+ title: `Network: Back to Wallet`,
1066
+ className: styles8.backButton,
1067
+ children: /* @__PURE__ */ jsx9(ChevronLeft2, {})
1068
+ }
1069
+ ),
1070
+ /* @__PURE__ */ jsx9("span", { children: "Network Settings" })
1071
+ ] }),
1072
+ /* @__PURE__ */ jsx9(
1073
+ ClusterElement,
1074
+ {
1075
+ render: ({ cluster, clusters, setCluster }) => {
1076
+ const currentClusterId = (cluster == null ? void 0 : cluster.id) || "solana:mainnet";
1077
+ return /* @__PURE__ */ jsx9("div", { className: styles8.networkOptions, children: clusters.map((network, index) => {
1078
+ const isSelected = currentClusterId === network.id;
1079
+ return /* @__PURE__ */ jsxs4(
1080
+ "div",
1081
+ {
1082
+ role: "button",
1083
+ tabIndex: 0,
1084
+ onClick: () => setCluster(network.id),
1085
+ onKeyDown: (e) => {
1086
+ if (e.key === "Enter" || e.key === " ") {
1087
+ e.preventDefault();
1088
+ setCluster(network.id);
1089
+ }
1090
+ },
1091
+ className: styles8.networkButton,
1092
+ children: [
1093
+ /* @__PURE__ */ jsxs4("div", { className: styles8.networkName, children: [
1094
+ /* @__PURE__ */ jsx9(
1095
+ "span",
1096
+ {
1097
+ className: styles8.networkColor,
1098
+ style: { background: networkColor[network.id] }
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ jsx9("span", { className: styles8.networkLabel, children: network.label })
1102
+ ] }),
1103
+ /* @__PURE__ */ jsx9("div", { className: styles8.checkMark, "data-selected": isSelected, children: isSelected && /* @__PURE__ */ jsx9(Check2, {}) })
1104
+ ]
1105
+ },
1106
+ network.id
1107
+ );
1108
+ }) });
1109
+ }
1110
+ }
1111
+ )
1112
+ ]
1113
+ }
1114
+ );
1115
+ }
1116
+ }
1117
+ var WalletDropdown_default = WalletDropdown;
1118
+
1119
+ // src/components/WalletDropdown/index.ts
1120
+ var WalletDropdown_default2 = WalletDropdown_default;
1121
+
1122
+ // src/components/ConnectButton/ConnectButton.tsx
1123
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1124
+ function ConnectButton(props) {
1125
+ const {
1126
+ CN_DropdownMenu,
1127
+ theme = "light",
1128
+ CN_ConnectButton,
1129
+ connectText = "Connect Wallet",
1130
+ connectingText = "Connecting...",
1131
+ showSolBalance = false
1132
+ } = props;
1133
+ const [isModalOpen, setIsModalOpen] = useState4(false);
1134
+ const { isConnected, isConnecting, account, connector, walletConnectUri, clearWalletConnectUri } = useConnector2();
1135
+ if (isConnected && account && connector) {
1136
+ const shortAddress = `${account.slice(0, 4)}...${account.slice(-4)}`;
1137
+ const walletIcon = connector.icon || void 0;
1138
+ return /* @__PURE__ */ jsxs5(Menu, { children: [
1139
+ /* @__PURE__ */ jsx10(MenuTrigger, { render: /* @__PURE__ */ jsxs5(
1140
+ Button_default2,
1141
+ {
1142
+ variant: "outline",
1143
+ size: "sm",
1144
+ "data-theme": theme,
1145
+ className: clsx4(styles9.connectButton, CN_ConnectButton),
1146
+ children: [
1147
+ /* @__PURE__ */ jsx10(
1148
+ Avatar_default,
1149
+ {
1150
+ height: 20,
1151
+ width: 20,
1152
+ src: walletIcon,
1153
+ alt: connector.name,
1154
+ theme
1155
+ }
1156
+ ),
1157
+ /* @__PURE__ */ jsx10("span", { children: shortAddress }),
1158
+ /* @__PURE__ */ jsx10(ChevronDown, { size: 16 })
1159
+ ]
1160
+ }
1161
+ ) }),
1162
+ /* @__PURE__ */ jsx10(MenuPortal, { children: /* @__PURE__ */ jsx10(MenuPositioner, { sideOffset: 8, align: "end", children: /* @__PURE__ */ jsx10(MenuPopup, { theme, children: /* @__PURE__ */ jsx10(
1163
+ WalletDropdown_default2,
1164
+ {
1165
+ CN_ConnectButton: CN_DropdownMenu,
1166
+ selectedAccount: account,
1167
+ walletIcon,
1168
+ walletName: connector.name,
1169
+ allowNetworkSwitch: true,
1170
+ theme,
1171
+ showSolBalance
1172
+ }
1173
+ ) }) }) })
1174
+ ] });
1175
+ }
1176
+ const onOpenChange = (open) => {
1177
+ setIsModalOpen(open);
1178
+ if (!open) {
1179
+ clearWalletConnectUri();
1180
+ }
1181
+ };
1182
+ return /* @__PURE__ */ jsxs5("div", { children: [
1183
+ /* @__PURE__ */ jsx10(
1184
+ Button_default2,
1185
+ {
1186
+ variant: "outline",
1187
+ size: "sm",
1188
+ "data-theme": theme,
1189
+ onClick: () => setIsModalOpen(true),
1190
+ className: clsx4(styles9.connectButton, CN_ConnectButton),
1191
+ children: isConnecting ? /* @__PURE__ */ jsxs5("span", { children: [
1192
+ /* @__PURE__ */ jsx10(Spinner_default2, {}),
1193
+ connectingText
1194
+ ] }) : /* @__PURE__ */ jsx10("span", { children: connectText })
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ jsx10(
1198
+ WalletModal_default2,
1199
+ {
1200
+ theme,
1201
+ open: isModalOpen,
1202
+ onOpenChange,
1203
+ walletConnectUri,
1204
+ onClearWalletConnectUri: clearWalletConnectUri
1205
+ }
1206
+ )
1207
+ ] });
1208
+ }
1209
+ var ConnectButton_default = ConnectButton;
1210
+
1211
+ // src/components/ConnectButton/index.ts
1212
+ var ConnectButton_default2 = ConnectButton_default;
1213
+ export {
1214
+ ConnectButton_default2 as default
1215
+ };
1216
+ //# sourceMappingURL=ConnectButton.mjs.map