@rpcbase/auth 0.119.0 → 0.121.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 (59) hide show
  1. package/dist/handler-BNDemOGd.js +79 -0
  2. package/dist/handler-BNDemOGd.js.map +1 -0
  3. package/dist/handler-Bt53h0sk.js +64 -0
  4. package/dist/handler-Bt53h0sk.js.map +1 -0
  5. package/dist/handler-C4cw739Z.js +59 -0
  6. package/dist/handler-C4cw739Z.js.map +1 -0
  7. package/dist/handler-Ck7oLQ_R.js +87 -0
  8. package/dist/handler-Ck7oLQ_R.js.map +1 -0
  9. package/dist/handler-CyP6R8FM.js +24 -0
  10. package/dist/handler-CyP6R8FM.js.map +1 -0
  11. package/dist/handler-D6zJn86A.js +82 -0
  12. package/dist/handler-D6zJn86A.js.map +1 -0
  13. package/dist/handler-D7KnXlx3.js +58 -0
  14. package/dist/handler-D7KnXlx3.js.map +1 -0
  15. package/dist/handler-D8HfTbUs.js +58 -0
  16. package/dist/handler-D8HfTbUs.js.map +1 -0
  17. package/dist/handler-DfEsSB4T.js +74 -0
  18. package/dist/handler-DfEsSB4T.js.map +1 -0
  19. package/dist/index-Bxz6YdiB.js +20 -0
  20. package/dist/index-Bxz6YdiB.js.map +1 -0
  21. package/dist/index-C_uBu_fP.js +20 -0
  22. package/dist/index-C_uBu_fP.js.map +1 -0
  23. package/dist/index.js +685 -705
  24. package/dist/index.js.map +1 -1
  25. package/dist/middleware-8IfSkEEy.js +25 -0
  26. package/dist/middleware-8IfSkEEy.js.map +1 -0
  27. package/dist/oauth/index.js +746 -625
  28. package/dist/oauth/index.js.map +1 -1
  29. package/dist/routes.js +9 -18
  30. package/dist/routes.js.map +1 -1
  31. package/dist/schemas-Dn3gHDGz.js +3706 -0
  32. package/dist/schemas-Dn3gHDGz.js.map +1 -0
  33. package/package.json +1 -1
  34. package/dist/handler-BH38xcvj.js +0 -60
  35. package/dist/handler-BH38xcvj.js.map +0 -1
  36. package/dist/handler-Bjxe8iM2.js +0 -67
  37. package/dist/handler-Bjxe8iM2.js.map +0 -1
  38. package/dist/handler-CVeU9Nyf.js +0 -85
  39. package/dist/handler-CVeU9Nyf.js.map +0 -1
  40. package/dist/handler-CrTy-N1A.js +0 -51
  41. package/dist/handler-CrTy-N1A.js.map +0 -1
  42. package/dist/handler-D2-FmmDc.js +0 -56
  43. package/dist/handler-D2-FmmDc.js.map +0 -1
  44. package/dist/handler-D4-sXlBe.js +0 -74
  45. package/dist/handler-D4-sXlBe.js.map +0 -1
  46. package/dist/handler-D87G4mz9.js +0 -67
  47. package/dist/handler-D87G4mz9.js.map +0 -1
  48. package/dist/handler-DKrwSIQz.js +0 -19
  49. package/dist/handler-DKrwSIQz.js.map +0 -1
  50. package/dist/handler-tJUJWqII.js +0 -59
  51. package/dist/handler-tJUJWqII.js.map +0 -1
  52. package/dist/middleware-BbKZ_rOe.js +0 -18
  53. package/dist/middleware-BbKZ_rOe.js.map +0 -1
  54. package/dist/schemas-BKnjeqQ9.js +0 -3380
  55. package/dist/schemas-BKnjeqQ9.js.map +0 -1
  56. package/dist/sign-in-C9a-NvBu.js +0 -18
  57. package/dist/sign-in-C9a-NvBu.js.map +0 -1
  58. package/dist/sign-up-DqDJxb2D.js +0 -18
  59. package/dist/sign-up-DqDJxb2D.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,726 +1,706 @@
1
- import { n as requestSchema } from "./sign-in-C9a-NvBu.js";
2
- import { n as requestSchema$1 } from "./sign-up-DqDJxb2D.js";
3
- import { n as requireSession, r as restrictSessionMiddleware, t as redirectAuthMiddleware } from "./middleware-BbKZ_rOe.js";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
2
  import { c } from "react/compiler-runtime";
5
- import { createContext, createElement, forwardRef, useContext, useEffect, useState } from "react";
6
- import { Link, useLocation, useNavigate, useSearchParams } from "@rpcbase/router";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
8
4
  import clsx from "clsx";
