@thetechfossil/auth2 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,25 @@
1
+ "use client";
1
2
  'use strict';
2
3
 
3
- var react = require('react');
4
+ var React2 = require('react');
4
5
  var axios = require('axios');
5
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var PhoneInputWithCountry = require('react-phone-number-input');
8
+ require('react-phone-number-input/style.css');
6
9
 
7
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
11
 
12
+ var React2__default = /*#__PURE__*/_interopDefault(React2);
9
13
  var axios__default = /*#__PURE__*/_interopDefault(axios);
14
+ var PhoneInputWithCountry__default = /*#__PURE__*/_interopDefault(PhoneInputWithCountry);
10
15
 
11
- // src/react/components/LoginForm.tsx
12
16
  var HttpClient = class {
13
17
  constructor(baseUrl, defaultHeaders = {}) {
14
18
  this.csrfToken = null;
15
19
  this.frontendBaseUrl = null;
20
+ this.baseUrl = baseUrl.replace(/\/$/, "");
16
21
  this.axiosInstance = axios__default.default.create({
17
- baseURL: baseUrl.replace(/\/$/, ""),
22
+ baseURL: this.baseUrl,
18
23
  headers: {
19
24
  "Content-Type": "application/json",
20
25
  ...defaultHeaders
@@ -25,8 +30,16 @@ var HttpClient = class {
25
30
  // 30 second timeout
26
31
  });
27
32
  this.axiosInstance.interceptors.request.use(
28
- (config) => {
29
- if (this.csrfToken && ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "")) {
33
+ async (config) => {
34
+ const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
35
+ if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
36
+ try {
37
+ await this.refreshCsrfToken();
38
+ } catch (error) {
39
+ console.warn("Failed to fetch CSRF token:", error);
40
+ }
41
+ }
42
+ if (this.csrfToken && isMutatingRequest) {
30
43
  config.headers["x-csrf-token"] = this.csrfToken;
31
44
  }
32
45
  if (this.frontendBaseUrl) {
@@ -124,9 +137,6 @@ var AuthService = class {
124
137
  this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
125
138
  }
126
139
  }
127
- if (this.config.csrfEnabled && typeof window !== "undefined") {
128
- this.refreshCsrfToken();
129
- }
130
140
  }
131
141
  loadTokenFromStorage() {
132
142
  if (typeof window !== "undefined" && this.config.localStorageKey) {
@@ -228,7 +238,7 @@ var AuthService = class {
228
238
  this.saveTokenToStorage(response.token);
229
239
  return response;
230
240
  }
231
- if (response.success && response.message === "OTP sent to your email.") {
241
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
232
242
  return response;
233
243
  }
234
244
  if (response.success && response.message === "OTP verified successfully." && response.token) {
@@ -299,7 +309,7 @@ var AuthService = class {
299
309
  if (!this.token) {
300
310
  throw new Error("Not authenticated");
301
311
  }
302
- const response = await this.httpClient.post("/api/v1/user/update/user", data);
312
+ const response = await this.httpClient.post("/api/v1/user/update/profile", data);
303
313
  if (response.success && response.token) {
304
314
  this.token = response.token;
305
315
  this.httpClient.setAuthToken(response.token);
@@ -340,7 +350,7 @@ var AuthService = class {
340
350
  if (!this.token) {
341
351
  throw new Error("Not authenticated");
342
352
  }
343
- const response = await this.httpClient.post("/api/v1/user/update/avatar", { avatar });
353
+ const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
344
354
  if (response.success && response.token) {
345
355
  this.token = response.token;
346
356
  this.httpClient.setAuthToken(response.token);
@@ -403,21 +413,21 @@ var AuthService = class {
403
413
  if (!this.token) {
404
414
  throw new Error("Not authenticated");
405
415
  }
406
- const response = await this.httpClient.get("/api/v1/session");
416
+ const response = await this.httpClient.get("/api/v1/sessions");
407
417
  return response;
408
418
  }
409
419
  async revokeSession(sessionId) {
410
420
  if (!this.token) {
411
421
  throw new Error("Not authenticated");
412
422
  }
413
- const response = await this.httpClient.delete(`/api/v1/session/${sessionId}`);
423
+ const response = await this.httpClient.delete(`/api/v1/sessions/${sessionId}`);
414
424
  return response;
415
425
  }
416
426
  async revokeAllSessions() {
417
427
  if (!this.token) {
418
428
  throw new Error("Not authenticated");
419
429
  }
420
- const response = await this.httpClient.delete("/api/v1/session/revoke/all");
430
+ const response = await this.httpClient.delete("/api/v1/sessions/revoke/all");
421
431
  this.token = null;
422
432
  this.httpClient.removeAuthToken();
423
433
  this.removeTokenFromStorage();
@@ -466,11 +476,11 @@ var AuthService = class {
466
476
 
467
477
  // src/react/use-auth.ts
468
478
  var useAuth = (config) => {
469
- const [authService] = react.useState(() => new AuthService(config));
470
- const [user, setUser] = react.useState(null);
471
- const [isAuthenticated, setIsAuthenticated] = react.useState(false);
472
- const [loading, setLoading] = react.useState(true);
473
- const checkAuthStatus = react.useCallback(() => {
479
+ const [authService] = React2.useState(() => new AuthService(config));
480
+ const [user, setUser] = React2.useState(null);
481
+ const [isAuthenticated, setIsAuthenticated] = React2.useState(false);
482
+ const [loading, setLoading] = React2.useState(true);
483
+ const checkAuthStatus = React2.useCallback(() => {
474
484
  const authenticated = authService.isAuthenticated();
475
485
  setIsAuthenticated(authenticated);
476
486
  if (authenticated) {
@@ -481,10 +491,10 @@ var useAuth = (config) => {
481
491
  }
482
492
  setLoading(false);
483
493
  }, [authService]);
484
- react.useEffect(() => {
494
+ React2.useEffect(() => {
485
495
  checkAuthStatus();
486
496
  }, [checkAuthStatus]);
487
- const register = react.useCallback(async (data) => {
497
+ const register = React2.useCallback(async (data) => {
488
498
  setLoading(true);
489
499
  try {
490
500
  const response = await authService.register(data);
@@ -493,7 +503,7 @@ var useAuth = (config) => {
493
503
  setLoading(false);
494
504
  }
495
505
  }, [authService]);
496
- const login = react.useCallback(async (data) => {
506
+ const login = React2.useCallback(async (data) => {
497
507
  setLoading(true);
498
508
  try {
499
509
  const response = await authService.login(data);
@@ -506,7 +516,7 @@ var useAuth = (config) => {
506
516
  setLoading(false);
507
517
  }
508
518
  }, [authService]);
509
- const verify = react.useCallback(async (data) => {
519
+ const verify = React2.useCallback(async (data) => {
510
520
  setLoading(true);
511
521
  try {
512
522
  const response = await authService.verify(data);
@@ -519,7 +529,7 @@ var useAuth = (config) => {
519
529
  setLoading(false);
520
530
  }
521
531
  }, [authService]);
522
- const verifyEmailToken = react.useCallback(async (token) => {
532
+ const verifyEmailToken = React2.useCallback(async (token) => {
523
533
  setLoading(true);
524
534
  try {
525
535
  const response = await authService.verifyEmailToken(token);
@@ -532,7 +542,7 @@ var useAuth = (config) => {
532
542
  setLoading(false);
533
543
  }
534
544
  }, [authService]);
535
- const logout = react.useCallback(async () => {
545
+ const logout = React2.useCallback(async () => {
536
546
  setLoading(true);
537
547
  try {
538
548
  await authService.logout();
@@ -542,7 +552,7 @@ var useAuth = (config) => {
542
552
  setLoading(false);
543
553
  }
544
554
  }, [authService]);
545
- const updateProfile = react.useCallback(async (data) => {
555
+ const updateProfile = React2.useCallback(async (data) => {
546
556
  setLoading(true);
547
557
  try {
548
558
  const response = await authService.updateProfile(data);
@@ -554,7 +564,7 @@ var useAuth = (config) => {
554
564
  setLoading(false);
555
565
  }
556
566
  }, [authService]);
557
- const getProfile = react.useCallback(async () => {
567
+ const getProfile = React2.useCallback(async () => {
558
568
  setLoading(true);
559
569
  try {
560
570
  const userData = await authService.getProfile();
@@ -564,7 +574,7 @@ var useAuth = (config) => {
564
574
  setLoading(false);
565
575
  }
566
576
  }, [authService]);
567
- const getAllUsers = react.useCallback(async () => {
577
+ const getAllUsers = React2.useCallback(async () => {
568
578
  setLoading(true);
569
579
  try {
570
580
  return await authService.getAllUsers();
@@ -572,7 +582,7 @@ var useAuth = (config) => {
572
582
  setLoading(false);
573
583
  }
574
584
  }, [authService]);
575
- const getUserById = react.useCallback(async (id) => {
585
+ const getUserById = React2.useCallback(async (id) => {
576
586
  setLoading(true);
577
587
  try {
578
588
  return await authService.getUserById(id);
@@ -595,6 +605,271 @@ var useAuth = (config) => {
595
605
  getUserById
596
606
  };
597
607
  };
608
+ var ThemeContext = React2.createContext({ theme: "light", mounted: false });
609
+ function useAuthTheme() {
610
+ return React2.useContext(ThemeContext);
611
+ }
612
+
613
+ // src/react/hooks/useThemeColors.ts
614
+ var lightTheme = {
615
+ bgPrimary: "var(--auth-bg-primary, #ffffff)",
616
+ bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
617
+ bgHover: "var(--auth-bg-hover, #f1f5f9)",
618
+ textPrimary: "var(--auth-text-primary, #0f172a)",
619
+ textSecondary: "var(--auth-text-secondary, #475569)",
620
+ textTertiary: "var(--auth-text-tertiary, #94a3b8)",
621
+ borderPrimary: "var(--auth-border-primary, #e2e8f0)",
622
+ borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
623
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
624
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
625
+ errorBg: "var(--auth-error-bg, #fef2f2)",
626
+ errorText: "var(--auth-error-text, #dc2626)",
627
+ errorBorder: "var(--auth-error-border, #fecaca)",
628
+ successBg: "var(--auth-success-bg, #f0fdf4)",
629
+ successText: "var(--auth-success-text, #16a34a)",
630
+ successBorder: "var(--auth-success-border, #bbf7d0)"
631
+ };
632
+ var darkTheme = {
633
+ bgPrimary: "var(--auth-bg-primary, #1f2937)",
634
+ bgSecondary: "var(--auth-bg-secondary, #111827)",
635
+ bgHover: "var(--auth-bg-hover, #374151)",
636
+ textPrimary: "var(--auth-text-primary, #f9fafb)",
637
+ textSecondary: "var(--auth-text-secondary, #e5e7eb)",
638
+ textTertiary: "var(--auth-text-tertiary, #d1d5db)",
639
+ borderPrimary: "var(--auth-border-primary, #374151)",
640
+ borderSecondary: "var(--auth-border-secondary, #4b5563)",
641
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
642
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
643
+ errorBg: "var(--auth-error-bg, #7f1d1d)",
644
+ errorText: "var(--auth-error-text, #fecaca)",
645
+ errorBorder: "var(--auth-error-border, #991b1b)",
646
+ successBg: "var(--auth-success-bg, #14532d)",
647
+ successText: "var(--auth-success-text, #bbf7d0)",
648
+ successBorder: "var(--auth-success-border, #166534)"
649
+ };
650
+ function useThemeColors() {
651
+ const { theme } = useAuthTheme();
652
+ return theme === "dark" ? darkTheme : lightTheme;
653
+ }
654
+ var CustomPhoneInput = React2__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
655
+ "input",
656
+ {
657
+ ...props,
658
+ ref,
659
+ className: "PhoneInputInput"
660
+ }
661
+ ));
662
+ CustomPhoneInput.displayName = "CustomPhoneInput";
663
+ var PhoneInput = ({
664
+ value,
665
+ onChange,
666
+ disabled = false,
667
+ required = false,
668
+ placeholder = "Enter phone number",
669
+ id = "phone",
670
+ style = {}
671
+ }) => {
672
+ const colors = useThemeColors();
673
+ const [defaultCountry, setDefaultCountry] = React2.useState("US");
674
+ const styleContent = React2.useMemo(() => `
675
+ .PhoneInput {
676
+ display: flex;
677
+ align-items: center;
678
+ gap: 8px;
679
+ }
680
+
681
+ .PhoneInputCountry {
682
+ position: relative;
683
+ align-self: stretch;
684
+ display: flex;
685
+ align-items: center;
686
+ padding: 0 8px;
687
+ border: 1px solid ${colors.borderSecondary};
688
+ border-radius: 8px;
689
+ background-color: ${colors.bgSecondary};
690
+ transition: all 0.2s ease;
691
+ }
692
+
693
+ .PhoneInputCountry:focus-within {
694
+ border-color: ${colors.buttonPrimary};
695
+ outline: 2px solid ${colors.buttonPrimary}40;
696
+ }
697
+
698
+ .PhoneInputCountryIcon {
699
+ width: 24px;
700
+ height: 24px;
701
+ margin-right: 4px;
702
+ }
703
+
704
+ .PhoneInputCountryIcon--border {
705
+ box-shadow: none;
706
+ }
707
+
708
+ .PhoneInputCountrySelect {
709
+ position: absolute;
710
+ top: 0;
711
+ left: 0;
712
+ height: 100%;
713
+ width: 100%;
714
+ z-index: 1;
715
+ border: 0;
716
+ opacity: 0;
717
+ cursor: pointer;
718
+ color: ${colors.textPrimary};
719
+ background-color: ${colors.bgSecondary};
720
+ }
721
+
722
+ .PhoneInputCountrySelect:disabled {
723
+ cursor: not-allowed;
724
+ }
725
+
726
+ /* Dropdown menu styling */
727
+ .PhoneInputCountrySelect option {
728
+ background-color: ${colors.bgPrimary};
729
+ color: ${colors.textPrimary};
730
+ padding: 8px 12px;
731
+ font-size: 14px;
732
+ }
733
+
734
+ .PhoneInputCountrySelect option:hover,
735
+ .PhoneInputCountrySelect option:focus,
736
+ .PhoneInputCountrySelect option:checked {
737
+ background-color: ${colors.buttonPrimary};
738
+ color: white;
739
+ }
740
+
741
+ .PhoneInputCountrySelectArrow {
742
+ display: block;
743
+ content: '';
744
+ width: 0.3em;
745
+ height: 0.3em;
746
+ margin-left: 0.35em;
747
+ border-style: solid;
748
+ border-color: ${colors.textPrimary};
749
+ border-top-width: 0;
750
+ border-bottom-width: 1px;
751
+ border-left-width: 0;
752
+ border-right-width: 1px;
753
+ transform: rotate(45deg);
754
+ opacity: 0.7;
755
+ }
756
+
757
+ .PhoneInputInput {
758
+ flex: 1;
759
+ min-width: 0;
760
+ padding: 12px 16px;
761
+ border: 1px solid ${colors.borderSecondary};
762
+ border-radius: 8px;
763
+ font-size: 16px;
764
+ background-color: ${colors.bgSecondary};
765
+ color: ${colors.textPrimary};
766
+ transition: all 0.2s ease;
767
+ -webkit-text-fill-color: ${colors.textPrimary};
768
+ -webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
769
+ }
770
+
771
+ .PhoneInputInput:focus {
772
+ border-color: ${colors.buttonPrimary};
773
+ outline: 2px solid ${colors.buttonPrimary}40;
774
+ }
775
+
776
+ .PhoneInputInput:disabled {
777
+ cursor: not-allowed;
778
+ opacity: 0.6;
779
+ }
780
+
781
+ .PhoneInputInput::placeholder {
782
+ color: ${colors.textTertiary};
783
+ opacity: 0.6;
784
+ }
785
+ `, [colors]);
786
+ React2.useEffect(() => {
787
+ const detectCountry = async () => {
788
+ try {
789
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
790
+ const timezoneToCountry = {
791
+ "America/New_York": "US",
792
+ "America/Chicago": "US",
793
+ "America/Denver": "US",
794
+ "America/Los_Angeles": "US",
795
+ "America/Phoenix": "US",
796
+ "America/Anchorage": "US",
797
+ "Pacific/Honolulu": "US",
798
+ "Europe/London": "GB",
799
+ "Europe/Paris": "FR",
800
+ "Europe/Berlin": "DE",
801
+ "Europe/Rome": "IT",
802
+ "Europe/Madrid": "ES",
803
+ "Asia/Dubai": "AE",
804
+ "Asia/Kolkata": "IN",
805
+ "Asia/Shanghai": "CN",
806
+ "Asia/Tokyo": "JP",
807
+ "Asia/Seoul": "KR",
808
+ "Asia/Singapore": "SG",
809
+ "Asia/Hong_Kong": "HK",
810
+ "Australia/Sydney": "AU",
811
+ "Pacific/Auckland": "NZ",
812
+ "America/Toronto": "CA",
813
+ "America/Vancouver": "CA",
814
+ "America/Mexico_City": "MX",
815
+ "America/Sao_Paulo": "BR",
816
+ "America/Buenos_Aires": "AR",
817
+ "Africa/Cairo": "EG",
818
+ "Africa/Johannesburg": "ZA",
819
+ "Africa/Lagos": "NG",
820
+ "Africa/Nairobi": "KE"
821
+ };
822
+ const detectedCountry = timezoneToCountry[timezone];
823
+ if (detectedCountry) {
824
+ setDefaultCountry(detectedCountry);
825
+ return;
826
+ }
827
+ const response = await fetch("https://ipapi.co/json/", {
828
+ signal: AbortSignal.timeout(3e3)
829
+ // 3 second timeout
830
+ });
831
+ if (response.ok) {
832
+ const data = await response.json();
833
+ if (data.country_code) {
834
+ setDefaultCountry(data.country_code);
835
+ }
836
+ }
837
+ } catch (error) {
838
+ console.log("Country detection failed, using default US");
839
+ }
840
+ };
841
+ detectCountry();
842
+ }, []);
843
+ const handleChange = React2.useMemo(() => (val) => {
844
+ onChange(val || "");
845
+ }, [onChange]);
846
+ return /* @__PURE__ */ jsxRuntime.jsxs(
847
+ "div",
848
+ {
849
+ style: {
850
+ width: "100%",
851
+ ...style
852
+ },
853
+ children: [
854
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: styleContent }),
855
+ /* @__PURE__ */ jsxRuntime.jsx(
856
+ PhoneInputWithCountry__default.default,
857
+ {
858
+ id,
859
+ international: true,
860
+ defaultCountry,
861
+ value: value || "",
862
+ onChange: handleChange,
863
+ disabled,
864
+ placeholder,
865
+ inputComponent: CustomPhoneInput
866
+ },
867
+ id
868
+ )
869
+ ]
870
+ }
871
+ );
872
+ };
598
873
  var LoginForm = ({
599
874
  onSuccess,
600
875
  onLoginSuccess,
@@ -604,15 +879,18 @@ var LoginForm = ({
604
879
  oauthProviders = ["google", "github"],
605
880
  showOAuthButtons = true
606
881
  }) => {
607
- const [email, setEmail] = react.useState("");
608
- const [password, setPassword] = react.useState("");
609
- const [usePassword, setUsePassword] = react.useState(false);
610
- const [showPassword, setShowPassword] = react.useState(false);
611
- const [isLoading, setIsLoading] = react.useState(false);
612
- const [error, setError] = react.useState(null);
613
- const [rememberMe, setRememberMe] = react.useState(false);
882
+ const colors = useThemeColors();
883
+ const [email, setEmail] = React2.useState("");
884
+ const [phoneNumber, setPhoneNumber] = React2.useState("");
885
+ const [usePhone, setUsePhone] = React2.useState(false);
886
+ const [password, setPassword] = React2.useState("");
887
+ const [usePassword, setUsePassword] = React2.useState(false);
888
+ const [showPassword, setShowPassword] = React2.useState(false);
889
+ const [isLoading, setIsLoading] = React2.useState(false);
890
+ const [error, setError] = React2.useState(null);
891
+ const [rememberMe, setRememberMe] = React2.useState(false);
614
892
  const { login } = useAuth({
615
- baseUrl: config?.baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
893
+ baseUrl: config?.baseUrl || "http://localhost:7000"
616
894
  });
617
895
  const handleSubmit = async (e) => {
618
896
  e.preventDefault();
@@ -620,20 +898,28 @@ var LoginForm = ({
620
898
  setError(null);
621
899
  try {
622
900
  let response;
901
+ const loginData = {};
902
+ if (usePhone && phoneNumber) {
903
+ loginData.phoneNumber = phoneNumber;
904
+ } else if (email) {
905
+ loginData.email = email;
906
+ }
623
907
  if (usePassword) {
624
- response = await login({ email, password });
908
+ loginData.password = password;
909
+ response = await login(loginData);
625
910
  } else {
626
- response = await login({ email });
911
+ response = await login(loginData);
627
912
  }
628
913
  if (response.success) {
629
914
  onSuccess?.(response);
630
915
  if (onLoginSuccess) {
631
- if (response.message === "OTP sent to your email.") {
632
- onLoginSuccess(email, true);
916
+ const identifier = usePhone ? phoneNumber : email;
917
+ if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
918
+ onLoginSuccess(identifier, true);
633
919
  } else if (response.token) {
634
- onLoginSuccess(email, false);
920
+ onLoginSuccess(identifier, false);
635
921
  } else {
636
- onLoginSuccess(email, true);
922
+ onLoginSuccess(identifier, true);
637
923
  }
638
924
  }
639
925
  } else {
@@ -655,43 +941,53 @@ var LoginForm = ({
655
941
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
656
942
  maxWidth: "400px",
657
943
  margin: "0 auto",
658
- padding: "30px",
944
+ padding: "24px",
659
945
  borderRadius: "12px",
660
946
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
661
- backgroundColor: "#ffffff",
662
- border: "1px solid #eaeaea"
947
+ backgroundColor: colors.bgPrimary,
948
+ border: `1px solid ${colors.borderPrimary}`
663
949
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
664
950
  display: "flex",
665
951
  flexDirection: "column"
666
952
  }, children: [
667
953
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
668
954
  textAlign: "center",
669
- marginBottom: "24px",
670
- color: "#1f2937",
955
+ marginBottom: "20px",
956
+ color: colors.textPrimary,
671
957
  fontSize: "24px",
672
958
  fontWeight: 600
673
959
  }, children: usePassword ? "Login with Password" : "Login with OTP" }),
674
960
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
675
961
  padding: "12px 16px",
676
- marginBottom: "20px",
677
- backgroundColor: "#f8d7da",
678
- color: "#721c24",
679
- border: "1px solid #f5c6cb",
962
+ marginBottom: "16px",
963
+ backgroundColor: colors.errorBg,
964
+ color: colors.errorText,
965
+ border: `1px solid ${colors.errorBorder}`,
680
966
  borderRadius: "8px",
681
967
  fontSize: "14px",
682
968
  fontWeight: 500
683
969
  }, children: error }),
684
970
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
685
- marginBottom: "20px"
971
+ marginBottom: "16px"
686
972
  }, children: [
687
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
973
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
688
974
  display: "block",
689
975
  marginBottom: "8px",
690
976
  fontWeight: 500,
691
- color: "#374151",
977
+ color: colors.textSecondary,
692
978
  fontSize: "14px"
693
- }, children: "Email:" }),
694
- /* @__PURE__ */ jsxRuntime.jsx(
979
+ }, children: usePhone ? "Phone Number:" : "Email:" }),
980
+ usePhone ? /* @__PURE__ */ jsxRuntime.jsx(
981
+ PhoneInput,
982
+ {
983
+ id: "phone",
984
+ value: phoneNumber,
985
+ onChange: setPhoneNumber,
986
+ required: true,
987
+ disabled: isLoading,
988
+ placeholder: "1234567890"
989
+ }
990
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
695
991
  "input",
696
992
  {
697
993
  id: "email",
@@ -703,27 +999,48 @@ var LoginForm = ({
703
999
  style: {
704
1000
  width: "100%",
705
1001
  padding: "12px 16px",
706
- border: "1px solid #ddd",
1002
+ border: `1px solid ${colors.borderSecondary}`,
707
1003
  borderRadius: "8px",
708
1004
  fontSize: "16px",
709
1005
  boxSizing: "border-box",
710
- color: "#111827",
1006
+ color: colors.textPrimary,
711
1007
  transition: "all 0.2s ease",
712
- backgroundColor: "#ffffff"
1008
+ backgroundColor: colors.bgSecondary
713
1009
  },
714
1010
  placeholder: "Enter your email"
715
1011
  }
1012
+ ),
1013
+ /* @__PURE__ */ jsxRuntime.jsx(
1014
+ "button",
1015
+ {
1016
+ type: "button",
1017
+ onClick: () => setUsePhone(!usePhone),
1018
+ disabled: isLoading,
1019
+ style: {
1020
+ marginTop: "8px",
1021
+ background: "none",
1022
+ border: "none",
1023
+ color: colors.buttonPrimary,
1024
+ textDecoration: "none",
1025
+ cursor: "pointer",
1026
+ fontSize: "13px",
1027
+ fontWeight: 500,
1028
+ padding: "0",
1029
+ transition: "color 0.2s ease"
1030
+ },
1031
+ children: usePhone ? "Use email instead" : "Use phone number instead"
1032
+ }
716
1033
  )
717
1034
  ] }),
718
1035
  usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
719
- marginBottom: "20px",
1036
+ marginBottom: "16px",
720
1037
  position: "relative"
721
1038
  }, children: [
722
1039
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "login-password", style: {
723
1040
  display: "block",
724
1041
  marginBottom: "8px",
725
1042
  fontWeight: 500,
726
- color: "#555",
1043
+ color: colors.textSecondary,
727
1044
  fontSize: "14px"
728
1045
  }, children: "Password:" }),
729
1046
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -738,13 +1055,13 @@ var LoginForm = ({
738
1055
  style: {
739
1056
  width: "100%",
740
1057
  padding: "12px 16px",
741
- border: "1px solid #ddd",
1058
+ border: `1px solid ${colors.borderSecondary}`,
742
1059
  borderRadius: "8px",
743
1060
  fontSize: "16px",
744
1061
  boxSizing: "border-box",
745
- color: "#333",
1062
+ color: colors.textPrimary,
746
1063
  transition: "all 0.2s ease",
747
- backgroundColor: "#fafafa"
1064
+ backgroundColor: colors.bgSecondary
748
1065
  },
749
1066
  placeholder: "Enter your password"
750
1067
  }
@@ -762,7 +1079,7 @@ var LoginForm = ({
762
1079
  background: "none",
763
1080
  border: "none",
764
1081
  cursor: "pointer",
765
- color: "#666",
1082
+ color: colors.textTertiary,
766
1083
  fontSize: "14px"
767
1084
  },
768
1085
  children: showPassword ? "Hide" : "Show"
@@ -772,8 +1089,8 @@ var LoginForm = ({
772
1089
  usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
773
1090
  display: "flex",
774
1091
  alignItems: "center",
775
- marginBottom: "16px",
776
- marginTop: "8px"
1092
+ marginBottom: "12px",
1093
+ marginTop: "4px"
777
1094
  }, children: [
778
1095
  /* @__PURE__ */ jsxRuntime.jsx(
779
1096
  "input",
@@ -797,7 +1114,7 @@ var LoginForm = ({
797
1114
  htmlFor: "remember-me",
798
1115
  style: {
799
1116
  fontSize: "14px",
800
- color: "#666",
1117
+ color: colors.textSecondary,
801
1118
  cursor: "pointer",
802
1119
  userSelect: "none"
803
1120
  },
@@ -812,7 +1129,7 @@ var LoginForm = ({
812
1129
  disabled: isLoading,
813
1130
  style: {
814
1131
  padding: "14px",
815
- backgroundColor: "#007bff",
1132
+ backgroundColor: colors.buttonPrimary,
816
1133
  color: "white",
817
1134
  border: "none",
818
1135
  borderRadius: "8px",
@@ -820,16 +1137,16 @@ var LoginForm = ({
820
1137
  fontWeight: 600,
821
1138
  cursor: "pointer",
822
1139
  transition: "all 0.2s ease",
823
- marginTop: "8px"
1140
+ marginTop: "4px"
824
1141
  },
825
1142
  children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
826
1143
  }
827
1144
  ),
828
1145
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
829
1146
  textAlign: "center",
830
- marginTop: "20px",
831
- paddingTop: "20px",
832
- borderTop: "1px solid #eee"
1147
+ marginTop: "16px",
1148
+ paddingTop: "16px",
1149
+ borderTop: `1px solid ${colors.borderPrimary}`
833
1150
  }, children: /* @__PURE__ */ jsxRuntime.jsx(
834
1151
  "button",
835
1152
  {
@@ -839,7 +1156,7 @@ var LoginForm = ({
839
1156
  style: {
840
1157
  background: "none",
841
1158
  border: "none",
842
- color: "#007bff",
1159
+ color: colors.buttonPrimary,
843
1160
  textDecoration: "none",
844
1161
  cursor: "pointer",
845
1162
  fontSize: "14px",
@@ -851,9 +1168,9 @@ var LoginForm = ({
851
1168
  }
852
1169
  ) }),
853
1170
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
854
- marginTop: "20px",
855
- paddingTop: "20px",
856
- borderTop: "1px solid #eee"
1171
+ marginTop: "16px",
1172
+ paddingTop: "16px",
1173
+ borderTop: `1px solid ${colors.borderPrimary}`
857
1174
  }, children: [
858
1175
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
859
1176
  position: "relative",
@@ -865,15 +1182,15 @@ var LoginForm = ({
865
1182
  left: 0,
866
1183
  right: 0,
867
1184
  height: "1px",
868
- backgroundColor: "#eee"
1185
+ backgroundColor: colors.borderPrimary
869
1186
  } }),
870
1187
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
871
1188
  position: "relative",
872
1189
  textAlign: "center"
873
1190
  }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
874
- backgroundColor: "#ffffff",
1191
+ backgroundColor: colors.bgPrimary,
875
1192
  padding: "0 12px",
876
- color: "#666",
1193
+ color: colors.textSecondary,
877
1194
  fontSize: "14px"
878
1195
  }, children: "Or continue with" }) })
879
1196
  ] }),
@@ -892,10 +1209,10 @@ var LoginForm = ({
892
1209
  justifyContent: "center",
893
1210
  gap: "8px",
894
1211
  padding: "10px 16px",
895
- backgroundColor: "#ffffff",
896
- border: "1px solid #ddd",
1212
+ backgroundColor: colors.bgPrimary,
1213
+ border: `1px solid ${colors.borderSecondary}`,
897
1214
  borderRadius: "8px",
898
- color: "#333",
1215
+ color: colors.textPrimary,
899
1216
  textDecoration: "none",
900
1217
  fontSize: "14px",
901
1218
  fontWeight: 500,
@@ -903,12 +1220,12 @@ var LoginForm = ({
903
1220
  transition: "all 0.2s ease"
904
1221
  },
905
1222
  onMouseEnter: (e) => {
906
- e.currentTarget.style.backgroundColor = "#f8f8f8";
907
- e.currentTarget.style.borderColor = "#007bff";
1223
+ e.currentTarget.style.backgroundColor = colors.bgHover;
1224
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
908
1225
  },
909
1226
  onMouseLeave: (e) => {
910
- e.currentTarget.style.backgroundColor = "#ffffff";
911
- e.currentTarget.style.borderColor = "#ddd";
1227
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
1228
+ e.currentTarget.style.borderColor = colors.borderSecondary;
912
1229
  },
913
1230
  children: [
914
1231
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -983,11 +1300,11 @@ var LoginForm = ({
983
1300
  ] }),
984
1301
  showRegisterLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
985
1302
  textAlign: "center",
986
- marginTop: "20px",
987
- paddingTop: "20px",
988
- borderTop: "1px solid #eee"
1303
+ marginTop: "16px",
1304
+ paddingTop: "16px",
1305
+ borderTop: `1px solid ${colors.borderPrimary}`
989
1306
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
990
- color: "#666",
1307
+ color: colors.textSecondary,
991
1308
  fontSize: "14px"
992
1309
  }, children: [
993
1310
  "Don't have an account?",
@@ -1001,7 +1318,7 @@ var LoginForm = ({
1001
1318
  style: {
1002
1319
  background: "none",
1003
1320
  border: "none",
1004
- color: "#007bff",
1321
+ color: colors.buttonPrimary,
1005
1322
  textDecoration: "none",
1006
1323
  cursor: "pointer",
1007
1324
  fontSize: "14px",
@@ -1021,16 +1338,19 @@ var RegisterForm = ({
1021
1338
  showLoginLink = true,
1022
1339
  authConfig,
1023
1340
  oauthProviders = ["google", "github"],
1024
- showOAuthButtons = true
1341
+ showOAuthButtons = true,
1342
+ invitationToken
1025
1343
  }) => {
1026
- const [name, setName] = react.useState("");
1027
- const [email, setEmail] = react.useState("");
1028
- const [password, setPassword] = react.useState("");
1029
- const [confirmPassword, setConfirmPassword] = react.useState("");
1030
- const [isLoading, setIsLoading] = react.useState(false);
1031
- const [error, setError] = react.useState(null);
1032
- react.useState(false);
1033
- react.useState(false);
1344
+ const colors = useThemeColors();
1345
+ const [name, setName] = React2.useState("");
1346
+ const [email, setEmail] = React2.useState("");
1347
+ const [phoneNumber, setPhoneNumber] = React2.useState("");
1348
+ const [password, setPassword] = React2.useState("");
1349
+ const [confirmPassword, setConfirmPassword] = React2.useState("");
1350
+ const [isLoading, setIsLoading] = React2.useState(false);
1351
+ const [error, setError] = React2.useState(null);
1352
+ React2.useState(false);
1353
+ React2.useState(false);
1034
1354
  const getPasswordStrength = (pwd) => {
1035
1355
  if (!pwd)
1036
1356
  return { strength: "weak", score: 0, label: "" };
@@ -1053,7 +1373,7 @@ var RegisterForm = ({
1053
1373
  };
1054
1374
  getPasswordStrength(password);
1055
1375
  const config = authConfig || {
1056
- baseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || window.location.origin : "http://localhost:7000"
1376
+ baseUrl: "http://localhost:7000"
1057
1377
  };
1058
1378
  const { register } = useAuth(config);
1059
1379
  const handleSubmit = async (e) => {
@@ -1071,17 +1391,45 @@ var RegisterForm = ({
1071
1391
  return;
1072
1392
  }
1073
1393
  try {
1074
- const registerData = {
1075
- name,
1076
- email,
1077
- password,
1078
- frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1079
- };
1080
- const response = await register(registerData);
1081
- if (response.success) {
1082
- onRegisterSuccess?.();
1394
+ if (invitationToken) {
1395
+ const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
1396
+ method: "POST",
1397
+ headers: {
1398
+ "Content-Type": "application/json"
1399
+ },
1400
+ body: JSON.stringify({
1401
+ name,
1402
+ email,
1403
+ password,
1404
+ phoneNumber: phoneNumber || void 0,
1405
+ invitationToken
1406
+ })
1407
+ });
1408
+ const data = await response.json();
1409
+ if (response.ok && data.success) {
1410
+ if (typeof window !== "undefined" && data.token) {
1411
+ localStorage.setItem("auth_token", data.token);
1412
+ }
1413
+ onRegisterSuccess?.();
1414
+ } else {
1415
+ setError(data.error || data.message || "Registration failed");
1416
+ }
1083
1417
  } else {
1084
- setError(response.message || "Registration failed");
1418
+ const registerData = {
1419
+ name,
1420
+ password,
1421
+ frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1422
+ };
1423
+ if (email)
1424
+ registerData.email = email;
1425
+ if (phoneNumber)
1426
+ registerData.phoneNumber = phoneNumber;
1427
+ const response = await register(registerData);
1428
+ if (response.success) {
1429
+ onRegisterSuccess?.();
1430
+ } else {
1431
+ setError(response.message || "Registration failed");
1432
+ }
1085
1433
  }
1086
1434
  } catch (err) {
1087
1435
  setError(err instanceof Error ? err.message : "An unknown error occurred");
@@ -1092,40 +1440,40 @@ var RegisterForm = ({
1092
1440
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1093
1441
  maxWidth: "400px",
1094
1442
  margin: "0 auto",
1095
- padding: "30px",
1443
+ padding: "24px",
1096
1444
  borderRadius: "12px",
1097
1445
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1098
- backgroundColor: "#ffffff",
1099
- border: "1px solid #eaeaea"
1446
+ backgroundColor: colors.bgPrimary,
1447
+ border: `1px solid ${colors.borderPrimary}`
1100
1448
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
1101
1449
  display: "flex",
1102
1450
  flexDirection: "column"
1103
1451
  }, children: [
1104
1452
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
1105
1453
  textAlign: "center",
1106
- marginBottom: "24px",
1107
- color: "#1f2937",
1454
+ marginBottom: "20px",
1455
+ color: colors.textPrimary,
1108
1456
  fontSize: "24px",
1109
1457
  fontWeight: 600
1110
1458
  }, children: "Register" }),
1111
1459
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1112
1460
  padding: "12px 16px",
1113
- marginBottom: "20px",
1114
- backgroundColor: "#f8d7da",
1115
- color: "#721c24",
1116
- border: "1px solid #f5c6cb",
1461
+ marginBottom: "16px",
1462
+ backgroundColor: colors.errorBg,
1463
+ color: colors.errorText,
1464
+ border: `1px solid ${colors.errorBorder}`,
1117
1465
  borderRadius: "8px",
1118
1466
  fontSize: "14px",
1119
1467
  fontWeight: 500
1120
1468
  }, children: error }),
1121
1469
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1122
- marginBottom: "20px"
1470
+ marginBottom: "16px"
1123
1471
  }, children: [
1124
1472
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
1125
1473
  display: "block",
1126
1474
  marginBottom: "8px",
1127
1475
  fontWeight: 500,
1128
- color: "#374151",
1476
+ color: colors.textSecondary,
1129
1477
  fontSize: "14px"
1130
1478
  }, children: "Name:" }),
1131
1479
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1140,26 +1488,26 @@ var RegisterForm = ({
1140
1488
  style: {
1141
1489
  width: "100%",
1142
1490
  padding: "12px 16px",
1143
- border: "1px solid #ddd",
1491
+ border: `1px solid ${colors.borderSecondary}`,
1144
1492
  borderRadius: "8px",
1145
1493
  fontSize: "16px",
1146
1494
  boxSizing: "border-box",
1147
- color: "#111827",
1495
+ color: colors.textPrimary,
1148
1496
  transition: "all 0.2s ease",
1149
- backgroundColor: "#ffffff"
1497
+ backgroundColor: colors.bgSecondary
1150
1498
  },
1151
1499
  placeholder: "Enter your name"
1152
1500
  }
1153
1501
  )
1154
1502
  ] }),
1155
1503
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1156
- marginBottom: "20px"
1504
+ marginBottom: "16px"
1157
1505
  }, children: [
1158
1506
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-email", style: {
1159
1507
  display: "block",
1160
1508
  marginBottom: "8px",
1161
1509
  fontWeight: 500,
1162
- color: "#555",
1510
+ color: colors.textSecondary,
1163
1511
  fontSize: "14px"
1164
1512
  }, children: "Email:" }),
1165
1513
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1169,31 +1517,52 @@ var RegisterForm = ({
1169
1517
  type: "email",
1170
1518
  value: email,
1171
1519
  onChange: (e) => setEmail(e.target.value),
1172
- required: true,
1520
+ required: !phoneNumber,
1173
1521
  disabled: isLoading,
1174
1522
  style: {
1175
1523
  width: "100%",
1176
1524
  padding: "12px 16px",
1177
- border: "1px solid #ddd",
1525
+ border: `1px solid ${colors.borderSecondary}`,
1178
1526
  borderRadius: "8px",
1179
1527
  fontSize: "16px",
1180
1528
  boxSizing: "border-box",
1181
- color: "#333",
1529
+ color: colors.textPrimary,
1182
1530
  transition: "all 0.2s ease",
1183
- backgroundColor: "#fafafa"
1531
+ backgroundColor: colors.bgSecondary
1184
1532
  },
1185
1533
  placeholder: "Enter your email"
1186
1534
  }
1187
1535
  )
1188
1536
  ] }),
1189
1537
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1190
- marginBottom: "20px"
1538
+ marginBottom: "16px"
1539
+ }, children: [
1540
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-phone", style: {
1541
+ display: "block",
1542
+ marginBottom: "8px",
1543
+ fontWeight: 500,
1544
+ color: colors.textSecondary,
1545
+ fontSize: "14px"
1546
+ }, children: "Phone Number (Optional):" }),
1547
+ /* @__PURE__ */ jsxRuntime.jsx(
1548
+ PhoneInput,
1549
+ {
1550
+ id: "register-phone",
1551
+ value: phoneNumber,
1552
+ onChange: setPhoneNumber,
1553
+ disabled: isLoading,
1554
+ placeholder: "1234567890"
1555
+ }
1556
+ )
1557
+ ] }),
1558
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1559
+ marginBottom: "16px"
1191
1560
  }, children: [
1192
1561
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
1193
1562
  display: "block",
1194
1563
  marginBottom: "8px",
1195
1564
  fontWeight: 500,
1196
- color: "#555",
1565
+ color: colors.textSecondary,
1197
1566
  fontSize: "14px"
1198
1567
  }, children: "Password:" }),
1199
1568
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1208,13 +1577,13 @@ var RegisterForm = ({
1208
1577
  style: {
1209
1578
  width: "100%",
1210
1579
  padding: "12px 16px",
1211
- border: "1px solid #ddd",
1580
+ border: `1px solid ${colors.borderSecondary}`,
1212
1581
  borderRadius: "8px",
1213
1582
  fontSize: "16px",
1214
1583
  boxSizing: "border-box",
1215
- color: "#333",
1584
+ color: colors.textPrimary,
1216
1585
  transition: "all 0.2s ease",
1217
- backgroundColor: "#fafafa"
1586
+ backgroundColor: colors.bgSecondary
1218
1587
  },
1219
1588
  placeholder: "Enter your password",
1220
1589
  minLength: 6
@@ -1222,13 +1591,13 @@ var RegisterForm = ({
1222
1591
  )
1223
1592
  ] }),
1224
1593
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1225
- marginBottom: "20px"
1594
+ marginBottom: "16px"
1226
1595
  }, children: [
1227
1596
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirm-password", style: {
1228
1597
  display: "block",
1229
1598
  marginBottom: "8px",
1230
1599
  fontWeight: 500,
1231
- color: "#555",
1600
+ color: colors.textSecondary,
1232
1601
  fontSize: "14px"
1233
1602
  }, children: "Confirm Password:" }),
1234
1603
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1243,13 +1612,13 @@ var RegisterForm = ({
1243
1612
  style: {
1244
1613
  width: "100%",
1245
1614
  padding: "12px 16px",
1246
- border: "1px solid #ddd",
1615
+ border: `1px solid ${colors.borderSecondary}`,
1247
1616
  borderRadius: "8px",
1248
1617
  fontSize: "16px",
1249
1618
  boxSizing: "border-box",
1250
- color: "#333",
1619
+ color: colors.textPrimary,
1251
1620
  transition: "all 0.2s ease",
1252
- backgroundColor: "#fafafa"
1621
+ backgroundColor: colors.bgSecondary
1253
1622
  },
1254
1623
  placeholder: "Confirm your password"
1255
1624
  }
@@ -1262,7 +1631,7 @@ var RegisterForm = ({
1262
1631
  disabled: isLoading,
1263
1632
  style: {
1264
1633
  padding: "14px",
1265
- backgroundColor: "#007bff",
1634
+ backgroundColor: colors.buttonPrimary,
1266
1635
  color: "white",
1267
1636
  border: "none",
1268
1637
  borderRadius: "8px",
@@ -1270,15 +1639,15 @@ var RegisterForm = ({
1270
1639
  fontWeight: 600,
1271
1640
  cursor: "pointer",
1272
1641
  transition: "all 0.2s ease",
1273
- marginTop: "8px"
1642
+ marginTop: "4px"
1274
1643
  },
1275
1644
  children: isLoading ? "Registering..." : "Register"
1276
1645
  }
1277
1646
  ),
1278
1647
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1279
- marginTop: "20px",
1280
- paddingTop: "20px",
1281
- borderTop: "1px solid #eee"
1648
+ marginTop: "16px",
1649
+ paddingTop: "16px",
1650
+ borderTop: `1px solid ${colors.borderPrimary}`
1282
1651
  }, children: [
1283
1652
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
1284
1653
  position: "relative",
@@ -1290,15 +1659,15 @@ var RegisterForm = ({
1290
1659
  left: 0,
1291
1660
  right: 0,
1292
1661
  height: "1px",
1293
- backgroundColor: "#eee"
1662
+ backgroundColor: colors.borderPrimary
1294
1663
  } }),
1295
1664
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1296
1665
  position: "relative",
1297
1666
  textAlign: "center"
1298
1667
  }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
1299
- backgroundColor: "#ffffff",
1668
+ backgroundColor: colors.bgPrimary,
1300
1669
  padding: "0 12px",
1301
- color: "#666",
1670
+ color: colors.textSecondary,
1302
1671
  fontSize: "14px"
1303
1672
  }, children: "Or continue with" }) })
1304
1673
  ] }),
@@ -1317,10 +1686,10 @@ var RegisterForm = ({
1317
1686
  justifyContent: "center",
1318
1687
  gap: "8px",
1319
1688
  padding: "10px 16px",
1320
- backgroundColor: "#ffffff",
1321
- border: "1px solid #ddd",
1689
+ backgroundColor: colors.bgPrimary,
1690
+ border: `1px solid ${colors.borderSecondary}`,
1322
1691
  borderRadius: "8px",
1323
- color: "#333",
1692
+ color: colors.textPrimary,
1324
1693
  textDecoration: "none",
1325
1694
  fontSize: "14px",
1326
1695
  fontWeight: 500,
@@ -1328,12 +1697,12 @@ var RegisterForm = ({
1328
1697
  transition: "all 0.2s ease"
1329
1698
  },
1330
1699
  onMouseEnter: (e) => {
1331
- e.currentTarget.style.backgroundColor = "#f8f8f8";
1332
- e.currentTarget.style.borderColor = "#007bff";
1700
+ e.currentTarget.style.backgroundColor = colors.bgHover;
1701
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
1333
1702
  },
1334
1703
  onMouseLeave: (e) => {
1335
- e.currentTarget.style.backgroundColor = "#ffffff";
1336
- e.currentTarget.style.borderColor = "#ddd";
1704
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
1705
+ e.currentTarget.style.borderColor = colors.borderSecondary;
1337
1706
  },
1338
1707
  children: [
1339
1708
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -1408,11 +1777,11 @@ var RegisterForm = ({
1408
1777
  ] }),
1409
1778
  showLoginLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1410
1779
  textAlign: "center",
1411
- marginTop: "20px",
1412
- paddingTop: "20px",
1413
- borderTop: "1px solid #eee"
1780
+ marginTop: "16px",
1781
+ paddingTop: "16px",
1782
+ borderTop: `1px solid ${colors.borderPrimary}`
1414
1783
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
1415
- color: "#666",
1784
+ color: colors.textSecondary,
1416
1785
  fontSize: "14px"
1417
1786
  }, children: [
1418
1787
  "Already have an account?",
@@ -1426,7 +1795,7 @@ var RegisterForm = ({
1426
1795
  style: {
1427
1796
  background: "none",
1428
1797
  border: "none",
1429
- color: "#007bff",
1798
+ color: colors.buttonPrimary,
1430
1799
  textDecoration: "none",
1431
1800
  cursor: "pointer",
1432
1801
  fontSize: "14px",
@@ -1443,15 +1812,17 @@ var RegisterForm = ({
1443
1812
  var OtpForm = ({
1444
1813
  email,
1445
1814
  onVerifySuccess,
1446
- onBackToLogin
1815
+ onBackToLogin,
1816
+ baseUrl
1447
1817
  }) => {
1448
- const [otp, setOtp] = react.useState("");
1449
- const [isLoading, setIsLoading] = react.useState(false);
1450
- const [error, setError] = react.useState(null);
1451
- const [resendCooldown, setResendCooldown] = react.useState(0);
1452
- const [resendLoading, setResendLoading] = react.useState(false);
1818
+ const colors = useThemeColors();
1819
+ const [otp, setOtp] = React2.useState("");
1820
+ const [isLoading, setIsLoading] = React2.useState(false);
1821
+ const [error, setError] = React2.useState(null);
1822
+ const [resendCooldown, setResendCooldown] = React2.useState(0);
1823
+ const [resendLoading, setResendLoading] = React2.useState(false);
1453
1824
  const { verify, login } = useAuth({
1454
- baseUrl: typeof window !== "undefined" ? window.location.origin : "http://localhost:7000"
1825
+ baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
1455
1826
  });
1456
1827
  const handleSubmit = async (e) => {
1457
1828
  e.preventDefault();
@@ -1514,8 +1885,8 @@ var OtpForm = ({
1514
1885
  padding: "30px",
1515
1886
  borderRadius: "12px",
1516
1887
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1517
- backgroundColor: "#ffffff",
1518
- border: "1px solid #eaeaea"
1888
+ backgroundColor: colors.bgPrimary,
1889
+ border: `1px solid ${colors.borderPrimary}`
1519
1890
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
1520
1891
  display: "flex",
1521
1892
  flexDirection: "column"
@@ -1523,25 +1894,25 @@ var OtpForm = ({
1523
1894
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
1524
1895
  textAlign: "center",
1525
1896
  marginBottom: "24px",
1526
- color: "#1f2937",
1897
+ color: colors.textPrimary,
1527
1898
  fontSize: "24px",
1528
1899
  fontWeight: 600
1529
1900
  }, children: "Verify OTP" }),
1530
1901
  /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
1531
1902
  textAlign: "center",
1532
1903
  marginBottom: "24px",
1533
- color: "#4b5563",
1904
+ color: colors.textSecondary,
1534
1905
  fontSize: "14px"
1535
1906
  }, children: [
1536
1907
  "Enter the 6-digit code sent to ",
1537
- /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: "#111827" }, children: email })
1908
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: colors.textPrimary }, children: email })
1538
1909
  ] }),
1539
1910
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1540
1911
  padding: "12px 16px",
1541
1912
  marginBottom: "20px",
1542
- backgroundColor: "#f8d7da",
1543
- color: "#721c24",
1544
- border: "1px solid #f5c6cb",
1913
+ backgroundColor: colors.errorBg,
1914
+ color: colors.errorText,
1915
+ border: `1px solid ${colors.errorBorder}`,
1545
1916
  borderRadius: "8px",
1546
1917
  fontSize: "14px",
1547
1918
  fontWeight: 500
@@ -1553,7 +1924,7 @@ var OtpForm = ({
1553
1924
  display: "block",
1554
1925
  marginBottom: "8px",
1555
1926
  fontWeight: 500,
1556
- color: "#374151",
1927
+ color: colors.textSecondary,
1557
1928
  fontSize: "14px"
1558
1929
  }, children: "OTP Code:" }),
1559
1930
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1568,13 +1939,13 @@ var OtpForm = ({
1568
1939
  style: {
1569
1940
  width: "100%",
1570
1941
  padding: "12px 16px",
1571
- border: "1px solid #ddd",
1942
+ border: `1px solid ${colors.borderSecondary}`,
1572
1943
  borderRadius: "8px",
1573
1944
  fontSize: "20px",
1574
1945
  boxSizing: "border-box",
1575
- color: "#111827",
1946
+ color: colors.textPrimary,
1576
1947
  transition: "all 0.2s ease",
1577
- backgroundColor: "#ffffff",
1948
+ backgroundColor: colors.bgSecondary,
1578
1949
  textAlign: "center",
1579
1950
  letterSpacing: "5px"
1580
1951
  },
@@ -1591,7 +1962,7 @@ var OtpForm = ({
1591
1962
  disabled: isLoading || otp.length !== 6,
1592
1963
  style: {
1593
1964
  padding: "14px",
1594
- backgroundColor: "#007bff",
1965
+ backgroundColor: colors.buttonPrimary,
1595
1966
  color: "white",
1596
1967
  border: "none",
1597
1968
  borderRadius: "8px",
@@ -1608,7 +1979,7 @@ var OtpForm = ({
1608
1979
  textAlign: "center",
1609
1980
  marginTop: "20px",
1610
1981
  paddingTop: "20px",
1611
- borderTop: "1px solid #eee"
1982
+ borderTop: `1px solid ${colors.borderPrimary}`
1612
1983
  }, children: [
1613
1984
  /* @__PURE__ */ jsxRuntime.jsx(
1614
1985
  "button",
@@ -1619,7 +1990,7 @@ var OtpForm = ({
1619
1990
  style: {
1620
1991
  background: "none",
1621
1992
  border: "none",
1622
- color: resendCooldown > 0 ? "#999" : "#007bff",
1993
+ color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
1623
1994
  textDecoration: "none",
1624
1995
  cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
1625
1996
  fontSize: "14px",
@@ -1642,7 +2013,7 @@ var OtpForm = ({
1642
2013
  style: {
1643
2014
  background: "none",
1644
2015
  border: "none",
1645
- color: "#007bff",
2016
+ color: colors.buttonPrimary,
1646
2017
  textDecoration: "none",
1647
2018
  cursor: "pointer",
1648
2019
  fontSize: "14px",
@@ -1661,9 +2032,9 @@ var AuthFlow = ({
1661
2032
  initialStep = "login",
1662
2033
  showTitle = true
1663
2034
  }) => {
1664
- const [step, setStep] = react.useState(initialStep);
1665
- const [email, setEmail] = react.useState("");
1666
- const [message, setMessage] = react.useState(null);
2035
+ const [step, setStep] = React2.useState(initialStep);
2036
+ const [email, setEmail] = React2.useState("");
2037
+ const [message, setMessage] = React2.useState(null);
1667
2038
  const handleLoginSuccess = (email2, needsOtpVerification) => {
1668
2039
  setEmail(email2);
1669
2040
  if (needsOtpVerification) {
@@ -1798,13 +2169,13 @@ var EmailVerificationPage = ({
1798
2169
  onVerificationError,
1799
2170
  baseUrl
1800
2171
  }) => {
1801
- const [isLoading, setIsLoading] = react.useState(true);
1802
- const [message, setMessage] = react.useState("");
1803
- const [isSuccess, setIsSuccess] = react.useState(false);
2172
+ const [isLoading, setIsLoading] = React2.useState(true);
2173
+ const [message, setMessage] = React2.useState("");
2174
+ const [isSuccess, setIsSuccess] = React2.useState(false);
1804
2175
  const { verifyEmailToken } = useAuth({
1805
2176
  baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
1806
2177
  });
1807
- react.useEffect(() => {
2178
+ React2.useEffect(() => {
1808
2179
  const verifyEmail = async () => {
1809
2180
  if (!token) {
1810
2181
  setIsLoading(false);
@@ -1909,26 +2280,39 @@ var EmailVerificationPage = ({
1909
2280
  ] })
1910
2281
  ] }) });
1911
2282
  };
1912
- var AuthContext = react.createContext(void 0);
2283
+ var AuthContext = React2.createContext(void 0);
1913
2284
  var useAuth2 = () => {
1914
- const context = react.useContext(AuthContext);
2285
+ const context = React2.useContext(AuthContext);
1915
2286
  if (context === void 0) {
1916
2287
  throw new Error("useAuth must be used within an AuthProvider");
1917
2288
  }
1918
2289
  return context;
1919
2290
  };
2291
+ var ThemeWrapper = React2.forwardRef(
2292
+ ({ children, className = "", style }, ref) => {
2293
+ const { theme, mounted } = useAuthTheme();
2294
+ if (!mounted) {
2295
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className, style, children });
2296
+ }
2297
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: `${theme} ${className}`, style, children });
2298
+ }
2299
+ );
2300
+ ThemeWrapper.displayName = "ThemeWrapper";
1920
2301
  var SignIn = ({ redirectUrl, appearance }) => {
1921
2302
  const { signIn, isSignedIn, loading: authLoading } = useAuth2();
1922
- const [email, setEmail] = react.useState("");
1923
- const [password, setPassword] = react.useState("");
1924
- const [otp, setOtp] = react.useState("");
1925
- const [usePassword, setUsePassword] = react.useState(false);
1926
- const [showPassword, setShowPassword] = react.useState(false);
1927
- const [isLoading, setIsLoading] = react.useState(false);
1928
- const [error, setError] = react.useState(null);
1929
- const [needsOtp, setNeedsOtp] = react.useState(false);
1930
- const [success, setSuccess] = react.useState(null);
1931
- react.useEffect(() => {
2303
+ const colors = useThemeColors();
2304
+ const [email, setEmail] = React2.useState("");
2305
+ const [phoneNumber, setPhoneNumber] = React2.useState("");
2306
+ const [password, setPassword] = React2.useState("");
2307
+ const [otp, setOtp] = React2.useState("");
2308
+ const [usePassword, setUsePassword] = React2.useState(false);
2309
+ const [usePhone, setUsePhone] = React2.useState(false);
2310
+ const [showPassword, setShowPassword] = React2.useState(false);
2311
+ const [isLoading, setIsLoading] = React2.useState(false);
2312
+ const [error, setError] = React2.useState(null);
2313
+ const [needsOtp, setNeedsOtp] = React2.useState(false);
2314
+ const [success, setSuccess] = React2.useState(null);
2315
+ React2.useEffect(() => {
1932
2316
  if (isSignedIn && redirectUrl) {
1933
2317
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
1934
2318
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -1941,25 +2325,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
1941
2325
  setError(null);
1942
2326
  setSuccess(null);
1943
2327
  try {
2328
+ const loginData = usePhone ? { phoneNumber } : { email };
1944
2329
  if (needsOtp) {
1945
- const response = await signIn({ email, otp });
2330
+ const response = await signIn({ ...loginData, otp });
1946
2331
  if (response.success) {
1947
2332
  setSuccess("Login successful!");
1948
2333
  } else {
1949
2334
  setError(response.message || "OTP verification failed");
1950
2335
  }
1951
2336
  } else if (usePassword) {
1952
- const response = await signIn({ email, password });
2337
+ const response = await signIn({ ...loginData, password });
1953
2338
  if (response.success) {
1954
2339
  setSuccess("Login successful!");
1955
2340
  } else {
1956
2341
  setError(response.message || "Login failed");
1957
2342
  }
1958
2343
  } else {
1959
- const response = await signIn({ email });
1960
- if (response.success && response.message === "OTP sent to your email.") {
2344
+ const response = await signIn(loginData);
2345
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
1961
2346
  setNeedsOtp(true);
1962
- setSuccess("OTP sent to your email. Please check your inbox.");
2347
+ setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
1963
2348
  } else {
1964
2349
  setError(response.message || "Failed to send OTP");
1965
2350
  }
@@ -1977,238 +2362,366 @@ var SignIn = ({ redirectUrl, appearance }) => {
1977
2362
  setSuccess(null);
1978
2363
  setOtp("");
1979
2364
  };
2365
+ const toggleLoginMethod = () => {
2366
+ setUsePhone(!usePhone);
2367
+ setNeedsOtp(false);
2368
+ setError(null);
2369
+ setSuccess(null);
2370
+ setOtp("");
2371
+ setEmail("");
2372
+ setPhoneNumber("");
2373
+ };
1980
2374
  if (authLoading) {
1981
2375
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
1982
2376
  }
1983
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
1984
- maxWidth: "400px",
1985
- margin: "0 auto",
1986
- padding: "30px",
1987
- borderRadius: "12px",
1988
- boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1989
- backgroundColor: "#ffffff",
1990
- border: "1px solid #eaeaea",
1991
- ...appearance?.elements?.card
1992
- }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
1993
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
1994
- textAlign: "center",
1995
- marginBottom: "24px",
1996
- color: "#1f2937",
1997
- fontSize: "24px",
1998
- fontWeight: 600,
1999
- ...appearance?.elements?.headerTitle
2000
- }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2001
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2002
- padding: "12px 16px",
2003
- marginBottom: "20px",
2004
- backgroundColor: "#fee",
2005
- color: "#c33",
2006
- border: "1px solid #fcc",
2007
- borderRadius: "8px",
2008
- fontSize: "14px"
2009
- }, children: error }),
2010
- success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2011
- padding: "12px 16px",
2012
- marginBottom: "20px",
2013
- backgroundColor: "#efe",
2014
- color: "#3c3",
2015
- border: "1px solid #cfc",
2016
- borderRadius: "8px",
2017
- fontSize: "14px"
2018
- }, children: success }),
2019
- !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2020
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
2021
- display: "block",
2022
- marginBottom: "8px",
2023
- fontWeight: 500,
2024
- color: "#374151",
2025
- fontSize: "14px"
2026
- }, children: "Email" }),
2027
- /* @__PURE__ */ jsxRuntime.jsx(
2028
- "input",
2029
- {
2030
- id: "email",
2031
- type: "email",
2032
- value: email,
2033
- onChange: (e) => setEmail(e.target.value),
2034
- required: true,
2035
- disabled: isLoading,
2036
- style: {
2037
- width: "100%",
2038
- padding: "12px 16px",
2039
- border: "1px solid #ddd",
2040
- borderRadius: "8px",
2041
- fontSize: "16px",
2042
- boxSizing: "border-box",
2043
- ...appearance?.elements?.formFieldInput
2044
- },
2045
- placeholder: "Enter your email"
2046
- }
2047
- )
2048
- ] }),
2049
- usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2050
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
2051
- display: "block",
2052
- marginBottom: "8px",
2053
- fontWeight: 500,
2054
- color: "#374151",
2055
- fontSize: "14px"
2056
- }, children: "Password" }),
2057
- /* @__PURE__ */ jsxRuntime.jsx(
2058
- "input",
2059
- {
2060
- id: "password",
2061
- type: showPassword ? "text" : "password",
2062
- value: password,
2063
- onChange: (e) => setPassword(e.target.value),
2064
- required: true,
2065
- disabled: isLoading,
2066
- style: {
2067
- width: "100%",
2068
- padding: "12px 16px",
2069
- border: "1px solid #ddd",
2070
- borderRadius: "8px",
2071
- fontSize: "16px",
2072
- boxSizing: "border-box",
2073
- ...appearance?.elements?.formFieldInput
2074
- },
2075
- placeholder: "Enter your password"
2076
- }
2077
- ),
2078
- /* @__PURE__ */ jsxRuntime.jsx(
2079
- "button",
2080
- {
2081
- type: "button",
2082
- onClick: () => setShowPassword(!showPassword),
2083
- style: {
2084
- position: "absolute",
2085
- right: "12px",
2086
- top: "38px",
2087
- background: "none",
2088
- border: "none",
2089
- cursor: "pointer",
2090
- color: "#666",
2091
- fontSize: "14px"
2092
- },
2093
- children: showPassword ? "Hide" : "Show"
2094
- }
2095
- )
2096
- ] }),
2097
- needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2098
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
2099
- display: "block",
2100
- marginBottom: "8px",
2101
- fontWeight: 500,
2102
- color: "#374151",
2103
- fontSize: "14px"
2104
- }, children: "One-Time Password" }),
2105
- /* @__PURE__ */ jsxRuntime.jsx(
2106
- "input",
2107
- {
2108
- id: "otp",
2109
- type: "text",
2110
- value: otp,
2111
- onChange: (e) => setOtp(e.target.value),
2112
- required: true,
2113
- disabled: isLoading,
2114
- maxLength: 6,
2115
- style: {
2116
- width: "100%",
2117
- padding: "12px 16px",
2118
- border: "1px solid #ddd",
2119
- borderRadius: "8px",
2120
- fontSize: "16px",
2121
- boxSizing: "border-box",
2122
- letterSpacing: "0.5em",
2123
- textAlign: "center",
2124
- ...appearance?.elements?.formFieldInput
2125
- },
2126
- placeholder: "000000"
2127
- }
2128
- )
2129
- ] }),
2130
- /* @__PURE__ */ jsxRuntime.jsx(
2131
- "button",
2132
- {
2133
- type: "submit",
2134
- disabled: isLoading,
2135
- style: {
2136
- width: "100%",
2137
- padding: "14px",
2138
- backgroundColor: "#007bff",
2139
- color: "white",
2140
- border: "none",
2141
- borderRadius: "8px",
2142
- fontSize: "16px",
2377
+ return /* @__PURE__ */ jsxRuntime.jsx(
2378
+ ThemeWrapper,
2379
+ {
2380
+ style: {
2381
+ maxWidth: "400px",
2382
+ margin: "0 auto",
2383
+ padding: "30px",
2384
+ borderRadius: "12px",
2385
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2386
+ backgroundColor: colors.bgPrimary,
2387
+ border: `1px solid ${colors.borderPrimary}`,
2388
+ ...appearance?.elements?.card
2389
+ },
2390
+ children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
2391
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
2392
+ textAlign: "center",
2393
+ marginBottom: "24px",
2394
+ color: colors.textPrimary,
2395
+ fontSize: "24px",
2143
2396
  fontWeight: 600,
2144
- cursor: "pointer",
2145
- transition: "all 0.2s ease",
2146
- ...appearance?.elements?.formButtonPrimary
2147
- },
2148
- children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : "Continue with email"
2149
- }
2150
- ),
2151
- !needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2152
- "button",
2153
- {
2154
- type: "button",
2155
- onClick: toggleAuthMethod,
2156
- disabled: isLoading,
2157
- style: {
2158
- background: "none",
2159
- border: "none",
2160
- color: "#007bff",
2161
- cursor: "pointer",
2162
- fontSize: "14px",
2163
- fontWeight: 600
2164
- },
2165
- children: usePassword ? "Use email code instead" : "Use password instead"
2166
- }
2167
- ) }),
2168
- needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2169
- "button",
2170
- {
2171
- type: "button",
2172
- onClick: () => {
2173
- setNeedsOtp(false);
2174
- setOtp("");
2175
- setError(null);
2176
- setSuccess(null);
2177
- },
2178
- disabled: isLoading,
2179
- style: {
2180
- background: "none",
2181
- border: "none",
2182
- color: "#007bff",
2183
- cursor: "pointer",
2184
- fontSize: "14px",
2185
- fontWeight: 600
2186
- },
2187
- children: "Back to sign in"
2188
- }
2189
- ) })
2190
- ] }) });
2397
+ ...appearance?.elements?.headerTitle
2398
+ }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2399
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2400
+ padding: "12px 16px",
2401
+ marginBottom: "20px",
2402
+ backgroundColor: colors.errorBg,
2403
+ color: colors.errorText,
2404
+ border: `1px solid ${colors.errorBorder}`,
2405
+ borderRadius: "8px",
2406
+ fontSize: "14px"
2407
+ }, children: error }),
2408
+ success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2409
+ padding: "12px 16px",
2410
+ marginBottom: "20px",
2411
+ backgroundColor: colors.successBg,
2412
+ color: colors.successText,
2413
+ border: `1px solid ${colors.successBorder}`,
2414
+ borderRadius: "8px",
2415
+ fontSize: "14px"
2416
+ }, children: success }),
2417
+ !needsOtp && !usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2418
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
2419
+ display: "block",
2420
+ marginBottom: "8px",
2421
+ fontWeight: 500,
2422
+ color: colors.textSecondary,
2423
+ fontSize: "14px"
2424
+ }, children: "Email" }),
2425
+ /* @__PURE__ */ jsxRuntime.jsx(
2426
+ "input",
2427
+ {
2428
+ id: "email",
2429
+ type: "email",
2430
+ value: email,
2431
+ onChange: (e) => setEmail(e.target.value),
2432
+ onFocus: (e) => {
2433
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2434
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2435
+ },
2436
+ onBlur: (e) => {
2437
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2438
+ e.currentTarget.style.outline = "none";
2439
+ },
2440
+ required: true,
2441
+ disabled: isLoading,
2442
+ style: {
2443
+ width: "100%",
2444
+ padding: "12px 16px",
2445
+ border: `1px solid ${colors.borderSecondary}`,
2446
+ borderRadius: "8px",
2447
+ fontSize: "16px",
2448
+ boxSizing: "border-box",
2449
+ backgroundColor: colors.bgSecondary,
2450
+ color: colors.textPrimary,
2451
+ transition: "all 0.2s ease",
2452
+ WebkitTextFillColor: colors.textPrimary,
2453
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2454
+ ...appearance?.elements?.formFieldInput
2455
+ },
2456
+ placeholder: "Enter your email"
2457
+ }
2458
+ )
2459
+ ] }),
2460
+ !needsOtp && usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2461
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
2462
+ display: "block",
2463
+ marginBottom: "8px",
2464
+ fontWeight: 500,
2465
+ color: colors.textSecondary,
2466
+ fontSize: "14px"
2467
+ }, children: "Phone Number" }),
2468
+ /* @__PURE__ */ jsxRuntime.jsx(
2469
+ "input",
2470
+ {
2471
+ id: "phoneNumber",
2472
+ type: "tel",
2473
+ value: phoneNumber,
2474
+ onChange: (e) => setPhoneNumber(e.target.value),
2475
+ onFocus: (e) => {
2476
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2477
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2478
+ },
2479
+ onBlur: (e) => {
2480
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2481
+ e.currentTarget.style.outline = "none";
2482
+ },
2483
+ required: true,
2484
+ disabled: isLoading,
2485
+ style: {
2486
+ width: "100%",
2487
+ padding: "12px 16px",
2488
+ border: `1px solid ${colors.borderSecondary}`,
2489
+ borderRadius: "8px",
2490
+ fontSize: "16px",
2491
+ boxSizing: "border-box",
2492
+ backgroundColor: colors.bgSecondary,
2493
+ color: colors.textPrimary,
2494
+ transition: "all 0.2s ease",
2495
+ WebkitTextFillColor: colors.textPrimary,
2496
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2497
+ ...appearance?.elements?.formFieldInput
2498
+ },
2499
+ placeholder: "Enter your phone number"
2500
+ }
2501
+ )
2502
+ ] }),
2503
+ usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2504
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
2505
+ display: "block",
2506
+ marginBottom: "8px",
2507
+ fontWeight: 500,
2508
+ color: colors.textSecondary,
2509
+ fontSize: "14px"
2510
+ }, children: "Password" }),
2511
+ /* @__PURE__ */ jsxRuntime.jsx(
2512
+ "input",
2513
+ {
2514
+ id: "password",
2515
+ type: showPassword ? "text" : "password",
2516
+ value: password,
2517
+ onChange: (e) => setPassword(e.target.value),
2518
+ onFocus: (e) => {
2519
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2520
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2521
+ },
2522
+ onBlur: (e) => {
2523
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2524
+ e.currentTarget.style.outline = "none";
2525
+ },
2526
+ required: true,
2527
+ disabled: isLoading,
2528
+ style: {
2529
+ width: "100%",
2530
+ padding: "12px 16px",
2531
+ border: `1px solid ${colors.borderSecondary}`,
2532
+ borderRadius: "8px",
2533
+ fontSize: "16px",
2534
+ boxSizing: "border-box",
2535
+ backgroundColor: colors.bgSecondary,
2536
+ color: colors.textPrimary,
2537
+ transition: "all 0.2s ease",
2538
+ WebkitTextFillColor: colors.textPrimary,
2539
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2540
+ ...appearance?.elements?.formFieldInput
2541
+ },
2542
+ placeholder: "Enter your password"
2543
+ }
2544
+ ),
2545
+ /* @__PURE__ */ jsxRuntime.jsx(
2546
+ "button",
2547
+ {
2548
+ type: "button",
2549
+ onClick: () => setShowPassword(!showPassword),
2550
+ style: {
2551
+ position: "absolute",
2552
+ right: "12px",
2553
+ top: "38px",
2554
+ background: "none",
2555
+ border: "none",
2556
+ cursor: "pointer",
2557
+ color: colors.textTertiary,
2558
+ fontSize: "14px"
2559
+ },
2560
+ children: showPassword ? "Hide" : "Show"
2561
+ }
2562
+ )
2563
+ ] }),
2564
+ needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2565
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
2566
+ display: "block",
2567
+ marginBottom: "8px",
2568
+ fontWeight: 500,
2569
+ color: colors.textSecondary,
2570
+ fontSize: "14px"
2571
+ }, children: "One-Time Password" }),
2572
+ /* @__PURE__ */ jsxRuntime.jsx(
2573
+ "input",
2574
+ {
2575
+ id: "otp",
2576
+ type: "text",
2577
+ value: otp,
2578
+ onChange: (e) => setOtp(e.target.value),
2579
+ onFocus: (e) => {
2580
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2581
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2582
+ },
2583
+ onBlur: (e) => {
2584
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2585
+ e.currentTarget.style.outline = "none";
2586
+ },
2587
+ required: true,
2588
+ disabled: isLoading,
2589
+ maxLength: 6,
2590
+ style: {
2591
+ width: "100%",
2592
+ padding: "12px 16px",
2593
+ border: `1px solid ${colors.borderSecondary}`,
2594
+ borderRadius: "8px",
2595
+ fontSize: "16px",
2596
+ boxSizing: "border-box",
2597
+ letterSpacing: "0.5em",
2598
+ textAlign: "center",
2599
+ backgroundColor: colors.bgSecondary,
2600
+ color: colors.textPrimary,
2601
+ transition: "all 0.2s ease",
2602
+ WebkitTextFillColor: colors.textPrimary,
2603
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2604
+ ...appearance?.elements?.formFieldInput
2605
+ },
2606
+ placeholder: "000000"
2607
+ }
2608
+ )
2609
+ ] }),
2610
+ /* @__PURE__ */ jsxRuntime.jsx(
2611
+ "button",
2612
+ {
2613
+ type: "submit",
2614
+ disabled: isLoading,
2615
+ onMouseEnter: (e) => {
2616
+ if (!isLoading) {
2617
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
2618
+ }
2619
+ },
2620
+ onMouseLeave: (e) => {
2621
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
2622
+ },
2623
+ style: {
2624
+ width: "100%",
2625
+ padding: "14px",
2626
+ backgroundColor: colors.buttonPrimary,
2627
+ color: "white",
2628
+ border: "none",
2629
+ borderRadius: "8px",
2630
+ fontSize: "16px",
2631
+ fontWeight: 600,
2632
+ cursor: isLoading ? "not-allowed" : "pointer",
2633
+ opacity: isLoading ? 0.6 : 1,
2634
+ transition: "all 0.2s ease",
2635
+ ...appearance?.elements?.formButtonPrimary
2636
+ },
2637
+ children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
2638
+ }
2639
+ ),
2640
+ !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
2641
+ /* @__PURE__ */ jsxRuntime.jsx(
2642
+ "button",
2643
+ {
2644
+ type: "button",
2645
+ onClick: toggleAuthMethod,
2646
+ disabled: isLoading,
2647
+ style: {
2648
+ background: "none",
2649
+ border: "none",
2650
+ color: colors.buttonPrimary,
2651
+ cursor: "pointer",
2652
+ fontSize: "14px",
2653
+ fontWeight: 600,
2654
+ marginRight: "16px"
2655
+ },
2656
+ children: usePassword ? "Use OTP code instead" : "Use password instead"
2657
+ }
2658
+ ),
2659
+ /* @__PURE__ */ jsxRuntime.jsx(
2660
+ "button",
2661
+ {
2662
+ type: "button",
2663
+ onClick: toggleLoginMethod,
2664
+ disabled: isLoading,
2665
+ style: {
2666
+ background: "none",
2667
+ border: "none",
2668
+ color: colors.buttonPrimary,
2669
+ cursor: "pointer",
2670
+ fontSize: "14px",
2671
+ fontWeight: 600
2672
+ },
2673
+ children: usePhone ? "Use email instead" : "Use phone instead"
2674
+ }
2675
+ )
2676
+ ] }),
2677
+ needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2678
+ "button",
2679
+ {
2680
+ type: "button",
2681
+ onClick: () => {
2682
+ setNeedsOtp(false);
2683
+ setOtp("");
2684
+ setError(null);
2685
+ setSuccess(null);
2686
+ },
2687
+ disabled: isLoading,
2688
+ style: {
2689
+ background: "none",
2690
+ border: "none",
2691
+ color: colors.buttonPrimary,
2692
+ cursor: "pointer",
2693
+ fontSize: "14px",
2694
+ fontWeight: 600
2695
+ },
2696
+ children: "Back to sign in"
2697
+ }
2698
+ ) })
2699
+ ] })
2700
+ }
2701
+ );
2191
2702
  };
