@cedros/login-react 0.0.46 → 0.0.47

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 (83) hide show
  1. package/README.md +32 -2
  2. package/dist/EmailRegisterForm-ByYQ43yL.cjs +1 -0
  3. package/dist/EmailRegisterForm-ByYQ43yL.cjs.map +1 -0
  4. package/dist/EmailRegisterForm-DMUcNQT-.js +781 -0
  5. package/dist/EmailRegisterForm-DMUcNQT-.js.map +1 -0
  6. package/dist/GoogleLoginButton-DEwtBp56.cjs +1 -0
  7. package/dist/GoogleLoginButton-DEwtBp56.cjs.map +1 -0
  8. package/dist/{GoogleLoginButton-C1WNu7W3.js → GoogleLoginButton-DwyxvhnL.js} +82 -80
  9. package/dist/GoogleLoginButton-DwyxvhnL.js.map +1 -0
  10. package/dist/{PermissionsSection-mm9hfp-u.js → PermissionsSection-0oNHPZzL.js} +383 -415
  11. package/dist/PermissionsSection-0oNHPZzL.js.map +1 -0
  12. package/dist/PermissionsSection-CZsJuxo4.cjs +1 -0
  13. package/dist/PermissionsSection-CZsJuxo4.cjs.map +1 -0
  14. package/dist/SolanaLoginButton-2504p6cr.cjs +1 -0
  15. package/dist/SolanaLoginButton-2504p6cr.cjs.map +1 -0
  16. package/dist/SolanaLoginButton-C7Kc_m6n.js +234 -0
  17. package/dist/SolanaLoginButton-C7Kc_m6n.js.map +1 -0
  18. package/dist/{TeamSection-Km7EwLWD.cjs → TeamSection-DN8PEHH3.cjs} +1 -1
  19. package/dist/{TeamSection-Km7EwLWD.cjs.map → TeamSection-DN8PEHH3.cjs.map} +1 -1
  20. package/dist/{TeamSection-C_eODdLU.js → TeamSection-gUyP4YDM.js} +1 -1
  21. package/dist/{TeamSection-C_eODdLU.js.map → TeamSection-gUyP4YDM.js.map} +1 -1
  22. package/dist/{UsersSection-C1Tt0ePx.cjs → UsersSection-8wLuD0fr.cjs} +1 -1
  23. package/dist/{UsersSection-C1Tt0ePx.cjs.map → UsersSection-8wLuD0fr.cjs.map} +1 -1
  24. package/dist/{UsersSection-Ct_E-MBF.js → UsersSection-CnsFrG-6.js} +1 -1
  25. package/dist/{UsersSection-Ct_E-MBF.js.map → UsersSection-CnsFrG-6.js.map} +1 -1
  26. package/dist/admin-only.cjs +1 -1
  27. package/dist/admin-only.js +1 -1
  28. package/dist/email-only.cjs +1 -1
  29. package/dist/email-only.d.ts +10 -2
  30. package/dist/email-only.js +2 -2
  31. package/dist/google-only.cjs +1 -1
  32. package/dist/google-only.d.ts +7 -2
  33. package/dist/google-only.js +2 -2
  34. package/dist/index.cjs +12 -12
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.ts +182 -11
  37. package/dist/index.js +5221 -4657
  38. package/dist/index.js.map +1 -1
  39. package/dist/login-react.css +1 -1
  40. package/dist/{plugin-Ci67QMGG.cjs → plugin-DNFjEfYp.cjs} +1 -1
  41. package/dist/{plugin-Ci67QMGG.cjs.map → plugin-DNFjEfYp.cjs.map} +1 -1
  42. package/dist/{plugin-Cm8Q6O4-.js → plugin-WYMrRNbz.js} +1 -1
  43. package/dist/{plugin-Cm8Q6O4-.js.map → plugin-WYMrRNbz.js.map} +1 -1
  44. package/dist/solana-only.cjs +1 -1
  45. package/dist/solana-only.d.ts +6 -1
  46. package/dist/solana-only.js +2 -2
  47. package/dist/useAuth-2vgrAH-M.cjs +1 -0
  48. package/dist/useAuth-2vgrAH-M.cjs.map +1 -0
  49. package/dist/{useAuth-l-itM5am.js → useAuth-CNflw856.js} +465 -469
  50. package/dist/useAuth-CNflw856.js.map +1 -0
  51. package/dist/useServerFeatures-9_aNPaa6.cjs +1 -0
  52. package/dist/useServerFeatures-9_aNPaa6.cjs.map +1 -0
  53. package/dist/useServerFeatures-DSkYdan-.js +82 -0
  54. package/dist/useServerFeatures-DSkYdan-.js.map +1 -0
  55. package/dist/{useUsersStatsSummary-BGeh3RnI.js → useUsersStatsSummary-B4_RBEYy.js} +504 -442
  56. package/dist/useUsersStatsSummary-B4_RBEYy.js.map +1 -0
  57. package/dist/useUsersStatsSummary-CHRMrlk4.cjs +1 -0
  58. package/dist/useUsersStatsSummary-CHRMrlk4.cjs.map +1 -0
  59. package/package.json +1 -1
  60. package/dist/EmailRegisterForm-p2X5QP58.js +0 -750
  61. package/dist/EmailRegisterForm-p2X5QP58.js.map +0 -1
  62. package/dist/EmailRegisterForm-xFb6MaVA.cjs +0 -1
  63. package/dist/EmailRegisterForm-xFb6MaVA.cjs.map +0 -1
  64. package/dist/GoogleLoginButton-2zNTIKMm.cjs +0 -1
  65. package/dist/GoogleLoginButton-2zNTIKMm.cjs.map +0 -1
  66. package/dist/GoogleLoginButton-C1WNu7W3.js.map +0 -1
  67. package/dist/PermissionsSection-4zcE9Zs9.cjs +0 -1
  68. package/dist/PermissionsSection-4zcE9Zs9.cjs.map +0 -1
  69. package/dist/PermissionsSection-mm9hfp-u.js.map +0 -1
  70. package/dist/SolanaLoginButton-CqdzSSeJ.cjs +0 -1
  71. package/dist/SolanaLoginButton-CqdzSSeJ.cjs.map +0 -1
  72. package/dist/SolanaLoginButton-CyeX35eU.js +0 -232
  73. package/dist/SolanaLoginButton-CyeX35eU.js.map +0 -1
  74. package/dist/sanitization-Bo_tn-L2.cjs +0 -1
  75. package/dist/sanitization-Bo_tn-L2.cjs.map +0 -1
  76. package/dist/sanitization-CQ-H1MSg.js +0 -39
  77. package/dist/sanitization-CQ-H1MSg.js.map +0 -1
  78. package/dist/useAuth-B1yS_YiD.cjs +0 -1
  79. package/dist/useAuth-B1yS_YiD.cjs.map +0 -1
  80. package/dist/useAuth-l-itM5am.js.map +0 -1
  81. package/dist/useUsersStatsSummary-BGeh3RnI.js.map +0 -1
  82. package/dist/useUsersStatsSummary-DnsYtFGX.cjs +0 -1
  83. package/dist/useUsersStatsSummary-DnsYtFGX.cjs.map +0 -1