9
- import { FormProvider, useForm, useFormContext, zodResolver } from "@rpcbase/form";
10
- //#region src/components/AuthLayout/index.tsx
11
- var LINKS_REDIRECTION_MAP = {
12
- "/auth/sign-in": {
13
- "title": "Sign Up",
14
- "location": "/auth/sign-up"
15
- },
16
- "/auth/sign-up": {
17
- "title": "Sign In",
18
- "location": "/auth/sign-in"
19
- },
20
- "/auth/logout-success": {
21
- "title": "Sign In",
22
- "location": "/auth/sign-in"
23
- }
5
+ import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
6
+ import { r as requestSchema } from "./index-Bxz6YdiB.js";
7
+ import { useState, forwardRef, createElement, useEffect } from "react";
8
+ import { r as requestSchema$1 } from "./index-C_uBu_fP.js";
9
+ import { r, a, b } from "./middleware-8IfSkEEy.js";
10
+ const LINKS_REDIRECTION_MAP = {
11
+ "/auth/sign-in": {
12
+ "title": "Sign Up",
13
+ "location": "/auth/sign-up"
14
+ },
15
+ "/auth/sign-up": {
16
+ "title": "Sign In",
17
+ "location": "/auth/sign-in"
18
+ },
19
+ "/auth/logout-success": {
20
+ "title": "Sign In",
21
+ "location": "/auth/sign-in"
22
+ }
24
23
  };
25
- var AuthLayout = (t0) => {
26
- const $ = c(11);
27
- const { sidePanel: t1, children } = t0;
28
- const sidePanel = t1 === void 0 ? null : t1;
29
- const location = useLocation();
30
- const linkTitle = LINKS_REDIRECTION_MAP[location.pathname]?.title;
31
- const linkLocation = LINKS_REDIRECTION_MAP[location.pathname]?.location;
32
- let t2;
33
- if ($[0] !== linkLocation || $[1] !== linkTitle) {
34
- t2 = linkTitle && linkLocation ? /* @__PURE__ */ jsx(Link, {
35
- className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 absolute right-4 top-4 md:right-8 md:top-8",
36
- to: linkLocation,
37
- children: linkTitle
38
- }) : null;
39
- $[0] = linkLocation;
40
- $[1] = linkTitle;
41
- $[2] = t2;
42
- } else t2 = $[2];
43
- let t3;
44
- if ($[3] !== sidePanel) {
45
- t3 = /* @__PURE__ */ jsx("div", {
46
- className: "relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex",
47
- children: sidePanel
48
- });
49
- $[3] = sidePanel;
50
- $[4] = t3;
51
- } else t3 = $[4];
52
- let t4;
53
- if ($[5] !== children) {
54
- t4 = /* @__PURE__ */ jsx("div", {
55
- className: "mx-auto flex w-full flex-col justify-center gap-6 /*sm:w-[350px]*/",
56
- children
57
- });
58
- $[5] = children;
59
- $[6] = t4;
60
- } else t4 = $[6];
61
- let t5;
62
- if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
63
- t5 = /* @__PURE__ */ jsxs("div", {
64
- className: "container relative hidden h-dvh flex-col items-center justify-center md:grid md:w-full lg:max-w-none lg:grid-cols-2 lg:px-0",
65
- children: [
66
- t2,
67
- t3,
68
- t4
69
- ]
70
- });
71
- $[7] = t2;
72
- $[8] = t3;
73
- $[9] = t4;
74
- $[10] = t5;
75
- } else t5 = $[10];
76
- return t5;
24
+ const AuthLayout = (t0) => {
25
+ const $ = c(11);
26
+ const {
27
+ sidePanel: t1,
28
+ children
29
+ } = t0;
30
+ const sidePanel = t1 === void 0 ? null : t1;
31
+ const location = useLocation();
32
+ const linkTitle = LINKS_REDIRECTION_MAP[location.pathname]?.title;
33
+ const linkLocation = LINKS_REDIRECTION_MAP[location.pathname]?.location;
34
+ let t2;
35
+ if ($[0] !== linkLocation || $[1] !== linkTitle) {
36
+ t2 = linkTitle && linkLocation ? /* @__PURE__ */ jsx(Link, { className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 absolute right-4 top-4 md:right-8 md:top-8", to: linkLocation, children: linkTitle }) : null;
37
+ $[0] = linkLocation;
38
+ $[1] = linkTitle;
39
+ $[2] = t2;
40
+ } else {
41
+ t2 = $[2];
42
+ }
43
+ let t3;
44
+ if ($[3] !== sidePanel) {
45
+ t3 = /* @__PURE__ */ jsx("div", { className: "relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex", children: sidePanel });
46
+ $[3] = sidePanel;
47
+ $[4] = t3;
48
+ } else {
49
+ t3 = $[4];
50
+ }
51
+ let t4;
52
+ if ($[5] !== children) {
53
+ t4 = /* @__PURE__ */ jsx("div", { className: "mx-auto flex w-full flex-col justify-center gap-6 /*sm:w-[350px]*/", children });
54
+ $[5] = children;
55
+ $[6] = t4;
56
+ } else {
57
+ t4 = $[6];
58
+ }
59
+ let t5;
60
+ if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
61
+ t5 = /* @__PURE__ */ jsxs("div", { className: "container relative hidden h-dvh flex-col items-center justify-center md:grid md:w-full lg:max-w-none lg:grid-cols-2 lg:px-0", children: [
62
+ t2,
63
+ t3,
64
+ t4
65
+ ] });
66
+ $[7] = t2;
67
+ $[8] = t3;
68
+ $[9] = t4;
69
+ $[10] = t5;
70
+ } else {
71
+ t5 = $[10];
72
+ }
73
+ return t5;
77
74
  };
78
- //#endregion
79
- //#region src/components/AppleSignInButton/index.tsx
80
- var AppleSignInButton = (t0) => {
81
- const $ = c(7);
82
- const { onPress, className } = t0;
83
- let t1;
84
- if ($[0] !== className) {
85
- t1 = clsx("\n w-full\n bg-black text-white hover:bg-gray-800\n flex items-center justify-center\n px-6 py-2\n rounded-lg\n font-medium\n transition duration-150 ease-in-out\n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black\n ", className);
86
- $[0] = className;
87
- $[1] = t1;
88
- } else t1 = $[1];
89
- let t2;
90
- let t3;
91
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
92
- t2 = /* @__PURE__ */ jsx("svg", {
93
- className: "w-5 h-5 mr-3",
94
- xmlns: "http://www.w3.org/2000/svg",
95
- viewBox: "0 0 24 24",
96
- fill: "white",
97
- children: /* @__PURE__ */ jsx("path", { d: "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.539 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" })
98
- });
99
- t3 = /* @__PURE__ */ jsx("span", { children: "Continue with Apple" });
100
- $[2] = t2;
101
- $[3] = t3;
102
- } else {
103
- t2 = $[2];
104
- t3 = $[3];
105
- }
106
- let t4;
107
- if ($[4] !== onPress || $[5] !== t1) {
108
- t4 = /* @__PURE__ */ jsxs("button", {
109
- onClick: onPress,
110
- className: t1,
111
- children: [t2, t3]
112
- });
113
- $[4] = onPress;
114
- $[5] = t1;
115
- $[6] = t4;
116
- } else t4 = $[6];
117
- return t4;
75
+ const AppleSignInButton = (t0) => {
76
+ const $ = c(7);
77
+ const {
78
+ onPress,
79
+ className
80
+ } = t0;
81
+ let t1;
82
+ if ($[0] !== className) {
83
+ t1 = clsx("\n w-full\n bg-black text-white hover:bg-gray-800\n flex items-center justify-center\n px-6 py-2\n rounded-lg\n font-medium\n transition duration-150 ease-in-out\n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black\n ", className);
84
+ $[0] = className;
85
+ $[1] = t1;
86
+ } else {
87
+ t1 = $[1];
88
+ }
89
+ let t2;
90
+ let t3;
91
+ if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
92
+ t2 = /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 mr-3", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ jsx("path", { d: "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.539 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" }) });
93
+ t3 = /* @__PURE__ */ jsx("span", { children: "Continue with Apple" });
94
+ $[2] = t2;
95
+ $[3] = t3;
96
+ } else {
97
+ t2 = $[2];
98
+ t3 = $[3];
99
+ }
100
+ let t4;
101
+ if ($[4] !== onPress || $[5] !== t1) {
102
+ t4 = /* @__PURE__ */ jsxs("button", { onClick: onPress, className: t1, children: [
103
+ t2,
104
+ t3
105
+ ] });
106
+ $[4] = onPress;
107
+ $[5] = t1;
108
+ $[6] = t4;
109
+ } else {
110
+ t4 = $[6];
111
+ }
112
+ return t4;
118
113
  };
119
- //#endregion
120
- //#region src/components/EmailInput/index.tsx
121
- var EmailInput = (t0) => {
122
- const $ = c(12);
123
- const { id, className, placeholder } = t0;
124
- const { register, formState } = useFormContext();
125
- const error = formState.errors.email;
126
- let errorMessage;
127
- if (typeof error === "string") errorMessage = error;
128
- else if (error && typeof error.message === "string") errorMessage = error.message;
129
- let t1;
130
- if ($[0] !== register) {
131
- t1 = register("email");
132
- $[0] = register;
133
- $[1] = t1;
134
- } else t1 = $[1];
135
- let t2;
136
- if ($[2] !== className || $[3] !== id || $[4] !== placeholder || $[5] !== t1) {
137
- t2 = /* @__PURE__ */ jsx("input", {
138
- id,
139
- type: "email",
140
- required: true,
141
- autoComplete: "email",
142
- className,
143
- placeholder,
144
- ...t1
145
- });
146
- $[2] = className;
147
- $[3] = id;
148
- $[4] = placeholder;
149
- $[5] = t1;
150
- $[6] = t2;
151
- } else t2 = $[6];
152
- let t3;
153
- if ($[7] !== errorMessage) {
154
- t3 = errorMessage ? /* @__PURE__ */ jsx("p", {
155
- className: "mt-1 -mb-2 text-sm/6 text-red-500",
156
- children: errorMessage
157
- }) : null;
158
- $[7] = errorMessage;
159
- $[8] = t3;
160
- } else t3 = $[8];
161
- let t4;
162
- if ($[9] !== t2 || $[10] !== t3) {
163
- t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t3] });
164
- $[9] = t2;
165
- $[10] = t3;
166
- $[11] = t4;
167
- } else t4 = $[11];
168
- return t4;
114
+ const EmailInput = (t0) => {
115
+ const $ = c(12);
116
+ const {
117
+ id,
118
+ className,
119
+ placeholder
120
+ } = t0;
121
+ const {
122
+ register,
123
+ formState
124
+ } = useFormContext();
125
+ const error = formState.errors.email;
126
+ let errorMessage;
127
+ if (typeof error === "string") {
128
+ errorMessage = error;
129
+ } else {
130
+ if (error && typeof error.message === "string") {
131
+ errorMessage = error.message;
132
+ }
133
+ }
134
+ let t1;
135
+ if ($[0] !== register) {
136
+ t1 = register("email");
137
+ $[0] = register;
138
+ $[1] = t1;
139
+ } else {
140
+ t1 = $[1];
141
+ }
142
+ let t2;
143
+ if ($[2] !== className || $[3] !== id || $[4] !== placeholder || $[5] !== t1) {
144
+ t2 = /* @__PURE__ */ jsx("input", { id, type: "email", required: true, autoComplete: "email", className, placeholder, ...t1 });
145
+ $[2] = className;
146
+ $[3] = id;
147
+ $[4] = placeholder;
148
+ $[5] = t1;
149
+ $[6] = t2;
150
+ } else {
151
+ t2 = $[6];
152
+ }
153
+ let t3;
154
+ if ($[7] !== errorMessage) {
155
+ t3 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
156
+ $[7] = errorMessage;
157
+ $[8] = t3;
158
+ } else {
159
+ t3 = $[8];
160
+ }
161
+ let t4;
162
+ if ($[9] !== t2 || $[10] !== t3) {
163
+ t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
164
+ t2,
165
+ t3
166
+ ] });
167
+ $[9] = t2;
168
+ $[10] = t3;
169
+ $[11] = t4;
170
+ } else {
171
+ t4 = $[11];
172
+ }
173
+ return t4;
169
174
  };