2192
2703
  var SignUp = ({ redirectUrl, appearance }) => {
2193
2704
  const { signUp, isSignedIn } = useAuth2();
2194
- const [name, setName] = react.useState("");
2195
- const [email, setEmail] = react.useState("");
2196
- const [password, setPassword] = react.useState("");
2197
- const [confirmPassword, setConfirmPassword] = react.useState("");
2198
- const [showPassword, setShowPassword] = react.useState(false);
2199
- const [isLoading, setIsLoading] = react.useState(false);
2200
- const [error, setError] = react.useState(null);
2201
- const [success, setSuccess] = react.useState(null);
2202
- react.useEffect(() => {
2705
+ const colors = useThemeColors();
2706
+ const [name, setName] = React2.useState("");
2707
+ const [email, setEmail] = React2.useState("");
2708
+ const [phoneNumber, setPhoneNumber] = React2.useState("");
2709
+ const [password, setPassword] = React2.useState("");
2710
+ const [confirmPassword, setConfirmPassword] = React2.useState("");
2711
+ const [showPassword, setShowPassword] = React2.useState(false);
2712
+ const [isLoading, setIsLoading] = React2.useState(false);
2713
+ const [error, setError] = React2.useState(null);
2714
+ const [success, setSuccess] = React2.useState(null);
2715
+ React2.useEffect(() => {
2203
2716
  if (isSignedIn && redirectUrl) {
2204
2717
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
2205
2718
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2206
2719
  window.location.href = `${baseUrl}${redirect}`;
2207
2720
  }
2208
2721
  }, [isSignedIn, redirectUrl]);
2209
- const getPasswordStrength = (pwd) => {
2722
+ const getPasswordStrength = (pwd, colors2) => {
2210
2723
  if (!pwd)
2211
- return { strength: "weak", color: "#ddd" };
2724
+ return { strength: "weak", color: colors2.borderSecondary };
2212
2725
  let score = 0;
2213
2726
  if (pwd.length >= 6)
2214
2727
  score++;
@@ -2221,12 +2734,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2221
2734
  if (/[^a-zA-Z\d]/.test(pwd))
2222
2735
  score++;
2223
2736
  if (score <= 2)
2224
- return { strength: "weak", color: "#f44" };
2737
+ return { strength: "weak", color: colors2.errorText };
2225
2738
  if (score <= 3)
2226
- return { strength: "medium", color: "#fa4" };
2227
- return { strength: "strong", color: "#4f4" };
2739
+ return { strength: "medium", color: colors2.warningText || "#fa4" };
2740
+ return { strength: "strong", color: colors2.successText };
2228
2741
  };
2229
- const passwordStrength = getPasswordStrength(password);
2742
+ const passwordStrength = getPasswordStrength(password, colors);
2230
2743
  const handleSubmit = async (e) => {
2231
2744
  e.preventDefault();
2232
2745
  setIsLoading(true);
@@ -2243,7 +2756,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2243
2756
  return;
2244
2757
  }
2245
2758
  try {
2246
- const response = await signUp({ name, email, password });
2759
+ const signUpData = { name, password };
2760
+ if (email)
2761
+ signUpData.email = email;
2762
+ if (phoneNumber)
2763
+ signUpData.phoneNumber = phoneNumber;
2764
+ const response = await signUp(signUpData);
2247
2765
  if (response.success) {
2248
2766
  setSuccess("Registration successful! Please check your email to verify your account.");
2249
2767
  } else {
@@ -2255,20 +2773,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
2255
2773
  setIsLoading(false);
2256
2774
  }
2257
2775
  };
2258
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2776
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeWrapper, { style: {
2259
2777
  maxWidth: "400px",
2260
2778
  margin: "0 auto",
2261
2779
  padding: "30px",
2262
2780
  borderRadius: "12px",
2263
2781
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2264
- backgroundColor: "#ffffff",
2265
- border: "1px solid #eaeaea",
2782
+ backgroundColor: colors.bgPrimary,
2783
+ border: `1px solid ${colors.borderPrimary}`,
2266
2784
  ...appearance?.elements?.card
2267
2785
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
2268
2786
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
2269
2787
  textAlign: "center",
2270
2788
  marginBottom: "24px",
2271
- color: "#1f2937",
2789
+ color: colors.textPrimary,
2272
2790
  fontSize: "24px",
2273
2791
  fontWeight: 600,
2274
2792
  ...appearance?.elements?.headerTitle
@@ -2276,18 +2794,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
2276
2794
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2277
2795
  padding: "12px 16px",
2278
2796
  marginBottom: "20px",
2279
- backgroundColor: "#fee",
2280
- color: "#c33",
2281
- border: "1px solid #fcc",
2797
+ backgroundColor: colors.errorBg,
2798
+ color: colors.errorText,
2799
+ border: `1px solid ${colors.errorBorder}`,
2282
2800
  borderRadius: "8px",
2283
2801
  fontSize: "14px"
2284
2802
  }, children: error }),
2285
2803
  success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2286
2804
  padding: "12px 16px",
2287
2805
  marginBottom: "20px",
2288
- backgroundColor: "#efe",
2289
- color: "#3c3",
2290
- border: "1px solid #cfc",
2806
+ backgroundColor: colors.successBg,
2807
+ color: colors.successText,
2808
+ border: `1px solid ${colors.successBorder}`,
2291
2809
  borderRadius: "8px",
2292
2810
  fontSize: "14px"
2293
2811
  }, children: success }),