@@ -0,0 +1,781 @@
1
+ import { jsxs as h, jsx as e, Fragment as I } from "react/jsx-runtime";
2
+ import { useRef as H, useState as w, useCallback as E, useEffect as U, useMemo as K, useId as Z } from "react";
3
+ import { L as _ } from "./LoadingSpinner-6vml-zwr.js";
4
+ import { E as Y } from "./ErrorMessage-CcEK0pYO.js";
5
+ import { u as F, A as G, h as x } from "./useCedrosLogin-CFfID-0i.js";
6
+ import { b as j, v as he } from "./validation-B8kMV3BL.js";
7
+ import { u as fe, s as ge } from "./useServerFeatures-DSkYdan-.js";
8
+ function J(c = {}) {
9
+ const { maxAttempts: m = 5, windowMs: C = 6e4, showCountdown: f = !1 } = c, d = H([]), [u, a] = w(!1), [, v] = w(0), p = E(() => {
10
+ v((o) => o + 1);
11
+ }, []), i = E(() => {
12
+ const o = Date.now();
13
+ d.current = d.current.filter((t) => o - t < C);
14
+ }, [C]), b = E(() => {
15
+ i(), a((o) => d.current.length === 0 && o ? !1 : o);
16
+ }, [i]), s = E(() => (i(), Math.max(0, m - d.current.length)), [i, m]), g = E(() => {
17
+ if (i(), d.current.length === 0)
18
+ return 0;
19
+ const t = d.current[0] + C;
20
+ return Math.max(0, t - Date.now());
21
+ }, [i, C]), k = E(() => (i(), d.current.length < m), [i, m]), N = E(() => {
22
+ if (b(), d.current.length >= m) {
23
+ const o = g(), t = Math.ceil(o / 1e3);
24
+ throw new Error(
25
+ `Too many attempts. Please wait ${t} second${t === 1 ? "" : "s"} before trying again.`
26
+ );
27
+ }
28
+ d.current.push(Date.now()), a((o) => o || !0), p();
29
+ }, [b, m, g, p]), y = E(() => {
30
+ d.current = [], a((o) => o && !1), p();
31
+ }, [p]);
32
+ return U(() => {
33
+ if (!u || !f) return;
34
+ const o = window.setInterval(() => {
35
+ b(), p();
36
+ }, 1e3);
37
+ return () => {
38
+ window.clearInterval(o);
39
+ };
40
+ }, [u, f, p, b]), {
41
+ checkLimit: N,
42
+ isAllowed: k,
43
+ getRemainingAttempts: s,
44
+ getTimeUntilReset: g,
45
+ reset: y
46
+ };
47
+ }
48
+ function ve(c) {
49
+ return "mfaRequired" in c && c.mfaRequired === !0;
50
+ }
51
+ function Q() {
52
+ const { config: c, _internal: m } = F(), [C, f] = w(!1), [d, u] = w(null), {
53
+ checkLimit: a,
54
+ getRemainingAttempts: v,
55
+ getTimeUntilReset: p,
56
+ reset: i
57
+ } = J({ maxAttempts: 5, windowMs: 6e4 }), b = K(
58
+ () => new G({
59
+ baseUrl: c.serverUrl,
60
+ timeoutMs: c.requestTimeout,
61
+ retryAttempts: c.retryAttempts
62
+ }),
63
+ [c.serverUrl, c.requestTimeout, c.retryAttempts]
64
+ ), s = c.callbacks, g = E(
65
+ async (y, o) => {
66
+ if (!j(y)) {
67
+ const t = {
68
+ code: "VALIDATION_ERROR",
69
+ message: "Please enter a valid email address"
70
+ };
71
+ throw u(t), t;
72
+ }
73
+ try {
74
+ a();
75
+ } catch (t) {
76
+ const r = {
77
+ code: "RATE_LIMITED",
78
+ message: t instanceof Error ? t.message : "Too many attempts"
79
+ };
80
+ throw u(r), r;
81
+ }
82
+ f(!0), u(null);
83
+ try {
84
+ const t = await b.post("/login", {
85
+ email: y,
86
+ password: o
87
+ });
88
+ if (ve(t))
89
+ return {
90
+ mfaRequired: !0,
91
+ mfaToken: t.mfaToken,
92
+ email: y,
93
+ userId: t.userId
94
+ };
95
+ const r = t;
96
+ return s?.onLoginSuccess?.(r.user, "email"), m?.handleLoginSuccess(r.user, r.tokens), i(), {
97
+ mfaRequired: !1,
98
+ response: r
99
+ };
100
+ } catch (t) {
101
+ const r = x(t, "Unable to sign in. Please try again.");
102
+ throw u(r), r;
103
+ } finally {
104
+ f(!1);
105
+ }
106
+ },
107
+ [b, s, m, a, i]
108
+ ), k = E(
109
+ async (y, o, t, r, n) => {
110
+ if (!j(y)) {
111
+ const l = {
112
+ code: "VALIDATION_ERROR",
113
+ message: "Please enter a valid email address"
114
+ };
115
+ throw u(l), l;
116
+ }
117
+ try {
118
+ a();
119
+ } catch (l) {
120
+ const A = {
121
+ code: "RATE_LIMITED",
122
+ message: l instanceof Error ? l.message : "Too many attempts"
123
+ };
124
+ throw u(A), A;
125
+ }
126
+ f(!0), u(null);
127
+ try {
128
+ const l = r ?? m?.getReferralCode?.() ?? void 0, A = await b.post("/register", {
129
+ email: y,
130
+ password: o,
131
+ name: t,
132
+ referral: l,
133
+ ...n ? { access_code: n } : {}
134
+ });
135
+ return s?.onLoginSuccess?.(A.user, "email"), m?.handleLoginSuccess(A.user, A.tokens), i(), A;
136
+ } catch (l) {
137
+ const A = x(l, "Unable to create your account. Please try again.");
138
+ throw u(A), A;
139
+ } finally {
140
+ f(!1);
141
+ }
142
+ },
143
+ [b, s, m, a, i]
144
+ ), N = E(() => u(null), []);
145
+ return {
146
+ login: g,
147
+ register: k,
148
+ isLoading: C,
149
+ error: d,
150
+ clearError: N,
151
+ // M-10: Point-in-time snapshots for UI display (see interface JSDoc)
152
+ remainingAttempts: v(),
153
+ timeUntilReset: p()
154
+ };
155
+ }
156
+ function $({
157
+ label: c = "Password",
158
+ labelAction: m,
159
+ showStrengthMeter: C = !1,
160
+ onValidationChange: f,
161
+ error: d,
162
+ className: u = "",
163
+ onChange: a,
164
+ value: v,
165
+ ...p
166
+ }) {
167
+ const [i, b] = w(!1), [s, g] = w(null), k = Z(), N = (o) => {
168
+ const t = o.target.value;
169
+ if (C || f) {
170
+ const r = he(t);
171
+ g(r), f?.(r);
172
+ }
173
+ a?.(o);
174
+ }, y = {
175
+ weak: "var(--cedros-destructive, #ef4444)",
176
+ fair: "var(--cedros-warning, #f59e0b)",
177
+ good: "var(--cedros-success, #22c55e)",
178
+ strong: "var(--cedros-success, #22c55e)"
179
+ };
180
+ return /* @__PURE__ */ h("div", { className: `cedros-password-input ${u}`, children: [
181
+ /* @__PURE__ */ h("div", { className: "cedros-label-row", children: [
182
+ /* @__PURE__ */ e("label", { htmlFor: k, className: "cedros-label", children: c }),
183
+ m
184
+ ] }),
185
+ /* @__PURE__ */ h("div", { className: "cedros-password-wrapper", children: [
186
+ /* @__PURE__ */ e(
187
+ "input",
188
+ {
189
+ id: k,
190
+ type: i ? "text" : "password",
191
+ className: "cedros-input",
192
+ onChange: N,
193
+ value: v,
194
+ "aria-invalid": d ? "true" : void 0,
195
+ "aria-describedby": d ? `${k}-error` : void 0,
196
+ ...p
197
+ }
198
+ ),
199
+ /* @__PURE__ */ e(
200
+ "button",
201
+ {
202
+ type: "button",
203
+ className: "cedros-password-toggle",
204
+ onClick: () => b(!i),
205
+ "aria-label": i ? "Hide password" : "Show password",
206
+ "aria-pressed": i,
207
+ children: i ? /* @__PURE__ */ h("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
208
+ /* @__PURE__ */ e(
209
+ "path",
210
+ {
211
+ d: "M2.5 10s3-6 7.5-6 7.5 6 7.5 6-3 6-7.5 6-7.5-6-7.5-6z",
212
+ stroke: "currentColor",
213
+ strokeWidth: "1.5"
214
+ }
215
+ ),
216
+ /* @__PURE__ */ e("circle", { cx: "10", cy: "10", r: "2.5", stroke: "currentColor", strokeWidth: "1.5" }),
217
+ /* @__PURE__ */ e("path", { d: "M3 17L17 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
218
+ ] }) : /* @__PURE__ */ h("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
219
+ /* @__PURE__ */ e(
220
+ "path",
221
+ {
222
+ d: "M2.5 10s3-6 7.5-6 7.5 6 7.5 6-3 6-7.5 6-7.5-6-7.5-6z",
223
+ stroke: "currentColor",
224
+ strokeWidth: "1.5"
225
+ }
226
+ ),
227
+ /* @__PURE__ */ e("circle", { cx: "10", cy: "10", r: "2.5", stroke: "currentColor", strokeWidth: "1.5" })
228
+ ] })
229
+ }
230
+ )
231
+ ] }),
232
+ d && /* @__PURE__ */ e("p", { id: `${k}-error`, className: "cedros-input-error", children: d }),
233
+ C && s && v?.length > 0 && /* @__PURE__ */ h("div", { className: "cedros-password-strength", children: [
234
+ /* @__PURE__ */ e("div", { className: "cedros-strength-bar", children: /* @__PURE__ */ e(
235
+ "div",
236
+ {
237
+ className: "cedros-strength-fill",
238
+ style: {
239
+ width: `${s.strength === "weak" ? 25 : s.strength === "fair" ? 50 : s.strength === "good" ? 75 : 100}%`,
240
+ backgroundColor: y[s.strength]
241
+ }
242
+ }
243
+ ) }),
244
+ /* @__PURE__ */ e("span", { className: "cedros-strength-label", children: s.strength })
245
+ ] })
246
+ ] });
247
+ }
248
+ function be() {
249
+ const { config: c, _internal: m } = F(), [C, f] = w("idle"), [d, u] = w(!1), [a, v] = w(null), {
250
+ checkLimit: p,
251
+ getRemainingAttempts: i,
252
+ getTimeUntilReset: b,
253
+ reset: s
254
+ } = J({ maxAttempts: 5, windowMs: 12e4 }), g = K(
255
+ () => new G({
256
+ baseUrl: c.serverUrl,
257
+ timeoutMs: c.requestTimeout,
258
+ retryAttempts: c.retryAttempts
259
+ }),
260
+ [c.serverUrl, c.requestTimeout, c.retryAttempts]
261
+ ), k = E(
262
+ async (o, t) => {
263
+ const r = /^[A-Z0-9]{16}$/i.test(t) || /^[A-Z0-9]{4}(-[A-Z0-9]{4}){3}$/i.test(t);
264
+ if (!(/^\d{6}$/.test(t) || r)) {
265
+ const l = {
266
+ code: "VALIDATION_ERROR",
267
+ message: "Please enter a valid 6-digit code or recovery code"
268
+ };
269
+ throw v(l), l;
270
+ }
271
+ try {
272
+ p();
273
+ } catch (l) {
274
+ const A = {
275
+ code: "RATE_LIMITED",
276
+ message: l instanceof Error ? l.message : "Too many attempts"
277
+ };
278
+ throw v(A), A;
279
+ }
280
+ u(!0), v(null), f("verifying");
281
+ try {
282
+ const l = await g.post("/login/mfa", { mfaToken: o, code: t });
283
+ return f("success"), s(), m && l.user && l.tokens && m.handleLoginSuccess(l.user, l.tokens), l;
284
+ } catch (l) {
285
+ const A = x(l, "Incorrect verification code. Please check and try again.");
286
+ throw v(A), f("error"), A;
287
+ } finally {
288
+ u(!1);
289
+ }
290
+ },
291
+ [g, m, p, s]
292
+ ), N = E(() => v(null), []), y = E(() => {
293
+ v(null), f("idle"), u(!1);
294
+ }, []);
295
+ return {
296
+ state: C,
297
+ isLoading: d,
298
+ error: a,
299
+ verifyTotp: k,
300
+ clearError: N,
301
+ reset: y,
302
+ // Point-in-time snapshots for UI display
303
+ remainingAttempts: i(),
304
+ timeUntilReset: b()
305
+ };
306
+ }
307
+ const R = 6;
308
+ function we({
309
+ value: c = "",
310
+ onChange: m,
311
+ onComplete: C,
312
+ disabled: f = !1,
313
+ error: d,
314
+ autoFocus: u = !1,
315
+ className: a = ""
316
+ }) {
317
+ const v = H([]), [p, i] = w(c.padEnd(R, "")), b = Z();
318
+ U(() => {
319
+ i(c.padEnd(R, ""));
320
+ }, [c]);
321
+ const s = E((t) => {
322
+ t >= 0 && t < R && v.current[t]?.focus();
323
+ }, []), g = E(
324
+ (t) => {
325
+ const r = t.replace(/\D/g, "").slice(0, R);
326
+ i(r.padEnd(R, "")), m?.(r), r.length === R && C?.(r);
327
+ },
328
+ [m, C]
329
+ ), k = E(
330
+ (t, r) => {
331
+ if (!/^\d?$/.test(r)) return;
332
+ const n = p.split("");
333
+ n[t] = r;
334
+ const l = n.join("").replace(/ /g, "");
335
+ g(l), r && t < R - 1 && s(t + 1);
336
+ },
337
+ [p, g, s]
338
+ ), N = E(
339
+ (t, r) => {
340
+ if (r.key === "Backspace") {
341
+ r.preventDefault();
342
+ const n = p.split("");
343
+ n[t] && n[t] !== " " ? (n[t] = " ", g(n.join("").replace(/ /g, ""))) : t > 0 && (n[t - 1] = " ", g(n.join("").replace(/ /g, "")), s(t - 1));
344
+ } else r.key === "ArrowLeft" && t > 0 ? (r.preventDefault(), s(t - 1)) : r.key === "ArrowRight" && t < R - 1 && (r.preventDefault(), s(t + 1));
345
+ },
346
+ [p, g, s]
347
+ ), y = E(
348
+ (t) => {
349
+ t.preventDefault();
350
+ const n = t.clipboardData.getData("text").replace(/\D/g, "").slice(0, R);
351
+ n && (g(n), s(Math.min(n.length, R - 1)));
352
+ },
353
+ [g, s]
354
+ ), o = E((t) => {
355
+ t.target.select();
356
+ }, []);
357
+ return U(() => {
358
+ u && !f && v.current[0]?.focus();
359
+ }, [u, f]), /* @__PURE__ */ h("div", { className: `cedros-otp-input ${a}`, children: [
360
+ /* @__PURE__ */ e("div", { className: "cedros-otp-slots", role: "group", "aria-label": "One-time password", children: Array.from({ length: R }).map((t, r) => /* @__PURE__ */ e(
361
+ "input",
362
+ {
363
+ ref: (n) => {
364
+ v.current[r] = n;
365
+ },
366
+ id: `${b}-${r}`,
367
+ type: "text",
368
+ inputMode: "numeric",
369
+ pattern: "[0-9]*",
370
+ maxLength: 1,
371
+ className: `cedros-otp-slot ${d ? "cedros-otp-slot-error" : ""}`,
372
+ value: p[r] === " " ? "" : p[r] || "",
373
+ onChange: (n) => k(r, n.target.value),
374
+ onKeyDown: (n) => N(r, n),
375
+ onPaste: y,
376
+ onFocus: o,
377
+ disabled: f,
378
+ autoComplete: "one-time-code",
379
+ "aria-label": `Digit ${r + 1}`,
380
+ "aria-invalid": d ? "true" : void 0
381
+ },
382
+ r
383
+ )) }),
384
+ d && /* @__PURE__ */ e("p", { className: "cedros-otp-error", role: "alert", children: d })
385
+ ] });
386
+ }
387
+ function ye({
388
+ mfaToken: c,
389
+ email: m,
390
+ onSuccess: C,
391
+ onBack: f,
392
+ className: d = ""
393
+ }) {
394
+ const { verifyTotp: u, isLoading: a, error: v, clearError: p } = be(), [i, b] = w(""), [s, g] = w(!1), [k, N] = w(""), y = async (r) => {
395
+ const n = r || (s ? k : i);
396
+ if (n)
397
+ try {
398
+ await u(c, n), C?.();
399
+ } catch {
400
+ s ? N("") : b("");
401
+ }
402
+ }, o = (r) => {
403
+ y(r);
404
+ }, t = () => {
405
+ g(!s), p(), b(""), N("");
406
+ };
407
+ return /* @__PURE__ */ h("div", { className: `cedros-totp-verify ${d}`, children: [
408
+ /* @__PURE__ */ h("div", { className: "cedros-totp-verify-header", children: [
409
+ /* @__PURE__ */ h(
410
+ "svg",
411
+ {
412
+ className: "cedros-totp-verify-icon",
413
+ width: "48",
414
+ height: "48",
415
+ viewBox: "0 0 48 48",
416
+ fill: "none",
417
+ "aria-hidden": "true",
418
+ children: [
419
+ /* @__PURE__ */ e("rect", { x: "8", y: "20", width: "32", height: "24", rx: "4", stroke: "currentColor", strokeWidth: "2" }),
420
+ /* @__PURE__ */ e(
421
+ "path",
422
+ {
423
+ d: "M16 20V14a8 8 0 1 1 16 0v6",
424
+ stroke: "currentColor",
425
+ strokeWidth: "2",
426
+ strokeLinecap: "round"
427
+ }
428
+ ),
429
+ /* @__PURE__ */ e("circle", { cx: "24", cy: "32", r: "3", fill: "currentColor" })
430
+ ]
431
+ }
432
+ ),
433
+ /* @__PURE__ */ e("h3", { className: "cedros-totp-title", children: "Two-factor authentication" }),
434
+ /* @__PURE__ */ e("p", { className: "cedros-totp-description", children: s ? "Enter one of your recovery codes to sign in." : "Enter the 6-digit code from your authenticator app." }),
435
+ m && /* @__PURE__ */ e("p", { className: "cedros-totp-email", children: m })
436
+ ] }),
437
+ s ? /* @__PURE__ */ h("div", { className: "cedros-totp-backup-input", children: [
438
+ /* @__PURE__ */ e(
439
+ "input",
440
+ {
441
+ type: "text",
442
+ className: `cedros-input ${v ? "cedros-input-error" : ""}`,
443
+ placeholder: "Enter recovery code",
444
+ value: k,
445
+ onChange: (r) => {
446
+ N(r.target.value.toUpperCase()), p();
447
+ },
448
+ onKeyDown: (r) => {
449
+ r.key === "Enter" && k && y();
450
+ },
451
+ disabled: a,
452
+ autoFocus: !0,
453
+ autoComplete: "one-time-code"
454
+ }
455
+ ),
456
+ v && /* @__PURE__ */ e("p", { className: "cedros-input-error", role: "alert", children: v.message })
457
+ ] }) : /* @__PURE__ */ e(
458
+ we,
459
+ {
460
+ value: i,
461
+ onChange: (r) => {
462
+ b(r), p();
463
+ },
464
+ onComplete: o,
465
+ disabled: a,
466
+ error: v?.message,
467
+ autoFocus: !0
468
+ }
469
+ ),
470
+ /* @__PURE__ */ e(
471
+ "button",
472
+ {
473
+ type: "button",
474
+ className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
475
+ onClick: () => y(),
476
+ disabled: a || (s ? !k : i.length !== 6),
477
+ children: a ? /* @__PURE__ */ h(I, { children: [
478
+ /* @__PURE__ */ e(_, { size: "sm" }),
479
+ /* @__PURE__ */ e("span", { children: "Verifying..." })
480
+ ] }) : "Verify"
481
+ }
482
+ ),
483
+ /* @__PURE__ */ h("div", { className: "cedros-totp-verify-footer", children: [
484
+ /* @__PURE__ */ e(
485
+ "button",
486
+ {
487
+ type: "button",
488
+ className: "cedros-link cedros-link-sm",
489
+ onClick: t,
490
+ disabled: a,
491
+ children: s ? "Use authenticator app" : "Use a recovery code"
492
+ }
493
+ ),
494
+ f && /* @__PURE__ */ h(I, { children: [
495
+ /* @__PURE__ */ e("span", { className: "cedros-totp-verify-divider", children: "•" }),
496
+ /* @__PURE__ */ e(
497
+ "button",
498
+ {
499
+ type: "button",
500
+ className: "cedros-link cedros-link-sm",
501
+ onClick: f,
502
+ disabled: a,
503
+ children: "Back to login"
504
+ }
505
+ )
506
+ ] })
507
+ ] })
508
+ ] });
509
+ }
510
+ function Le({
511
+ onSuccess: c,
512
+ onSwitchToRegister: m,
513
+ onForgotPassword: C,
514
+ className: f = ""
515
+ }) {
516
+ const { login: d, isLoading: u, error: a, clearError: v } = Q(), [p, i] = w(""), [b, s] = w(""), [g, k] = w(null), [N, y] = w(""), o = async (n) => {
517
+ n.preventDefault();
518
+ try {
519
+ const l = await d(p, b);
520
+ l.mfaRequired ? (k(l.mfaToken), y(l.email)) : c?.();
521
+ } catch {
522
+ }
523
+ }, t = () => {
524
+ k(null), y(""), c?.();
525
+ }, r = () => {
526
+ k(null), y(""), s("");
527
+ };
528
+ return g ? /* @__PURE__ */ e(
529
+ ye,
530
+ {
531
+ mfaToken: g,
532
+ email: N,
533
+ onSuccess: t,
534
+ onBack: r,
535
+ className: f
536
+ }
537
+ ) : /* @__PURE__ */ h("form", { onSubmit: o, className: `cedros-form ${f}`, children: [
538
+ /* @__PURE__ */ h("div", { className: "cedros-form-field", children: [
539
+ /* @__PURE__ */ e("label", { htmlFor: "email", className: "cedros-label", children: "Email" }),
540
+ /* @__PURE__ */ e(
541
+ "input",
542
+ {
543
+ id: "email",
544
+ type: "email",
545
+ className: "cedros-input",
546
+ value: p,
547
+ onChange: (n) => i(n.target.value),
548
+ placeholder: "you@example.com",
549
+ required: !0,
550
+ "aria-required": "true",
551
+ autoComplete: "email",
552
+ disabled: u
553
+ }
554
+ )
555
+ ] }),
556
+ /* @__PURE__ */ e("div", { className: "cedros-form-field", children: /* @__PURE__ */ e(
557
+ $,
558
+ {
559
+ value: b,
560
+ onChange: (n) => s(n.target.value),
561
+ placeholder: "Enter your password",
562
+ required: !0,
563
+ autoComplete: "current-password",
564
+ disabled: u,
565
+ labelAction: C ? /* @__PURE__ */ e(
566
+ "button",
567
+ {
568
+ type: "button",
569
+ className: "cedros-link cedros-link-muted cedros-link-sm",
570
+ onClick: C,
571
+ children: "Forgot your password?"
572
+ }
573
+ ) : void 0
574
+ }
575
+ ) }),
576
+ /* @__PURE__ */ e(Y, { error: a, onDismiss: v }),
577
+ /* @__PURE__ */ e(
578
+ "button",
579
+ {
580
+ type: "submit",
581
+ className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
582
+ disabled: u || !p || !b,
583
+ "aria-busy": u,
584
+ children: u ? /* @__PURE__ */ h(I, { children: [
585
+ /* @__PURE__ */ e(_, { size: "sm", announce: !0, label: "Signing in" }),
586
+ /* @__PURE__ */ e("span", { children: "Signing in..." })
587
+ ] }) : "Sign in"
588
+ }
589
+ ),
590
+ m && /* @__PURE__ */ h("p", { className: "cedros-form-footer", children: [
591
+ "Don't have an account?",
592
+ " ",
593
+ /* @__PURE__ */ e("button", { type: "button", className: "cedros-link cedros-link-muted", onClick: m, children: "Sign up" })
594
+ ] })
595
+ ] });
596
+ }
597
+ function Ie({
598
+ onSuccess: c,
599
+ onSwitchToLogin: m,
600
+ className: C = "",
601
+ accessCode: f
602
+ }) {
603
+ const { config: d } = F(), { register: u, isLoading: a, error: v, clearError: p } = Q(), { features: i } = fe(), [b, s] = w(""), [g, k] = w(""), [N, y] = w(""), [o, t] = w(""), [r, n] = w(""), l = f ?? r, [A, X] = w(null), [ee, S] = w(null), L = d.forms?.termsOfService, q = d.forms?.emailOptIn, V = L?.show ?? !1, D = L?.required ?? !0, te = L?.defaultChecked ?? !1, B = L?.label ?? "I agree to the Terms of Service", re = L?.url, z = ge(re), se = q?.show ?? !1, oe = q?.defaultChecked ?? !1, ae = q?.label ?? "Send me updates and news", [M, ne] = w(te), [ce, ie] = w(oe), P = N === o, le = A?.isValid ?? !1, de = !V || !D || M, O = i?.signupAccessCodeRequired ?? !1, W = g && N && o && P && le && de && (!O || l.trim()) && !a, ue = async (T) => {
604
+ if (T.preventDefault(), S(null), V && D && !M) {
605
+ S({
606
+ code: "VALIDATION_ERROR",
607
+ message: "You must agree to the Terms of Service to continue"
608
+ });
609
+ return;
610
+ }
611
+ if (W)
612
+ try {
613
+ await u(
614
+ g,
615
+ N,
616
+ b || void 0,
617
+ void 0,
618
+ O && l.trim() || void 0
619
+ ), c?.();
620
+ } catch {
621
+ }
622
+ }, me = v || ee, pe = () => {
623
+ p(), S(null);
624
+ };
625
+ return /* @__PURE__ */ h("form", { onSubmit: ue, className: `cedros-form ${C}`, children: [
626
+ /* @__PURE__ */ h("div", { className: "cedros-form-field", children: [
627
+ /* @__PURE__ */ h("label", { htmlFor: "name", className: "cedros-label", children: [
628
+ "Name ",
629
+ /* @__PURE__ */ e("span", { className: "cedros-optional", children: "(optional)" })
630
+ ] }),
631
+ /* @__PURE__ */ e(
632
+ "input",
633
+ {
634
+ id: "name",
635
+ type: "text",
636
+ className: "cedros-input",
637
+ value: b,
638
+ onChange: (T) => s(T.target.value),
639
+ placeholder: "Your name",
640
+ autoComplete: "name",
641
+ disabled: a
642
+ }
643
+ )
644
+ ] }),
645
+ /* @__PURE__ */ h("div", { className: "cedros-form-field", children: [
646
+ /* @__PURE__ */ e("label", { htmlFor: "register-email", className: "cedros-label", children: "Email" }),
647
+ /* @__PURE__ */ e(
648
+ "input",
649
+ {
650
+ id: "register-email",
651
+ type: "email",
652
+ className: "cedros-input",
653
+ value: g,
654
+ onChange: (T) => k(T.target.value),
655
+ placeholder: "you@example.com",
656
+ required: !0,
657
+ "aria-required": "true",
658
+ autoComplete: "email",
659
+ disabled: a
660
+ }
661
+ )
662
+ ] }),
663
+ /* @__PURE__ */ e("div", { className: "cedros-form-field", children: /* @__PURE__ */ e(
664
+ $,
665
+ {
666
+ value: N,
667
+ onChange: (T) => y(T.target.value),
668
+ placeholder: "Create a password",
669
+ required: !0,
670
+ autoComplete: "new-password",
671
+ disabled: a,
672
+ showStrengthMeter: !0,
673
+ onValidationChange: X
674
+ }
675
+ ) }),
676
+ /* @__PURE__ */ e("div", { className: "cedros-form-field", children: /* @__PURE__ */ e(
677
+ $,
678
+ {
679
+ label: "Confirm Password",
680
+ value: o,
681
+ onChange: (T) => t(T.target.value),
682
+ placeholder: "Confirm your password",
683
+ required: !0,
684
+ autoComplete: "new-password",
685
+ disabled: a,
686
+ "aria-invalid": o && !P ? "true" : void 0,
687
+ error: o && !P ? "Passwords do not match" : void 0
688
+ }
689
+ ) }),
690
+ O && f === void 0 && /* @__PURE__ */ h("div", { className: "cedros-form-field", children: [
691
+ /* @__PURE__ */ e("label", { htmlFor: "register-access-code", className: "cedros-label", children: "Access Code" }),
692
+ /* @__PURE__ */ e(
693
+ "input",
694
+ {
695
+ id: "register-access-code",
696
+ type: "text",
697
+ className: "cedros-input",
698
+ value: r,
699
+ onChange: (T) => n(T.target.value),
700
+ placeholder: "Enter access code",
701
+ required: !0,
702
+ "aria-required": "true",
703
+ disabled: a,
704
+ autoComplete: "off"
705
+ }
706
+ )
707
+ ] }),
708
+ V && /* @__PURE__ */ e("div", { className: "cedros-form-field cedros-checkbox-field", children: /* @__PURE__ */ h("label", { className: "cedros-checkbox-label", children: [
709
+ /* @__PURE__ */ e(
710
+ "input",
711
+ {
712
+ type: "checkbox",
713
+ className: "cedros-checkbox",
714
+ checked: M,
715
+ onChange: (T) => ne(T.target.checked),
716
+ disabled: a,
717
+ "aria-required": D
718
+ }
719
+ ),
720
+ /* @__PURE__ */ h("span", { className: "cedros-checkbox-text", children: [
721
+ z ? /* @__PURE__ */ h(I, { children: [
722
+ B.replace("Terms of Service", "").trim() || "I agree to the",
723
+ " ",
724
+ /* @__PURE__ */ e(
725
+ "a",
726
+ {
727
+ href: z,
728
+ target: "_blank",
729
+ rel: "noopener noreferrer",
730
+ className: "cedros-link",
731
+ children: "Terms of Service"
732
+ }
733
+ )
734
+ ] }) : B,
735
+ D && /* @__PURE__ */ e("span", { className: "cedros-required", children: "*" })
736
+ ] })
737
+ ] }) }),
738
+ se && /* @__PURE__ */ e("div", { className: "cedros-form-field cedros-checkbox-field", children: /* @__PURE__ */ h("label", { className: "cedros-checkbox-label", children: [
739
+ /* @__PURE__ */ e(
740
+ "input",
741
+ {
742
+ type: "checkbox",
743
+ className: "cedros-checkbox",
744
+ checked: ce,
745
+ onChange: (T) => ie(T.target.checked),
746
+ disabled: a
747
+ }
748
+ ),
749
+ /* @__PURE__ */ e("span", { className: "cedros-checkbox-text", children: ae })
750
+ ] }) }),
751
+ /* @__PURE__ */ e(Y, { error: me, onDismiss: pe }),
752
+ /* @__PURE__ */ e(
753
+ "button",
754
+ {
755
+ type: "submit",
756
+ className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
757
+ disabled: !W,
758
+ "aria-busy": a,
759
+ children: a ? /* @__PURE__ */ h(I, { children: [
760
+ /* @__PURE__ */ e(_, { size: "sm", announce: !0, label: "Creating account" }),
761
+ /* @__PURE__ */ e("span", { children: "Creating account..." })
762
+ ] }) : "Create account"
763
+ }
764
+ ),
765
+ m && /* @__PURE__ */ h("p", { className: "cedros-form-footer", children: [
766
+ "Already have an account?",
767
+ " ",
768
+ /* @__PURE__ */ e("button", { type: "button", className: "cedros-link cedros-link-muted", onClick: m, children: "Sign in" })
769
+ ] })
770
+ ] });
771
+ }
772
+ export {
773
+ Le as E,
774
+ we as O,
775
+ $ as P,
776
+ ye as T,
777
+ Ie as a,
778
+ J as b,
779
+ be as c,
780
+ Q as u
781
+ };