170
- //#endregion
171
- //#region src/utils/sanitizeNextPath.ts
172
- var hasUnsafeNextPathChars = (value) => {
173
- for (let i = 0; i < value.length; i++) {
174
- const code = value.charCodeAt(i);
175
- if (code === 92 || code <= 31 || code === 127) return true;
176
- }
177
- return false;
175
+ const hasUnsafeNextPathChars = (value) => {
176
+ for (let i = 0; i < value.length; i++) {
177
+ const code = value.charCodeAt(i);
178
+ if (code === 92 || code <= 31 || code === 127) return true;
179
+ }
180
+ return false;
178
181
  };
179
- var sanitizeNextPath = (raw) => {
180
- if (!raw) return null;
181
- const nextPath = raw.trim();
182
- if (!nextPath) return null;
183
- if (!nextPath.startsWith("/") || nextPath.startsWith("//")) return null;
184
- if (hasUnsafeNextPathChars(nextPath)) return null;
185
- try {
186
- const base = new URL("http://localhost");
187
- const url = new URL(nextPath, base);
188
- if (url.origin !== base.origin) return null;
189
- return `${url.pathname}${url.search}${url.hash}`;
190
- } catch {
191
- return null;
192
- }
182
+ const sanitizeNextPath = (raw) => {
183
+ if (!raw) return null;
184
+ const nextPath = raw.trim();
185
+ if (!nextPath) return null;
186
+ if (!nextPath.startsWith("/") || nextPath.startsWith("//")) {
187
+ return null;
188
+ }
189
+ if (hasUnsafeNextPathChars(nextPath)) {
190
+ return null;
191
+ }
192
+ try {
193
+ const base = new URL("http://localhost");
194
+ const url = new URL(nextPath, base);
195
+ if (url.origin !== base.origin) {
196
+ return null;
197
+ }
198
+ return `${url.pathname}${url.search}${url.hash}`;
199
+ } catch {
200
+ return null;
201
+ }
193
202
  };
194
- //#endregion
195
- //#region src/components/SignInForm/index.tsx
196
- var SignInForm = ({ children, className }) => {
197
- const navigate = useNavigate();
198
- const [searchParams] = useSearchParams();
199
- const methods = useForm({
200
- defaultValues: {
201
- email: "",
202
- password: "",
203
- rememberMe: true
204
- },
205
- navigationGuard: false,
206
- resolver: zodResolver(requestSchema)
207
- });
208
- const onSubmit = async (data) => {
209
- methods.clearErrors("root");
210
- try {
211
- const res = await fetch("/api/rb/auth/sign-in", {
212
- method: "POST",
213
- headers: { "Content-Type": "application/json" },
214
- body: JSON.stringify(data),
215
- credentials: "include"
216
- });
217
- const json = await res.json().catch(() => null);
218
- if (!res.ok || !json?.success) {
219
- const message = json?.error === "invalid_credentials" ? "Invalid email or password." : "Sign-in failed. Please try again.";
220
- methods.setError("root", {
221
- type: "server",
222
- message
223
- });
224
- return;
225
- }
226
- navigate(sanitizeNextPath(searchParams.get("next")) ?? "/", { replace: true });
227
- } catch (err) {
228
- methods.setError("root", {
229
- type: "server",
230
- message: "Network error. Please try again."
231
- });
232
- }
233
- };
234
- return /* @__PURE__ */ jsx(FormProvider, {
235
- ...methods,
236
- children: /* @__PURE__ */ jsxs("form", {
237
- method: "post",
238
- noValidate: true,
239
- className,
240
- onSubmit: methods.handleSubmit(onSubmit),
241
- children: [children, methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", {
242
- className: "mt-2 text-sm text-red-600",
243
- role: "alert",
244
- children: methods.formState.errors.root.message
245
- })]
246
- })
247
- });
203
+ const SignInForm = ({
204
+ children,
205
+ className
206
+ }) => {
207
+ const navigate = useNavigate();
208
+ const [searchParams] = useSearchParams();
209
+ const methods = useForm({
210
+ defaultValues: {
211
+ email: "",
212
+ password: "",
213
+ rememberMe: true
214
+ },
215
+ navigationGuard: false,
216
+ resolver: zodResolver(requestSchema)
217
+ });
218
+ const onSubmit = async (data) => {
219
+ methods.clearErrors("root");
220
+ try {
221
+ const res = await fetch("/api/rb/auth/sign-in", {
222
+ method: "POST",
223
+ headers: {
224
+ "Content-Type": "application/json"
225
+ },
226
+ body: JSON.stringify(data),
227
+ credentials: "include"
228
+ });
229
+ const json = await res.json().catch(() => null);
230
+ if (!res.ok || !json?.success) {
231
+ const message = json?.error === "invalid_credentials" ? "Invalid email or password." : "Sign-in failed. Please try again.";
232
+ methods.setError("root", {
233
+ type: "server",
234
+ message
235
+ });
236
+ return;
237
+ }
238
+ const nextPath = sanitizeNextPath(searchParams.get("next")) ?? "/";
239
+ navigate(nextPath, {
240
+ replace: true
241
+ });
242
+ } catch (err) {
243
+ methods.setError("root", {
244
+ type: "server",
245
+ message: "Network error. Please try again."
246
+ });
247
+ }
248
+ };
249
+ return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
250
+ children,
251
+ methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-red-600", role: "alert", children: methods.formState.errors.root.message })
252
+ ] }) });
248
253
  };