@@ -2296,7 +2814,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2296
2814
  display: "block",
2297
2815
  marginBottom: "8px",
2298
2816
  fontWeight: 500,
2299
- color: "#374151",
2817
+ color: colors.textSecondary,
2300
2818
  fontSize: "14px"
2301
2819
  }, children: "Full name" }),
2302
2820
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2306,15 +2824,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2306
2824
  type: "text",
2307
2825
  value: name,
2308
2826
  onChange: (e) => setName(e.target.value),
2827
+ onFocus: (e) => {
2828
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2829
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2830
+ },
2831
+ onBlur: (e) => {
2832
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2833
+ e.currentTarget.style.outline = "none";
2834
+ },
2309
2835
  required: true,
2310
2836
  disabled: isLoading,
2311
2837
  style: {
2312
2838
  width: "100%",
2313
2839
  padding: "12px 16px",
2314
- border: "1px solid #ddd",
2840
+ border: `1px solid ${colors.borderSecondary}`,
2315
2841
  borderRadius: "8px",
2316
2842
  fontSize: "16px",
2317
2843
  boxSizing: "border-box",
2844
+ backgroundColor: colors.bgSecondary,
2845
+ color: colors.textPrimary,
2846
+ transition: "all 0.2s ease",
2847
+ WebkitTextFillColor: colors.textPrimary,
2848
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2318
2849
  ...appearance?.elements?.formFieldInput
2319
2850
  },
