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