249
- //#endregion
250
- //#region src/components/SignUpForm/index.tsx
251
- var SignUpForm = ({ children, className, otpNextPath }) => {
252
- const navigate = useNavigate();
253
- const [serverMessage, setServerMessage] = useState(null);
254
- const methods = useForm({
255
- defaultValues: {
256
- email: "",
257
- password: "",
258
- rememberMe: true
259
- },
260
- navigationGuard: false,
261
- resolver: zodResolver(requestSchema$1)
262
- });
263
- const onSubmit = async (data) => {
264
- setServerMessage(null);
265
- methods.clearErrors("root");
266
- try {
267
- const res = await fetch("/api/rb/auth/sign-up", {
268
- method: "POST",
269
- headers: { "Content-Type": "application/json" },
270
- body: JSON.stringify(data),
271
- credentials: "include"
272
- });
273
- const json = await res.json();
274
- if (!res.ok) {
275
- const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
276
- methods.setError("root", {
277
- type: "server",
278
- message
279
- });
280
- return;
281
- }
282
- if (!json.success) {
283
- methods.setError("root", {
284
- type: "server",
285
- message: "Sign-up failed. Please try again."
286
- });
287
- return;
288
- }
289
- const search = new URLSearchParams({ email: data.email });
290
- if (otpNextPath) search.set("next", otpNextPath);
291
- navigate(`/auth/sign-up-otp?${search.toString()}`);
292
- setServerMessage("Account created. Check your inbox to verify your email.");
293
- } catch (err) {
294
- methods.setError("root", {
295
- type: "server",
296
- message: "Network error. Please try again."
297
- });
298
- }
299
- };
300
- return /* @__PURE__ */ jsx(FormProvider, {
301
- ...methods,
302
- children: /* @__PURE__ */ jsxs("form", {
303
- method: "post",
304
- noValidate: true,
305
- className,
306
- onSubmit: methods.handleSubmit(onSubmit),
307
- children: [
308
- children,
309
- methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", {
310
- className: "mt-2 text-sm text-red-600",
311
- role: "alert",
312
- children: methods.formState.errors.root.message
313
- }),
314
- serverMessage && /* @__PURE__ */ jsx("p", {
315
- className: "mt-2 text-sm text-green-700",
316
- role: "status",
317
- children: serverMessage
318
- })
319
- ]
320
- })
321
- });
254
+ const SignUpForm = ({
255
+ children,
256
+ className,
257
+ otpNextPath
258
+ }) => {
259
+ const navigate = useNavigate();
260
+ const [serverMessage, setServerMessage] = useState(null);
261
+ const methods = useForm({
262
+ defaultValues: {
263
+ email: "",
264
+ password: "",
265
+ rememberMe: true
266
+ },
267
+ navigationGuard: false,
268
+ resolver: zodResolver(requestSchema$1)
269
+ });
270
+ const onSubmit = async (data) => {
271
+ setServerMessage(null);
272
+ methods.clearErrors("root");
273
+ try {
274
+ const res = await fetch("/api/rb/auth/sign-up", {
275
+ method: "POST",
276
+ headers: {
277
+ "Content-Type": "application/json"
278
+ },
279
+ body: JSON.stringify(data),
280
+ credentials: "include"
281
+ });
282
+ const json = await res.json();
283
+ if (!res.ok) {
284
+ const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
285
+ methods.setError("root", {
286
+ type: "server",
287
+ message
288
+ });
289
+ return;
290
+ }
291
+ if (!json.success) {
292
+ methods.setError("root", {
293
+ type: "server",
294
+ message: "Sign-up failed. Please try again."
295
+ });
296
+ return;
297
+ }
298
+ const search = new URLSearchParams({
299
+ email: data.email
300
+ });
301
+ if (otpNextPath) {
302
+ search.set("next", otpNextPath);
303
+ }
304
+ navigate(`/auth/sign-up-otp?${search.toString()}`);
305
+ setServerMessage("Account created. Check your inbox to verify your email.");
306
+ } catch (err) {
307
+ methods.setError("root", {
308
+ type: "server",
309
+ message: "Network error. Please try again."
310
+ });
311
+ }
312
+ };
313
+ return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
314
+ children,
315
+ methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-red-600", role: "alert", children: methods.formState.errors.root.message }),
316
+ serverMessage && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-green-700", role: "status", children: serverMessage })
317
+ ] }) });
322
318
  };