2320
2851
  placeholder: "Enter your full name"
@@ -2326,7 +2857,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2326
2857
  display: "block",
2327
2858
  marginBottom: "8px",
2328
2859
  fontWeight: 500,
2329
- color: "#374151",
2860
+ color: colors.textSecondary,
2330
2861
  fontSize: "14px"
2331
2862
  }, children: "Email" }),
2332
2863
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2336,27 +2867,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
2336
2867
  type: "email",
2337
2868
  value: email,
2338
2869
  onChange: (e) => setEmail(e.target.value),
2339
- required: true,
2870
+ onFocus: (e) => {
2871
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2872
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2873
+ },
2874
+ onBlur: (e) => {
2875
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2876
+ e.currentTarget.style.outline = "none";
2877
+ },
2878
+ required: !phoneNumber,
2340
2879
  disabled: isLoading,
2341
2880
  style: {
2342
2881
  width: "100%",
2343
2882
  padding: "12px 16px",
2344
- border: "1px solid #ddd",
2883
+ border: `1px solid ${colors.borderSecondary}`,
2345
2884
  borderRadius: "8px",
2346
2885
  fontSize: "16px",
2347
2886
  boxSizing: "border-box",
2887
+ backgroundColor: colors.bgSecondary,
2888
+ color: colors.textPrimary,
2889
+ transition: "all 0.2s ease",
2890
+ WebkitTextFillColor: colors.textPrimary,
2891
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2348
2892
  ...appearance?.elements?.formFieldInput
2349
2893
  },
