@spicenet-io/spiceflow-ui 1.9.33 → 1.9.35

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.
@@ -1,1026 +1,12 @@
1
1
  "use client";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import React, { useEffect, useState, useCallback } from 'react';
4
- import { c as createTheme, B as Button } from './Button-CWjGZdAM.js';
5
- import { useDynamicContext, useConnectWithOtp } from '@dynamic-labs/sdk-react-core';
6
-
7
- const Input = ({
8
- label,
9
- error,
10
- helper,
11
- fullWidth = false,
12
- startAdornment,
13
- endAdornment,
14
- className = "",
15
- style,
16
- theme: providedTheme,
17
- ...props
18
- }) => {
19
- const theme = providedTheme || createTheme("light");
20
- const containerStyles = {
21
- width: fullWidth ? "100%" : "auto",
22
- display: "flex",
23
- flexDirection: "column",
24
- gap: theme.spacing.xs
25
- };
26
- const inputContainerStyles = {
27
- position: "relative",
28
- display: "flex",
29
- alignItems: "center"
30
- };
31
- const inputStyles = {
32
- backgroundColor: theme.colors.surface,
33
- border: `1px solid ${error ? theme.colors.error : theme.colors.border}`,
34
- borderRadius: theme.borderRadius.md,
35
- color: theme.colors.text,
36
- fontSize: theme.typography.fontSize.base,
37
- padding: theme.spacing.md,
38
- paddingLeft: startAdornment ? theme.spacing.xl : theme.spacing.md,
39
- paddingRight: endAdornment ? theme.spacing.xl : theme.spacing.md,
40
- width: "100%",
41
- outline: "none",
42
- transition: `border-color ${theme.animation.normal}`,
43
- ":focus": {
44
- borderColor: error ? theme.colors.error : theme.colors.primary
45
- },
46
- ":hover": {
47
- borderColor: error ? theme.colors.error : theme.colors.borderHover
48
- },
49
- "::placeholder": {
50
- color: theme.colors.textMuted
51
- }
52
- };
53
- const labelStyles = {
54
- fontSize: theme.typography.fontSize.sm,
55
- fontWeight: theme.typography.fontWeight.medium,
56
- color: theme.colors.textSecondary
57
- };
58
- const helperStyles = {
59
- fontSize: theme.typography.fontSize.xs,
60
- color: error ? theme.colors.error : theme.colors.textMuted
61
- };
62
- const adornmentStyles = {
63
- position: "absolute",
64
- top: "50%",
65
- transform: "translateY(-50%)",
66
- color: theme.colors.textMuted,
67
- pointerEvents: "none"
68
- };
69
- return /* @__PURE__ */ jsxs("div", { style: containerStyles, children: [
70
- label && /* @__PURE__ */ jsx("label", { style: labelStyles, children: label }),
71
- /* @__PURE__ */ jsxs("div", { style: inputContainerStyles, children: [
72
- startAdornment && /* @__PURE__ */ jsx("div", { style: { ...adornmentStyles, left: theme.spacing.md }, children: startAdornment }),
73
- /* @__PURE__ */ jsx(
74
- "input",
75
- {
76
- style: { ...inputStyles, ...style },
77
- className,
78
- ...props
79
- }
80
- ),
81
- endAdornment && /* @__PURE__ */ jsx("div", { style: { ...adornmentStyles, right: theme.spacing.md }, children: endAdornment })
82
- ] }),
83
- (error || helper) && /* @__PURE__ */ jsx("span", { style: helperStyles, children: error || helper })
84
- ] });
85
- };
86
-
87
- const Modal = ({
88
- isOpen,
89
- onClose,
90
- title,
91
- children,
92
- maxWidth = "32rem",
93
- className = "",
94
- theme: providedTheme
95
- }) => {
96
- const theme = providedTheme || createTheme("light");
97
- useEffect(() => {
98
- const handleEscape = (event) => {
99
- if (event.key === "Escape") {
100
- onClose();
101
- }
102
- };
103
- if (isOpen) {
104
- document.addEventListener("keydown", handleEscape);
105
- document.body.style.overflow = "hidden";
106
- }
107
- return () => {
108
- document.removeEventListener("keydown", handleEscape);
109
- document.body.style.overflow = "unset";
110
- };
111
- }, [isOpen, onClose]);
112
- if (!isOpen) return null;
113
- const overlayStyles = {
114
- position: "fixed",
115
- top: 0,
116
- left: 0,
117
- right: 0,
118
- bottom: 0,
119
- backgroundColor: "rgba(0, 0, 0, 0.5)",
120
- display: "flex",
121
- alignItems: "center",
122
- justifyContent: "center",
123
- zIndex: 1e3,
124
- padding: theme.spacing.md
125
- };
126
- const modalStyles = {
127
- backgroundColor: theme.colors.background,
128
- border: `1px solid ${theme.colors.border}`,
129
- borderRadius: theme.borderRadius.lg,
130
- boxShadow: theme.shadows.lg,
131
- maxWidth,
132
- width: "100%",
133
- maxHeight: "90vh",
134
- overflow: "auto"
135
- };
136
- const headerStyles = {
137
- padding: theme.spacing.lg,
138
- borderBottom: `1px solid ${theme.colors.border}`,
139
- display: "flex",
140
- alignItems: "center",
141
- justifyContent: "space-between"
142
- };
143
- const titleStyles = {
144
- fontSize: theme.typography.fontSize.lg,
145
- fontWeight: theme.typography.fontWeight.semibold,
146
- color: theme.colors.text,
147
- margin: 0
148
- };
149
- const closeButtonStyles = {
150
- background: "none",
151
- border: "none",
152
- color: theme.colors.textMuted,
153
- cursor: "pointer",
154
- padding: theme.spacing.sm,
155
- borderRadius: theme.borderRadius.sm,
156
- display: "flex",
157
- alignItems: "center",
158
- justifyContent: "center",
159
- transition: `color ${theme.animation.normal}`,
160
- ":hover": {
161
- color: theme.colors.text
162
- }
163
- };
164
- const contentStyles = {
165
- padding: theme.spacing.lg
166
- };
167
- return /* @__PURE__ */ jsx("div", { style: overlayStyles, onClick: onClose, children: /* @__PURE__ */ jsxs(
168
- "div",
169
- {
170
- style: modalStyles,
171
- className,
172
- onClick: (e) => e.stopPropagation(),
173
- children: [
174
- title && /* @__PURE__ */ jsxs("div", { style: headerStyles, children: [
175
- /* @__PURE__ */ jsx("h2", { style: titleStyles, children: title }),
176
- /* @__PURE__ */ jsx("button", { style: closeButtonStyles, onClick: onClose, children: /* @__PURE__ */ jsxs(
177
- "svg",
178
- {
179
- width: "20",
180
- height: "20",
181
- viewBox: "0 0 24 24",
182
- fill: "none",
183
- stroke: "currentColor",
184
- strokeWidth: "2",
185
- strokeLinecap: "round",
186
- strokeLinejoin: "round",
187
- children: [
188
- /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
189
- /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
190
- ]
191
- }
192
- ) })
193
- ] }),
194
- /* @__PURE__ */ jsx("div", { style: contentStyles, children })
195
- ]
196
- }
197
- ) });
198
- };
199
-
200
- const DynamicLoginInternal = ({
201
- onAuthSuccess,
202
- onAuthError,
203
- theme: themeMode = "light",
204
- className = "",
205
- buttonText = "Login with Dynamic",
206
- autoTrigger = false
207
- }) => {
208
- const theme = createTheme(themeMode);
209
- const [isClient, setIsClient] = useState(false);
210
- const [isModalOpen, setIsModalOpen] = useState(autoTrigger);
211
- const [hasAutoTriggered, setHasAutoTriggered] = useState(false);
212
- const [email, setEmail] = useState("");
213
- const [otp, setOtp] = useState("");
214
- const [error, setError] = useState(null);
215
- const [walletCreationStartTime, setWalletCreationStartTime] = useState(null);
216
- const [timeoutReached, setTimeoutReached] = useState(false);
217
- const [loginMethod, setLoginMethod] = useState(
218
- "options"
219
- );
220
- let dynamicState = null;
221
- let otpHooks = null;
222
- let isDynamicReady = false;
223
- let hookError = null;
224
- try {
225
- dynamicState = useDynamicContext();
226
- otpHooks = useConnectWithOtp();
227
- isDynamicReady = true;
228
- } catch (error2) {
229
- hookError = error2 instanceof Error ? error2.message : String(error2);
230
- }
231
- const connectWithEmail = otpHooks?.connectWithEmail;
232
- const verifyOneTimePassword = otpHooks?.verifyOneTimePassword;
233
- const handleLogOut = dynamicState?.handleLogOut;
234
- const { user, primaryWallet } = dynamicState || {
235
- user: null,
236
- primaryWallet: null
237
- };
238
- const isAuthenticated = !!user;
239
- const address = primaryWallet?.address;
240
- const isConnected = isAuthenticated && !!address;
241
- useEffect(() => {
242
- setIsClient(true);
243
- }, []);
244
- useEffect(() => {
245
- if (autoTrigger && isClient && isDynamicReady && !isConnected && !hasAutoTriggered) {
246
- setHasAutoTriggered(true);
247
- setIsModalOpen(true);
248
- }
249
- }, [autoTrigger, isClient, isDynamicReady, isConnected, hasAutoTriggered]);
250
- useEffect(() => {
251
- if (isClient && !isDynamicReady && hookError) {
252
- const retryTimer = setTimeout(() => {
253
- setError(null);
254
- }, 2e3);
255
- return () => clearTimeout(retryTimer);
256
- }
257
- }, [isClient, isDynamicReady, hookError]);
258
- useEffect(() => {
259
- if (walletCreationStartTime) {
260
- const timer = setTimeout(() => {
261
- setTimeoutReached(true);
262
- }, 3e4);
263
- return () => clearTimeout(timer);
264
- }
265
- }, [walletCreationStartTime]);
266
- useEffect(() => {
267
- if (isConnected && address) {
268
- setIsModalOpen(false);
269
- setLoginMethod("options");
270
- setEmail("");
271
- setOtp("");
272
- setError(null);
273
- setWalletCreationStartTime(null);
274
- setTimeoutReached(false);
275
- if (onAuthSuccess) {
276
- onAuthSuccess(address);
277
- }
278
- }
279
- }, [isConnected, address, onAuthSuccess]);
280
- const handleEmailSubmit = useCallback(
281
- async (e) => {
282
- e.preventDefault();
283
- if (!email.trim()) {
284
- setError("Please enter a valid email address");
285
- return;
286
- }
287
- if (!connectWithEmail) {
288
- setError("Dynamic context not ready. Please try again.");
289
- return;
290
- }
291
- setError(null);
292
- try {
293
- await connectWithEmail(email);
294
- setLoginMethod("otp");
295
- } catch (error2) {
296
- setError("Failed to send verification code. Please try again.");
297
- if (onAuthError) {
298
- onAuthError(`Failed to send verification code: ${String(error2)}`);
299
- }
300
- }
301
- },
302
- [email, connectWithEmail, onAuthError]
303
- );
304
- const handleOtpSubmit = useCallback(
305
- async (e) => {
306
- e.preventDefault();
307
- if (!otp.trim()) {
308
- setError("Please enter the verification code");
309
- return;
310
- }
311
- if (!verifyOneTimePassword) {
312
- setError("Dynamic context not ready. Please try again.");
313
- return;
314
- }
315
- setError(null);
316
- try {
317
- await verifyOneTimePassword(otp);
318
- if (user && !primaryWallet) {
319
- setWalletCreationStartTime(Date.now());
320
- }
321
- } catch (error2) {
322
- setError("Invalid verification code. Please try again.");
323
- if (onAuthError) {
324
- onAuthError(`OTP verification failed: ${String(error2)}`);
325
- }
326
- }
327
- },
328
- [otp, verifyOneTimePassword, user, primaryWallet, onAuthError]
329
- );
330
- const handleLogout = useCallback(async () => {
331
- try {
332
- if (handleLogOut) {
333
- await handleLogOut();
334
- }
335
- setIsModalOpen(false);
336
- setLoginMethod("options");
337
- setEmail("");
338
- setOtp("");
339
- setError(null);
340
- setWalletCreationStartTime(null);
341
- setTimeoutReached(false);
342
- } catch (error2) {
343
- setIsModalOpen(false);
344
- setLoginMethod("options");
345
- setEmail("");
346
- setOtp("");
347
- setError(null);
348
- setWalletCreationStartTime(null);
349
- setTimeoutReached(false);
350
- }
351
- }, [handleLogOut]);
352
- if (!isClient) {
353
- return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(Button, { variant: "primary", disabled: true, theme, children: buttonText }) });
354
- }
355
- if (!isDynamicReady) {
356
- return /* @__PURE__ */ jsxs("div", { className, children: [
357
- /* @__PURE__ */ jsx(Button, { variant: "primary", disabled: true, theme, children: "Loading Dynamic..." }),
358
- hookError && /* @__PURE__ */ jsx(
359
- "div",
360
- {
361
- style: {
362
- marginTop: "8px",
363
- fontSize: "12px",
364
- color: theme.colors.error,
365
- padding: theme.spacing.xs,
366
- backgroundColor: theme.mode === "light" ? "#fef2f2" : `${theme.colors.error}20`,
367
- borderRadius: theme.borderRadius.sm
368
- },
369
- children: "Initializing Dynamic context..."
370
- }
371
- )
372
- ] });
373
- }
374
- const renderAuthOptionsStep = () => /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[450px] space-y-8", children: [
375
- /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: theme.spacing.lg }, children: /* @__PURE__ */ jsx(
376
- "h1",
377
- {
378
- style: {
379
- fontSize: "1.875rem",
380
- fontWeight: "bold",
381
- color: theme.colors.text,
382
- marginBottom: theme.spacing.sm
383
- },
384
- children: "Get Started"
385
- }
386
- ) }),
387
- /* @__PURE__ */ jsx("div", { style: { marginBottom: theme.spacing.md }, children: /* @__PURE__ */ jsx(
388
- Button,
389
- {
390
- variant: "primary",
391
- fullWidth: true,
392
- onClick: () => setLoginMethod("email"),
393
- theme,
394
- children: "Continue with Email"
395
- }
396
- ) }),
397
- error && /* @__PURE__ */ jsx(
398
- "div",
399
- {
400
- style: {
401
- padding: theme.spacing.md,
402
- backgroundColor: theme.mode === "light" ? "#fef2f2" : `${theme.colors.error}20`,
403
- border: `1px solid ${theme.mode === "light" ? "#fecaca" : theme.colors.error}`,
404
- borderRadius: theme.borderRadius.md,
405
- marginTop: theme.spacing.md
406
- },
407
- children: /* @__PURE__ */ jsx(
408
- "p",
409
- {
410
- style: {
411
- color: theme.colors.error,
412
- fontSize: theme.typography.fontSize.sm,
413
- margin: 0
414
- },
415
- children: error
416
- }
417
- )
418
- }
419
- )
420
- ] });
421
- const renderEmailStep = () => /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[450px] space-y-6", children: [
422
- /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: theme.spacing.lg }, children: [
423
- /* @__PURE__ */ jsx(
424
- "div",
425
- {
426
- style: {
427
- width: "4rem",
428
- height: "4rem",
429
- backgroundColor: theme.colors.primary,
430
- borderRadius: "50%",
431
- display: "flex",
432
- alignItems: "center",
433
- justifyContent: "center",
434
- margin: `0 auto ${theme.spacing.md}`
435
- },
436
- children: /* @__PURE__ */ jsx("span", { style: { fontSize: "1.25rem" }, children: "\u2709\uFE0F" })
437
- }
438
- ),
439
- /* @__PURE__ */ jsx(
440
- "h1",
441
- {
442
- style: {
443
- fontSize: "1.5rem",
444
- fontWeight: "bold",
445
- color: theme.colors.text,
446
- marginBottom: theme.spacing.sm
447
- },
448
- children: "Email Authentication"
449
- }
450
- ),
451
- /* @__PURE__ */ jsx("p", { style: { color: theme.colors.textMuted }, children: "Enter your email to get started" })
452
- ] }),
453
- /* @__PURE__ */ jsxs(
454
- "form",
455
- {
456
- onSubmit: handleEmailSubmit,
457
- style: { marginBottom: theme.spacing.md },
458
- children: [
459
- /* @__PURE__ */ jsxs("div", { style: { marginBottom: theme.spacing.md }, children: [
460
- /* @__PURE__ */ jsx(
461
- "label",
462
- {
463
- style: {
464
- display: "block",
465
- fontSize: theme.typography.fontSize.sm,
466
- fontWeight: theme.typography.fontWeight.medium,
467
- color: theme.colors.text,
468
- marginBottom: theme.spacing.xs
469
- },
470
- children: "Email Address"
471
- }
472
- ),
473
- /* @__PURE__ */ jsx(
474
- Input,
475
- {
476
- type: "email",
477
- value: email,
478
- onChange: (e) => setEmail(e.target.value),
479
- placeholder: "Enter your email address",
480
- required: true,
481
- theme
482
- }
483
- )
484
- ] }),
485
- error && /* @__PURE__ */ jsx(
486
- "div",
487
- {
488
- style: {
489
- padding: theme.spacing.md,
490
- backgroundColor: theme.mode === "light" ? "#fef2f2" : `${theme.colors.error}20`,
491
- border: `1px solid ${theme.mode === "light" ? "#fecaca" : theme.colors.error}`,
492
- borderRadius: theme.borderRadius.md,
493
- marginBottom: theme.spacing.md
494
- },
495
- children: /* @__PURE__ */ jsx(
496
- "p",
497
- {
498
- style: {
499
- color: theme.colors.error,
500
- fontSize: theme.typography.fontSize.sm,
501
- margin: 0
502
- },
503
- children: error
504
- }
505
- )
506
- }
507
- ),
508
- /* @__PURE__ */ jsxs(
509
- "div",
510
- {
511
- style: {
512
- display: "flex",
513
- flexDirection: "column",
514
- gap: theme.spacing.sm
515
- },
516
- children: [
517
- /* @__PURE__ */ jsx(
518
- Button,
519
- {
520
- type: "submit",
521
- variant: "primary",
522
- fullWidth: true,
523
- disabled: !email.trim(),
524
- theme,
525
- children: "Send Verification Code"
526
- }
527
- ),
528
- /* @__PURE__ */ jsx(
529
- Button,
530
- {
531
- type: "button",
532
- variant: "secondary",
533
- fullWidth: true,
534
- onClick: () => {
535
- setLoginMethod("options");
536
- setError(null);
537
- setEmail("");
538
- },
539
- theme,
540
- children: "\u2190 Back"
541
- }
542
- )
543
- ]
544
- }
545
- )
546
- ]
547
- }
548
- )
549
- ] });
550
- const renderOtpStep = () => /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[450px] space-y-6", children: [
551
- /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: theme.spacing.lg }, children: [
552
- /* @__PURE__ */ jsx(
553
- "div",
554
- {
555
- style: {
556
- width: "4rem",
557
- height: "4rem",
558
- backgroundColor: theme.colors.success,
559
- borderRadius: "50%",
560
- display: "flex",
561
- alignItems: "center",
562
- justifyContent: "center",
563
- margin: `0 auto ${theme.spacing.md}`
564
- },
565
- children: /* @__PURE__ */ jsx("span", { style: { fontSize: "1.25rem", color: "#ffffff" }, children: "\u2713" })
566
- }
567
- ),
568
- /* @__PURE__ */ jsx(
569
- "h1",
570
- {
571
- style: {
572
- fontSize: "1.5rem",
573
- fontWeight: "bold",
574
- color: theme.colors.text,
575
- marginBottom: theme.spacing.sm
576
- },
577
- children: "Check Your Email"
578
- }
579
- ),
580
- /* @__PURE__ */ jsxs("p", { style: { color: theme.colors.textMuted }, children: [
581
- "Enter the verification code sent to",
582
- " ",
583
- /* @__PURE__ */ jsx("span", { style: { color: theme.colors.primary, fontWeight: "medium" }, children: email })
584
- ] })
585
- ] }),
586
- /* @__PURE__ */ jsxs(
587
- "form",
588
- {
589
- onSubmit: handleOtpSubmit,
590
- style: { marginBottom: theme.spacing.md },
591
- children: [
592
- /* @__PURE__ */ jsxs("div", { style: { marginBottom: theme.spacing.md }, children: [
593
- /* @__PURE__ */ jsx(
594
- "label",
595
- {
596
- style: {
597
- display: "block",
598
- fontSize: theme.typography.fontSize.sm,
599
- fontWeight: theme.typography.fontWeight.medium,
600
- color: theme.colors.text,
601
- marginBottom: theme.spacing.xs
602
- },
603
- children: "Verification Code"
604
- }
605
- ),
606
- /* @__PURE__ */ jsx(
607
- Input,
608
- {
609
- type: "text",
610
- value: otp,
611
- onChange: (e) => setOtp(e.target.value),
612
- placeholder: "Enter 6-digit code",
613
- maxLength: 6,
614
- required: true,
615
- theme,
616
- className: "ibm-plex-mono",
617
- style: {
618
- textAlign: "center",
619
- fontSize: "1.3rem",
620
- letterSpacing: "0.2em",
621
- fontFamily: "IBM Plex Mono"
622
- }
623
- }
624
- )
625
- ] }),
626
- error && /* @__PURE__ */ jsx(
627
- "div",
628
- {
629
- style: {
630
- padding: theme.spacing.md,
631
- backgroundColor: theme.mode === "light" ? "#fef2f2" : `${theme.colors.error}20`,
632
- border: `1px solid ${theme.mode === "light" ? "#fecaca" : theme.colors.error}`,
633
- borderRadius: theme.borderRadius.md,
634
- marginBottom: theme.spacing.md
635
- },
636
- children: /* @__PURE__ */ jsx(
637
- "p",
638
- {
639
- style: {
640
- color: theme.colors.error,
641
- fontSize: theme.typography.fontSize.sm,
642
- margin: 0
643
- },
644
- children: error
645
- }
646
- )
647
- }
648
- ),
649
- /* @__PURE__ */ jsxs(
650
- "div",
651
- {
652
- style: {
653
- display: "flex",
654
- flexDirection: "column",
655
- gap: theme.spacing.sm
656
- },
657
- children: [
658
- /* @__PURE__ */ jsx(
659
- Button,
660
- {
661
- type: "submit",
662
- variant: "primary",
663
- fullWidth: true,
664
- disabled: !otp.trim(),
665
- theme,
666
- children: "Verify Code"
667
- }
668
- ),
669
- /* @__PURE__ */ jsx(
670
- Button,
671
- {
672
- type: "button",
673
- variant: "secondary",
674
- fullWidth: true,
675
- onClick: () => {
676
- setError(null);
677
- setOtp("");
678
- setLoginMethod("email");
679
- },
680
- theme,
681
- children: "\u2190 Back to Email"
682
- }
683
- )
684
- ]
685
- }
686
- )
687
- ]
688
- }
689
- )
690
- ] });
691
- const renderWalletCreationStep = () => {
692
- const isStuck = timeoutReached || walletCreationStartTime && Date.now() - (walletCreationStartTime || 0) > 3e4;
693
- return /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[450px] space-y-6", children: [
694
- /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: theme.spacing.lg }, children: [
695
- /* @__PURE__ */ jsx(
696
- "div",
697
- {
698
- style: {
699
- width: "4rem",
700
- height: "4rem",
701
- backgroundColor: theme.colors.warning,
702
- borderRadius: "50%",
703
- display: "flex",
704
- alignItems: "center",
705
- justifyContent: "center",
706
- margin: `0 auto ${theme.spacing.md}`
707
- },
708
- children: /* @__PURE__ */ jsx(
709
- "div",
710
- {
711
- style: {
712
- width: "1.5rem",
713
- height: "1.5rem",
714
- border: `2px solid ${theme.colors.text}`,
715
- borderTop: "2px solid transparent",
716
- borderRadius: "50%",
717
- animation: "spin 1s linear infinite"
718
- }
719
- }
720
- )
721
- }
722
- ),
723
- /* @__PURE__ */ jsx(
724
- "h1",
725
- {
726
- style: {
727
- fontSize: "1.5rem",
728
- fontWeight: "bold",
729
- color: theme.colors.text,
730
- marginBottom: theme.spacing.sm
731
- },
732
- children: "Setting up your wallet..."
733
- }
734
- ),
735
- /* @__PURE__ */ jsx("p", { style: { color: theme.colors.textMuted }, children: "Creating your wallet automatically. This may take a few moments." }),
736
- walletCreationStartTime && /* @__PURE__ */ jsxs(
737
- "div",
738
- {
739
- style: {
740
- fontSize: theme.typography.fontSize.sm,
741
- color: theme.colors.textMuted,
742
- marginTop: theme.spacing.sm
743
- },
744
- children: [
745
- /* @__PURE__ */ jsxs("p", { children: [
746
- "Waiting time:",
747
- " ",
748
- Math.floor(
749
- (Date.now() - (walletCreationStartTime || 0)) / 1e3
750
- ),
751
- "s"
752
- ] }),
753
- timeoutReached && /* @__PURE__ */ jsx(
754
- "p",
755
- {
756
- style: { color: theme.colors.warning, fontWeight: "medium" },
757
- children: "\u26A0\uFE0F Taking longer than expected"
758
- }
759
- )
760
- ]
761
- }
762
- )
763
- ] }),
764
- /* @__PURE__ */ jsxs(
765
- "div",
766
- {
767
- style: {
768
- display: "flex",
769
- flexDirection: "column",
770
- gap: theme.spacing.sm
771
- },
772
- children: [
773
- /* @__PURE__ */ jsx(
774
- Button,
775
- {
776
- variant: "secondary",
777
- fullWidth: true,
778
- onClick: () => window.location.reload(),
779
- theme,
780
- children: "Retry Automatic Creation"
781
- }
782
- ),
783
- /* @__PURE__ */ jsx(
784
- Button,
785
- {
786
- variant: "secondary",
787
- fullWidth: true,
788
- onClick: handleLogout,
789
- theme,
790
- children: "Cancel & Start Over"
791
- }
792
- )
793
- ]
794
- }
795
- ),
796
- isStuck && /* @__PURE__ */ jsxs(
797
- "div",
798
- {
799
- style: {
800
- marginTop: theme.spacing.md,
801
- padding: theme.spacing.md,
802
- backgroundColor: theme.mode === "light" ? "#fef3c7" : `${theme.colors.warning}20`,
803
- border: `1px solid ${theme.mode === "light" ? "#fde68a" : theme.colors.warning}`,
804
- borderRadius: theme.borderRadius.md
805
- },
806
- children: [
807
- /* @__PURE__ */ jsx(
808
- "p",
809
- {
810
- style: {
811
- color: theme.colors.warning,
812
- fontSize: theme.typography.fontSize.sm,
813
- marginBottom: theme.spacing.sm
814
- },
815
- children: "\u26A0\uFE0F Wallet creation is taking longer than expected. This might be due to network issues."
816
- }
817
- ),
818
- /* @__PURE__ */ jsxs(
819
- "div",
820
- {
821
- style: {
822
- fontSize: theme.typography.fontSize.xs,
823
- color: theme.colors.textMuted
824
- },
825
- children: [
826
- /* @__PURE__ */ jsx("p", { children: "\u2022 Try refreshing the page to restart automatic creation" }),
827
- /* @__PURE__ */ jsx("p", { children: "\u2022 Check your internet connection" }),
828
- /* @__PURE__ */ jsx("p", { children: "\u2022 If the issue persists, start over with a new email" })
829
- ]
830
- }
831
- )
832
- ]
833
- }
834
- )
835
- ] });
836
- };
837
- const getModalContent = () => {
838
- if (!isDynamicReady) {
839
- return /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", padding: theme.spacing.xl }, children: [
840
- /* @__PURE__ */ jsx(
841
- "div",
842
- {
843
- style: {
844
- width: "2.5rem",
845
- height: "2.5rem",
846
- border: `2px solid ${theme.colors.border}`,
847
- borderTop: `2px solid ${theme.colors.primary}`,
848
- borderRadius: "50%",
849
- animation: "spin 1s linear infinite",
850
- margin: `0 auto ${theme.spacing.md}`
851
- }
852
- }
853
- ),
854
- /* @__PURE__ */ jsx("p", { style: { color: theme.colors.textMuted }, children: "Initializing Dynamic..." })
855
- ] });
856
- }
857
- if (isAuthenticated && !address) {
858
- return renderWalletCreationStep();
859
- }
860
- if (loginMethod === "otp") {
861
- return renderOtpStep();
862
- }
863
- if (loginMethod === "email") {
864
- return renderEmailStep();
865
- }
866
- return renderAuthOptionsStep();
867
- };
868
- if (isConnected && address) {
869
- return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleLogout, theme, children: [
870
- "Logout (",
871
- address.slice(0, 6),
872
- "...",
873
- address.slice(-4),
874
- ")"
875
- ] }) });
876
- }
877
- if (autoTrigger) {
878
- return /* @__PURE__ */ jsxs("div", { className, children: [
879
- /* @__PURE__ */ jsxs(
880
- "div",
881
- {
882
- style: {
883
- display: "flex",
884
- alignItems: "center",
885
- justifyContent: "center",
886
- padding: "20px",
887
- flexDirection: "column",
888
- gap: "12px"
889
- },
890
- children: [
891
- /* @__PURE__ */ jsx(
892
- "div",
893
- {
894
- style: {
895
- width: "40px",
896
- height: "40px",
897
- border: "3px solid #e5e7eb",
898
- borderTop: "3px solid #3b82f6",
899
- borderRadius: "50%",
900
- animation: "spin 1s linear infinite"
901
- }
902
- }
903
- ),
904
- /* @__PURE__ */ jsx("p", { style: { color: "#6b7280", fontSize: "14px" }, children: "Opening login..." })
905
- ]
906
- }
907
- ),
908
- /* @__PURE__ */ jsx(
909
- Modal,
910
- {
911
- isOpen: isModalOpen,
912
- onClose: () => {
913
- if (!isAuthenticated || isConnected) {
914
- setIsModalOpen(false);
915
- setLoginMethod("options");
916
- setEmail("");
917
- setOtp("");
918
- setError(null);
919
- }
920
- },
921
- title: "",
922
- theme,
923
- children: getModalContent()
924
- }
925
- ),
926
- /* @__PURE__ */ jsx(
927
- "style",
928
- {
929
- dangerouslySetInnerHTML: {
930
- __html: `
2
+ import{jsxs as o,jsx as t}from"react/jsx-runtime";import re,{useEffect as B,useState as b,useCallback as _}from"react";import{c as A,B as m}from"./Button-4ryz2e1P.js";import{useDynamicContext as oe,useConnectWithOtp as ie}from"@dynamic-labs/sdk-react-core";const J=({label:s,error:n,helper:y,fullWidth:p=!1,startAdornment:h,endAdornment:c,className:e="",style:i,theme:E,...C})=>{const r=E||A("light"),k={width:p?"100%":"auto",display:"flex",flexDirection:"column",gap:r.spacing.xs},R={position:"relative",display:"flex",alignItems:"center"},g={backgroundColor:r.colors.surface,border:`1px solid ${n?r.colors.error:r.colors.border}`,borderRadius:r.borderRadius.md,color:r.colors.text,fontSize:r.typography.fontSize.base,padding:r.spacing.md,paddingLeft:h?r.spacing.xl:r.spacing.md,paddingRight:c?r.spacing.xl:r.spacing.md,width:"100%",outline:"none",transition:`border-color ${r.animation.normal}`,":focus":{borderColor:n?r.colors.error:r.colors.primary},":hover":{borderColor:n?r.colors.error:r.colors.borderHover},"::placeholder":{color:r.colors.textMuted}},d={fontSize:r.typography.fontSize.sm,fontWeight:r.typography.fontWeight.medium,color:r.colors.textSecondary},f={fontSize:r.typography.fontSize.xs,color:n?r.colors.error:r.colors.textMuted},u={position:"absolute",top:"50%",transform:"translateY(-50%)",color:r.colors.textMuted,pointerEvents:"none"};return o("div",{style:k,children:[s&&t("label",{style:d,children:s}),o("div",{style:R,children:[h&&t("div",{style:{...u,left:r.spacing.md},children:h}),t("input",{style:{...g,...i},className:e,...C}),c&&t("div",{style:{...u,right:r.spacing.md},children:c})]}),(n||y)&&t("span",{style:f,children:n||y})]})},K=({isOpen:s,onClose:n,title:y,children:p,maxWidth:h="32rem",className:c="",theme:e})=>{const i=e||A("light");if(B(()=>{const d=f=>{f.key==="Escape"&&n()};return s&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="unset"}},[s,n]),!s)return null;const E={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:i.spacing.md},C={backgroundColor:i.colors.background,border:`1px solid ${i.colors.border}`,borderRadius:i.borderRadius.lg,boxShadow:i.shadows.lg,maxWidth:h,width:"100%",maxHeight:"90vh",overflow:"auto"},r={padding:i.spacing.lg,borderBottom:`1px solid ${i.colors.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},k={fontSize:i.typography.fontSize.lg,fontWeight:i.typography.fontWeight.semibold,color:i.colors.text,margin:0},R={background:"none",border:"none",color:i.colors.textMuted,cursor:"pointer",padding:i.spacing.sm,borderRadius:i.borderRadius.sm,display:"flex",alignItems:"center",justifyContent:"center",transition:`color ${i.animation.normal}`,":hover":{color:i.colors.text}},g={padding:i.spacing.lg};return t("div",{style:E,onClick:n,children:o("div",{style:C,className:c,onClick:d=>d.stopPropagation(),children:[y&&o("div",{style:r,children:[t("h2",{style:k,children:y}),t("button",{style:R,onClick:n,children:o("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t("div",{style:g,children:p})]})})},ne=({onAuthSuccess:s,onAuthError:n,theme:y="light",className:p="",buttonText:h="Login with Dynamic",autoTrigger:c=!1})=>{const e=A(y),[i,E]=b(!1),[C,r]=b(c),[k,R]=b(!1),[g,d]=b(""),[f,u]=b(""),[z,a]=b(null),[W,T]=b(null),[V,$]=b(!1),[q,x]=b("options");let M=null,N=null,w=!1,D=null;try{M=oe(),N=ie(),w=!0}catch(l){D=l instanceof Error?l.message:String(l)}const L=N?.connectWithEmail,P=N?.verifyOneTimePassword,F=M?.handleLogOut,{user:j,primaryWallet:O}=M||{user:null,primaryWallet:null},I=!!j,v=O?.address,S=I&&!!v;B(()=>{E(!0)},[]),B(()=>{c&&i&&w&&!S&&!k&&(R(!0),r(!0))},[c,i,w,S,k]),B(()=>{if(i&&!w&&D){const l=setTimeout(()=>{a(null)},2e3);return()=>clearTimeout(l)}},[i,w,D]),B(()=>{if(W){const l=setTimeout(()=>{$(!0)},3e4);return()=>clearTimeout(l)}},[W]),B(()=>{S&&v&&(r(!1),x("options"),d(""),u(""),a(null),T(null),$(!1),s&&s(v))},[S,v,s]);const Q=_(async l=>{if(l.preventDefault(),!g.trim()){a("Please enter a valid email address");return}if(!L){a("Dynamic context not ready. Please try again.");return}a(null);try{await L(g),x("otp")}catch(H){a("Failed to send verification code. Please try again."),n&&n(`Failed to send verification code: ${String(H)}`)}},[g,L,n]),U=_(async l=>{if(l.preventDefault(),!f.trim()){a("Please enter the verification code");return}if(!P){a("Dynamic context not ready. Please try again.");return}a(null);try{await P(f),j&&!O&&T(Date.now())}catch(H){a("Invalid verification code. Please try again."),n&&n(`OTP verification failed: ${String(H)}`)}},[f,P,j,O,n]),Y=_(async()=>{try{F&&await F(),r(!1),x("options"),d(""),u(""),a(null),T(null),$(!1)}catch{r(!1),x("options"),d(""),u(""),a(null),T(null),$(!1)}},[F]);if(!i)return t("div",{className:p,children:t(m,{variant:"primary",disabled:!0,theme:e,children:h})});if(!w)return o("div",{className:p,children:[t(m,{variant:"primary",disabled:!0,theme:e,children:"Loading Dynamic..."}),D&&t("div",{style:{marginTop:"8px",fontSize:"12px",color:e.colors.error,padding:e.spacing.xs,backgroundColor:e.mode==="light"?"#fef2f2":`${e.colors.error}20`,borderRadius:e.borderRadius.sm},children:"Initializing Dynamic context..."})]});const X=()=>o("div",{className:"w-full max-w-[450px] space-y-8",children:[t("div",{style:{textAlign:"center",marginBottom:e.spacing.lg},children:t("h1",{style:{fontSize:"1.875rem",fontWeight:"bold",color:e.colors.text,marginBottom:e.spacing.sm},children:"Get Started"})}),t("div",{style:{marginBottom:e.spacing.md},children:t(m,{variant:"primary",fullWidth:!0,onClick:()=>x("email"),theme:e,children:"Continue with Email"})}),z&&t("div",{style:{padding:e.spacing.md,backgroundColor:e.mode==="light"?"#fef2f2":`${e.colors.error}20`,border:`1px solid ${e.mode==="light"?"#fecaca":e.colors.error}`,borderRadius:e.borderRadius.md,marginTop:e.spacing.md},children:t("p",{style:{color:e.colors.error,fontSize:e.typography.fontSize.sm,margin:0},children:z})})]}),Z=()=>o("div",{className:"w-full max-w-[450px] space-y-6",children:[o("div",{style:{textAlign:"center",marginBottom:e.spacing.lg},children:[t("div",{style:{width:"4rem",height:"4rem",backgroundColor:e.colors.primary,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:`0 auto ${e.spacing.md}`},children:t("span",{style:{fontSize:"1.25rem"},children:"\u2709\uFE0F"})}),t("h1",{style:{fontSize:"1.5rem",fontWeight:"bold",color:e.colors.text,marginBottom:e.spacing.sm},children:"Email Authentication"}),t("p",{style:{color:e.colors.textMuted},children:"Enter your email to get started"})]}),o("form",{onSubmit:Q,style:{marginBottom:e.spacing.md},children:[o("div",{style:{marginBottom:e.spacing.md},children:[t("label",{style:{display:"block",fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,color:e.colors.text,marginBottom:e.spacing.xs},children:"Email Address"}),t(J,{type:"email",value:g,onChange:l=>d(l.target.value),placeholder:"Enter your email address",required:!0,theme:e})]}),z&&t("div",{style:{padding:e.spacing.md,backgroundColor:e.mode==="light"?"#fef2f2":`${e.colors.error}20`,border:`1px solid ${e.mode==="light"?"#fecaca":e.colors.error}`,borderRadius:e.borderRadius.md,marginBottom:e.spacing.md},children:t("p",{style:{color:e.colors.error,fontSize:e.typography.fontSize.sm,margin:0},children:z})}),o("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.sm},children:[t(m,{type:"submit",variant:"primary",fullWidth:!0,disabled:!g.trim(),theme:e,children:"Send Verification Code"}),t(m,{type:"button",variant:"secondary",fullWidth:!0,onClick:()=>{x("options"),a(null),d("")},theme:e,children:"\u2190 Back"})]})]})]}),ee=()=>o("div",{className:"w-full max-w-[450px] space-y-6",children:[o("div",{style:{textAlign:"center",marginBottom:e.spacing.lg},children:[t("div",{style:{width:"4rem",height:"4rem",backgroundColor:e.colors.success,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:`0 auto ${e.spacing.md}`},children:t("span",{style:{fontSize:"1.25rem",color:"#ffffff"},children:"\u2713"})}),t("h1",{style:{fontSize:"1.5rem",fontWeight:"bold",color:e.colors.text,marginBottom:e.spacing.sm},children:"Check Your Email"}),o("p",{style:{color:e.colors.textMuted},children:["Enter the verification code sent to"," ",t("span",{style:{color:e.colors.primary,fontWeight:"medium"},children:g})]})]}),o("form",{onSubmit:U,style:{marginBottom:e.spacing.md},children:[o("div",{style:{marginBottom:e.spacing.md},children:[t("label",{style:{display:"block",fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,color:e.colors.text,marginBottom:e.spacing.xs},children:"Verification Code"}),t(J,{type:"text",value:f,onChange:l=>u(l.target.value),placeholder:"Enter 6-digit code",maxLength:6,required:!0,theme:e,className:"ibm-plex-mono",style:{textAlign:"center",fontSize:"1.3rem",letterSpacing:"0.2em",fontFamily:"IBM Plex Mono"}})]}),z&&t("div",{style:{padding:e.spacing.md,backgroundColor:e.mode==="light"?"#fef2f2":`${e.colors.error}20`,border:`1px solid ${e.mode==="light"?"#fecaca":e.colors.error}`,borderRadius:e.borderRadius.md,marginBottom:e.spacing.md},children:t("p",{style:{color:e.colors.error,fontSize:e.typography.fontSize.sm,margin:0},children:z})}),o("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.sm},children:[t(m,{type:"submit",variant:"primary",fullWidth:!0,disabled:!f.trim(),theme:e,children:"Verify Code"}),t(m,{type:"button",variant:"secondary",fullWidth:!0,onClick:()=>{a(null),u(""),x("email")},theme:e,children:"\u2190 Back to Email"})]})]})]}),te=()=>{const l=V||W&&Date.now()-(W||0)>3e4;return o("div",{className:"w-full max-w-[450px] space-y-6",children:[o("div",{style:{textAlign:"center",marginBottom:e.spacing.lg},children:[t("div",{style:{width:"4rem",height:"4rem",backgroundColor:e.colors.warning,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:`0 auto ${e.spacing.md}`},children:t("div",{style:{width:"1.5rem",height:"1.5rem",border:`2px solid ${e.colors.text}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}})}),t("h1",{style:{fontSize:"1.5rem",fontWeight:"bold",color:e.colors.text,marginBottom:e.spacing.sm},children:"Setting up your wallet..."}),t("p",{style:{color:e.colors.textMuted},children:"Creating your wallet automatically. This may take a few moments."}),W&&o("div",{style:{fontSize:e.typography.fontSize.sm,color:e.colors.textMuted,marginTop:e.spacing.sm},children:[o("p",{children:["Waiting time:"," ",Math.floor((Date.now()-(W||0))/1e3),"s"]}),V&&t("p",{style:{color:e.colors.warning,fontWeight:"medium"},children:"\u26A0\uFE0F Taking longer than expected"})]})]}),o("div",{style:{display:"flex",flexDirection:"column",gap:e.spacing.sm},children:[t(m,{variant:"secondary",fullWidth:!0,onClick:()=>window.location.reload(),theme:e,children:"Retry Automatic Creation"}),t(m,{variant:"secondary",fullWidth:!0,onClick:Y,theme:e,children:"Cancel & Start Over"})]}),l&&o("div",{style:{marginTop:e.spacing.md,padding:e.spacing.md,backgroundColor:e.mode==="light"?"#fef3c7":`${e.colors.warning}20`,border:`1px solid ${e.mode==="light"?"#fde68a":e.colors.warning}`,borderRadius:e.borderRadius.md},children:[t("p",{style:{color:e.colors.warning,fontSize:e.typography.fontSize.sm,marginBottom:e.spacing.sm},children:"\u26A0\uFE0F Wallet creation is taking longer than expected. This might be due to network issues."}),o("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textMuted},children:[t("p",{children:"\u2022 Try refreshing the page to restart automatic creation"}),t("p",{children:"\u2022 Check your internet connection"}),t("p",{children:"\u2022 If the issue persists, start over with a new email"})]})]})]})},G=()=>w?I&&!v?te():q==="otp"?ee():q==="email"?Z():X():o("div",{style:{textAlign:"center",padding:e.spacing.xl},children:[t("div",{style:{width:"2.5rem",height:"2.5rem",border:`2px solid ${e.colors.border}`,borderTop:`2px solid ${e.colors.primary}`,borderRadius:"50%",animation:"spin 1s linear infinite",margin:`0 auto ${e.spacing.md}`}}),t("p",{style:{color:e.colors.textMuted},children:"Initializing Dynamic..."})]});return S&&v?t("div",{className:p,children:o(m,{variant:"primary",onClick:Y,theme:e,children:["Logout (",v.slice(0,6),"...",v.slice(-4),")"]})}):c?o("div",{className:p,children:[o("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[t("div",{style:{width:"40px",height:"40px",border:"3px solid #e5e7eb",borderTop:"3px solid #3b82f6",borderRadius:"50%",animation:"spin 1s linear infinite"}}),t("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]}),t(K,{isOpen:C,onClose:()=>{(!I||S)&&(r(!1),x("options"),d(""),u(""),a(null))},title:"",theme:e,children:G()}),t("style",{dangerouslySetInnerHTML:{__html:`
931
3
  @keyframes spin {
932
4
  0% { transform: rotate(0deg); }
933
5
  100% { transform: rotate(360deg); }
934
6
  }
935
- `
936
- }
937
- }
938
- )
939
- ] });
940
- }
941
- return /* @__PURE__ */ jsxs("div", { className, children: [
942
- /* @__PURE__ */ jsx(
943
- Button,
944
- {
945
- variant: "primary",
946
- onClick: () => setIsModalOpen(true),
947
- theme,
948
- children: buttonText
949
- }
950
- ),
951
- /* @__PURE__ */ jsx(
952
- Modal,
953
- {
954
- isOpen: isModalOpen,
955
- onClose: () => {
956
- if (!isAuthenticated || isConnected) {
957
- setIsModalOpen(false);
958
- setLoginMethod("options");
959
- setEmail("");
960
- setOtp("");
961
- setError(null);
962
- }
963
- },
964
- title: "",
965
- theme,
966
- children: getModalContent()
967
- }
968
- ),
969
- /* @__PURE__ */ jsx(
970
- "style",
971
- {
972
- dangerouslySetInnerHTML: {
973
- __html: `
7
+ `}})]}):o("div",{className:p,children:[t(m,{variant:"primary",onClick:()=>r(!0),theme:e,children:h}),t(K,{isOpen:C,onClose:()=>{(!I||S)&&(r(!1),x("options"),d(""),u(""),a(null))},title:"",theme:e,children:G()}),t("style",{dangerouslySetInnerHTML:{__html:`
974
8
  @keyframes spin {
975
9
  0% { transform: rotate(0deg); }
976
10
  100% { transform: rotate(360deg); }
977
11
  }
978
- `
979
- }
980
- }
981
- )
982
- ] });
983
- };
984
- class DynamicErrorBoundary extends React.Component {
985
- constructor(props) {
986
- super(props);
987
- this.state = { hasError: false };
988
- }
989
- static getDerivedStateFromError() {
990
- return { hasError: true };
991
- }
992
- componentDidCatch(error) {
993
- }
994
- render() {
995
- if (this.state.hasError) {
996
- return this.props.fallback;
997
- }
998
- return this.props.children;
999
- }
1000
- }
1001
- const DynamicLogin = (props) => {
1002
- const {
1003
- theme: themeMode = "light",
1004
- className = "",
1005
- buttonText = "Login with Dynamic",
1006
- onAuthError
1007
- } = props;
1008
- const theme = createTheme(themeMode);
1009
- const fallbackComponent = /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
1010
- Button,
1011
- {
1012
- variant: "primary",
1013
- onClick: () => {
1014
- const errorMessage = "DynamicLogin must be used within SpiceFlowProvider. Please wrap your app with <SpiceFlowProvider>.";
1015
- if (onAuthError) {
1016
- onAuthError(errorMessage);
1017
- }
1018
- },
1019
- theme,
1020
- children: buttonText
1021
- }
1022
- ) });
1023
- return /* @__PURE__ */ jsx(DynamicErrorBoundary, { fallback: fallbackComponent, children: /* @__PURE__ */ jsx(DynamicLoginInternal, { ...props }) });
1024
- };
1025
-
1026
- export { DynamicLogin };
12
+ `}})]})};class le extends re.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){}render(){return this.state.hasError?this.props.fallback:this.props.children}}const ae=s=>{const{theme:n="light",className:y="",buttonText:p="Login with Dynamic",onAuthError:h}=s,c=A(n);return t(le,{fallback:t("div",{className:y,children:t(m,{variant:"primary",onClick:()=>{h&&h("DynamicLogin must be used within SpiceFlowProvider. Please wrap your app with <SpiceFlowProvider>.")},theme:c,children:p})}),children:t(ne,{...s})})};export{ae as DynamicLogin};