323
- //#endregion
324
- //#region src/components/RememberMeCheckbox/index.tsx
325
- var RememberMeCheckbox = (t0) => {
326
- const $ = c(10);
327
- const { label, as: t1 } = t0;
328
- const Component = t1 === void 0 ? "input" : t1;
329
- const { register } = useFormContext();
330
- let t2;
331
- if ($[0] !== register) {
332
- t2 = register("rememberMe");
333
- $[0] = register;
334
- $[1] = t2;
335
- } else t2 = $[1];
336
- let t3;
337
- if ($[2] !== Component || $[3] !== t2) {
338
- t3 = /* @__PURE__ */ jsx(Component, {
339
- id: "rememberMe",
340
- ...t2
341
- });
342
- $[2] = Component;
343
- $[3] = t2;
344
- $[4] = t3;
345
- } else t3 = $[4];
346
- let t4;
347
- if ($[5] !== label) {
348
- t4 = /* @__PURE__ */ jsx("label", {
349
- htmlFor: "rememberMe",
350
- className: "pl-2 block text-sm/6 text-gray-900",
351
- children: label
352
- });
353
- $[5] = label;
354
- $[6] = t4;
355
- } else t4 = $[6];
356
- let t5;
357
- if ($[7] !== t3 || $[8] !== t4) {
358
- t5 = /* @__PURE__ */ jsxs(Fragment, { children: [t3, t4] });
359
- $[7] = t3;
360
- $[8] = t4;
361
- $[9] = t5;
362
- } else t5 = $[9];
363
- return t5;
319
+ const RememberMeCheckbox = (t0) => {
320
+ const $ = c(10);
321
+ const {
322
+ label,
323
+ as: t1
324
+ } = t0;
325
+ const Component = t1 === void 0 ? "input" : t1;
326
+ const {
327
+ register
328
+ } = useFormContext();
329
+ let t2;
330
+ if ($[0] !== register) {
331
+ t2 = register("rememberMe");
332
+ $[0] = register;
333
+ $[1] = t2;
334
+ } else {
335
+ t2 = $[1];
336
+ }
337
+ let t3;
338
+ if ($[2] !== Component || $[3] !== t2) {
339
+ t3 = /* @__PURE__ */ jsx(Component, { id: "rememberMe", ...t2 });
340
+ $[2] = Component;
341
+ $[3] = t2;
342
+ $[4] = t3;
343
+ } else {
344
+ t3 = $[4];
345
+ }
346
+ let t4;
347
+ if ($[5] !== label) {
348
+ t4 = /* @__PURE__ */ jsx("label", { htmlFor: "rememberMe", className: "pl-2 block text-sm/6 text-gray-900", children: label });
349
+ $[5] = label;
350
+ $[6] = t4;
351
+ } else {
352
+ t4 = $[6];
353
+ }
354
+ let t5;
355
+ if ($[7] !== t3 || $[8] !== t4) {
356
+ t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
357
+ t3,
358
+ t4
359
+ ] });
360
+ $[7] = t3;
361
+ $[8] = t4;
362
+ $[9] = t5;
363
+ } else {
364
+ t5 = $[9];
365
+ }
366
+ return t5;
364
367
  };