2350
2894
  placeholder: "Enter your email"
2351
2895
  }
2352
2896
  )
2353
2897
  ] }),
2898
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
2899
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
2900
+ display: "block",
2901
+ marginBottom: "8px",
2902
+ fontWeight: 500,
2903
+ color: colors.textSecondary,
2904
+ fontSize: "14px"
2905
+ }, children: "Phone Number (Optional)" }),
2906
+ /* @__PURE__ */ jsxRuntime.jsx(
2907
+ PhoneInput,
2908
+ {
2909
+ id: "phoneNumber",
2910
+ value: phoneNumber,
2911
+ onChange: setPhoneNumber,
2912
+ disabled: isLoading,
2913
+ placeholder: "1234567890",
2914
+ style: appearance?.elements?.formFieldInput
2915
+ }
2916
+ )
2917
+ ] }),
2354
2918
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2355
2919
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
2356
2920
  display: "block",
2357
2921
  marginBottom: "8px",
2358
2922
  fontWeight: 500,
2359
- color: "#374151",
2923
+ color: colors.textSecondary,
2360
2924
  fontSize: "14px"
2361
2925
  }, children: "Password" }),
2362
2926
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2366,16 +2930,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
2366
2930
  type: showPassword ? "text" : "password",
2367
2931
  value: password,
