@sikka/hawa 0.23.8-next → 0.23.10-next

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 (65) hide show
  1. package/dist/DropdownMenu-jh4puuXw.d.ts +95 -0
  2. package/dist/DropdownMenu-vm2kRAhL.d.mts +95 -0
  3. package/dist/Radio-2ZwcMDWt.d.ts +74 -0
  4. package/dist/Radio-5ZANA8Vh.d.mts +74 -0
  5. package/dist/SimpleTable-EE4ejgUR.d.mts +97 -0
  6. package/dist/SimpleTable-vY1ziD-2.d.ts +97 -0
  7. package/dist/Toast-jAb16JQg.d.mts +23 -0
  8. package/dist/Toast-xcELwcIX.d.ts +23 -0
  9. package/dist/blocks/auth/index.d.mts +202 -0
  10. package/dist/blocks/auth/index.d.ts +202 -0
  11. package/dist/blocks/auth/index.js +4182 -0
  12. package/dist/blocks/auth/index.mjs +1057 -0
  13. package/dist/blocks/feedback/index.d.mts +74 -0
  14. package/dist/blocks/feedback/index.d.ts +74 -0
  15. package/dist/blocks/feedback/index.js +1531 -0
  16. package/dist/blocks/feedback/index.mjs +493 -0
  17. package/dist/blocks/index.d.mts +480 -0
  18. package/dist/blocks/index.d.ts +480 -0
  19. package/dist/blocks/index.js +8119 -0
  20. package/dist/blocks/index.mjs +2535 -0
  21. package/dist/blocks/misc/index.d.mts +90 -0
  22. package/dist/blocks/misc/index.d.ts +90 -0
  23. package/dist/blocks/misc/index.js +1163 -0
  24. package/dist/blocks/misc/index.mjs +322 -0
  25. package/dist/blocks/pricing/index.d.mts +93 -0
  26. package/dist/blocks/pricing/index.d.ts +93 -0
  27. package/dist/blocks/pricing/index.js +3320 -0
  28. package/dist/blocks/pricing/index.mjs +2161 -0
  29. package/dist/chunk-2R2QPJT7.mjs +7519 -0
  30. package/dist/chunk-343SRWR4.mjs +146 -0
  31. package/dist/chunk-677VOLD4.mjs +464 -0
  32. package/dist/chunk-A25EXELT.mjs +131 -0
  33. package/dist/chunk-F6TKEDDP.mjs +57 -0
  34. package/dist/chunk-FNVYY7ND.mjs +22 -0
  35. package/dist/chunk-P2O6R3S6.mjs +268 -0
  36. package/dist/chunk-QGKW5R5F.mjs +196 -0
  37. package/dist/chunk-TR56G3NM.mjs +2350 -0
  38. package/dist/chunk-UAVBFK53.mjs +346 -0
  39. package/dist/commonTypes-CKtkuNFH.d.mts +11 -0
  40. package/dist/commonTypes-CKtkuNFH.d.ts +11 -0
  41. package/dist/commonTypes-MxCJyrHv.d.mts +8 -0
  42. package/dist/commonTypes-MxCJyrHv.d.ts +8 -0
  43. package/dist/elements/index.d.mts +715 -0
  44. package/dist/elements/index.d.ts +715 -0
  45. package/dist/elements/index.js +7719 -0
  46. package/dist/elements/index.mjs +285 -0
  47. package/dist/hooks/index.d.mts +107 -0
  48. package/dist/hooks/index.d.ts +107 -0
  49. package/dist/hooks/index.js +451 -0
  50. package/dist/hooks/index.mjs +254 -0
  51. package/dist/index.d.mts +1905 -0
  52. package/dist/index.d.ts +1905 -0
  53. package/dist/index.js +11987 -0
  54. package/dist/index.mjs +11760 -0
  55. package/dist/layout/index.d.mts +249 -0
  56. package/dist/layout/index.d.ts +249 -0
  57. package/dist/layout/index.js +4373 -0
  58. package/dist/layout/index.mjs +1381 -0
  59. package/dist/textTypes-559CaoOV.d.mts +88 -0
  60. package/dist/textTypes-559CaoOV.d.ts +88 -0
  61. package/dist/types/index.d.mts +115 -0
  62. package/dist/types/index.d.ts +115 -0
  63. package/dist/types/index.js +18 -0
  64. package/dist/types/index.mjs +0 -0
  65. package/package.json +1 -1