365
- //#endregion
366
- //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
367
- /**
368
- * @license lucide-react v1.7.0 - ISC
369
- *
370
- * This source code is licensed under the ISC license.
371
- * See the LICENSE file in the root directory of this source tree.
372
- */
373
- var mergeClasses = (...classes) => classes.filter((className, index, array) => {
374
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
368
+ const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
369
+ const toCamelCase = (string) => string.replace(
370
+ /^([A-Z])|[\s-_]+(\w)/g,
371
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
372
+ );
373
+ const toPascalCase = (string) => {
374
+ const camelCase = toCamelCase(string);
375
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
376
+ };
377
+ const mergeClasses = (...classes) => classes.filter((className, index, array) => {
378
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
375
379
  }).join(" ").trim();
376
- //#endregion
377
- //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.js
378
- /**
379
- * @license lucide-react v1.7.0 - ISC
380
- *
381
- * This source code is licensed under the ISC license.
382
- * See the LICENSE file in the root directory of this source tree.
383
- */
384
- var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
385
- //#endregion
386
- //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.js
387
- /**
388
- * @license lucide-react v1.7.0 - ISC
389
- *
390
- * This source code is licensed under the ISC license.
391
- * See the LICENSE file in the root directory of this source tree.
392
- */
393
- var toCamelCase = (string) => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
394
- //#endregion
395
- //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.js
396
- /**
397
- * @license lucide-react v1.7.0 - ISC
398
- *
399
- * This source code is licensed under the ISC license.
400
- * See the LICENSE file in the root directory of this source tree.
401
- */
402
- var toPascalCase = (string) => {
403
- const camelCase = toCamelCase(string);
404
- return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
380
+ const hasA11yProp = (props) => {
381
+ for (const prop in props) {
382
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
383
+ return true;
384
+ }
385
+ }
405
386
  };
406
- //#endregion
407
- //#region ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
408
- /**
409
- * @license lucide-react v1.7.0 - ISC
410
- *
411
- * This source code is licensed under the ISC license.
412
- * See the LICENSE file in the root directory of this source tree.
413
- */
414
387
  var defaultAttributes = {
415
- xmlns: "http://www.w3.org/2000/svg",
416
- width: 24,
417
- height: 24,
418
- viewBox: "0 0 24 24",
419
- fill: "none",
420
- stroke: "currentColor",
421
- strokeWidth: 2,
422
- strokeLinecap: "round",
423
- strokeLinejoin: "round"
424
- };
425
- //#endregion
426
- //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.js
427
- /**
428
- * @license lucide-react v1.7.0 - ISC
429
- *
430
- * This source code is licensed under the ISC license.
431
- * See the LICENSE file in the root directory of this source tree.
432
- */
433
- var hasA11yProp = (props) => {
434
- for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
435
- return false;
388
+ xmlns: "http://www.w3.org/2000/svg",
389
+ width: 24,
390
+ height: 24,
391
+ viewBox: "0 0 24 24",
392
+ fill: "none",
393
+ stroke: "currentColor",
394
+ strokeWidth: 2,
395
+ strokeLinecap: "round",
396
+ strokeLinejoin: "round"
436
397
  };
437
- //#endregion
438
- //#region ../../node_modules/lucide-react/dist/esm/context.js
439
- /**
440
- * @license lucide-react v1.7.0 - ISC
441
- *
442
- * This source code is licensed under the ISC license.
443
- * See the LICENSE file in the root directory of this source tree.
444
- */
445
- var LucideContext = createContext({});
446
- var useLucideContext = () => useContext(LucideContext);
447
- //#endregion
448
- //#region ../../node_modules/lucide-react/dist/esm/Icon.js
449
- /**
450
- * @license lucide-react v1.7.0 - ISC
451
- *
452
- * This source code is licensed under the ISC license.
453
- * See the LICENSE file in the root directory of this source tree.
454
- */
455
- var Icon = forwardRef(({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => {
456
- const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, color: contextColor = "currentColor", className: contextClass = "" } = useLucideContext() ?? {};
457
- const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
458
- return createElement("svg", {
459
- ref,
460
- ...defaultAttributes,
461
- width: size ?? contextSize ?? defaultAttributes.width,
462
- height: size ?? contextSize ?? defaultAttributes.height,
463
- stroke: color ?? contextColor,
464
- strokeWidth: calculatedStrokeWidth,
465
- className: mergeClasses("lucide", contextClass, className),
466
- ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
467
- ...rest
468
- }, [...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
469
- });
470
- //#endregion
471
- //#region ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
472
- /**
473
- * @license lucide-react v1.7.0 - ISC
474
- *
475
- * This source code is licensed under the ISC license.
476
- * See the LICENSE file in the root directory of this source tree.
477
- */
478
- var createLucideIcon = (iconName, iconNode) => {
479
- const Component = forwardRef(({ className, ...props }, ref) => createElement(Icon, {
480
- ref,
481
- iconNode,
482
- className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
483
- ...props
484
- }));
485
- Component.displayName = toPascalCase(iconName);
486
- return Component;
398
+ const Icon = forwardRef(
399
+ ({
400
+ color = "currentColor",
401
+ size = 24,
402
+ strokeWidth = 2,
403
+ absoluteStrokeWidth,
404
+ className = "",
405
+ children,
406
+ iconNode,
407
+ ...rest
408
+ }, ref) => createElement(
409
+ "svg",
410
+ {
411
+ ref,
412
+ ...defaultAttributes,
413
+ width: size,
414
+ height: size,
415
+ stroke: color,
416
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
417
+ className: mergeClasses("lucide", className),
418
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
419
+ ...rest
420
+ },
421
+ [
422
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
423
+ ...Array.isArray(children) ? children : [children]
424
+ ]
425
+ )
426
+ );
427
+ const createLucideIcon = (iconName, iconNode) => {
428
+ const Component = forwardRef(
429
+ ({ className, ...props }, ref) => createElement(Icon, {
430
+ ref,
431
+ iconNode,
432
+ className: mergeClasses(
433
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
434
+ `lucide-${iconName}`,
435
+ className
436
+ ),
437
+ ...props
438
+ })
439
+ );
440
+ Component.displayName = toPascalCase(iconName);
441
+ return Component;
487
442
  };
488
- var EyeOff = createLucideIcon("eye-off", [
489
- ["path", {
490
- d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
491
- key: "ct8e1f"
492
- }],
493
- ["path", {
494
- d: "M14.084 14.158a3 3 0 0 1-4.242-4.242",
495
- key: "151rxh"
496
- }],
497
- ["path", {
498
- d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
499
- key: "13bj9a"
500
- }],
501
- ["path", {
502
- d: "m2 2 20 20",
503
- key: "1ooewy"
504
- }]
505
- ]);
506
- var Eye = createLucideIcon("eye", [["path", {
507
- d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
508
- key: "1nclc0"
509
- }], ["circle", {
510
- cx: "12",
511
- cy: "12",
512
- r: "3",
513
- key: "1v7zrd"
514
- }]]);
515
- //#endregion
516
- //#region src/components/PasswordInput/index.tsx
517
- var PasswordInput = (t0) => {
518
- const $ = c(24);
519
- const { id, name: t1, className, placeholder, autoComplete: t2 } = t0;
520
- const name = t1 === void 0 ? "password" : t1;
521
- const autoComplete = t2 === void 0 ? "current-password" : t2;
522
- const [showPassword, setShowPassword] = useState(false);
523
- const { register, formState } = useFormContext();
524
- const fieldError = formState.errors[name];
525
- const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
526
- const inputClassName = className ? `${className} pr-11` : "pr-11";
527
- const t3 = showPassword ? "text" : "password";
528
- const t4 = name;
529
- let t5;
530
- if ($[0] !== register || $[1] !== t4) {
531
- t5 = register(t4);
532
- $[0] = register;
533
- $[1] = t4;
534
- $[2] = t5;
535
- } else t5 = $[2];
536
- let t6;
537
- if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
538
- t6 = /* @__PURE__ */ jsx("input", {
539
- id,
540
- type: t3,
541
- autoComplete,
542
- className: inputClassName,
543
- placeholder,
544
- ...t5
545
- });
546
- $[3] = autoComplete;
547
- $[4] = id;
548
- $[5] = inputClassName;
549
- $[6] = placeholder;
550
- $[7] = t3;
551
- $[8] = t5;
552
- $[9] = t6;
553
- } else t6 = $[9];
554
- let t7;
555
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
556
- t7 = () => setShowPassword(_temp);
557
- $[10] = t7;
558
- } else t7 = $[10];
559
- const t8 = showPassword ? "Hide characters" : "Show characters";
560
- let t9;
561
- if ($[11] !== showPassword) {
562
- t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, {
563
- className: "h-5 w-5",
564
- "aria-hidden": true
565
- }) : /* @__PURE__ */ jsx(Eye, {
566
- className: "h-5 w-5",
567
- "aria-hidden": true
568
- });
569
- $[11] = showPassword;
570
- $[12] = t9;
571
- } else t9 = $[12];
572
- let t10;
573
- if ($[13] !== t8 || $[14] !== t9) {
574
- t10 = /* @__PURE__ */ jsx("button", {
575
- type: "button",
576
- className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500",
577
- onClick: t7,
578
- "aria-label": t8,
579
- children: t9
580
- });
581
- $[13] = t8;
582
- $[14] = t9;
583
- $[15] = t10;
584
- } else t10 = $[15];
585
- let t11;
586
- if ($[16] !== t10 || $[17] !== t6) {
587
- t11 = /* @__PURE__ */ jsxs("div", {
588
- className: "relative",
589
- children: [t6, t10]
590
- });
591
- $[16] = t10;
592
- $[17] = t6;
593
- $[18] = t11;
594
- } else t11 = $[18];
595
- let t12;
596
- if ($[19] !== errorMessage) {
597
- t12 = errorMessage ? /* @__PURE__ */ jsx("p", {
598
- className: "mt-1 -mb-2 text-sm/6 text-red-500",
599
- children: errorMessage
600
- }) : null;
601
- $[19] = errorMessage;
602
- $[20] = t12;
603
- } else t12 = $[20];
604
- let t13;
605
- if ($[21] !== t11 || $[22] !== t12) {
606
- t13 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t12] });
607
- $[21] = t11;
608
- $[22] = t12;
609
- $[23] = t13;
610
- } else t13 = $[23];
611
- return t13;
443
+ const __iconNode$1 = [
444
+ [
445
+ "path",
446
+ {
447
+ d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
448
+ key: "ct8e1f"
449
+ }
450
+ ],
451
+ ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
452
+ [
453
+ "path",
454
+ {
455
+ d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
456
+ key: "13bj9a"
457
+ }
458
+ ],
459
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }]
460
+ ];
461
+ const EyeOff = createLucideIcon("eye-off", __iconNode$1);
462
+ const __iconNode = [
463
+ [
464
+ "path",
465
+ {
466
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
467
+ key: "1nclc0"
468
+ }
469
+ ],
470
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
471
+ ];
472
+ const Eye = createLucideIcon("eye", __iconNode);
473
+ const PasswordInput = (t0) => {
474
+ const $ = c(24);
475
+ const {
476
+ id,
477
+ name: t1,
478
+ className,
479
+ placeholder,
480
+ autoComplete: t2
481
+ } = t0;
482
+ const name = t1 === void 0 ? "password" : t1;
483
+ const autoComplete = t2 === void 0 ? "current-password" : t2;
484
+ const [showPassword, setShowPassword] = useState(false);
485
+ const {
486
+ register,
487
+ formState
488
+ } = useFormContext();
489
+ const fieldError = formState.errors[name];
490
+ const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
491
+ const inputClassName = className ? `${className} pr-11` : "pr-11";
492
+ const t3 = showPassword ? "text" : "password";
493
+ const t4 = name;
494
+ let t5;
495
+ if ($[0] !== register || $[1] !== t4) {
496
+ t5 = register(t4);
497
+ $[0] = register;
498
+ $[1] = t4;
499
+ $[2] = t5;
500
+ } else {
501
+ t5 = $[2];
502
+ }
503
+ let t6;
504
+ if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
505
+ t6 = /* @__PURE__ */ jsx("input", { id, type: t3, autoComplete, className: inputClassName, placeholder, ...t5 });
506
+ $[3] = autoComplete;
507
+ $[4] = id;
508
+ $[5] = inputClassName;
509
+ $[6] = placeholder;
510
+ $[7] = t3;
511
+ $[8] = t5;
512
+ $[9] = t6;
513
+ } else {
514
+ t6 = $[9];
515
+ }
516
+ let t7;
517
+ if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
518
+ t7 = () => setShowPassword(_temp);
519
+ $[10] = t7;
520
+ } else {
521
+ t7 = $[10];
522
+ }
523
+ const t8 = showPassword ? "Hide characters" : "Show characters";
524
+ let t9;
525
+ if ($[11] !== showPassword) {
526
+ t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, { className: "h-5 w-5", "aria-hidden": true }) : /* @__PURE__ */ jsx(Eye, { className: "h-5 w-5", "aria-hidden": true });
527
+ $[11] = showPassword;
528
+ $[12] = t9;
529
+ } else {
530
+ t9 = $[12];
531
+ }
532
+ let t10;
533
+ if ($[13] !== t8 || $[14] !== t9) {
534
+ t10 = /* @__PURE__ */ jsx("button", { type: "button", className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500", onClick: t7, "aria-label": t8, children: t9 });
535
+ $[13] = t8;
536
+ $[14] = t9;
537
+ $[15] = t10;
538
+ } else {
539
+ t10 = $[15];
540
+ }
541
+ let t11;
542
+ if ($[16] !== t10 || $[17] !== t6) {
543
+ t11 = /* @__PURE__ */ jsxs("div", { className: "relative", children: [
544
+ t6,
545
+ t10
546
+ ] });
547
+ $[16] = t10;
548
+ $[17] = t6;
549
+ $[18] = t11;
550
+ } else {
551
+ t11 = $[18];
552
+ }
553
+ let t12;
554
+ if ($[19] !== errorMessage) {
555
+ t12 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
556
+ $[19] = errorMessage;
557
+ $[20] = t12;
558
+ } else {
559
+ t12 = $[20];
560
+ }
561
+ let t13;
562
+ if ($[21] !== t11 || $[22] !== t12) {
563
+ t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
564
+ t11,
565
+ t12
566
+ ] });
567
+ $[21] = t11;
568
+ $[22] = t12;
569
+ $[23] = t13;
570
+ } else {
571
+ t13 = $[23];
572
+ }
573
+ return t13;
612
574
  };