2368
2932
  onChange: (e) => setPassword(e.target.value),
2933
+ onFocus: (e) => {
2934
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2935
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2936
+ },
2937
+ onBlur: (e) => {
2938
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2939
+ e.currentTarget.style.outline = "none";
2940
+ },
2369
2941
  required: true,
2370
2942
  disabled: isLoading,
2371
2943
  minLength: 6,
2372
2944
  style: {
2373
2945
  width: "100%",
2374
2946
  padding: "12px 16px",
2375
- border: "1px solid #ddd",
2947
+ border: `1px solid ${colors.borderSecondary}`,
2376
2948
  borderRadius: "8px",
2377
2949
  fontSize: "16px",
2378
2950
  boxSizing: "border-box",
2951
+ backgroundColor: colors.bgSecondary,
2952
+ color: colors.textPrimary,
2953
+ transition: "all 0.2s ease",
2954
+ WebkitTextFillColor: colors.textPrimary,
2955
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2379
2956
  ...appearance?.elements?.formFieldInput
2380
2957
  },
2381
2958
  placeholder: "Create a password"
@@ -2393,7 +2970,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2393
2970
  background: "none",
2394
2971
  border: "none",
2395
2972
  cursor: "pointer",
2396
- color: "#666",
2973
+ color: colors.textTertiary,
2397
2974
  fontSize: "14px"