@@ -0,0 +1,1057 @@
1
+ import {
2
+ Alert,
3
+ Checkbox,
4
+ Logos,
5
+ PhoneInput,
6
+ PinInput,
7
+ StopPropagationWrapper
8
+ } from "../../chunk-TR56G3NM.mjs";
9
+ import {
10
+ Input
11
+ } from "../../chunk-A25EXELT.mjs";
12
+ import {
13
+ EyeIcon,
14
+ HiddenEyeIcon,
15
+ Select
16
+ } from "../../chunk-UAVBFK53.mjs";
17
+ import {
18
+ Button,
19
+ Card,
20
+ CardContent,
21
+ CardDescription,
22
+ CardFooter,
23
+ CardHeader,
24
+ CardTitle,
25
+ Loading,
26
+ cn
27
+ } from "../../chunk-677VOLD4.mjs";
28
+
29
+ // components/blocks/auth/LoginForm.tsx
30
+ import React2, { useState } from "react";
31
+ import { Controller, useForm } from "react-hook-form";
32
+ import { zodResolver } from "@hookform/resolvers/zod";
33
+ import { parsePhoneNumber } from "libphonenumber-js";
34
+ import * as z from "zod";
35
+
36
+ // components/blocks/auth/AuthButtons.tsx
37
+ import React from "react";
38
+ var AuthButtons = (props) => {
39
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
40
+ return /* @__PURE__ */ React.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, props.viaGoogle && /* @__PURE__ */ React.createElement(
41
+ Button,
42
+ {
43
+ disabled: props.isGoogleLoading,
44
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
45
+ variant: "outline",
46
+ onClick: props.handleGoogle
47
+ },
48
+ props.isGoogleLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.google, { className: "hawa-icon" }),
49
+ (_b = (_a = props.texts) == null ? void 0 : _a.continueWithGoogle) != null ? _b : "Continue With Google"
50
+ ), props.viaGithub && /* @__PURE__ */ React.createElement(
51
+ Button,
52
+ {
53
+ disabled: props.isGithubLoading,
54
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
55
+ variant: "outline",
56
+ onClick: props.handleGithub
57
+ },
58
+ props.isGithubLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.github, { className: "hawa-icon" }),
59
+ (_d = (_c = props.texts) == null ? void 0 : _c.continueWithGithub) != null ? _d : "Continue With Github"
60
+ ), props.viaTwitter && /* @__PURE__ */ React.createElement(
61
+ Button,
62
+ {
63
+ disabled: props.isTwitterLoading,
64
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
65
+ variant: "outline",
66
+ onClick: props.handleTwitter
67
+ },
68
+ props.isTwitterLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.twitter, { className: "hawa-icon" }),
69
+ (_f = (_e = props.texts) == null ? void 0 : _e.continueWithTwitter) != null ? _f : "Continue With Twitter"
70
+ ), props.viaApple && /* @__PURE__ */ React.createElement(
71
+ Button,
72
+ {
73
+ disabled: props.isAppleLoading,
74
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
75
+ variant: "outline",
76
+ onClick: props.handleApple
77
+ },
78
+ props.isAppleLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.apple, { className: "hawa-icon" }),
79
+ (_h = (_g = props.texts) == null ? void 0 : _g.continueWithApple) != null ? _h : "Continue With Apple"
80
+ ), props.viaMicrosoft && /* @__PURE__ */ React.createElement(
81
+ Button,
82
+ {
83
+ disabled: props.isMicrosoftLoading,
84
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
85
+ variant: "outline",
86
+ onClick: props.handleMicrosoft
87
+ },
88
+ props.isMicrosoftLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.microsoft, { className: "hawa-icon" }),
89
+ (_j = (_i = props.texts) == null ? void 0 : _i.continueWithMicrosoft) != null ? _j : "Continue With Microsoft"
90
+ ), props.viaEmail && /* @__PURE__ */ React.createElement(
91
+ Button,
92
+ {
93
+ disabled: props.isEmailLoading,
94
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
95
+ variant: "outline",
96
+ onClick: props.handleEmail
97
+ },
98
+ props.isEmailLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.mail, { className: "hawa-icon" }),
99
+ (_l = (_k = props.texts) == null ? void 0 : _k.continueWithEmail) != null ? _l : "Continue With Email"
100
+ ), props.viaPhone && /* @__PURE__ */ React.createElement(
101
+ Button,
102
+ {
103
+ disabled: props.isPhoneLoading,
104
+ className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2",
105
+ variant: "outline",
106
+ onClick: props.handlePhone
107
+ },
108
+ props.isPhoneLoading ? /* @__PURE__ */ React.createElement(Loading, { size: "button" }) : /* @__PURE__ */ React.createElement(Logos.phone, { className: "hawa-icon" }),
109
+ (_n = (_m = props.texts) == null ? void 0 : _m.continueWithPhone) != null ? _n : "Continue With Phone"
110
+ ));
111
+ };
112
+
113
+ // components/blocks/auth/LoginForm.tsx
114
+ var LoginForm = ({
115
+ loginType,
116
+ texts,
117
+ passwordLength = 8,
118
+ ...props
119
+ }) => {
120
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
121
+ const [passwordVisible, setPasswordVisible] = useState(false);
122
+ const thirdPartyAuthTexts = {
123
+ continueWithGoogle: texts == null ? void 0 : texts.continueWithGoogle,
124
+ continueWithTwitter: texts == null ? void 0 : texts.continueWithTwitter,
125
+ continueWithApple: texts == null ? void 0 : texts.continueWithApple,
126
+ continueWithMicrosoft: texts == null ? void 0 : texts.continueWithMicrosoft,
127
+ continueWithGithub: texts == null ? void 0 : texts.continueWithGithub,
128
+ continueWithEmail: texts == null ? void 0 : texts.continueWithEmail,
129
+ continueWithPhone: texts == null ? void 0 : texts.continueWithPhone
130
+ };
131
+ let formSchema;
132
+ if (loginType === "email") {
133
+ formSchema = z.object({
134
+ email: z.string({ required_error: (_a = texts == null ? void 0 : texts.email) == null ? void 0 : _a.required }).min(1, { message: (_b = texts == null ? void 0 : texts.email) == null ? void 0 : _b.required }).email({ message: (_c = texts == null ? void 0 : texts.email) == null ? void 0 : _c.invalid }),
135
+ password: z.string({ required_error: (_d = texts == null ? void 0 : texts.password) == null ? void 0 : _d.required }).min(1, { message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required }).min(passwordLength, { message: (_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort })
136
+ });
137
+ } else if (loginType === "username") {
138
+ formSchema = z.object({
139
+ username: z.string({ required_error: (_g = texts == null ? void 0 : texts.username) == null ? void 0 : _g.required }).min(2, { message: (_h = texts == null ? void 0 : texts.username) == null ? void 0 : _h.tooShort }).refine(
140
+ (value) => {
141
+ const isValid = /^[a-zA-Z][a-zA-Z0-9_-]{2,14}$/.test(value);
142
+ return isValid;
143
+ },
144
+ { message: (_i = texts == null ? void 0 : texts.username) == null ? void 0 : _i.invalid }
145
+ ),
146
+ password: z.string({ required_error: (_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required }).min(1, { message: (_k = texts == null ? void 0 : texts.password) == null ? void 0 : _k.required }).min(passwordLength, { message: (_l = texts == null ? void 0 : texts.password) == null ? void 0 : _l.tooShort })
147
+ });
148
+ } else if (loginType === "phone") {
149
+ formSchema = z.object({
150
+ phone: z.string({ required_error: (_m = texts == null ? void 0 : texts.phone) == null ? void 0 : _m.required }).refine(
151
+ (value) => {
152
+ let phoneNumber = parsePhoneNumber(value);
153
+ return phoneNumber.isValid();
154
+ },
155
+ { message: (_n = texts == null ? void 0 : texts.phone) == null ? void 0 : _n.invalid }
156
+ )
157
+ });
158
+ } else if (loginType === "link") {
159
+ formSchema = z.object({
160
+ email: z.string({ required_error: (_o = texts == null ? void 0 : texts.email) == null ? void 0 : _o.required }).min(1, { message: (_p = texts == null ? void 0 : texts.email) == null ? void 0 : _p.required }).email({ message: (_q = texts == null ? void 0 : texts.email) == null ? void 0 : _q.invalid })
161
+ });
162
+ } else {
163
+ formSchema = z.object({});
164
+ }
165
+ const { handleSubmit, control, formState } = useForm({
166
+ resolver: zodResolver(formSchema)
167
+ });
168
+ const renderFields = () => {
169
+ switch (loginType) {
170
+ case "email":
171
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
172
+ Controller,
173
+ {
174
+ control,
175
+ name: "email",
176
+ render: ({ field }) => {
177
+ var _a2, _b2, _c2;
178
+ return /* @__PURE__ */ React2.createElement(
179
+ Input,
180
+ {
181
+ inputProps: {
182
+ className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
183
+ },
184
+ dir: "ltr",
185
+ width: "full",
186
+ autoComplete: "email",
187
+ label: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label,
188
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
189
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "contact@sikka.io",
190
+ ...field
191
+ }
192
+ );
193
+ }
194
+ }
195
+ ), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
196
+ Controller,
197
+ {
198
+ control,
199
+ name: "password",
200
+ render: ({ field }) => {
201
+ var _a2, _b2, _c2;
202
+ return /* @__PURE__ */ React2.createElement(
203
+ Input,
204
+ {
205
+ width: "full",
206
+ autoComplete: "current-password",
207
+ type: passwordVisible ? "text" : "password",
208
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
209
+ endIcon: /* @__PURE__ */ React2.createElement(
210
+ "div",
211
+ {
212
+ className: "hawa-cursor-pointer",
213
+ onClick: () => setPasswordVisible(!passwordVisible)
214
+ },
215
+ passwordVisible ? /* @__PURE__ */ React2.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React2.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" })
216
+ ),
217
+ placeholder: ((_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder) || "Enter your password",
218
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
219
+ ...field
220
+ }
221
+ );
222
+ }
223
+ }
224
+ ), !props.withoutResetPassword && /* @__PURE__ */ React2.createElement(
225
+ "div",
226
+ {
227
+ onClick: props.onForgotPassword,
228
+ className: "hawa-mb-3 hawa-mt-2 hawa-w-fit hawa-cursor-pointer hawa-select-none hawa-text-xs dark:hawa-text-gray-300"
229
+ },
230
+ (texts == null ? void 0 : texts.forgotPassword) || "Forgot Password?"
231
+ )));
232
+ case "username":
233
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
234
+ Controller,
235
+ {
236
+ control,
237
+ name: "username",
238
+ render: ({ field }) => {
239
+ var _a2, _b2, _c2;
240
+ return /* @__PURE__ */ React2.createElement(
241
+ Input,
242
+ {
243
+ width: "full",
244
+ autoComplete: "username",
245
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
246
+ helperText: (_b2 = formState.errors.username) == null ? void 0 : _b2.message,
247
+ placeholder: ((_c2 = texts == null ? void 0 : texts.username) == null ? void 0 : _c2.placeholder) || "sikka_sa",
248
+ ...field
249
+ }
250
+ );
251
+ }
252
+ }
253
+ ), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
254
+ Controller,
255
+ {
256
+ control,
257
+ name: "password",
258
+ render: ({ field }) => {
259
+ var _a2, _b2, _c2;
260
+ return /* @__PURE__ */ React2.createElement(
261
+ Input,
262
+ {
263
+ width: "full",
264
+ autoComplete: "current-password",
265
+ type: passwordVisible ? "text" : "password",
266
+ label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
267
+ endIcon: /* @__PURE__ */ React2.createElement(
268
+ "div",
269
+ {
270
+ className: "hawa-cursor-pointer",
271
+ onClick: () => setPasswordVisible(!passwordVisible)
272
+ },
273
+ passwordVisible ? /* @__PURE__ */ React2.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React2.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" })
274
+ ),
275
+ placeholder: ((_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder) || "Enter your password",
276
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
277
+ ...field
278
+ }
279
+ );
280
+ }
281
+ }
282
+ ), !props.withoutResetPassword && /* @__PURE__ */ React2.createElement(
283
+ "div",
284
+ {
285
+ onClick: props.onForgotPassword,
286
+ className: "hawa-mb-3 hawa-mt-2 hawa-w-fit hawa-cursor-pointer hawa-select-none hawa-text-xs dark:hawa-text-gray-300"
287
+ },
288
+ (texts == null ? void 0 : texts.forgotPassword) || "Forgot Password?"
289
+ )));
290
+ case "phone":
291
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
292
+ Controller,
293
+ {
294
+ control,
295
+ name: "phone",
296
+ render: ({ field }) => {
297
+ var _a2, _b2;
298
+ return /* @__PURE__ */ React2.createElement(
299
+ PhoneInput,
300
+ {
301
+ label: (_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label,
302
+ helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
303
+ preferredCountry: { label: "+966" },
304
+ handleChange: (e) => field.onChange(parsePhoneNumber(e).number)
305
+ }
306
+ );
307
+ }
308
+ }
309
+ ));
310
+ case "link":
311
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
312
+ Controller,
313
+ {
314
+ control,
315
+ name: "email",
316
+ render: ({ field }) => {
317
+ var _a2, _b2, _c2;
318
+ return /* @__PURE__ */ React2.createElement(
319
+ Input,
320
+ {
321
+ width: "full",
322
+ autoComplete: "email",
323
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
324
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
325
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "contact@sikka.io",
326
+ ...field
327
+ }
328
+ );
329
+ }
330
+ }
331
+ ));
332
+ default:
333
+ break;
334
+ }
335
+ };
336
+ return /* @__PURE__ */ React2.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, /* @__PURE__ */ React2.createElement(Card, { dir: props.direction }, /* @__PURE__ */ React2.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React2.createElement(
337
+ Alert,
338
+ {
339
+ direction: props.direction,
340
+ title: props.errorTitle,
341
+ text: props.errorText,
342
+ severity: "error"
343
+ }
344
+ ), /* @__PURE__ */ React2.createElement(
345
+ "form",
346
+ {
347
+ noValidate: true,
348
+ className: "hawa-flex hawa-flex-col hawa-gap-4",
349
+ onSubmit: handleSubmit((e) => {
350
+ if (props.onLogin) {
351
+ return props.onLogin(e);
352
+ } else {
353
+ console.log("Form is submitted but onLogin prop is missing");
354
+ }
355
+ })
356
+ },
357
+ renderFields(),
358
+ /* @__PURE__ */ React2.createElement(
359
+ Button,
360
+ {
361
+ className: "hawa-mt-0 hawa-w-full",
362
+ type: "submit",
363
+ isLoading: props.isLoading,
364
+ disabled: props.isLoading
365
+ },
366
+ (texts == null ? void 0 : texts.loginText) || "Login"
367
+ ),
368
+ props.additionalButtons,
369
+ props.allowRegister && /* @__PURE__ */ React2.createElement("div", { className: "hawa-select-none hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-gray-300" }, (texts == null ? void 0 : texts.newUserText) || "New user?", " ", /* @__PURE__ */ React2.createElement(
370
+ "span",
371
+ {
372
+ onClick: props.onRouteToRegister,
373
+ className: "clickable-link"
374
+ },
375
+ (texts == null ? void 0 : texts.createAccount) || "Create Account"
376
+ ))
377
+ )), props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React2.createElement(
378
+ CardFooter,
379
+ {
380
+ className: cn(
381
+ props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
382
+ )
383
+ },
384
+ /* @__PURE__ */ React2.createElement(
385
+ AuthButtons,
386
+ {
387
+ texts: thirdPartyAuthTexts,
388
+ viaGoogle: props.viaGoogle,
389
+ viaGithub: props.viaGithub,
390
+ viaTwitter: props.viaTwitter,
391
+ isGoogleLoading: props.isGoogleLoading,
392
+ isGithubLoading: props.isGithubLoading,
393
+ isTwitterLoading: props.isTwitterLoading,
394
+ handleGoogle: props.onGoogleLogin,
395
+ handleGithub: props.onGithubLogin,
396
+ handleTwitter: props.onTwitterLogin
397
+ }
398
+ )
399
+ ) : null));
400
+ };
401
+
402
+ // components/blocks/auth/RegisterForm.tsx
403
+ import React3, { useState as useState2 } from "react";
404
+ import { Controller as Controller2, FormProvider, useForm as useForm2 } from "react-hook-form";
405
+ import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
406
+ import * as z2 from "zod";
407
+ var RegisterForm = ({
408
+ texts,
409
+ registerFields = ["email"],
410
+ ...props
411
+ }) => {
412
+ var _a, _b, _c, _d, _e, _f;
413
+ const [passwordVisible, setPasswordVisible] = useState2(false);
414
+ const thirdPartyAuthTexts = {
415
+ continueWithGoogle: texts == null ? void 0 : texts.continueWithGoogle,
416
+ continueWithTwitter: texts == null ? void 0 : texts.continueWithTwitter,
417
+ continueWithApple: texts == null ? void 0 : texts.continueWithApple,
418
+ continueWithMicrosoft: texts == null ? void 0 : texts.continueWithMicrosoft,
419
+ continueWithGithub: texts == null ? void 0 : texts.continueWithGithub,
420
+ continueWithEmail: texts == null ? void 0 : texts.continueWithEmail,
421
+ continueWithPhone: texts == null ? void 0 : texts.continueWithPhone
422
+ };
423
+ const methods = useForm2();
424
+ let fieldSchemas = {};
425
+ registerFields.forEach((field) => {
426
+ var _a2, _b2, _c2, _d2, _e2, _f2;
427
+ switch (field) {
428
+ case "fullname":
429
+ fieldSchemas["fullName"] = z2.string().optional();
430
+ break;
431
+ case "email":
432
+ fieldSchemas["email"] = z2.string({ required_error: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.required }).email({ message: (_b2 = texts == null ? void 0 : texts.email) == null ? void 0 : _b2.invalid }).min(1, { message: (_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.required });
433
+ break;
434
+ case "username":
435
+ fieldSchemas["username"] = z2.string({ required_error: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.required }).min(1, { message: (_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.required }).refine(
436
+ (value) => {
437
+ const isValid = /^[a-zA-Z][a-zA-Z0-9_-]{2,14}$/.test(value);
438
+ return isValid;
439
+ },
440
+ { message: (_f2 = texts == null ? void 0 : texts.username) == null ? void 0 : _f2.invalid }
441
+ );
442
+ break;
443
+ }
444
+ });
445
+ const formSchema = z2.object({
446
+ ...fieldSchemas,
447
+ password: z2.string({ required_error: (_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required }).min(5, { message: (_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort }).refine((value) => value !== "", {
448
+ message: (_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required
449
+ }),
450
+ confirm_password: z2.string({ required_error: (_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required }).refine((value) => value !== "", {
451
+ message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required
452
+ }),
453
+ refCode: z2.string().optional(),
454
+ reference: z2.string().optional(),
455
+ terms_accepted: z2.boolean({ required_error: texts == null ? void 0 : texts.termsRequired }).refine((value) => value, { message: texts == null ? void 0 : texts.termsRequired }),
456
+ newsletter_accepted: z2.boolean().optional()
457
+ }).refine((data) => data.password === data.confirm_password, {
458
+ message: (_f = texts == null ? void 0 : texts.confirm) == null ? void 0 : _f.dontMatch,
459
+ path: ["confirm_password"]
460
+ });
461
+ const { handleSubmit, control, formState } = useForm2({
462
+ resolver: zodResolver2(formSchema)
463
+ });
464
+ return /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, /* @__PURE__ */ React3.createElement(Card, { dir: props.direction }, /* @__PURE__ */ React3.createElement(CardContent, { headless: true }, /* @__PURE__ */ React3.createElement("div", null, props.showError && /* @__PURE__ */ React3.createElement(
465
+ Alert,
466
+ {
467
+ title: props.errorTitle,
468
+ text: props.errorText,
469
+ severity: "error"
470
+ }
471
+ ), /* @__PURE__ */ React3.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React3.createElement(
472
+ "form",
473
+ {
474
+ noValidate: true,
475
+ onSubmit: handleSubmit((e) => {
476
+ if (props.onRegister) {
477
+ return props.onRegister(e);
478
+ } else {
479
+ console.log(
480
+ "Form is submitted but onRegister prop is missing"
481
+ );
482
+ }
483
+ }),
484
+ className: "hawa-flex hawa-flex-col hawa-gap-4"
485
+ },
486
+ /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
487
+ if (fld === "fullname") {
488
+ return /* @__PURE__ */ React3.createElement(
489
+ Controller2,
490
+ {
491
+ key: i,
492
+ control,
493
+ name: "fullName",
494
+ render: ({ field }) => {
495
+ var _a2, _b2, _c2;
496
+ return /* @__PURE__ */ React3.createElement(
497
+ Input,
498
+ {
499
+ width: "full",
500
+ label: (_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label,
501
+ placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
502
+ helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
503
+ ...field
504
+ }
505
+ );
506
+ }
507
+ }
508
+ );
509
+ }
510
+ if (fld === "email") {
511
+ return /* @__PURE__ */ React3.createElement(
512
+ Controller2,
513
+ {
514
+ key: i,
515
+ control,
516
+ name: "email",
517
+ render: ({ field }) => {
518
+ var _a2, _b2, _c2;
519
+ return /* @__PURE__ */ React3.createElement(
520
+ Input,
521
+ {
522
+ dir: "ltr",
523
+ inputProps: {
524
+ className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
525
+ },
526
+ width: "full",
527
+ autoComplete: "email",
528
+ label: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label,
529
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
530
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
531
+ ...field
532
+ }
533
+ );
534
+ }
535
+ }
536
+ );
537
+ }
538
+ if (fld === "username") {
539
+ return /* @__PURE__ */ React3.createElement(
540
+ Controller2,
541
+ {
542
+ key: i,
543
+ control,
544
+ name: "username",
545
+ render: ({ field }) => {
546
+ var _a2, _b2, _c2;
547
+ return /* @__PURE__ */ React3.createElement(
548
+ Input,
549
+ {
550
+ width: "full",
551
+ autoComplete: "username",
552
+ label: (_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label,
553
+ helperText: (_b2 = formState.errors.username) == null ? void 0 : _b2.message,
554
+ placeholder: (_c2 = texts == null ? void 0 : texts.username) == null ? void 0 : _c2.placeholder,
555
+ ...field
556
+ }
557
+ );
558
+ }
559
+ }
560
+ );
561
+ }
562
+ })),
563
+ /* @__PURE__ */ React3.createElement(
564
+ Controller2,
565
+ {
566
+ control,
567
+ name: "password",
568
+ render: ({ field }) => {
569
+ var _a2, _b2, _c2;
570
+ return /* @__PURE__ */ React3.createElement(
571
+ Input,
572
+ {
573
+ width: "full",
574
+ type: passwordVisible ? "text" : "password",
575
+ endIcon: /* @__PURE__ */ React3.createElement(
576
+ "div",
577
+ {
578
+ className: "hawa-cursor-pointer",
579
+ onClick: () => setPasswordVisible(!passwordVisible)
580
+ },
581
+ passwordVisible ? /* @__PURE__ */ React3.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React3.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
582
+ " "
583
+ ),
584
+ autoComplete: "new-password",
585
+ label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
586
+ placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
587
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
588
+ ...field
589
+ }
590
+ );
591
+ }
592
+ }
593
+ ),
594
+ /* @__PURE__ */ React3.createElement(
595
+ Controller2,
596
+ {
597
+ control,
598
+ name: "confirm_password",
599
+ render: ({ field }) => {
600
+ var _a2, _b2, _c2;
601
+ return /* @__PURE__ */ React3.createElement(
602
+ Input,
603
+ {
604
+ width: "full",
605
+ type: "password",
606
+ autoComplete: "new-password",
607
+ label: (_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label,
608
+ placeholder: (_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder,
609
+ helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
610
+ ...field
611
+ }
612
+ );
613
+ }
614
+ }
615
+ ),
616
+ props.additionalInputs,
617
+ props.showRefCode && /* @__PURE__ */ React3.createElement(
618
+ Controller2,
619
+ {
620
+ control,
621
+ name: "refCode",
622
+ render: ({ field }) => {
623
+ var _a2;
624
+ return /* @__PURE__ */ React3.createElement(
625
+ Input,
626
+ {
627
+ width: "full",
628
+ label: texts == null ? void 0 : texts.refCode,
629
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
630
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
631
+ ...field
632
+ }
633
+ );
634
+ }
635
+ }
636
+ ),
637
+ props.showUserSource && /* @__PURE__ */ React3.createElement(
638
+ Controller2,
639
+ {
640
+ control,
641
+ name: "reference",
642
+ render: ({ field }) => {
643
+ var _a2, _b2;
644
+ return /* @__PURE__ */ React3.createElement(
645
+ Select,
646
+ {
647
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
648
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
649
+ isCreatable: false,
650
+ isMulti: false,
651
+ isSearchable: false,
652
+ isClearable: false,
653
+ options: props.userReferenceOptions,
654
+ onChange: (e) => {
655
+ field.onChange(e.value);
656
+ }
657
+ }
658
+ );
659
+ }
660
+ }
661
+ ),
662
+ /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3" }, props.showTermsOption && /* @__PURE__ */ React3.createElement(
663
+ Controller2,
664
+ {
665
+ control,
666
+ name: "terms_accepted",
667
+ render: ({ field }) => {
668
+ var _a2, _b2;
669
+ return /* @__PURE__ */ React3.createElement(
670
+ Checkbox,
671
+ {
672
+ id: "terms_accepted",
673
+ helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
674
+ onCheckedChange: (e) => field.onChange(e),
675
+ label: /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-gap-0.5" }, /* @__PURE__ */ React3.createElement("span", null, texts == null ? void 0 : texts.iAcceptText), " ", /* @__PURE__ */ React3.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React3.createElement(
676
+ "a",
677
+ {
678
+ onClick: props.onRouteToTOS,
679
+ className: "clickable-link"
680
+ },
681
+ texts == null ? void 0 : texts.termsText
682
+ )))
683
+ }
684
+ );
685
+ }
686
+ }
687
+ ), props.showNewsletterOption && /* @__PURE__ */ React3.createElement(
688
+ Controller2,
689
+ {
690
+ control,
691
+ name: "newsletter_accepted",
692
+ render: ({ field }) => /* @__PURE__ */ React3.createElement(
693
+ Checkbox,
694
+ {
695
+ id: "newsletter_accepted",
696
+ label: texts == null ? void 0 : texts.subscribeToNewsletter,
697
+ onCheckedChange: field.onChange
698
+ }
699
+ )
700
+ }
701
+ )),
702
+ /* @__PURE__ */ React3.createElement(
703
+ Button,
704
+ {
705
+ isLoading: props.isLoading,
706
+ className: "hawa-mt-4 hawa-w-full"
707
+ },
708
+ texts == null ? void 0 : texts.registerText
709
+ ),
710
+ props.additionalButtons
711
+ )), /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-1 hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-white" }, /* @__PURE__ */ React3.createElement("span", null, texts == null ? void 0 : texts.existingUserText), /* @__PURE__ */ React3.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))), props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React3.createElement(
712
+ CardFooter,
713
+ {
714
+ className: cn(
715
+ props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
716
+ )
717
+ },
718
+ /* @__PURE__ */ React3.createElement(
719
+ AuthButtons,
720
+ {
721
+ texts: thirdPartyAuthTexts,
722
+ viaGoogle: props.viaGoogle,
723
+ viaGithub: props.viaGithub,
724
+ viaTwitter: props.viaTwitter,
725
+ isGoogleLoading: props.isGoogleLoading,
726
+ isGithubLoading: props.isGithubLoading,
727
+ isTwitterLoading: props.isTwitterLoading,
728
+ handleGoogle: props.onGoogleRegister,
729
+ handleGithub: props.onGithubRegister,
730
+ handleTwitter: props.onTwitterRegister
731
+ }
732
+ )
733
+ ) : null));
734
+ };
735
+
736
+ // components/blocks/auth/AppLanding.tsx
737
+ import React4 from "react";
738
+ var AppLanding = ({ texts, ...props }) => {
739
+ const thirdPartyAuthTexts = {
740
+ continueWithGoogle: texts == null ? void 0 : texts.continueWithGoogle,
741
+ continueWithTwitter: texts == null ? void 0 : texts.continueWithTwitter,
742
+ continueWithApple: texts == null ? void 0 : texts.continueWithApple,
743
+ continueWithMicrosoft: texts == null ? void 0 : texts.continueWithMicrosoft,
744
+ continueWithGithub: texts == null ? void 0 : texts.continueWithGithub,
745
+ continueWithEmail: texts == null ? void 0 : texts.continueWithEmail,
746
+ continueWithPhone: texts == null ? void 0 : texts.continueWithPhone
747
+ };
748
+ return /* @__PURE__ */ React4.createElement("div", { dir: props.direction }, /* @__PURE__ */ React4.createElement(Card, null, /* @__PURE__ */ React4.createElement(CardContent, { headless: true, className: "hawa-flex hawa-flex-col hawa-gap-6" }, /* @__PURE__ */ React4.createElement(
749
+ AuthButtons,
750
+ {
751
+ texts: thirdPartyAuthTexts,
752
+ viaApple: props.viaApple,
753
+ viaGoogle: props.viaGoogle,
754
+ viaEmail: props.viaEmail,
755
+ viaGithub: props.viaGithub,
756
+ viaMicrosoft: props.viaMicrosoft,
757
+ viaPhone: props.viaPhone,
758
+ viaTwitter: props.viaTwitter,
759
+ handleApple: props.handleApple,
760
+ handleGoogle: props.handleGoogle,
761
+ handleTwitter: props.handleTwitter,
762
+ handleMicrosoft: props.handleMicrosoft,
763
+ handleGithub: props.handleGithub,
764
+ handleEmail: props.handleEmail,
765
+ handlePhone: props.handlePhone
766
+ }
767
+ ), props.allowRegister && /* @__PURE__ */ React4.createElement("div", { className: "hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-gray-300" }, texts == null ? void 0 : texts.newUserText, " ", /* @__PURE__ */ React4.createElement(
768
+ "span",
769
+ {
770
+ onClick: props.handleRouteToRegister,
771
+ className: "clickable-link"
772
+ },
773
+ texts == null ? void 0 : texts.createAccount
774
+ )))));
775
+ };
776
+
777
+ // components/blocks/auth/CheckEmail.tsx
778
+ import React5 from "react";
779
+ var CheckEmail = ({ texts, handleResend }) => {
780
+ return /* @__PURE__ */ React5.createElement(Card, null, /* @__PURE__ */ React5.createElement(CardContent, { headless: true }, /* @__PURE__ */ React5.createElement("div", { className: "hawa-flex hawa-flex-col hawa-items-center hawa-justify-center hawa-text-center" }, /* @__PURE__ */ React5.createElement("div", { className: "hawa-flex hawa-h-16 hawa-w-16 hawa-flex-col hawa-items-center hawa-justify-center hawa-rounded-3xl hawa-bg-primary hawa-text-6xl hawa-font-bold hawa-text-primary-foreground" }, /* @__PURE__ */ React5.createElement(
781
+ "svg",
782
+ {
783
+ stroke: "currentColor",
784
+ fill: "none",
785
+ strokeWidth: "2",
786
+ viewBox: "0 0 24 24",
787
+ strokeLinecap: "round",
788
+ strokeLinejoin: "round",
789
+ height: "0.5em",
790
+ width: "0.5em",
791
+ xmlns: "http://www.w3.org/2000/svg"
792
+ },
793
+ /* @__PURE__ */ React5.createElement("path", { d: "M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" }),
794
+ /* @__PURE__ */ React5.createElement("polyline", { points: "22,6 12,13 2,6" })
795
+ )), /* @__PURE__ */ React5.createElement("div", { className: "hawa-m-2 hawa-text-xl hawa-font-bold" }, (texts == null ? void 0 : texts.checkEmail) || "Check your Email"), /* @__PURE__ */ React5.createElement("div", { className: "hawa-text-sm" }, (texts == null ? void 0 : texts.pleaseVerify) || "Thank you for signing up! To complete your registration, we've sent a verification email to the address you provided. Please check your inbox and follow the instructions in the email to activate your account."))), /* @__PURE__ */ React5.createElement(CardFooter, { className: "hawa-flex hawa-flex-col hawa-justify-center " }, /* @__PURE__ */ React5.createElement("span", { className: "clickable-link hawa-text-sm", onClick: handleResend }, (texts == null ? void 0 : texts.resendEmail) || "Resend Email")));
796
+ };
797
+
798
+ // components/blocks/auth/NewPassword.tsx
799
+ import React6, { useState as useState3 } from "react";
800
+ import { Controller as Controller3, useForm as useForm3 } from "react-hook-form";
801
+ import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
802
+ import * as z3 from "zod";
803
+ var NewPasswordForm = ({ texts, ...props }) => {
804
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
805
+ const formSchema = z3.object({
806
+ password: z3.string({ required_error: (_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required }).min(1, { message: (_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.required }).min(8, { message: (_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.tooShort }),
807
+ confirm_password: z3.string({ required_error: (_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required }).refine((value) => value !== "", {
808
+ message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required
809
+ })
810
+ }).refine((data) => data.password === data.confirm_password, {
811
+ message: (_f = texts == null ? void 0 : texts.confirm) == null ? void 0 : _f.dontMatch,
812
+ path: ["confirm_password"]
813
+ });
814
+ const { handleSubmit, control, formState } = useForm3({
815
+ resolver: zodResolver3(formSchema)
816
+ });
817
+ const [matchError, setMatchError] = useState3(false);
818
+ return /* @__PURE__ */ React6.createElement(Card, { dir: props.direction }, matchError && /* @__PURE__ */ React6.createElement(Alert, { text: (_g = texts == null ? void 0 : texts.confirm) == null ? void 0 : _g.dontMatch, severity: "error" }), props.passwordChanged ? /* @__PURE__ */ React6.createElement(CardContent, { headless: true }, /* @__PURE__ */ React6.createElement("div", { className: "hawa-text-center" }, texts == null ? void 0 : texts.passwordChanged)) : /* @__PURE__ */ React6.createElement(
819
+ "form",
820
+ {
821
+ noValidate: true,
822
+ onSubmit: handleSubmit((e) => {
823
+ if (props.handleNewPassword) {
824
+ return props.handleNewPassword(e);
825
+ } else {
826
+ console.log(
827
+ "Form is submitted but handleSubmission prop is missing"
828
+ );
829
+ }
830
+ })
831
+ },
832
+ !props.headless && /* @__PURE__ */ React6.createElement(CardHeader, null, /* @__PURE__ */ React6.createElement(CardTitle, null, "Create Password"), /* @__PURE__ */ React6.createElement(CardDescription, null, "Set a new password for your account")),
833
+ /* @__PURE__ */ React6.createElement(
834
+ CardContent,
835
+ {
836
+ headless: props.headless,
837
+ className: "hawa-flex hawa-flex-col hawa-gap-4"
838
+ },
839
+ /* @__PURE__ */ React6.createElement(
840
+ Controller3,
841
+ {
842
+ control,
843
+ name: "password",
844
+ render: ({ field }) => {
845
+ var _a2, _b2, _c2;
846
+ return /* @__PURE__ */ React6.createElement(
847
+ Input,
848
+ {
849
+ width: "full",
850
+ type: "password",
851
+ autoComplete: "new-password",
852
+ label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
853
+ placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
854
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
855
+ ...field
856
+ }
857
+ );
858
+ }
859
+ }
860
+ ),
861
+ /* @__PURE__ */ React6.createElement(
862
+ Controller3,
863
+ {
864
+ control,
865
+ name: "confirm_password",
866
+ render: ({ field }) => {
867
+ var _a2, _b2, _c2;
868
+ return /* @__PURE__ */ React6.createElement(
869
+ Input,
870
+ {
871
+ width: "full",
872
+ type: "password",
873
+ autoComplete: "new-password",
874
+ label: (_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label,
875
+ placeholder: (_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder,
876
+ helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
877
+ ...field
878
+ }
879
+ );
880
+ }
881
+ }
882
+ )
883
+ ),
884
+ /* @__PURE__ */ React6.createElement(CardFooter, { className: "hawa-flex hawa-flex-col" }, /* @__PURE__ */ React6.createElement(Button, { className: "hawa-w-full", type: "submit" }, texts == null ? void 0 : texts.updatePassword), props.allowRegister && /* @__PURE__ */ React6.createElement("div", { className: "hawa-mt-4 hawa-pb-0 hawa-text-center hawa-text-sm dark:hawa-text-gray-300" }, (_h = texts == null ? void 0 : texts.dontHaveAccount) != null ? _h : "Don't have an account? ", /* @__PURE__ */ React6.createElement(
885
+ "span",
886
+ {
887
+ className: "clickable-link",
888
+ onClick: props.handleRouteToRegister
889
+ },
890
+ (_i = texts == null ? void 0 : texts.registerText) != null ? _i : "Register"
891
+ )))
892
+ ));
893
+ };
894
+
895
+ // components/blocks/auth/ResetPassword.tsx
896
+ import React7 from "react";
897
+ import { Controller as Controller4, useForm as useForm4 } from "react-hook-form";
898
+ import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
899
+ import * as z4 from "zod";
900
+ var ResetPasswordForm = (props) => {
901
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
902
+ const formSchema = z4.object({
903
+ email: z4.string({ required_error: (_b = (_a = props.texts) == null ? void 0 : _a.email) == null ? void 0 : _b.required }).email({ message: (_d = (_c = props.texts) == null ? void 0 : _c.email) == null ? void 0 : _d.invalid }).min(1, { message: (_f = (_e = props.texts) == null ? void 0 : _e.email) == null ? void 0 : _f.required })
904
+ });
905
+ const { handleSubmit, control, formState } = useForm4({
906
+ resolver: zodResolver4(formSchema)
907
+ });
908
+ return /* @__PURE__ */ React7.createElement(Card, { dir: props.direction }, !props.sent ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, !props.headless && /* @__PURE__ */ React7.createElement(CardHeader, null, /* @__PURE__ */ React7.createElement(CardTitle, null, " ", ((_g = props.texts) == null ? void 0 : _g.headTitle) || "Reset Password"), /* @__PURE__ */ React7.createElement(CardDescription, null, ((_h = props.texts) == null ? void 0 : _h.headDescription) || "Enter your email to reset your account password")), /* @__PURE__ */ React7.createElement(
909
+ "form",
910
+ {
911
+ noValidate: true,
912
+ onSubmit: handleSubmit((e) => {
913
+ if (props.handleResetPassword) {
914
+ return props.handleResetPassword(e);
915
+ } else {
916
+ console.log("handleResetPassword prop is missing");
917
+ }
918
+ })
919
+ },
920
+ /* @__PURE__ */ React7.createElement(CardContent, { headless: props.headless }, /* @__PURE__ */ React7.createElement(
921
+ Controller4,
922
+ {
923
+ control,
924
+ name: "email",
925
+ render: ({ field }) => {
926
+ var _a2, _b2, _c2, _d2, _e2;
927
+ return /* @__PURE__ */ React7.createElement(
928
+ Input,
929
+ {
930
+ width: "full",
931
+ label: (_b2 = (_a2 = props.texts) == null ? void 0 : _a2.email) == null ? void 0 : _b2.label,
932
+ helperText: (_c2 = formState.errors.email) == null ? void 0 : _c2.message,
933
+ placeholder: (_e2 = (_d2 = props.texts) == null ? void 0 : _d2.email) == null ? void 0 : _e2.placeholder,
934
+ ...field
935
+ }
936
+ );
937
+ }
938
+ }
939
+ )),
940
+ /* @__PURE__ */ React7.createElement(CardFooter, { className: "hawa-flex hawa-flex-col" }, /* @__PURE__ */ React7.createElement(Button, { type: "submit", className: "hawa-w-full" }, (_i = props.texts) == null ? void 0 : _i.resetPassword), props.allowRegister && /* @__PURE__ */ React7.createElement("div", { className: "hawa-mt-4 hawa-pb-0 hawa-text-center hawa-text-sm dark:hawa-text-gray-300" }, (_k = (_j = props.texts) == null ? void 0 : _j.dontHaveAccount) != null ? _k : "Don't have an account? ", /* @__PURE__ */ React7.createElement(
941
+ "span",
942
+ {
943
+ className: "clickable-link",
944
+ onClick: props.handleRouteToRegister
945
+ },
946
+ (_m = (_l = props.texts) == null ? void 0 : _l.registerText) != null ? _m : "Register"
947
+ )))
948
+ )) : /* @__PURE__ */ React7.createElement(CardContent, { headless: true }, /* @__PURE__ */ React7.createElement("div", { className: "hawa-text-center" }, (_n = props.texts) == null ? void 0 : _n.emailSentText)));
949
+ };
950
+
951
+ // components/blocks/auth/CodeConfirmation.tsx
952
+ import React8, { useEffect, useState as useState4 } from "react";
953
+ import { Controller as Controller5, useForm as useForm5 } from "react-hook-form";
954
+ import { zodResolver as zodResolver5 } from "@hookform/resolvers/zod";
955
+ import * as z5 from "zod";
956
+ var CodeConfirmation = (props) => {
957
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
958
+ const formSchema = z5.object({
959
+ otp_code: z5.string({ required_error: (_a = props.texts) == null ? void 0 : _a.codeRequiredText }).min(6, { message: (_b = props.texts) == null ? void 0 : _b.codeTooShort })
960
+ });
961
+ const { handleSubmit, control, formState, setValue } = useForm5({
962
+ resolver: zodResolver5(formSchema)
963
+ });
964
+ const [resendTimer, setResendTimer] = useState4(null);
965
+ const [remainingTime, setRemainingTime] = useState4(0);
966
+ const [showResendTimer, setShowResendTimer] = useState4(false);
967
+ const startResendTimer = () => {
968
+ if (resendTimer !== null) {
969
+ clearInterval(resendTimer);
970
+ setResendTimer(null);
971
+ }
972
+ const timerDuration = 60;
973
+ setRemainingTime(timerDuration);
974
+ setShowResendTimer(true);
975
+ const newTimer = window.setInterval(() => {
976
+ setRemainingTime((prevTime) => {
977
+ if (prevTime > 0) {
978
+ return prevTime - 1;
979
+ } else {
980
+ clearInterval(newTimer);
981
+ setShowResendTimer(false);
982
+ return 0;
983
+ }
984
+ });
985
+ }, 1e3);
986
+ setResendTimer(newTimer);
987
+ };
988
+ useEffect(() => {
989
+ return () => {
990
+ if (resendTimer !== null) {
991
+ clearInterval(resendTimer);
992
+ }
993
+ };
994
+ }, []);
995
+ return /* @__PURE__ */ React8.createElement(Card, null, /* @__PURE__ */ React8.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React8.createElement(
996
+ Alert,
997
+ {
998
+ title: props.errorTitle,
999
+ text: props.errorText,
1000
+ severity: "error"
1001
+ }
1002
+ ), /* @__PURE__ */ React8.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React8.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourPhone) || "Please check your phone"), /* @__PURE__ */ React8.createElement("div", { className: "hawa-text-muted-foreground" }, /* @__PURE__ */ React8.createElement("span", null, ((_d = props.texts) == null ? void 0 : _d.weSentCode) || "We've sent a code to "), /* @__PURE__ */ React8.createElement("span", null, props.phoneNumber))), /* @__PURE__ */ React8.createElement(
1003
+ "form",
1004
+ {
1005
+ noValidate: true,
1006
+ onSubmit: handleSubmit((e) => {
1007
+ if (props.handleConfirm) {
1008
+ return props.handleConfirm(e);
1009
+ } else {
1010
+ console.log(
1011
+ "Form is submitted but handleConfirm prop is missing"
1012
+ );
1013
+ }
1014
+ })
1015
+ },
1016
+ /* @__PURE__ */ React8.createElement(
1017
+ Controller5,
1018
+ {
1019
+ control,
1020
+ name: "otp_code",
1021
+ render: ({ field }) => {
1022
+ var _a2;
1023
+ return /* @__PURE__ */ React8.createElement(
1024
+ PinInput,
1025
+ {
1026
+ width: "full",
1027
+ digits: 6,
1028
+ getPins: (e) => setValue("otp_code", e.join("")),
1029
+ helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message
1030
+ }
1031
+ );
1032
+ }
1033
+ }
1034
+ ),
1035
+ showResendTimer ? /* @__PURE__ */ React8.createElement("div", { className: " hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, (_e = props.texts) == null ? void 0 : _e.resendCodeTimer, " ", /* @__PURE__ */ React8.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React8.createElement("div", { className: " hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React8.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React8.createElement(
1036
+ "span",
1037
+ {
1038
+ className: "clickable-link",
1039
+ onClick: () => {
1040
+ startResendTimer();
1041
+ props.handleResend();
1042
+ }
1043
+ },
1044
+ ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
1045
+ )),
1046
+ /* @__PURE__ */ React8.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React8.createElement(Button, { variant: "secondary" }, ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"), /* @__PURE__ */ React8.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
1047
+ )));
1048
+ };
1049
+ export {
1050
+ AppLanding,
1051
+ CheckEmail,
1052
+ CodeConfirmation,
1053
+ LoginForm,
1054
+ NewPasswordForm,
1055
+ RegisterForm,
1056
+ ResetPasswordForm
1057
+ };