613
575
  function _temp(prev) {
614
- return !prev;
576
+ return !prev;
615
577
  }
616
- //#endregion
617
- //#region src/components/ResendCodeButton/index.tsx
618
- var useResendCountdown = (t0) => {
619
- const $ = c(14);
620
- const seconds = t0 === void 0 ? 60 : t0;
621
- const [remaining, setRemaining] = useState(seconds);
622
- const [isCountingDown, setIsCountingDown] = useState(true);
623
- let t1;
624
- let t2;
625
- if ($[0] !== isCountingDown || $[1] !== seconds) {
626
- t1 = () => {
627
- if (!isCountingDown) return;
628
- const timer = setInterval(() => {
629
- setRemaining((prev) => {
630
- if (prev <= 1) {
631
- setIsCountingDown(false);
632
- return seconds;
633
- }
634
- return prev - 1;
635
- });
636
- }, 1e3);
637
- return () => clearInterval(timer);
638
- };
639
- t2 = [isCountingDown, seconds];
640
- $[0] = isCountingDown;
641
- $[1] = seconds;
642
- $[2] = t1;
643
- $[3] = t2;
644
- } else {
645
- t1 = $[2];
646
- t2 = $[3];
647
- }
648
- useEffect(t1, t2);
649
- let t3;
650
- if ($[4] !== seconds) {
651
- t3 = (nextSeconds) => {
652
- setRemaining(typeof nextSeconds === "number" ? nextSeconds : seconds);
653
- setIsCountingDown(true);
654
- };
655
- $[4] = seconds;
656
- $[5] = t3;
657
- } else t3 = $[5];
658
- const restart = t3;
659
- const minutes = Math.floor(remaining / 60);
660
- const secs = remaining % 60;
661
- let t4;
662
- if ($[6] !== secs) {
663
- t4 = secs.toString().padStart(2, "0");
664
- $[6] = secs;
665
- $[7] = t4;
666
- } else t4 = $[7];
667
- const formatted = `${minutes}:${t4}`;
668
- const canResend = !isCountingDown;
669
- let t5;
670
- if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
671
- t5 = {
672
- remaining,
673
- formatted,
674
- isCountingDown,
675
- canResend,
676
- restart
677
- };
678
- $[8] = canResend;
679
- $[9] = formatted;
680
- $[10] = isCountingDown;
681
- $[11] = remaining;
682
- $[12] = restart;
683
- $[13] = t5;
684
- } else t5 = $[13];
685
- return t5;
578
+ const useResendCountdown = (t0) => {
579
+ const $ = c(14);
580
+ const seconds = t0 === void 0 ? 60 : t0;
581
+ const [remaining, setRemaining] = useState(seconds);
582
+ const [isCountingDown, setIsCountingDown] = useState(true);
583
+ let t1;
584
+ let t2;
585
+ if ($[0] !== isCountingDown || $[1] !== seconds) {
586
+ t1 = () => {
587
+ if (!isCountingDown) {
588
+ return;
589
+ }
590
+ const timer = setInterval(() => {
591
+ setRemaining((prev) => {
592
+ if (prev <= 1) {
593
+ setIsCountingDown(false);
594
+ return seconds;
595
+ }
596
+ return prev - 1;
597
+ });
598
+ }, 1e3);
599
+ return () => clearInterval(timer);
600
+ };
601
+ t2 = [isCountingDown, seconds];
602
+ $[0] = isCountingDown;
603
+ $[1] = seconds;
604
+ $[2] = t1;
605
+ $[3] = t2;
606
+ } else {
607
+ t1 = $[2];
608
+ t2 = $[3];
609
+ }
610
+ useEffect(t1, t2);
611
+ let t3;
612
+ if ($[4] !== seconds) {
613
+ t3 = (nextSeconds) => {
614
+ const value = typeof nextSeconds === "number" ? nextSeconds : seconds;
615
+ setRemaining(value);
616
+ setIsCountingDown(true);
617
+ };
618
+ $[4] = seconds;
619
+ $[5] = t3;
620
+ } else {
621
+ t3 = $[5];
622
+ }
623
+ const restart = t3;
624
+ const minutes = Math.floor(remaining / 60);
625
+ const secs = remaining % 60;
626
+ let t4;
627
+ if ($[6] !== secs) {
628
+ t4 = secs.toString().padStart(2, "0");
629
+ $[6] = secs;
630
+ $[7] = t4;
631
+ } else {
632
+ t4 = $[7];
633
+ }
634
+ const formatted = `${minutes}:${t4}`;
635
+ const canResend = !isCountingDown;
636
+ let t5;
637
+ if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
638
+ t5 = {
639
+ remaining,
640
+ formatted,
641
+ isCountingDown,
642
+ canResend,
643
+ restart
644
+ };
645
+ $[8] = canResend;
646
+ $[9] = formatted;
647
+ $[10] = isCountingDown;
648
+ $[11] = remaining;
649
+ $[12] = restart;
650
+ $[13] = t5;
651
+ } else {
652
+ t5 = $[13];
653
+ }
654
+ return t5;
655
+ };
656
+ const ResendCodeButton = ({
657
+ seconds = 60,
658
+ onResend,
659
+ className,
660
+ disabled
661
+ }) => {
662
+ const [isSending, setIsSending] = useState(false);
663
+ const {
664
+ formatted,
665
+ isCountingDown,
666
+ restart,
667
+ canResend
668
+ } = useResendCountdown(seconds);
669
+ const handleClick = async () => {
670
+ if (!canResend || isSending || disabled) return;
671
+ try {
672
+ setIsSending(true);
673
+ if (onResend) {
674
+ await onResend();
675
+ }
676
+ } finally {
677
+ restart();
678
+ setIsSending(false);
679
+ }
680
+ };
681
+ const isDisabled = disabled || isCountingDown || isSending;
682
+ const showCountdown = isDisabled && (isCountingDown || isSending);
683
+ return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
684
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, disabled: isDisabled, "aria-label": "Resend code", className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className), children: "Resend code" }),
685
+ showCountdown ? /* @__PURE__ */ jsxs("span", { "data-testid": "resend-countdown", className: "text-sm text-gray-500", "aria-live": "polite", children: [
686
+ "(",
687
+ formatted,
688
+ ")"
689
+ ] }) : null
690
+ ] });
686
691
  };