2398
2975
  },
2399
2976
  children: showPassword ? "Hide" : "Show"
@@ -2402,7 +2979,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2402
2979
  password && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "8px" }, children: [
2403
2980
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2404
2981
  height: "4px",
2405
- backgroundColor: "#eee",
2982
+ backgroundColor: colors.borderSecondary,
2406
2983
  borderRadius: "2px",
2407
2984
  overflow: "hidden"
2408
2985
  }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
@@ -2427,7 +3004,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2427
3004
  display: "block",
2428
3005
  marginBottom: "8px",
2429
3006
  fontWeight: 500,
2430
- color: "#374151",
3007
+ color: colors.textSecondary,
2431
3008
  fontSize: "14px"
2432
3009
  }, children: "Confirm password" }),
2433
3010
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2437,15 +3014,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2437
3014
  type: showPassword ? "text" : "password",
2438
3015
  value: confirmPassword,
2439
3016
  onChange: (e) => setConfirmPassword(e.target.value),
3017
+ onFocus: (e) => {
3018
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3019
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3020
+ },
3021
+ onBlur: (e) => {
3022
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3023
+ e.currentTarget.style.outline = "none";
3024
+ },
2440
3025
  required: true,
2441
3026
  disabled: isLoading,
2442
3027
  style: {
2443
3028
  width: "100%",
2444
3029
  padding: "12px 16px",
2445
- border: "1px solid #ddd",
3030
+ border: `1px solid ${colors.borderSecondary}`,
2446
3031
  borderRadius: "8px",
2447
3032
  fontSize: "16px",
2448
3033
  boxSizing: "border-box",
3034
+ backgroundColor: colors.bgSecondary,
3035
+ color: colors.textPrimary,
3036
+ transition: "all 0.2s ease",
3037
+ WebkitTextFillColor: colors.textPrimary,
3038
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2449
3039
  ...appearance?.elements?.formFieldInput
2450
3040
  },
2451
3041
  placeholder: "Confirm your password"
@@ -2457,16 +3047,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
2457
3047
  {
2458
3048
  type: "submit",
2459
3049
  disabled: isLoading,
3050
+ onMouseEnter: (e) => {
3051
+ if (!isLoading) {
3052
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
3053
+ }
3054
+ },
3055
+ onMouseLeave: (e) => {
3056
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3057
+ },
2460
3058
  style: {
2461
3059
  width: "100%",
2462
3060
  padding: "14px",
2463
- backgroundColor: "#007bff",
3061
+ backgroundColor: colors.buttonPrimary,
2464
3062
  color: "white",
2465
3063
  border: "none",
2466
3064
  borderRadius: "8px",
2467
3065
  fontSize: "16px",
2468
3066
  fontWeight: 600,
2469
- cursor: "pointer",
3067
+ cursor: isLoading ? "not-allowed" : "pointer",
3068
+ opacity: isLoading ? 0.6 : 1,
2470
3069
  transition: "all 0.2s ease",
2471
3070
  ...appearance?.elements?.formButtonPrimary
2472
3071
  },
@@ -2477,7 +3076,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2477
3076
  };