687
- var ResendCodeButton = ({ seconds = 60, onResend, className, disabled }) => {
688
- const [isSending, setIsSending] = useState(false);
689
- const { formatted, isCountingDown, restart, canResend } = useResendCountdown(seconds);
690
- const handleClick = async () => {
691
- if (!canResend || isSending || disabled) return;
692
- try {
693
- setIsSending(true);
694
- if (onResend) await onResend();
695
- } finally {
696
- restart();
697
- setIsSending(false);
698
- }
699
- };
700
- const isDisabled = disabled || isCountingDown || isSending;
701
- const showCountdown = isDisabled && (isCountingDown || isSending);
702
- return /* @__PURE__ */ jsxs("span", {
703
- className: "inline-flex items-center gap-2",
704
- children: [/* @__PURE__ */ jsx("button", {
705
- type: "button",
706
- onClick: handleClick,
707
- disabled: isDisabled,
708
- "aria-label": "Resend code",
709
- className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className),
710
- children: "Resend code"
711
- }), showCountdown ? /* @__PURE__ */ jsxs("span", {
712
- "data-testid": "resend-countdown",
713
- className: "text-sm text-gray-500",
714
- "aria-live": "polite",
715
- children: [
716
- "(",
717
- formatted,
718
- ")"
719
- ]
720
- }) : null]
721
- });
692
+ export {
693
+ AppleSignInButton,
694
+ AuthLayout,
695
+ EmailInput,
696
+ PasswordInput,
697
+ RememberMeCheckbox,
698
+ ResendCodeButton,
699
+ SignInForm,
700
+ SignUpForm,
701
+ r as redirectAuthMiddleware,
702
+ a as requireSession,
703
+ b as restrictSessionMiddleware,
704
+ useResendCountdown
722
705
  };
723
- //#endregion
724
- export { AppleSignInButton, AuthLayout, EmailInput, PasswordInput, RememberMeCheckbox, ResendCodeButton, SignInForm, SignUpForm, redirectAuthMiddleware, requireSession, restrictSessionMiddleware, useResendCountdown };
725
-
726
- //# sourceMappingURL=index.js.map
706
+ //# sourceMappingURL=index.js.map