2478
3077
  var SignOut = ({ redirectUrl }) => {
2479
3078
  const { signOut } = useAuth2();
2480
- react.useEffect(() => {
3079
+ React2.useEffect(() => {
2481
3080
  const performSignOut = async () => {
2482
3081
  await signOut();
2483
3082
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
@@ -2490,9 +3089,10 @@ var SignOut = ({ redirectUrl }) => {
2490
3089
  };
2491
3090
  var UserButton = ({ showName = false, appearance }) => {
2492
3091
  const { user, signOut } = useAuth2();
2493
- const [isOpen, setIsOpen] = react.useState(false);
2494
- const dropdownRef = react.useRef(null);
2495
- react.useEffect(() => {
3092
+ const colors = useThemeColors();
3093
+ const [isOpen, setIsOpen] = React2.useState(false);
3094
+ const dropdownRef = React2.useRef(null);
3095
+ React2.useEffect(() => {
2496
3096
  const handleClickOutside = (event) => {
2497
3097
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
2498
3098
  setIsOpen(false);
@@ -2512,7 +3112,7 @@ var UserButton = ({ showName = false, appearance }) => {
2512
3112
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2513
3113
  window.location.href = `${baseUrl}${redirect}`;
2514
3114
  };
2515
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
3115
+ return /* @__PURE__ */ jsxRuntime.jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
2516
3116
  /* @__PURE__ */ jsxRuntime.jsxs(
2517
3117
  "button",
2518
3118
  {
@@ -2530,7 +3130,7 @@ var UserButton = ({ showName = false, appearance }) => {
2530
3130
  ...appearance?.elements?.userButtonTrigger
2531
3131
  },
2532
3132
  onMouseEnter: (e) => {
2533
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3133
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2534
3134
  },
2535
3135
  onMouseLeave: (e) => {
2536
3136
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2540,15 +3140,15 @@ var UserButton = ({ showName = false, appearance }) => {
2540
3140
  width: "36px",
2541
3141
  height: "36px",
2542
3142
  borderRadius: "50%",
2543
- backgroundColor: "#007bff",
2544
- color: "white",
3143
+ backgroundColor: colors.buttonPrimary,
3144
+ color: colors.textPrimary,
2545
3145
  display: "flex",
2546
3146
  alignItems: "center",
2547
3147
  justifyContent: "center",
2548
3148
  fontSize: "14px",
2549
3149
  fontWeight: 600
2550
3150
  }, children: getInitials(user.name) }),
2551
- showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: "#333" }, children: user.name })
3151
+ showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
2552
3152
  ]
2553
3153
  }
2554
3154
  ),
@@ -2558,16 +3158,16 @@ var UserButton = ({ showName = false, appearance }) => {
2558
3158
  right: 0,
2559
3159
  marginTop: "8px",
2560
3160
  width: "240px",
2561
- backgroundColor: "white",
3161
+ backgroundColor: colors.bgPrimary,
2562
3162
  borderRadius: "12px",
2563
3163
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
2564
- border: "1px solid #eaeaea",
3164
+ border: `1px solid ${colors.borderPrimary}`,
2565
3165
  zIndex: 1e3,
2566
3166
  ...appearance?.elements?.userButtonPopoverCard
2567
3167
  }, children: [
2568
3168
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2569
3169
  padding: "16px",
2570
- borderBottom: "1px solid #eee"
3170
+ borderBottom: `1px solid ${colors.borderPrimary}`
2571
3171
  }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
2572
3172
  display: "flex",
2573
3173
  alignItems: "center",
@@ -2577,8 +3177,8 @@ var UserButton = ({ showName = false, appearance }) => {
2577
3177
  width: "48px",
2578
3178
  height: "48px",
2579
3179
  borderRadius: "50%",
2580
- backgroundColor: "#007bff",
2581
- color: "white",
3180
+ backgroundColor: colors.buttonPrimary,
3181
+ color: colors.textPrimary,
2582
3182
  display: "flex",
2583
3183
  alignItems: "center",
2584
3184
  justifyContent: "center",
@@ -2589,14 +3189,14 @@ var UserButton = ({ showName = false, appearance }) => {
2589
3189
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2590
3190
  fontSize: "14px",
2591
3191
  fontWeight: 600,
2592
- color: "#333",
3192
+ color: colors.textPrimary,
2593
3193
  overflow: "hidden",
2594
3194
  textOverflow: "ellipsis",
2595
3195
  whiteSpace: "nowrap"
2596
3196
  }, children: user.name }),
2597
3197
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2598
3198
  fontSize: "12px",
2599
- color: "#666",
3199
+ color: colors.textTertiary,
2600
3200
  overflow: "hidden",
2601
3201
  textOverflow: "ellipsis",
2602
3202
  whiteSpace: "nowrap"
@@ -2616,12 +3216,12 @@ var UserButton = ({ showName = false, appearance }) => {
2616
3216
  textAlign: "left",
2617
3217
  cursor: "pointer",
2618
3218
  fontSize: "14px",
2619
- color: "#333",
3219
+ color: colors.textPrimary,
2620
3220
  fontWeight: 500,
2621
3221
  transition: "background-color 0.2s"
2622
3222
  },
2623
3223
  onMouseEnter: (e) => {
2624
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3224
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2625
3225
  },
2626
3226
  onMouseLeave: (e) => {
2627
3227
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2638,7 +3238,7 @@ var ProtectedRoute = ({
2638
3238
  redirectTo
2639
3239
  }) => {
2640
3240
  const { isSignedIn, isLoaded } = useAuth2();
2641
- react.useEffect(() => {
3241
+ React2.useEffect(() => {
2642
3242
  if (isLoaded && !isSignedIn) {
2643
3243
  const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
2644
3244
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -2663,7 +3263,7 @@ var PublicRoute = ({
2663
3263
  redirectTo
2664
3264
  }) => {
2665
3265
  const { isSignedIn, isLoaded } = useAuth2();
2666
- react.useEffect(() => {
3266
+ React2.useEffect(() => {
2667
3267
  if (isLoaded && isSignedIn) {
2668
3268
  const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2669
3269
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -2685,9 +3285,9 @@ var PublicRoute = ({
2685
3285
  };
2686
3286
  var VerifyEmail = ({ token, onSuccess, onError }) => {
2687
3287
  const { verifyEmailToken } = useAuth2();
2688
- const [status, setStatus] = react.useState("loading");
2689
- const [message, setMessage] = react.useState("");
2690
- react.useEffect(() => {
3288
+ const [status, setStatus] = React2.useState("loading");
3289
+ const [message, setMessage] = React2.useState("");
3290
+ React2.useEffect(() => {
2691
3291
  const verify = async () => {
2692
3292
  const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
2693
3293
  if (!verifyToken) {
@@ -2821,10 +3421,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
2821
3421
  };
2822
3422
  var ForgotPassword = ({ appearance }) => {
2823
3423
  const { forgotPassword } = useAuth2();
2824
- const [email, setEmail] = react.useState("");
2825
- const [isLoading, setIsLoading] = react.useState(false);
2826
- const [error, setError] = react.useState(null);
2827
- const [success, setSuccess] = react.useState(null);
3424
+ const [email, setEmail] = React2.useState("");
3425
+ const [isLoading, setIsLoading] = React2.useState(false);
3426
+ const [error, setError] = React2.useState(null);
3427
+ const [success, setSuccess] = React2.useState(null);
2828
3428
  const handleSubmit = async (e) => {
2829
3429
  e.preventDefault();
2830
3430
  setIsLoading(true);
@@ -2963,14 +3563,14 @@ var ForgotPassword = ({ appearance }) => {
2963
3563
  };
2964
3564
  var ResetPassword = ({ token, appearance }) => {
2965
3565
  const { resetPassword } = useAuth2();
2966
- const [resetToken, setResetToken] = react.useState(token || "");
2967
- const [password, setPassword] = react.useState("");
2968
- const [confirmPassword, setConfirmPassword] = react.useState("");
2969
- const [showPassword, setShowPassword] = react.useState(false);
2970
- const [isLoading, setIsLoading] = react.useState(false);
2971
- const [error, setError] = react.useState(null);
2972
- const [success, setSuccess] = react.useState(false);
2973
- react.useEffect(() => {
3566
+ const [resetToken, setResetToken] = React2.useState(token || "");
3567
+ const [password, setPassword] = React2.useState("");
3568
+ const [confirmPassword, setConfirmPassword] = React2.useState("");
3569
+ const [showPassword, setShowPassword] = React2.useState(false);
3570
+ const [isLoading, setIsLoading] = React2.useState(false);
3571
+ const [error, setError] = React2.useState(null);
3572
+ const [success, setSuccess] = React2.useState(false);
3573
+ React2.useEffect(() => {
2974
3574
  if (!resetToken && typeof window !== "undefined") {
2975
3575
  const urlToken = new URLSearchParams(window.location.search).get("token");
2976
3576
  if (urlToken) {
@@ -3225,13 +3825,13 @@ var ResetPassword = ({ token, appearance }) => {
3225
3825
  };
3226
3826
  var ChangePassword = ({ onSuccess, appearance }) => {
3227
3827
  const { changePassword } = useAuth2();
3228
- const [oldPassword, setOldPassword] = react.useState("");
3229
- const [newPassword, setNewPassword] = react.useState("");
3230
- const [confirmPassword, setConfirmPassword] = react.useState("");
3231
- const [showPasswords, setShowPasswords] = react.useState(false);
3232
- const [isLoading, setIsLoading] = react.useState(false);
3233
- const [error, setError] = react.useState(null);
3234
- const [success, setSuccess] = react.useState(false);
3828
+ const [oldPassword, setOldPassword] = React2.useState("");
3829
+ const [newPassword, setNewPassword] = React2.useState("");
3830
+ const [confirmPassword, setConfirmPassword] = React2.useState("");
3831
+ const [showPasswords, setShowPasswords] = React2.useState(false);
3832
+ const [isLoading, setIsLoading] = React2.useState(false);
3833
+ const [error, setError] = React2.useState(null);
3834
+ const [success, setSuccess] = React2.useState(false);
3235
3835
  const getPasswordStrength = (pwd) => {
3236
3836
  if (!pwd)
3237
3837
  return { strength: "weak", color: "#ddd" };
@@ -3474,43 +4074,41 @@ var UserProfile = ({
3474
4074
  showEmailChange = true,
3475
4075
  showPasswordChange = true
3476
4076
  }) => {
3477
- const { user, updateProfile, updateAvatar, requestEmailChange } = useAuth2();
3478
- const [name, setName] = react.useState(user?.name || "");
3479
- const [avatar, setAvatar] = react.useState("");
3480
- const [newEmail, setNewEmail] = react.useState("");
3481
- const [isLoading, setIsLoading] = react.useState(false);
3482
- const [error, setError] = react.useState(null);
3483
- const [success, setSuccess] = react.useState(null);
3484
- const handleUpdateName = async (e) => {
4077
+ const { user, updateProfile, requestEmailChange } = useAuth2();
4078
+ const colors = useThemeColors();
4079
+ const [name, setName] = React2.useState(user?.name || "");
4080
+ const [avatar, setAvatar] = React2.useState(user?.avatar || "");
4081
+ const [phoneNumber, setPhoneNumber] = React2.useState(user?.phoneNumber || "");
4082
+ const [newEmail, setNewEmail] = React2.useState("");
4083
+ const [isLoading, setIsLoading] = React2.useState(false);
4084
+ const [error, setError] = React2.useState(null);
4085
+ const [success, setSuccess] = React2.useState(null);
4086
+ const handleUpdateProfile = async (e) => {
3485
4087
  e.preventDefault();
3486
4088
  setIsLoading(true);
3487
4089
  setError(null);
3488
4090
  setSuccess(null);
3489
4091
  try {
3490
- const response = await updateProfile({ name });
3491
- if (response.success) {
3492
- setSuccess("Name updated successfully!");
3493
- } else {
3494
- setError(response.message || "Failed to update name");
4092
+ const updates = {};
4093
+ if (name !== user?.name) {
4094
+ updates.name = name;
3495
4095
  }
3496
- } catch (err) {
3497
- setError(err instanceof Error ? err.message : "An error occurred");
3498
- } finally {
3499
- setIsLoading(false);
3500
- }
3501
- };
3502
- const handleUpdateAvatar = async (e) => {
3503
- e.preventDefault();
3504
- setIsLoading(true);
3505
- setError(null);
3506
- setSuccess(null);
3507
- try {
3508
- const response = await updateAvatar(avatar);
4096
+ if (showAvatar && avatar !== user?.avatar) {
4097
+ updates.avatar = avatar;
4098
+ }
4099
+ if (phoneNumber !== user?.phoneNumber) {
4100
+ updates.phoneNumber = phoneNumber;
4101
+ }
4102
+ if (Object.keys(updates).length === 0) {
4103
+ setError("No changes to save");
4104
+ setIsLoading(false);
4105
+ return;
4106
+ }
4107
+ const response = await updateProfile(updates);
3509
4108
  if (response.success) {
3510
- setSuccess("Avatar updated successfully!");
3511
- setAvatar("");
4109
+ setSuccess("Profile updated successfully!");
3512
4110
  } else {
3513
- setError(response.message || "Failed to update avatar");
4111
+ setError(response.message || "Failed to update profile");
3514
4112
  }
3515
4113
  } catch (err) {
3516
4114
  setError(err instanceof Error ? err.message : "An error occurred");
@@ -3539,173 +4137,220 @@ var UserProfile = ({
3539
4137
  };
3540
4138
  if (!user)
3541
4139
  return null;
3542
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "600px", margin: "0 auto", padding: "20px" }, children: [
3543
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
4140
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4141
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
3544
4142
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3545
4143
  padding: "12px 16px",
3546
4144
  marginBottom: "20px",
3547
- backgroundColor: "#fee",
3548
- color: "#c33",
3549
- border: "1px solid #fcc",
4145
+ backgroundColor: colors.errorBg,
4146
+ color: colors.errorText,
4147
+ border: `1px solid ${colors.errorBorder}`,
3550
4148
  borderRadius: "8px",
3551
4149
  fontSize: "14px"
3552
4150
  }, children: error }),
3553
4151
  success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3554
4152
  padding: "12px 16px",
3555
4153
  marginBottom: "20px",
3556
- backgroundColor: "#efe",
3557
- color: "#3c3",
3558
- border: "1px solid #cfc",
4154
+ backgroundColor: colors.successBg,
4155
+ color: colors.successText,
4156
+ border: `1px solid ${colors.successBorder}`,
3559
4157
  borderRadius: "8px",
3560
4158
  fontSize: "14px"
3561
4159
  }, children: success }),
3562
4160
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3563
- padding: "20px",
3564
- backgroundColor: "#fff",
3565
- borderRadius: "8px",
4161
+ padding: "24px",
4162
+ backgroundColor: colors.bgPrimary,
4163
+ borderRadius: "12px",
3566
4164
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3567
- marginBottom: "20px"
4165
+ marginBottom: "24px",
4166
+ border: `1px solid ${colors.borderPrimary}`
3568
4167
  }, children: [
3569
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Name" }),
3570
- /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateName, children: [
3571
- /* @__PURE__ */ jsxRuntime.jsx(
3572
- "input",
3573
- {
3574
- type: "text",
3575
- value: name,
3576
- onChange: (e) => setName(e.target.value),
3577
- required: true,
3578
- disabled: isLoading,
3579
- style: {
3580
- width: "100%",
3581
- padding: "12px 16px",
3582
- border: "1px solid #ddd",
3583
- borderRadius: "8px",
3584
- fontSize: "16px",
3585
- boxSizing: "border-box",
3586
- marginBottom: "12px"
3587
- },
3588
- placeholder: "Your name"
3589
- }
3590
- ),
4168
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
4169
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateProfile, children: [
4170
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
4171
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
4172
+ display: "block",
4173
+ marginBottom: "8px",
4174
+ fontWeight: 500,
4175
+ color: colors.textSecondary,
4176
+ fontSize: "14px"
4177
+ }, children: "Full Name" }),
4178
+ /* @__PURE__ */ jsxRuntime.jsx(
4179
+ "input",
4180
+ {
4181
+ id: "name",
4182
+ type: "text",
4183
+ value: name,
4184
+ onChange: (e) => setName(e.target.value),
4185
+ required: true,
4186
+ disabled: isLoading,
4187
+ style: {
4188
+ width: "100%",
4189
+ padding: "12px 16px",
4190
+ border: `1px solid ${colors.borderSecondary}`,
4191
+ borderRadius: "8px",
4192
+ fontSize: "16px",
4193
+ boxSizing: "border-box",
4194
+ backgroundColor: colors.bgSecondary,
4195
+ color: colors.textPrimary,
4196
+ transition: "all 0.2s ease"
4197
+ },
4198
+ placeholder: "Manish Batra"
4199
+ }
4200
+ )
4201
+ ] }),
4202
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
4203
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
4204
+ display: "block",
4205
+ marginBottom: "8px",
4206
+ fontWeight: 500,
4207
+ color: colors.textSecondary,
4208
+ fontSize: "14px"
4209
+ }, children: "Phone Number" }),
4210
+ /* @__PURE__ */ jsxRuntime.jsx(
4211
+ PhoneInput,
4212
+ {
4213
+ id: "phoneNumber",
4214
+ value: phoneNumber,
4215
+ onChange: setPhoneNumber,
4216
+ disabled: isLoading,
4217
+ placeholder: "1234567890"
4218
+ }
4219
+ )
4220
+ ] }),
4221
+ showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
4222
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "avatar", style: {
4223
+ display: "block",
4224
+ marginBottom: "8px",
4225
+ fontWeight: 500,
4226
+ color: colors.textSecondary,
4227
+ fontSize: "14px"
4228
+ }, children: "Avatar URL" }),
4229
+ /* @__PURE__ */ jsxRuntime.jsx(
4230
+ "input",
4231
+ {
4232
+ id: "avatar",
4233
+ type: "url",
4234
+ value: avatar,
4235
+ onChange: (e) => setAvatar(e.target.value),
4236
+ disabled: isLoading,
4237
+ style: {
4238
+ width: "100%",
4239
+ padding: "12px 16px",
4240
+ border: `1px solid ${colors.borderSecondary}`,
4241
+ borderRadius: "8px",
4242
+ fontSize: "16px",
4243
+ boxSizing: "border-box",
4244
+ backgroundColor: colors.bgSecondary,
4245
+ color: colors.textPrimary,
4246
+ transition: "all 0.2s ease"
4247
+ },
4248
+ placeholder: "https://example.com/avatar.jpg"
4249
+ }
4250
+ )
4251
+ ] }),
3591
4252
  /* @__PURE__ */ jsxRuntime.jsx(
3592
4253
  "button",
3593
4254
  {
3594
4255
  type: "submit",
3595
4256
  disabled: isLoading,
3596
- style: {
3597
- padding: "10px 20px",
3598
- backgroundColor: "#007bff",
3599
- color: "white",
3600
- border: "none",
3601
- borderRadius: "8px",
3602
- fontSize: "14px",
3603
- fontWeight: 600,
3604
- cursor: "pointer"
4257
+ onMouseEnter: (e) => {
4258
+ if (!isLoading) {
4259
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4260
+ }
3605
4261
  },
3606
- children: "Update Name"
3607
- }
3608
- )
3609
- ] })
3610
- ] }),
3611
- showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3612
- padding: "20px",
3613
- backgroundColor: "#fff",
3614
- borderRadius: "8px",
3615
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3616
- marginBottom: "20px"
3617
- }, children: [
3618
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
3619
- /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateAvatar, children: [
3620
- /* @__PURE__ */ jsxRuntime.jsx(
3621
- "input",
3622
- {
3623
- type: "url",
3624
- value: avatar,
3625
- onChange: (e) => setAvatar(e.target.value),
3626
- required: true,
3627
- disabled: isLoading,
3628
- style: {
3629
- width: "100%",
3630
- padding: "12px 16px",
3631
- border: "1px solid #ddd",
3632
- borderRadius: "8px",
3633
- fontSize: "16px",
3634
- boxSizing: "border-box",
3635
- marginBottom: "12px"
4262
+ onMouseLeave: (e) => {
4263
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3636
4264
  },
3637
- placeholder: "Avatar URL"
3638
- }
3639
- ),
3640
- /* @__PURE__ */ jsxRuntime.jsx(
3641
- "button",
3642
- {
3643
- type: "submit",
3644
- disabled: isLoading,
3645
4265
  style: {
3646
- padding: "10px 20px",
3647
- backgroundColor: "#007bff",
4266
+ padding: "12px 24px",
4267
+ backgroundColor: colors.buttonPrimary,
3648
4268
  color: "white",
3649
4269
  border: "none",
3650
4270
  borderRadius: "8px",
3651
4271
  fontSize: "14px",
3652
4272
  fontWeight: 600,
3653
- cursor: "pointer"
4273
+ cursor: isLoading ? "not-allowed" : "pointer",
4274
+ opacity: isLoading ? 0.6 : 1,
4275
+ transition: "all 0.2s ease"
3654
4276
  },
3655
- children: "Update Avatar"
4277
+ children: isLoading ? "Saving..." : "Save Changes"
3656
4278
  }
3657
4279
  )
3658
4280
  ] })
3659
4281
  ] }),
3660
4282
  showEmailChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
3661
- padding: "20px",
3662
- backgroundColor: "#fff",
3663
- borderRadius: "8px",
4283
+ padding: "24px",
4284
+ backgroundColor: colors.bgPrimary,
4285
+ borderRadius: "12px",
3664
4286
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3665
- marginBottom: "20px"
4287
+ marginBottom: "20px",
4288
+ border: `1px solid ${colors.borderPrimary}`
3666
4289
  }, children: [
3667
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
3668
- /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color: "#666", marginBottom: "12px" }, children: [
4290
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
4291
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
3669
4292
  "Current email: ",
3670
4293
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: user.email })
3671
4294
  ] }),
3672
4295
  /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleRequestEmailChange, children: [
3673
- /* @__PURE__ */ jsxRuntime.jsx(
3674
- "input",
3675
- {
3676
- type: "email",
3677
- value: newEmail,
3678
- onChange: (e) => setNewEmail(e.target.value),
3679
- required: true,
3680
- disabled: isLoading,
3681
- style: {
3682
- width: "100%",
3683
- padding: "12px 16px",
3684
- border: "1px solid #ddd",
3685
- borderRadius: "8px",
3686
- fontSize: "16px",
3687
- boxSizing: "border-box",
3688
- marginBottom: "12px"
3689
- },
3690
- placeholder: "New email address"
3691
- }
3692
- ),
4296
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
4297
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "newEmail", style: {
4298
+ display: "block",
4299
+ marginBottom: "8px",
4300
+ fontWeight: 500,
4301
+ color: colors.textSecondary,
4302
+ fontSize: "14px"
4303
+ }, children: "New Email Address" }),
4304
+ /* @__PURE__ */ jsxRuntime.jsx(
4305
+ "input",
4306
+ {
4307
+ id: "newEmail",
4308
+ type: "email",
4309
+ value: newEmail,
4310
+ onChange: (e) => setNewEmail(e.target.value),
4311
+ required: true,
4312
+ disabled: isLoading,
4313
+ style: {
4314
+ width: "100%",
4315
+ padding: "12px 16px",
4316
+ border: `1px solid ${colors.borderSecondary}`,
4317
+ borderRadius: "8px",
4318
+ fontSize: "16px",
4319
+ boxSizing: "border-box",
4320
+ backgroundColor: colors.bgSecondary,
4321
+ color: colors.textPrimary,
4322
+ transition: "all 0.2s ease"
4323
+ },
4324
+ placeholder: "newemail@example.com"
4325
+ }
4326
+ )
4327
+ ] }),
3693
4328
  /* @__PURE__ */ jsxRuntime.jsx(
3694
4329
  "button",
3695
4330
  {
3696
4331
  type: "submit",
3697
4332
  disabled: isLoading,
4333
+ onMouseEnter: (e) => {
4334
+ if (!isLoading) {
4335
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4336
+ }
4337
+ },
4338
+ onMouseLeave: (e) => {
4339
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
4340
+ },
3698
4341
  style: {
3699
- padding: "10px 20px",
3700
- backgroundColor: "#007bff",
4342
+ padding: "12px 24px",
4343
+ backgroundColor: colors.buttonPrimary,
3701
4344
  color: "white",
3702
4345
  border: "none",
3703
4346
  borderRadius: "8px",
3704
4347
  fontSize: "14px",
3705
4348
  fontWeight: 600,
3706
- cursor: "pointer"
4349
+ cursor: isLoading ? "not-allowed" : "pointer",
4350
+ opacity: isLoading ? 0.6 : 1,
4351
+ transition: "all 0.2s ease"
3707
4352
  },
3708
- children: "Request Email Change"
4353
+ children: isLoading ? "Sending..." : "Request Email Change"
3709
4354
  }
3710
4355
  )
3711
4356
  ] })
@@ -3719,6 +4364,7 @@ exports.EmailVerificationPage = EmailVerificationPage;
3719
4364
  exports.ForgotPassword = ForgotPassword;
3720
4365
  exports.LoginForm = LoginForm;
3721
4366
  exports.OtpForm = OtpForm;
4367
+ exports.PhoneInput = PhoneInput;
3722
4368
  exports.ProtectedRoute = ProtectedRoute;
3723
4369
  exports.PublicRoute = PublicRoute;
3724
4370
  exports.RegisterForm = RegisterForm;