@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,14 +1,17 @@
1
- import { createContext, useState, useEffect, useRef, useCallback, useContext } from 'react';
1
+ "use client";
2
+ import React2, { createContext, forwardRef, useContext, useState, useMemo, useEffect, useRef, useCallback } from 'react';
2
3
  import axios from 'axios';
3
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import PhoneInputWithCountry from 'react-phone-number-input';
6
+ import 'react-phone-number-input/style.css';
4
7
 
5
- // src/react/components/LoginForm.tsx
6
8
  var HttpClient = class {
7
9
  constructor(baseUrl, defaultHeaders = {}) {
8
10
  this.csrfToken = null;
9
11
  this.frontendBaseUrl = null;
12
+ this.baseUrl = baseUrl.replace(/\/$/, "");
10
13
  this.axiosInstance = axios.create({
11
- baseURL: baseUrl.replace(/\/$/, ""),
14
+ baseURL: this.baseUrl,
12
15
  headers: {
13
16
  "Content-Type": "application/json",
14
17
  ...defaultHeaders
@@ -19,8 +22,16 @@ var HttpClient = class {
19
22
  // 30 second timeout
20
23
  });
21
24
  this.axiosInstance.interceptors.request.use(
22
- (config) => {
23
- if (this.csrfToken && ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "")) {
25
+ async (config) => {
26
+ const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
27
+ if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
28
+ try {
29
+ await this.refreshCsrfToken();
30
+ } catch (error) {
31
+ console.warn("Failed to fetch CSRF token:", error);
32
+ }
33
+ }
34
+ if (this.csrfToken && isMutatingRequest) {
24
35
  config.headers["x-csrf-token"] = this.csrfToken;
25
36
  }
26
37
  if (this.frontendBaseUrl) {
@@ -118,9 +129,6 @@ var AuthService = class {
118
129
  this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
119
130
  }
120
131
  }
121
- if (this.config.csrfEnabled && typeof window !== "undefined") {
122
- this.refreshCsrfToken();
123
- }
124
132
  }
125
133
  loadTokenFromStorage() {
126
134
  if (typeof window !== "undefined" && this.config.localStorageKey) {
@@ -222,7 +230,7 @@ var AuthService = class {
222
230
  this.saveTokenToStorage(response.token);
223
231
  return response;
224
232
  }
225
- if (response.success && response.message === "OTP sent to your email.") {
233
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
226
234
  return response;
227
235
  }
228
236
  if (response.success && response.message === "OTP verified successfully." && response.token) {
@@ -293,7 +301,7 @@ var AuthService = class {
293
301
  if (!this.token) {
294
302
  throw new Error("Not authenticated");
295
303
  }
296
- const response = await this.httpClient.post("/api/v1/user/update/user", data);
304
+ const response = await this.httpClient.post("/api/v1/user/update/profile", data);
297
305
  if (response.success && response.token) {
298
306
  this.token = response.token;
299
307
  this.httpClient.setAuthToken(response.token);
@@ -334,7 +342,7 @@ var AuthService = class {
334
342
  if (!this.token) {
335
343
  throw new Error("Not authenticated");
336
344
  }
337
- const response = await this.httpClient.post("/api/v1/user/update/avatar", { avatar });
345
+ const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
338
346
  if (response.success && response.token) {
339
347
  this.token = response.token;
340
348
  this.httpClient.setAuthToken(response.token);
@@ -397,21 +405,21 @@ var AuthService = class {
397
405
  if (!this.token) {
398
406
  throw new Error("Not authenticated");
399
407
  }
400
- const response = await this.httpClient.get("/api/v1/session");
408
+ const response = await this.httpClient.get("/api/v1/sessions");
401
409
  return response;
402
410
  }
403
411
  async revokeSession(sessionId) {
404
412
  if (!this.token) {
405
413
  throw new Error("Not authenticated");
406
414
  }
407
- const response = await this.httpClient.delete(`/api/v1/session/${sessionId}`);
415
+ const response = await this.httpClient.delete(`/api/v1/sessions/${sessionId}`);
408
416
  return response;
409
417
  }
410
418
  async revokeAllSessions() {
411
419
  if (!this.token) {
412
420
  throw new Error("Not authenticated");
413
421
  }
414
- const response = await this.httpClient.delete("/api/v1/session/revoke/all");
422
+ const response = await this.httpClient.delete("/api/v1/sessions/revoke/all");
415
423
  this.token = null;
416
424
  this.httpClient.removeAuthToken();
417
425
  this.removeTokenFromStorage();
@@ -589,6 +597,271 @@ var useAuth = (config) => {
589
597
  getUserById
590
598
  };
591
599
  };
600
+ var ThemeContext = createContext({ theme: "light", mounted: false });
601
+ function useAuthTheme() {
602
+ return useContext(ThemeContext);
603
+ }
604
+
605
+ // src/react/hooks/useThemeColors.ts
606
+ var lightTheme = {
607
+ bgPrimary: "var(--auth-bg-primary, #ffffff)",
608
+ bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
609
+ bgHover: "var(--auth-bg-hover, #f1f5f9)",
610
+ textPrimary: "var(--auth-text-primary, #0f172a)",
611
+ textSecondary: "var(--auth-text-secondary, #475569)",
612
+ textTertiary: "var(--auth-text-tertiary, #94a3b8)",
613
+ borderPrimary: "var(--auth-border-primary, #e2e8f0)",
614
+ borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
615
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
616
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
617
+ errorBg: "var(--auth-error-bg, #fef2f2)",
618
+ errorText: "var(--auth-error-text, #dc2626)",
619
+ errorBorder: "var(--auth-error-border, #fecaca)",
620
+ successBg: "var(--auth-success-bg, #f0fdf4)",
621
+ successText: "var(--auth-success-text, #16a34a)",
622
+ successBorder: "var(--auth-success-border, #bbf7d0)"
623
+ };
624
+ var darkTheme = {
625
+ bgPrimary: "var(--auth-bg-primary, #1f2937)",
626
+ bgSecondary: "var(--auth-bg-secondary, #111827)",
627
+ bgHover: "var(--auth-bg-hover, #374151)",
628
+ textPrimary: "var(--auth-text-primary, #f9fafb)",
629
+ textSecondary: "var(--auth-text-secondary, #e5e7eb)",
630
+ textTertiary: "var(--auth-text-tertiary, #d1d5db)",
631
+ borderPrimary: "var(--auth-border-primary, #374151)",
632
+ borderSecondary: "var(--auth-border-secondary, #4b5563)",
633
+ buttonPrimary: "var(--auth-button-primary, #3b82f6)",
634
+ buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
635
+ errorBg: "var(--auth-error-bg, #7f1d1d)",
636
+ errorText: "var(--auth-error-text, #fecaca)",
637
+ errorBorder: "var(--auth-error-border, #991b1b)",
638
+ successBg: "var(--auth-success-bg, #14532d)",
639
+ successText: "var(--auth-success-text, #bbf7d0)",
640
+ successBorder: "var(--auth-success-border, #166534)"
641
+ };
642
+ function useThemeColors() {
643
+ const { theme } = useAuthTheme();
644
+ return theme === "dark" ? darkTheme : lightTheme;
645
+ }
646
+ var CustomPhoneInput = React2.forwardRef((props, ref) => /* @__PURE__ */ jsx(
647
+ "input",
648
+ {
649
+ ...props,
650
+ ref,
651
+ className: "PhoneInputInput"
652
+ }
653
+ ));
654
+ CustomPhoneInput.displayName = "CustomPhoneInput";
655
+ var PhoneInput = ({
656
+ value,
657
+ onChange,
658
+ disabled = false,
659
+ required = false,
660
+ placeholder = "Enter phone number",
661
+ id = "phone",
662
+ style = {}
663
+ }) => {
664
+ const colors = useThemeColors();
665
+ const [defaultCountry, setDefaultCountry] = useState("US");
666
+ const styleContent = useMemo(() => `
667
+ .PhoneInput {
668
+ display: flex;
669
+ align-items: center;
670
+ gap: 8px;
671
+ }
672
+
673
+ .PhoneInputCountry {
674
+ position: relative;
675
+ align-self: stretch;
676
+ display: flex;
677
+ align-items: center;
678
+ padding: 0 8px;
679
+ border: 1px solid ${colors.borderSecondary};
680
+ border-radius: 8px;
681
+ background-color: ${colors.bgSecondary};
682
+ transition: all 0.2s ease;
683
+ }
684
+
685
+ .PhoneInputCountry:focus-within {
686
+ border-color: ${colors.buttonPrimary};
687
+ outline: 2px solid ${colors.buttonPrimary}40;
688
+ }
689
+
690
+ .PhoneInputCountryIcon {
691
+ width: 24px;
692
+ height: 24px;
693
+ margin-right: 4px;
694
+ }
695
+
696
+ .PhoneInputCountryIcon--border {
697
+ box-shadow: none;
698
+ }
699
+
700
+ .PhoneInputCountrySelect {
701
+ position: absolute;
702
+ top: 0;
703
+ left: 0;
704
+ height: 100%;
705
+ width: 100%;
706
+ z-index: 1;
707
+ border: 0;
708
+ opacity: 0;
709
+ cursor: pointer;
710
+ color: ${colors.textPrimary};
711
+ background-color: ${colors.bgSecondary};
712
+ }
713
+
714
+ .PhoneInputCountrySelect:disabled {
715
+ cursor: not-allowed;
716
+ }
717
+
718
+ /* Dropdown menu styling */
719
+ .PhoneInputCountrySelect option {
720
+ background-color: ${colors.bgPrimary};
721
+ color: ${colors.textPrimary};
722
+ padding: 8px 12px;
723
+ font-size: 14px;
724
+ }
725
+
726
+ .PhoneInputCountrySelect option:hover,
727
+ .PhoneInputCountrySelect option:focus,
728
+ .PhoneInputCountrySelect option:checked {
729
+ background-color: ${colors.buttonPrimary};
730
+ color: white;
731
+ }
732
+
733
+ .PhoneInputCountrySelectArrow {
734
+ display: block;
735
+ content: '';
736
+ width: 0.3em;
737
+ height: 0.3em;
738
+ margin-left: 0.35em;
739
+ border-style: solid;
740
+ border-color: ${colors.textPrimary};
741
+ border-top-width: 0;
742
+ border-bottom-width: 1px;
743
+ border-left-width: 0;
744
+ border-right-width: 1px;
745
+ transform: rotate(45deg);
746
+ opacity: 0.7;
747
+ }
748
+
749
+ .PhoneInputInput {
750
+ flex: 1;
751
+ min-width: 0;
752
+ padding: 12px 16px;
753
+ border: 1px solid ${colors.borderSecondary};
754
+ border-radius: 8px;
755
+ font-size: 16px;
756
+ background-color: ${colors.bgSecondary};
757
+ color: ${colors.textPrimary};
758
+ transition: all 0.2s ease;
759
+ -webkit-text-fill-color: ${colors.textPrimary};
760
+ -webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
761
+ }
762
+
763
+ .PhoneInputInput:focus {
764
+ border-color: ${colors.buttonPrimary};
765
+ outline: 2px solid ${colors.buttonPrimary}40;
766
+ }
767
+
768
+ .PhoneInputInput:disabled {
769
+ cursor: not-allowed;
770
+ opacity: 0.6;
771
+ }
772
+
773
+ .PhoneInputInput::placeholder {
774
+ color: ${colors.textTertiary};
775
+ opacity: 0.6;
776
+ }
777
+ `, [colors]);
778
+ useEffect(() => {
779
+ const detectCountry = async () => {
780
+ try {
781
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
782
+ const timezoneToCountry = {
783
+ "America/New_York": "US",
784
+ "America/Chicago": "US",
785
+ "America/Denver": "US",
786
+ "America/Los_Angeles": "US",
787
+ "America/Phoenix": "US",
788
+ "America/Anchorage": "US",
789
+ "Pacific/Honolulu": "US",
790
+ "Europe/London": "GB",
791
+ "Europe/Paris": "FR",
792
+ "Europe/Berlin": "DE",
793
+ "Europe/Rome": "IT",
794
+ "Europe/Madrid": "ES",
795
+ "Asia/Dubai": "AE",
796
+ "Asia/Kolkata": "IN",
797
+ "Asia/Shanghai": "CN",
798
+ "Asia/Tokyo": "JP",
799
+ "Asia/Seoul": "KR",
800
+ "Asia/Singapore": "SG",
801
+ "Asia/Hong_Kong": "HK",
802
+ "Australia/Sydney": "AU",
803
+ "Pacific/Auckland": "NZ",
804
+ "America/Toronto": "CA",
805
+ "America/Vancouver": "CA",
806
+ "America/Mexico_City": "MX",
807
+ "America/Sao_Paulo": "BR",
808
+ "America/Buenos_Aires": "AR",
809
+ "Africa/Cairo": "EG",
810
+ "Africa/Johannesburg": "ZA",
811
+ "Africa/Lagos": "NG",
812
+ "Africa/Nairobi": "KE"
813
+ };
814
+ const detectedCountry = timezoneToCountry[timezone];
815
+ if (detectedCountry) {
816
+ setDefaultCountry(detectedCountry);
817
+ return;
818
+ }
819
+ const response = await fetch("https://ipapi.co/json/", {
820
+ signal: AbortSignal.timeout(3e3)
821
+ // 3 second timeout
822
+ });
823
+ if (response.ok) {
824
+ const data = await response.json();
825
+ if (data.country_code) {
826
+ setDefaultCountry(data.country_code);
827
+ }
828
+ }
829
+ } catch (error) {
830
+ console.log("Country detection failed, using default US");
831
+ }
832
+ };
833
+ detectCountry();
834
+ }, []);
835
+ const handleChange = useMemo(() => (val) => {
836
+ onChange(val || "");
837
+ }, [onChange]);
838
+ return /* @__PURE__ */ jsxs(
839
+ "div",
840
+ {
841
+ style: {
842
+ width: "100%",
843
+ ...style
844
+ },
845
+ children: [
846
+ /* @__PURE__ */ jsx("style", { children: styleContent }),
847
+ /* @__PURE__ */ jsx(
848
+ PhoneInputWithCountry,
849
+ {
850
+ id,
851
+ international: true,
852
+ defaultCountry,
853
+ value: value || "",
854
+ onChange: handleChange,
855
+ disabled,
856
+ placeholder,
857
+ inputComponent: CustomPhoneInput
858
+ },
859
+ id
860
+ )
861
+ ]
862
+ }
863
+ );
864
+ };
592
865
  var LoginForm = ({
593
866
  onSuccess,
594
867
  onLoginSuccess,
@@ -598,7 +871,10 @@ var LoginForm = ({
598
871
  oauthProviders = ["google", "github"],
599
872
  showOAuthButtons = true
600
873
  }) => {
874
+ const colors = useThemeColors();
601
875
  const [email, setEmail] = useState("");
876
+ const [phoneNumber, setPhoneNumber] = useState("");
877
+ const [usePhone, setUsePhone] = useState(false);
602
878
  const [password, setPassword] = useState("");
603
879
  const [usePassword, setUsePassword] = useState(false);
604
880
  const [showPassword, setShowPassword] = useState(false);
@@ -606,7 +882,7 @@ var LoginForm = ({
606
882
  const [error, setError] = useState(null);
607
883
  const [rememberMe, setRememberMe] = useState(false);
608
884
  const { login } = useAuth({
609
- baseUrl: config?.baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
885
+ baseUrl: config?.baseUrl || "http://localhost:7000"
610
886
  });
611
887
  const handleSubmit = async (e) => {
612
888
  e.preventDefault();
@@ -614,20 +890,28 @@ var LoginForm = ({
614
890
  setError(null);
615
891
  try {
616
892
  let response;
893
+ const loginData = {};
894
+ if (usePhone && phoneNumber) {
895
+ loginData.phoneNumber = phoneNumber;
896
+ } else if (email) {
897
+ loginData.email = email;
898
+ }
617
899
  if (usePassword) {
618
- response = await login({ email, password });
900
+ loginData.password = password;
901
+ response = await login(loginData);
619
902
  } else {
620
- response = await login({ email });
903
+ response = await login(loginData);
621
904
  }
622
905
  if (response.success) {
623
906
  onSuccess?.(response);
624
907
  if (onLoginSuccess) {
625
- if (response.message === "OTP sent to your email.") {
626
- onLoginSuccess(email, true);
908
+ const identifier = usePhone ? phoneNumber : email;
909
+ if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
910
+ onLoginSuccess(identifier, true);
627
911
  } else if (response.token) {
628
- onLoginSuccess(email, false);
912
+ onLoginSuccess(identifier, false);
629
913
  } else {
630
- onLoginSuccess(email, true);
914
+ onLoginSuccess(identifier, true);
631
915
  }
632
916
  }
633
917
  } else {
@@ -649,43 +933,53 @@ var LoginForm = ({
649
933
  return /* @__PURE__ */ jsx("div", { style: {
650
934
  maxWidth: "400px",
651
935
  margin: "0 auto",
652
- padding: "30px",
936
+ padding: "24px",
653
937
  borderRadius: "12px",
654
938
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
655
- backgroundColor: "#ffffff",
656
- border: "1px solid #eaeaea"
939
+ backgroundColor: colors.bgPrimary,
940
+ border: `1px solid ${colors.borderPrimary}`
657
941
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
658
942
  display: "flex",
659
943
  flexDirection: "column"
660
944
  }, children: [
661
945
  /* @__PURE__ */ jsx("h2", { style: {
662
946
  textAlign: "center",
663
- marginBottom: "24px",
664
- color: "#1f2937",
947
+ marginBottom: "20px",
948
+ color: colors.textPrimary,
665
949
  fontSize: "24px",
666
950
  fontWeight: 600
667
951
  }, children: usePassword ? "Login with Password" : "Login with OTP" }),
668
952
  error && /* @__PURE__ */ jsx("div", { style: {
669
953
  padding: "12px 16px",
670
- marginBottom: "20px",
671
- backgroundColor: "#f8d7da",
672
- color: "#721c24",
673
- border: "1px solid #f5c6cb",
954
+ marginBottom: "16px",
955
+ backgroundColor: colors.errorBg,
956
+ color: colors.errorText,
957
+ border: `1px solid ${colors.errorBorder}`,
674
958
  borderRadius: "8px",
675
959
  fontSize: "14px",
676
960
  fontWeight: 500
677
961
  }, children: error }),
678
962
  /* @__PURE__ */ jsxs("div", { style: {
679
- marginBottom: "20px"
963
+ marginBottom: "16px"
680
964
  }, children: [
681
- /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
965
+ /* @__PURE__ */ jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
682
966
  display: "block",
683
967
  marginBottom: "8px",
684
968
  fontWeight: 500,
685
- color: "#374151",
969
+ color: colors.textSecondary,
686
970
  fontSize: "14px"
687
- }, children: "Email:" }),
688
- /* @__PURE__ */ jsx(
971
+ }, children: usePhone ? "Phone Number:" : "Email:" }),
972
+ usePhone ? /* @__PURE__ */ jsx(
973
+ PhoneInput,
974
+ {
975
+ id: "phone",
976
+ value: phoneNumber,
977
+ onChange: setPhoneNumber,
978
+ required: true,
979
+ disabled: isLoading,
980
+ placeholder: "1234567890"
981
+ }
982
+ ) : /* @__PURE__ */ jsx(
689
983
  "input",
690
984
  {
691
985
  id: "email",
@@ -697,27 +991,48 @@ var LoginForm = ({
697
991
  style: {
698
992
  width: "100%",
699
993
  padding: "12px 16px",
700
- border: "1px solid #ddd",
994
+ border: `1px solid ${colors.borderSecondary}`,
701
995
  borderRadius: "8px",
702
996
  fontSize: "16px",
703
997
  boxSizing: "border-box",
704
- color: "#111827",
998
+ color: colors.textPrimary,
705
999
  transition: "all 0.2s ease",
706
- backgroundColor: "#ffffff"
1000
+ backgroundColor: colors.bgSecondary
707
1001
  },
708
1002
  placeholder: "Enter your email"
709
1003
  }
1004
+ ),
1005
+ /* @__PURE__ */ jsx(
1006
+ "button",
1007
+ {
1008
+ type: "button",
1009
+ onClick: () => setUsePhone(!usePhone),
1010
+ disabled: isLoading,
1011
+ style: {
1012
+ marginTop: "8px",
1013
+ background: "none",
1014
+ border: "none",
1015
+ color: colors.buttonPrimary,
1016
+ textDecoration: "none",
1017
+ cursor: "pointer",
1018
+ fontSize: "13px",
1019
+ fontWeight: 500,
1020
+ padding: "0",
1021
+ transition: "color 0.2s ease"
1022
+ },
1023
+ children: usePhone ? "Use email instead" : "Use phone number instead"
1024
+ }
710
1025
  )
711
1026
  ] }),
712
1027
  usePassword && /* @__PURE__ */ jsxs("div", { style: {
713
- marginBottom: "20px",
1028
+ marginBottom: "16px",
714
1029
  position: "relative"
715
1030
  }, children: [
716
1031
  /* @__PURE__ */ jsx("label", { htmlFor: "login-password", style: {
717
1032
  display: "block",
718
1033
  marginBottom: "8px",
719
1034
  fontWeight: 500,
720
- color: "#555",
1035
+ color: colors.textSecondary,
721
1036
  fontSize: "14px"
722
1037
  }, children: "Password:" }),
723
1038
  /* @__PURE__ */ jsx(
@@ -732,13 +1047,13 @@ var LoginForm = ({
732
1047
  style: {
733
1048
  width: "100%",
734
1049
  padding: "12px 16px",
735
- border: "1px solid #ddd",
1050
+ border: `1px solid ${colors.borderSecondary}`,
736
1051
  borderRadius: "8px",
737
1052
  fontSize: "16px",
738
1053
  boxSizing: "border-box",
739
- color: "#333",
1054
+ color: colors.textPrimary,
740
1055
  transition: "all 0.2s ease",
741
- backgroundColor: "#fafafa"
1056
+ backgroundColor: colors.bgSecondary
742
1057
  },
743
1058
  placeholder: "Enter your password"
744
1059
  }
@@ -756,7 +1071,7 @@ var LoginForm = ({
756
1071
  background: "none",
757
1072
  border: "none",
758
1073
  cursor: "pointer",
759
- color: "#666",
1074
+ color: colors.textTertiary,
760
1075
  fontSize: "14px"
761
1076
  },
762
1077
  children: showPassword ? "Hide" : "Show"
@@ -766,8 +1081,8 @@ var LoginForm = ({
766
1081
  usePassword && /* @__PURE__ */ jsxs("div", { style: {
767
1082
  display: "flex",
768
1083
  alignItems: "center",
769
- marginBottom: "16px",
770
- marginTop: "8px"
1084
+ marginBottom: "12px",
1085
+ marginTop: "4px"
771
1086
  }, children: [
772
1087
  /* @__PURE__ */ jsx(
773
1088
  "input",
@@ -791,7 +1106,7 @@ var LoginForm = ({
791
1106
  htmlFor: "remember-me",
792
1107
  style: {
793
1108
  fontSize: "14px",
794
- color: "#666",
1109
+ color: colors.textSecondary,
795
1110
  cursor: "pointer",
796
1111
  userSelect: "none"
797
1112
  },
@@ -806,7 +1121,7 @@ var LoginForm = ({
806
1121
  disabled: isLoading,
807
1122
  style: {
808
1123
  padding: "14px",
809
- backgroundColor: "#007bff",
1124
+ backgroundColor: colors.buttonPrimary,
810
1125
  color: "white",
811
1126
  border: "none",
812
1127
  borderRadius: "8px",
@@ -814,16 +1129,16 @@ var LoginForm = ({
814
1129
  fontWeight: 600,
815
1130
  cursor: "pointer",
816
1131
  transition: "all 0.2s ease",
817
- marginTop: "8px"
1132
+ marginTop: "4px"
818
1133
  },
819
1134
  children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
820
1135
  }
821
1136
  ),
822
1137
  /* @__PURE__ */ jsx("div", { style: {
823
1138
  textAlign: "center",
824
- marginTop: "20px",
825
- paddingTop: "20px",
826
- borderTop: "1px solid #eee"
1139
+ marginTop: "16px",
1140
+ paddingTop: "16px",
1141
+ borderTop: `1px solid ${colors.borderPrimary}`
827
1142
  }, children: /* @__PURE__ */ jsx(
828
1143
  "button",
829
1144
  {
@@ -833,7 +1148,7 @@ var LoginForm = ({
833
1148
  style: {
834
1149
  background: "none",
835
1150
  border: "none",
836
- color: "#007bff",
1151
+ color: colors.buttonPrimary,
837
1152
  textDecoration: "none",
838
1153
  cursor: "pointer",
839
1154
  fontSize: "14px",
@@ -845,9 +1160,9 @@ var LoginForm = ({
845
1160
  }
846
1161
  ) }),
847
1162
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
848
- marginTop: "20px",
849
- paddingTop: "20px",
850
- borderTop: "1px solid #eee"
1163
+ marginTop: "16px",
1164
+ paddingTop: "16px",
1165
+ borderTop: `1px solid ${colors.borderPrimary}`
851
1166
  }, children: [
852
1167
  /* @__PURE__ */ jsxs("div", { style: {
853
1168
  position: "relative",
@@ -859,15 +1174,15 @@ var LoginForm = ({
859
1174
  left: 0,
860
1175
  right: 0,
861
1176
  height: "1px",
862
- backgroundColor: "#eee"
1177
+ backgroundColor: colors.borderPrimary
863
1178
  } }),
864
1179
  /* @__PURE__ */ jsx("div", { style: {
865
1180
  position: "relative",
866
1181
  textAlign: "center"
867
1182
  }, children: /* @__PURE__ */ jsx("span", { style: {
868
- backgroundColor: "#ffffff",
1183
+ backgroundColor: colors.bgPrimary,
869
1184
  padding: "0 12px",
870
- color: "#666",
1185
+ color: colors.textSecondary,
871
1186
  fontSize: "14px"
872
1187
  }, children: "Or continue with" }) })
873
1188
  ] }),
@@ -886,10 +1201,10 @@ var LoginForm = ({
886
1201
  justifyContent: "center",
887
1202
  gap: "8px",
888
1203
  padding: "10px 16px",
889
- backgroundColor: "#ffffff",
890
- border: "1px solid #ddd",
1204
+ backgroundColor: colors.bgPrimary,
1205
+ border: `1px solid ${colors.borderSecondary}`,
891
1206
  borderRadius: "8px",
892
- color: "#333",
1207
+ color: colors.textPrimary,
893
1208
  textDecoration: "none",
894
1209
  fontSize: "14px",
895
1210
  fontWeight: 500,
@@ -897,12 +1212,12 @@ var LoginForm = ({
897
1212
  transition: "all 0.2s ease"
898
1213
  },
899
1214
  onMouseEnter: (e) => {
900
- e.currentTarget.style.backgroundColor = "#f8f8f8";
901
- e.currentTarget.style.borderColor = "#007bff";
1215
+ e.currentTarget.style.backgroundColor = colors.bgHover;
1216
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
902
1217
  },
903
1218
  onMouseLeave: (e) => {
904
- e.currentTarget.style.backgroundColor = "#ffffff";
905
- e.currentTarget.style.borderColor = "#ddd";
1219
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
1220
+ e.currentTarget.style.borderColor = colors.borderSecondary;
906
1221
  },
907
1222
  children: [
908
1223
  /* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -977,11 +1292,11 @@ var LoginForm = ({
977
1292
  ] }),
978
1293
  showRegisterLink && /* @__PURE__ */ jsx("div", { style: {
979
1294
  textAlign: "center",
980
- marginTop: "20px",
981
- paddingTop: "20px",
982
- borderTop: "1px solid #eee"
1295
+ marginTop: "16px",
1296
+ paddingTop: "16px",
1297
+ borderTop: `1px solid ${colors.borderPrimary}`
983
1298
  }, children: /* @__PURE__ */ jsxs("p", { style: {
984
- color: "#666",
1299
+ color: colors.textSecondary,
985
1300
  fontSize: "14px"
986
1301
  }, children: [
987
1302
  "Don't have an account?",
@@ -995,7 +1310,7 @@ var LoginForm = ({
995
1310
  style: {
996
1311
  background: "none",
997
1312
  border: "none",
998
- color: "#007bff",
1313
+ color: colors.buttonPrimary,
999
1314
  textDecoration: "none",
1000
1315
  cursor: "pointer",
1001
1316
  fontSize: "14px",
@@ -1015,10 +1330,13 @@ var RegisterForm = ({
1015
1330
  showLoginLink = true,
1016
1331
  authConfig,
1017
1332
  oauthProviders = ["google", "github"],
1018
- showOAuthButtons = true
1333
+ showOAuthButtons = true,
1334
+ invitationToken
1019
1335
  }) => {
1336
+ const colors = useThemeColors();
1020
1337
  const [name, setName] = useState("");
1021
1338
  const [email, setEmail] = useState("");
1339
+ const [phoneNumber, setPhoneNumber] = useState("");
1022
1340
  const [password, setPassword] = useState("");
1023
1341
  const [confirmPassword, setConfirmPassword] = useState("");
1024
1342
  const [isLoading, setIsLoading] = useState(false);
@@ -1047,7 +1365,7 @@ var RegisterForm = ({
1047
1365
  };
1048
1366
  getPasswordStrength(password);
1049
1367
  const config = authConfig || {
1050
- baseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || window.location.origin : "http://localhost:7000"
1368
+ baseUrl: "http://localhost:7000"
1051
1369
  };
1052
1370
  const { register } = useAuth(config);
1053
1371
  const handleSubmit = async (e) => {
@@ -1065,17 +1383,45 @@ var RegisterForm = ({
1065
1383
  return;
1066
1384
  }
1067
1385
  try {
1068
- const registerData = {
1069
- name,
1070
- email,
1071
- password,
1072
- frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1073
- };
1074
- const response = await register(registerData);
1075
- if (response.success) {
1076
- onRegisterSuccess?.();
1386
+ if (invitationToken) {
1387
+ const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
1388
+ method: "POST",
1389
+ headers: {
1390
+ "Content-Type": "application/json"
1391
+ },
1392
+ body: JSON.stringify({
1393
+ name,
1394
+ email,
1395
+ password,
1396
+ phoneNumber: phoneNumber || void 0,
1397
+ invitationToken
1398
+ })
1399
+ });
1400
+ const data = await response.json();
1401
+ if (response.ok && data.success) {
1402
+ if (typeof window !== "undefined" && data.token) {
1403
+ localStorage.setItem("auth_token", data.token);
1404
+ }
1405
+ onRegisterSuccess?.();
1406
+ } else {
1407
+ setError(data.error || data.message || "Registration failed");
1408
+ }
1077
1409
  } else {
1078
- setError(response.message || "Registration failed");
1410
+ const registerData = {
1411
+ name,
1412
+ password,
1413
+ frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1414
+ };
1415
+ if (email)
1416
+ registerData.email = email;
1417
+ if (phoneNumber)
1418
+ registerData.phoneNumber = phoneNumber;
1419
+ const response = await register(registerData);
1420
+ if (response.success) {
1421
+ onRegisterSuccess?.();
1422
+ } else {
1423
+ setError(response.message || "Registration failed");
1424
+ }
1079
1425
  }
1080
1426
  } catch (err) {
1081
1427
  setError(err instanceof Error ? err.message : "An unknown error occurred");
@@ -1086,40 +1432,40 @@ var RegisterForm = ({
1086
1432
  return /* @__PURE__ */ jsx("div", { style: {
1087
1433
  maxWidth: "400px",
1088
1434
  margin: "0 auto",
1089
- padding: "30px",
1435
+ padding: "24px",
1090
1436
  borderRadius: "12px",
1091
1437
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1092
- backgroundColor: "#ffffff",
1093
- border: "1px solid #eaeaea"
1438
+ backgroundColor: colors.bgPrimary,
1439
+ border: `1px solid ${colors.borderPrimary}`
1094
1440
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
1095
1441
  display: "flex",
1096
1442
  flexDirection: "column"
1097
1443
  }, children: [
1098
1444
  /* @__PURE__ */ jsx("h2", { style: {
1099
1445
  textAlign: "center",
1100
- marginBottom: "24px",
1101
- color: "#1f2937",
1446
+ marginBottom: "20px",
1447
+ color: colors.textPrimary,
1102
1448
  fontSize: "24px",
1103
1449
  fontWeight: 600
1104
1450
  }, children: "Register" }),
1105
1451
  error && /* @__PURE__ */ jsx("div", { style: {
1106
1452
  padding: "12px 16px",
1107
- marginBottom: "20px",
1108
- backgroundColor: "#f8d7da",
1109
- color: "#721c24",
1110
- border: "1px solid #f5c6cb",
1453
+ marginBottom: "16px",
1454
+ backgroundColor: colors.errorBg,
1455
+ color: colors.errorText,
1456
+ border: `1px solid ${colors.errorBorder}`,
1111
1457
  borderRadius: "8px",
1112
1458
  fontSize: "14px",
1113
1459
  fontWeight: 500
1114
1460
  }, children: error }),
1115
1461
  /* @__PURE__ */ jsxs("div", { style: {
1116
- marginBottom: "20px"
1462
+ marginBottom: "16px"
1117
1463
  }, children: [
1118
1464
  /* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
1119
1465
  display: "block",
1120
1466
  marginBottom: "8px",
1121
1467
  fontWeight: 500,
1122
- color: "#374151",
1468
+ color: colors.textSecondary,
1123
1469
  fontSize: "14px"
1124
1470
  }, children: "Name:" }),
1125
1471
  /* @__PURE__ */ jsx(
@@ -1134,26 +1480,26 @@ var RegisterForm = ({
1134
1480
  style: {
1135
1481
  width: "100%",
1136
1482
  padding: "12px 16px",
1137
- border: "1px solid #ddd",
1483
+ border: `1px solid ${colors.borderSecondary}`,
1138
1484
  borderRadius: "8px",
1139
1485
  fontSize: "16px",
1140
1486
  boxSizing: "border-box",
1141
- color: "#111827",
1487
+ color: colors.textPrimary,
1142
1488
  transition: "all 0.2s ease",
1143
- backgroundColor: "#ffffff"
1489
+ backgroundColor: colors.bgSecondary
1144
1490
  },
1145
1491
  placeholder: "Enter your name"
1146
1492
  }
1147
1493
  )
1148
1494
  ] }),
1149
1495
  /* @__PURE__ */ jsxs("div", { style: {
1150
- marginBottom: "20px"
1496
+ marginBottom: "16px"
1151
1497
  }, children: [
1152
1498
  /* @__PURE__ */ jsx("label", { htmlFor: "register-email", style: {
1153
1499
  display: "block",
1154
1500
  marginBottom: "8px",
1155
1501
  fontWeight: 500,
1156
- color: "#555",
1502
+ color: colors.textSecondary,
1157
1503
  fontSize: "14px"
1158
1504
  }, children: "Email:" }),
1159
1505
  /* @__PURE__ */ jsx(
@@ -1163,31 +1509,52 @@ var RegisterForm = ({
1163
1509
  type: "email",
1164
1510
  value: email,
1165
1511
  onChange: (e) => setEmail(e.target.value),
1166
- required: true,
1512
+ required: !phoneNumber,
1167
1513
  disabled: isLoading,
1168
1514
  style: {
1169
1515
  width: "100%",
1170
1516
  padding: "12px 16px",
1171
- border: "1px solid #ddd",
1517
+ border: `1px solid ${colors.borderSecondary}`,
1172
1518
  borderRadius: "8px",
1173
1519
  fontSize: "16px",
1174
1520
  boxSizing: "border-box",
1175
- color: "#333",
1521
+ color: colors.textPrimary,
1176
1522
  transition: "all 0.2s ease",
1177
- backgroundColor: "#fafafa"
1523
+ backgroundColor: colors.bgSecondary
1178
1524
  },
1179
1525
  placeholder: "Enter your email"
1180
1526
  }
1181
1527
  )
1182
1528
  ] }),
1183
1529
  /* @__PURE__ */ jsxs("div", { style: {
1184
- marginBottom: "20px"
1530
+ marginBottom: "16px"
1531
+ }, children: [
1532
+ /* @__PURE__ */ jsx("label", { htmlFor: "register-phone", style: {
1533
+ display: "block",
1534
+ marginBottom: "8px",
1535
+ fontWeight: 500,
1536
+ color: colors.textSecondary,
1537
+ fontSize: "14px"
1538
+ }, children: "Phone Number (Optional):" }),
1539
+ /* @__PURE__ */ jsx(
1540
+ PhoneInput,
1541
+ {
1542
+ id: "register-phone",
1543
+ value: phoneNumber,
1544
+ onChange: setPhoneNumber,
1545
+ disabled: isLoading,
1546
+ placeholder: "1234567890"
1547
+ }
1548
+ )
1549
+ ] }),
1550
+ /* @__PURE__ */ jsxs("div", { style: {
1551
+ marginBottom: "16px"
1185
1552
  }, children: [
1186
1553
  /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
1187
1554
  display: "block",
1188
1555
  marginBottom: "8px",
1189
1556
  fontWeight: 500,
1190
- color: "#555",
1557
+ color: colors.textSecondary,
1191
1558
  fontSize: "14px"
1192
1559
  }, children: "Password:" }),
1193
1560
  /* @__PURE__ */ jsx(
@@ -1202,13 +1569,13 @@ var RegisterForm = ({
1202
1569
  style: {
1203
1570
  width: "100%",
1204
1571
  padding: "12px 16px",
1205
- border: "1px solid #ddd",
1572
+ border: `1px solid ${colors.borderSecondary}`,
1206
1573
  borderRadius: "8px",
1207
1574
  fontSize: "16px",
1208
1575
  boxSizing: "border-box",
1209
- color: "#333",
1576
+ color: colors.textPrimary,
1210
1577
  transition: "all 0.2s ease",
1211
- backgroundColor: "#fafafa"
1578
+ backgroundColor: colors.bgSecondary
1212
1579
  },
1213
1580
  placeholder: "Enter your password",
1214
1581
  minLength: 6
@@ -1216,13 +1583,13 @@ var RegisterForm = ({
1216
1583
  )
1217
1584
  ] }),
1218
1585
  /* @__PURE__ */ jsxs("div", { style: {
1219
- marginBottom: "20px"
1586
+ marginBottom: "16px"
1220
1587
  }, children: [
1221
1588
  /* @__PURE__ */ jsx("label", { htmlFor: "confirm-password", style: {
1222
1589
  display: "block",
1223
1590
  marginBottom: "8px",
1224
1591
  fontWeight: 500,
1225
- color: "#555",
1592
+ color: colors.textSecondary,
1226
1593
  fontSize: "14px"
1227
1594
  }, children: "Confirm Password:" }),
1228
1595
  /* @__PURE__ */ jsx(
@@ -1237,13 +1604,13 @@ var RegisterForm = ({
1237
1604
  style: {
1238
1605
  width: "100%",
1239
1606
  padding: "12px 16px",
1240
- border: "1px solid #ddd",
1607
+ border: `1px solid ${colors.borderSecondary}`,
1241
1608
  borderRadius: "8px",
1242
1609
  fontSize: "16px",
1243
1610
  boxSizing: "border-box",
1244
- color: "#333",
1611
+ color: colors.textPrimary,
1245
1612
  transition: "all 0.2s ease",
1246
- backgroundColor: "#fafafa"
1613
+ backgroundColor: colors.bgSecondary
1247
1614
  },
1248
1615
  placeholder: "Confirm your password"
1249
1616
  }
@@ -1256,7 +1623,7 @@ var RegisterForm = ({
1256
1623
  disabled: isLoading,
1257
1624
  style: {
1258
1625
  padding: "14px",
1259
- backgroundColor: "#007bff",
1626
+ backgroundColor: colors.buttonPrimary,
1260
1627
  color: "white",
1261
1628
  border: "none",
1262
1629
  borderRadius: "8px",
@@ -1264,15 +1631,15 @@ var RegisterForm = ({
1264
1631
  fontWeight: 600,
1265
1632
  cursor: "pointer",
1266
1633
  transition: "all 0.2s ease",
1267
- marginTop: "8px"
1634
+ marginTop: "4px"
1268
1635
  },
1269
1636
  children: isLoading ? "Registering..." : "Register"
1270
1637
  }
1271
1638
  ),
1272
1639
  showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
1273
- marginTop: "20px",
1274
- paddingTop: "20px",
1275
- borderTop: "1px solid #eee"
1640
+ marginTop: "16px",
1641
+ paddingTop: "16px",
1642
+ borderTop: `1px solid ${colors.borderPrimary}`
1276
1643
  }, children: [
1277
1644
  /* @__PURE__ */ jsxs("div", { style: {
1278
1645
  position: "relative",
@@ -1284,15 +1651,15 @@ var RegisterForm = ({
1284
1651
  left: 0,
1285
1652
  right: 0,
1286
1653
  height: "1px",
1287
- backgroundColor: "#eee"
1654
+ backgroundColor: colors.borderPrimary
1288
1655
  } }),
1289
1656
  /* @__PURE__ */ jsx("div", { style: {
1290
1657
  position: "relative",
1291
1658
  textAlign: "center"
1292
1659
  }, children: /* @__PURE__ */ jsx("span", { style: {
1293
- backgroundColor: "#ffffff",
1660
+ backgroundColor: colors.bgPrimary,
1294
1661
  padding: "0 12px",
1295
- color: "#666",
1662
+ color: colors.textSecondary,
1296
1663
  fontSize: "14px"
1297
1664
  }, children: "Or continue with" }) })
1298
1665
  ] }),
@@ -1311,10 +1678,10 @@ var RegisterForm = ({
1311
1678
  justifyContent: "center",
1312
1679
  gap: "8px",
1313
1680
  padding: "10px 16px",
1314
- backgroundColor: "#ffffff",
1315
- border: "1px solid #ddd",
1681
+ backgroundColor: colors.bgPrimary,
1682
+ border: `1px solid ${colors.borderSecondary}`,
1316
1683
  borderRadius: "8px",
1317
- color: "#333",
1684
+ color: colors.textPrimary,
1318
1685
  textDecoration: "none",
1319
1686
  fontSize: "14px",
1320
1687
  fontWeight: 500,
@@ -1322,12 +1689,12 @@ var RegisterForm = ({
1322
1689
  transition: "all 0.2s ease"
1323
1690
  },
1324
1691
  onMouseEnter: (e) => {
1325
- e.currentTarget.style.backgroundColor = "#f8f8f8";
1326
- e.currentTarget.style.borderColor = "#007bff";
1692
+ e.currentTarget.style.backgroundColor = colors.bgHover;
1693
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
1327
1694
  },
1328
1695
  onMouseLeave: (e) => {
1329
- e.currentTarget.style.backgroundColor = "#ffffff";
1330
- e.currentTarget.style.borderColor = "#ddd";
1696
+ e.currentTarget.style.backgroundColor = colors.bgPrimary;
1697
+ e.currentTarget.style.borderColor = colors.borderSecondary;
1331
1698
  },
1332
1699
  children: [
1333
1700
  /* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
@@ -1402,11 +1769,11 @@ var RegisterForm = ({
1402
1769
  ] }),
1403
1770
  showLoginLink && /* @__PURE__ */ jsx("div", { style: {
1404
1771
  textAlign: "center",
1405
- marginTop: "20px",
1406
- paddingTop: "20px",
1407
- borderTop: "1px solid #eee"
1772
+ marginTop: "16px",
1773
+ paddingTop: "16px",
1774
+ borderTop: `1px solid ${colors.borderPrimary}`
1408
1775
  }, children: /* @__PURE__ */ jsxs("p", { style: {
1409
- color: "#666",
1776
+ color: colors.textSecondary,
1410
1777
  fontSize: "14px"
1411
1778
  }, children: [
1412
1779
  "Already have an account?",
@@ -1420,7 +1787,7 @@ var RegisterForm = ({
1420
1787
  style: {
1421
1788
  background: "none",
1422
1789
  border: "none",
1423
- color: "#007bff",
1790
+ color: colors.buttonPrimary,
1424
1791
  textDecoration: "none",
1425
1792
  cursor: "pointer",
1426
1793
  fontSize: "14px",
@@ -1437,15 +1804,17 @@ var RegisterForm = ({
1437
1804
  var OtpForm = ({
1438
1805
  email,
1439
1806
  onVerifySuccess,
1440
- onBackToLogin
1807
+ onBackToLogin,
1808
+ baseUrl
1441
1809
  }) => {
1810
+ const colors = useThemeColors();
1442
1811
  const [otp, setOtp] = useState("");
1443
1812
  const [isLoading, setIsLoading] = useState(false);
1444
1813
  const [error, setError] = useState(null);
1445
1814
  const [resendCooldown, setResendCooldown] = useState(0);
1446
1815
  const [resendLoading, setResendLoading] = useState(false);
1447
1816
  const { verify, login } = useAuth({
1448
- baseUrl: typeof window !== "undefined" ? window.location.origin : "http://localhost:7000"
1817
+ baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
1449
1818
  });
1450
1819
  const handleSubmit = async (e) => {
1451
1820
  e.preventDefault();
@@ -1508,8 +1877,8 @@ var OtpForm = ({
1508
1877
  padding: "30px",
1509
1878
  borderRadius: "12px",
1510
1879
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1511
- backgroundColor: "#ffffff",
1512
- border: "1px solid #eaeaea"
1880
+ backgroundColor: colors.bgPrimary,
1881
+ border: `1px solid ${colors.borderPrimary}`
1513
1882
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
1514
1883
  display: "flex",
1515
1884
  flexDirection: "column"
@@ -1517,25 +1886,25 @@ var OtpForm = ({
1517
1886
  /* @__PURE__ */ jsx("h2", { style: {
1518
1887
  textAlign: "center",
1519
1888
  marginBottom: "24px",
1520
- color: "#1f2937",
1889
+ color: colors.textPrimary,
1521
1890
  fontSize: "24px",
1522
1891
  fontWeight: 600
1523
1892
  }, children: "Verify OTP" }),
1524
1893
  /* @__PURE__ */ jsxs("p", { style: {
1525
1894
  textAlign: "center",
1526
1895
  marginBottom: "24px",
1527
- color: "#4b5563",
1896
+ color: colors.textSecondary,
1528
1897
  fontSize: "14px"
1529
1898
  }, children: [
1530
1899
  "Enter the 6-digit code sent to ",
1531
- /* @__PURE__ */ jsx("strong", { style: { color: "#111827" }, children: email })
1900
+ /* @__PURE__ */ jsx("strong", { style: { color: colors.textPrimary }, children: email })
1532
1901
  ] }),
1533
1902
  error && /* @__PURE__ */ jsx("div", { style: {
1534
1903
  padding: "12px 16px",
1535
1904
  marginBottom: "20px",
1536
- backgroundColor: "#f8d7da",
1537
- color: "#721c24",
1538
- border: "1px solid #f5c6cb",
1905
+ backgroundColor: colors.errorBg,
1906
+ color: colors.errorText,
1907
+ border: `1px solid ${colors.errorBorder}`,
1539
1908
  borderRadius: "8px",
1540
1909
  fontSize: "14px",
1541
1910
  fontWeight: 500
@@ -1547,7 +1916,7 @@ var OtpForm = ({
1547
1916
  display: "block",
1548
1917
  marginBottom: "8px",
1549
1918
  fontWeight: 500,
1550
- color: "#374151",
1919
+ color: colors.textSecondary,
1551
1920
  fontSize: "14px"
1552
1921
  }, children: "OTP Code:" }),
1553
1922
  /* @__PURE__ */ jsx(
@@ -1562,13 +1931,13 @@ var OtpForm = ({
1562
1931
  style: {
1563
1932
  width: "100%",
1564
1933
  padding: "12px 16px",
1565
- border: "1px solid #ddd",
1934
+ border: `1px solid ${colors.borderSecondary}`,
1566
1935
  borderRadius: "8px",
1567
1936
  fontSize: "20px",
1568
1937
  boxSizing: "border-box",
1569
- color: "#111827",
1938
+ color: colors.textPrimary,
1570
1939
  transition: "all 0.2s ease",
1571
- backgroundColor: "#ffffff",
1940
+ backgroundColor: colors.bgSecondary,
1572
1941
  textAlign: "center",
1573
1942
  letterSpacing: "5px"
1574
1943
  },
@@ -1585,7 +1954,7 @@ var OtpForm = ({
1585
1954
  disabled: isLoading || otp.length !== 6,
1586
1955
  style: {
1587
1956
  padding: "14px",
1588
- backgroundColor: "#007bff",
1957
+ backgroundColor: colors.buttonPrimary,
1589
1958
  color: "white",
1590
1959
  border: "none",
1591
1960
  borderRadius: "8px",
@@ -1602,7 +1971,7 @@ var OtpForm = ({
1602
1971
  textAlign: "center",
1603
1972
  marginTop: "20px",
1604
1973
  paddingTop: "20px",
1605
- borderTop: "1px solid #eee"
1974
+ borderTop: `1px solid ${colors.borderPrimary}`
1606
1975
  }, children: [
1607
1976
  /* @__PURE__ */ jsx(
1608
1977
  "button",
@@ -1613,7 +1982,7 @@ var OtpForm = ({
1613
1982
  style: {
1614
1983
  background: "none",
1615
1984
  border: "none",
1616
- color: resendCooldown > 0 ? "#999" : "#007bff",
1985
+ color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
1617
1986
  textDecoration: "none",
1618
1987
  cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
1619
1988
  fontSize: "14px",
@@ -1636,7 +2005,7 @@ var OtpForm = ({
1636
2005
  style: {
1637
2006
  background: "none",
1638
2007
  border: "none",
1639
- color: "#007bff",
2008
+ color: colors.buttonPrimary,
1640
2009
  textDecoration: "none",
1641
2010
  cursor: "pointer",
1642
2011
  fontSize: "14px",
@@ -1911,12 +2280,25 @@ var useAuth2 = () => {
1911
2280
  }
1912
2281
  return context;
1913
2282
  };
2283
+ var ThemeWrapper = forwardRef(
2284
+ ({ children, className = "", style }, ref) => {
2285
+ const { theme, mounted } = useAuthTheme();
2286
+ if (!mounted) {
2287
+ return /* @__PURE__ */ jsx("div", { ref, className, style, children });
2288
+ }
2289
+ return /* @__PURE__ */ jsx("div", { ref, className: `${theme} ${className}`, style, children });
2290
+ }
2291
+ );
2292
+ ThemeWrapper.displayName = "ThemeWrapper";
1914
2293
  var SignIn = ({ redirectUrl, appearance }) => {
1915
2294
  const { signIn, isSignedIn, loading: authLoading } = useAuth2();
2295
+ const colors = useThemeColors();
1916
2296
  const [email, setEmail] = useState("");
2297
+ const [phoneNumber, setPhoneNumber] = useState("");
1917
2298
  const [password, setPassword] = useState("");
1918
2299
  const [otp, setOtp] = useState("");
1919
2300
  const [usePassword, setUsePassword] = useState(false);
2301
+ const [usePhone, setUsePhone] = useState(false);
1920
2302
  const [showPassword, setShowPassword] = useState(false);
1921
2303
  const [isLoading, setIsLoading] = useState(false);
1922
2304
  const [error, setError] = useState(null);
@@ -1935,25 +2317,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
1935
2317
  setError(null);
1936
2318
  setSuccess(null);
1937
2319
  try {
2320
+ const loginData = usePhone ? { phoneNumber } : { email };
1938
2321
  if (needsOtp) {
1939
- const response = await signIn({ email, otp });
2322
+ const response = await signIn({ ...loginData, otp });
1940
2323
  if (response.success) {
1941
2324
  setSuccess("Login successful!");
1942
2325
  } else {
1943
2326
  setError(response.message || "OTP verification failed");
1944
2327
  }
1945
2328
  } else if (usePassword) {
1946
- const response = await signIn({ email, password });
2329
+ const response = await signIn({ ...loginData, password });
1947
2330
  if (response.success) {
1948
2331
  setSuccess("Login successful!");
1949
2332
  } else {
1950
2333
  setError(response.message || "Login failed");
1951
2334
  }
1952
2335
  } else {
1953
- const response = await signIn({ email });
1954
- if (response.success && response.message === "OTP sent to your email.") {
2336
+ const response = await signIn(loginData);
2337
+ if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
1955
2338
  setNeedsOtp(true);
1956
- setSuccess("OTP sent to your email. Please check your inbox.");
2339
+ setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
1957
2340
  } else {
1958
2341
  setError(response.message || "Failed to send OTP");
1959
2342
  }
@@ -1971,222 +2354,350 @@ var SignIn = ({ redirectUrl, appearance }) => {
1971
2354
  setSuccess(null);
1972
2355
  setOtp("");
1973
2356
  };
2357
+ const toggleLoginMethod = () => {
2358
+ setUsePhone(!usePhone);
2359
+ setNeedsOtp(false);
2360
+ setError(null);
2361
+ setSuccess(null);
2362
+ setOtp("");
2363
+ setEmail("");
2364
+ setPhoneNumber("");
2365
+ };
1974
2366
  if (authLoading) {
1975
2367
  return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
1976
2368
  }
1977
- return /* @__PURE__ */ jsx("div", { style: {
1978
- maxWidth: "400px",
1979
- margin: "0 auto",
1980
- padding: "30px",
1981
- borderRadius: "12px",
1982
- boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
1983
- backgroundColor: "#ffffff",
1984
- border: "1px solid #eaeaea",
1985
- ...appearance?.elements?.card
1986
- }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
1987
- /* @__PURE__ */ jsx("h2", { style: {
1988
- textAlign: "center",
1989
- marginBottom: "24px",
1990
- color: "#1f2937",
1991
- fontSize: "24px",
1992
- fontWeight: 600,
1993
- ...appearance?.elements?.headerTitle
1994
- }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
1995
- error && /* @__PURE__ */ jsx("div", { style: {
1996
- padding: "12px 16px",
1997
- marginBottom: "20px",
1998
- backgroundColor: "#fee",
1999
- color: "#c33",
2000
- border: "1px solid #fcc",
2001
- borderRadius: "8px",
2002
- fontSize: "14px"
2003
- }, children: error }),
2004
- success && /* @__PURE__ */ jsx("div", { style: {
2005
- padding: "12px 16px",
2006
- marginBottom: "20px",
2007
- backgroundColor: "#efe",
2008
- color: "#3c3",
2009
- border: "1px solid #cfc",
2010
- borderRadius: "8px",
2011
- fontSize: "14px"
2012
- }, children: success }),
2013
- !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2014
- /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
2015
- display: "block",
2016
- marginBottom: "8px",
2017
- fontWeight: 500,
2018
- color: "#374151",
2019
- fontSize: "14px"
2020
- }, children: "Email" }),
2021
- /* @__PURE__ */ jsx(
2022
- "input",
2023
- {
2024
- id: "email",
2025
- type: "email",
2026
- value: email,
2027
- onChange: (e) => setEmail(e.target.value),
2028
- required: true,
2029
- disabled: isLoading,
2030
- style: {
2031
- width: "100%",
2032
- padding: "12px 16px",
2033
- border: "1px solid #ddd",
2034
- borderRadius: "8px",
2035
- fontSize: "16px",
2036
- boxSizing: "border-box",
2037
- ...appearance?.elements?.formFieldInput
2038
- },
2039
- placeholder: "Enter your email"
2040
- }
2041
- )
2042
- ] }),
2043
- usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2044
- /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
2045
- display: "block",
2046
- marginBottom: "8px",
2047
- fontWeight: 500,
2048
- color: "#374151",
2049
- fontSize: "14px"
2050
- }, children: "Password" }),
2051
- /* @__PURE__ */ jsx(
2052
- "input",
2053
- {
2054
- id: "password",
2055
- type: showPassword ? "text" : "password",
2056
- value: password,
2057
- onChange: (e) => setPassword(e.target.value),
2058
- required: true,
2059
- disabled: isLoading,
2060
- style: {
2061
- width: "100%",
2062
- padding: "12px 16px",
2063
- border: "1px solid #ddd",
2064
- borderRadius: "8px",
2065
- fontSize: "16px",
2066
- boxSizing: "border-box",
2067
- ...appearance?.elements?.formFieldInput
2068
- },
2069
- placeholder: "Enter your password"
2070
- }
2071
- ),
2072
- /* @__PURE__ */ jsx(
2073
- "button",
2074
- {
2075
- type: "button",
2076
- onClick: () => setShowPassword(!showPassword),
2077
- style: {
2078
- position: "absolute",
2079
- right: "12px",
2080
- top: "38px",
2081
- background: "none",
2082
- border: "none",
2083
- cursor: "pointer",
2084
- color: "#666",
2085
- fontSize: "14px"
2086
- },
2087
- children: showPassword ? "Hide" : "Show"
2088
- }
2089
- )
2090
- ] }),
2091
- needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2092
- /* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
2093
- display: "block",
2094
- marginBottom: "8px",
2095
- fontWeight: 500,
2096
- color: "#374151",
2097
- fontSize: "14px"
2098
- }, children: "One-Time Password" }),
2099
- /* @__PURE__ */ jsx(
2100
- "input",
2101
- {
2102
- id: "otp",
2103
- type: "text",
2104
- value: otp,
2105
- onChange: (e) => setOtp(e.target.value),
2106
- required: true,
2107
- disabled: isLoading,
2108
- maxLength: 6,
2109
- style: {
2110
- width: "100%",
2111
- padding: "12px 16px",
2112
- border: "1px solid #ddd",
2113
- borderRadius: "8px",
2114
- fontSize: "16px",
2115
- boxSizing: "border-box",
2116
- letterSpacing: "0.5em",
2117
- textAlign: "center",
2118
- ...appearance?.elements?.formFieldInput
2119
- },
2120
- placeholder: "000000"
2121
- }
2122
- )
2123
- ] }),
2124
- /* @__PURE__ */ jsx(
2125
- "button",
2126
- {
2127
- type: "submit",
2128
- disabled: isLoading,
2129
- style: {
2130
- width: "100%",
2131
- padding: "14px",
2132
- backgroundColor: "#007bff",
2133
- color: "white",
2134
- border: "none",
2135
- borderRadius: "8px",
2136
- fontSize: "16px",
2369
+ return /* @__PURE__ */ jsx(
2370
+ ThemeWrapper,
2371
+ {
2372
+ style: {
2373
+ maxWidth: "400px",
2374
+ margin: "0 auto",
2375
+ padding: "30px",
2376
+ borderRadius: "12px",
2377
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2378
+ backgroundColor: colors.bgPrimary,
2379
+ border: `1px solid ${colors.borderPrimary}`,
2380
+ ...appearance?.elements?.card
2381
+ },
2382
+ children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
2383
+ /* @__PURE__ */ jsx("h2", { style: {
2384
+ textAlign: "center",
2385
+ marginBottom: "24px",
2386
+ color: colors.textPrimary,
2387
+ fontSize: "24px",
2137
2388
  fontWeight: 600,
2138
- cursor: "pointer",
2139
- transition: "all 0.2s ease",
2140
- ...appearance?.elements?.formButtonPrimary
2141
- },
2142
- children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : "Continue with email"
2143
- }
2144
- ),
2145
- !needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
2146
- "button",
2147
- {
2148
- type: "button",
2149
- onClick: toggleAuthMethod,
2150
- disabled: isLoading,
2151
- style: {
2152
- background: "none",
2153
- border: "none",
2154
- color: "#007bff",
2155
- cursor: "pointer",
2156
- fontSize: "14px",
2157
- fontWeight: 600
2158
- },
2159
- children: usePassword ? "Use email code instead" : "Use password instead"
2160
- }
2161
- ) }),
2162
- needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
2163
- "button",
2164
- {
2165
- type: "button",
2166
- onClick: () => {
2167
- setNeedsOtp(false);
2168
- setOtp("");
2169
- setError(null);
2170
- setSuccess(null);
2171
- },
2172
- disabled: isLoading,
2173
- style: {
2174
- background: "none",
2175
- border: "none",
2176
- color: "#007bff",
2177
- cursor: "pointer",
2178
- fontSize: "14px",
2179
- fontWeight: 600
2180
- },
2181
- children: "Back to sign in"
2182
- }
2183
- ) })
2184
- ] }) });
2389
+ ...appearance?.elements?.headerTitle
2390
+ }, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
2391
+ error && /* @__PURE__ */ jsx("div", { style: {
2392
+ padding: "12px 16px",
2393
+ marginBottom: "20px",
2394
+ backgroundColor: colors.errorBg,
2395
+ color: colors.errorText,
2396
+ border: `1px solid ${colors.errorBorder}`,
2397
+ borderRadius: "8px",
2398
+ fontSize: "14px"
2399
+ }, children: error }),
2400
+ success && /* @__PURE__ */ jsx("div", { style: {
2401
+ padding: "12px 16px",
2402
+ marginBottom: "20px",
2403
+ backgroundColor: colors.successBg,
2404
+ color: colors.successText,
2405
+ border: `1px solid ${colors.successBorder}`,
2406
+ borderRadius: "8px",
2407
+ fontSize: "14px"
2408
+ }, children: success }),
2409
+ !needsOtp && !usePhone && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2410
+ /* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
2411
+ display: "block",
2412
+ marginBottom: "8px",
2413
+ fontWeight: 500,
2414
+ color: colors.textSecondary,
2415
+ fontSize: "14px"
2416
+ }, children: "Email" }),
2417
+ /* @__PURE__ */ jsx(
2418
+ "input",
2419
+ {
2420
+ id: "email",
2421
+ type: "email",
2422
+ value: email,
2423
+ onChange: (e) => setEmail(e.target.value),
2424
+ onFocus: (e) => {
2425
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2426
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2427
+ },
2428
+ onBlur: (e) => {
2429
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2430
+ e.currentTarget.style.outline = "none";
2431
+ },
2432
+ required: true,
2433
+ disabled: isLoading,
2434
+ style: {
2435
+ width: "100%",
2436
+ padding: "12px 16px",
2437
+ border: `1px solid ${colors.borderSecondary}`,
2438
+ borderRadius: "8px",
2439
+ fontSize: "16px",
2440
+ boxSizing: "border-box",
2441
+ backgroundColor: colors.bgSecondary,
2442
+ color: colors.textPrimary,
2443
+ transition: "all 0.2s ease",
2444
+ WebkitTextFillColor: colors.textPrimary,
2445
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2446
+ ...appearance?.elements?.formFieldInput
2447
+ },
2448
+ placeholder: "Enter your email"
2449
+ }
2450
+ )
2451
+ ] }),
2452
+ !needsOtp && usePhone && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2453
+ /* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
2454
+ display: "block",
2455
+ marginBottom: "8px",
2456
+ fontWeight: 500,
2457
+ color: colors.textSecondary,
2458
+ fontSize: "14px"
2459
+ }, children: "Phone Number" }),
2460
+ /* @__PURE__ */ jsx(
2461
+ "input",
2462
+ {
2463
+ id: "phoneNumber",
2464
+ type: "tel",
2465
+ value: phoneNumber,
2466
+ onChange: (e) => setPhoneNumber(e.target.value),
2467
+ onFocus: (e) => {
2468
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2469
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2470
+ },
2471
+ onBlur: (e) => {
2472
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2473
+ e.currentTarget.style.outline = "none";
2474
+ },
2475
+ required: true,
2476
+ disabled: isLoading,
2477
+ style: {
2478
+ width: "100%",
2479
+ padding: "12px 16px",
2480
+ border: `1px solid ${colors.borderSecondary}`,
2481
+ borderRadius: "8px",
2482
+ fontSize: "16px",
2483
+ boxSizing: "border-box",
2484
+ backgroundColor: colors.bgSecondary,
2485
+ color: colors.textPrimary,
2486
+ transition: "all 0.2s ease",
2487
+ WebkitTextFillColor: colors.textPrimary,
2488
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2489
+ ...appearance?.elements?.formFieldInput
2490
+ },
2491
+ placeholder: "Enter your phone number"
2492
+ }
2493
+ )
2494
+ ] }),
2495
+ usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2496
+ /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
2497
+ display: "block",
2498
+ marginBottom: "8px",
2499
+ fontWeight: 500,
2500
+ color: colors.textSecondary,
2501
+ fontSize: "14px"
2502
+ }, children: "Password" }),
2503
+ /* @__PURE__ */ jsx(
2504
+ "input",
2505
+ {
2506
+ id: "password",
2507
+ type: showPassword ? "text" : "password",
2508
+ value: password,
2509
+ onChange: (e) => setPassword(e.target.value),
2510
+ onFocus: (e) => {
2511
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2512
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2513
+ },
2514
+ onBlur: (e) => {
2515
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2516
+ e.currentTarget.style.outline = "none";
2517
+ },
2518
+ required: true,
2519
+ disabled: isLoading,
2520
+ style: {
2521
+ width: "100%",
2522
+ padding: "12px 16px",
2523
+ border: `1px solid ${colors.borderSecondary}`,
2524
+ borderRadius: "8px",
2525
+ fontSize: "16px",
2526
+ boxSizing: "border-box",
2527
+ backgroundColor: colors.bgSecondary,
2528
+ color: colors.textPrimary,
2529
+ transition: "all 0.2s ease",
2530
+ WebkitTextFillColor: colors.textPrimary,
2531
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2532
+ ...appearance?.elements?.formFieldInput
2533
+ },
2534
+ placeholder: "Enter your password"
2535
+ }
2536
+ ),
2537
+ /* @__PURE__ */ jsx(
2538
+ "button",
2539
+ {
2540
+ type: "button",
2541
+ onClick: () => setShowPassword(!showPassword),
2542
+ style: {
2543
+ position: "absolute",
2544
+ right: "12px",
2545
+ top: "38px",
2546
+ background: "none",
2547
+ border: "none",
2548
+ cursor: "pointer",
2549
+ color: colors.textTertiary,
2550
+ fontSize: "14px"
2551
+ },
2552
+ children: showPassword ? "Hide" : "Show"
2553
+ }
2554
+ )
2555
+ ] }),
2556
+ needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2557
+ /* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
2558
+ display: "block",
2559
+ marginBottom: "8px",
2560
+ fontWeight: 500,
2561
+ color: colors.textSecondary,
2562
+ fontSize: "14px"
2563
+ }, children: "One-Time Password" }),
2564
+ /* @__PURE__ */ jsx(
2565
+ "input",
2566
+ {
2567
+ id: "otp",
2568
+ type: "text",
2569
+ value: otp,
2570
+ onChange: (e) => setOtp(e.target.value),
2571
+ onFocus: (e) => {
2572
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2573
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2574
+ },
2575
+ onBlur: (e) => {
2576
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2577
+ e.currentTarget.style.outline = "none";
2578
+ },
2579
+ required: true,
2580
+ disabled: isLoading,
2581
+ maxLength: 6,
2582
+ style: {
2583
+ width: "100%",
2584
+ padding: "12px 16px",
2585
+ border: `1px solid ${colors.borderSecondary}`,
2586
+ borderRadius: "8px",
2587
+ fontSize: "16px",
2588
+ boxSizing: "border-box",
2589
+ letterSpacing: "0.5em",
2590
+ textAlign: "center",
2591
+ backgroundColor: colors.bgSecondary,
2592
+ color: colors.textPrimary,
2593
+ transition: "all 0.2s ease",
2594
+ WebkitTextFillColor: colors.textPrimary,
2595
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2596
+ ...appearance?.elements?.formFieldInput
2597
+ },
2598
+ placeholder: "000000"
2599
+ }
2600
+ )
2601
+ ] }),
2602
+ /* @__PURE__ */ jsx(
2603
+ "button",
2604
+ {
2605
+ type: "submit",
2606
+ disabled: isLoading,
2607
+ onMouseEnter: (e) => {
2608
+ if (!isLoading) {
2609
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
2610
+ }
2611
+ },
2612
+ onMouseLeave: (e) => {
2613
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
2614
+ },
2615
+ style: {
2616
+ width: "100%",
2617
+ padding: "14px",
2618
+ backgroundColor: colors.buttonPrimary,
2619
+ color: "white",
2620
+ border: "none",
2621
+ borderRadius: "8px",
2622
+ fontSize: "16px",
2623
+ fontWeight: 600,
2624
+ cursor: isLoading ? "not-allowed" : "pointer",
2625
+ opacity: isLoading ? 0.6 : 1,
2626
+ transition: "all 0.2s ease",
2627
+ ...appearance?.elements?.formButtonPrimary
2628
+ },
2629
+ children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
2630
+ }
2631
+ ),
2632
+ !needsOtp && /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
2633
+ /* @__PURE__ */ jsx(
2634
+ "button",
2635
+ {
2636
+ type: "button",
2637
+ onClick: toggleAuthMethod,
2638
+ disabled: isLoading,
2639
+ style: {
2640
+ background: "none",
2641
+ border: "none",
2642
+ color: colors.buttonPrimary,
2643
+ cursor: "pointer",
2644
+ fontSize: "14px",
2645
+ fontWeight: 600,
2646
+ marginRight: "16px"
2647
+ },
2648
+ children: usePassword ? "Use OTP code instead" : "Use password instead"
2649
+ }
2650
+ ),
2651
+ /* @__PURE__ */ jsx(
2652
+ "button",
2653
+ {
2654
+ type: "button",
2655
+ onClick: toggleLoginMethod,
2656
+ disabled: isLoading,
2657
+ style: {
2658
+ background: "none",
2659
+ border: "none",
2660
+ color: colors.buttonPrimary,
2661
+ cursor: "pointer",
2662
+ fontSize: "14px",
2663
+ fontWeight: 600
2664
+ },
2665
+ children: usePhone ? "Use email instead" : "Use phone instead"
2666
+ }
2667
+ )
2668
+ ] }),
2669
+ needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
2670
+ "button",
2671
+ {
2672
+ type: "button",
2673
+ onClick: () => {
2674
+ setNeedsOtp(false);
2675
+ setOtp("");
2676
+ setError(null);
2677
+ setSuccess(null);
2678
+ },
2679
+ disabled: isLoading,
2680
+ style: {
2681
+ background: "none",
2682
+ border: "none",
2683
+ color: colors.buttonPrimary,
2684
+ cursor: "pointer",
2685
+ fontSize: "14px",
2686
+ fontWeight: 600
2687
+ },
2688
+ children: "Back to sign in"
2689
+ }
2690
+ ) })
2691
+ ] })
2692
+ }
2693
+ );
2185
2694
  };
2186
2695
  var SignUp = ({ redirectUrl, appearance }) => {
2187
2696
  const { signUp, isSignedIn } = useAuth2();
2697
+ const colors = useThemeColors();
2188
2698
  const [name, setName] = useState("");
2189
2699
  const [email, setEmail] = useState("");
2700
+ const [phoneNumber, setPhoneNumber] = useState("");
2190
2701
  const [password, setPassword] = useState("");
2191
2702
  const [confirmPassword, setConfirmPassword] = useState("");
2192
2703
  const [showPassword, setShowPassword] = useState(false);
@@ -2200,9 +2711,9 @@ var SignUp = ({ redirectUrl, appearance }) => {
2200
2711
  window.location.href = `${baseUrl}${redirect}`;
2201
2712
  }
2202
2713
  }, [isSignedIn, redirectUrl]);
2203
- const getPasswordStrength = (pwd) => {
2714
+ const getPasswordStrength = (pwd, colors2) => {
2204
2715
  if (!pwd)
2205
- return { strength: "weak", color: "#ddd" };
2716
+ return { strength: "weak", color: colors2.borderSecondary };
2206
2717
  let score = 0;
2207
2718
  if (pwd.length >= 6)
2208
2719
  score++;
@@ -2215,12 +2726,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2215
2726
  if (/[^a-zA-Z\d]/.test(pwd))
2216
2727
  score++;
2217
2728
  if (score <= 2)
2218
- return { strength: "weak", color: "#f44" };
2729
+ return { strength: "weak", color: colors2.errorText };
2219
2730
  if (score <= 3)
2220
- return { strength: "medium", color: "#fa4" };
2221
- return { strength: "strong", color: "#4f4" };
2731
+ return { strength: "medium", color: colors2.warningText || "#fa4" };
2732
+ return { strength: "strong", color: colors2.successText };
2222
2733
  };
2223
- const passwordStrength = getPasswordStrength(password);
2734
+ const passwordStrength = getPasswordStrength(password, colors);
2224
2735
  const handleSubmit = async (e) => {
2225
2736
  e.preventDefault();
2226
2737
  setIsLoading(true);
@@ -2237,7 +2748,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
2237
2748
  return;
2238
2749
  }
2239
2750
  try {
2240
- const response = await signUp({ name, email, password });
2751
+ const signUpData = { name, password };
2752
+ if (email)
2753
+ signUpData.email = email;
2754
+ if (phoneNumber)
2755
+ signUpData.phoneNumber = phoneNumber;
2756
+ const response = await signUp(signUpData);
2241
2757
  if (response.success) {
2242
2758
  setSuccess("Registration successful! Please check your email to verify your account.");
2243
2759
  } else {
@@ -2249,20 +2765,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
2249
2765
  setIsLoading(false);
2250
2766
  }
2251
2767
  };
2252
- return /* @__PURE__ */ jsx("div", { style: {
2768
+ return /* @__PURE__ */ jsx(ThemeWrapper, { style: {
2253
2769
  maxWidth: "400px",
2254
2770
  margin: "0 auto",
2255
2771
  padding: "30px",
2256
2772
  borderRadius: "12px",
2257
2773
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
2258
- backgroundColor: "#ffffff",
2259
- border: "1px solid #eaeaea",
2774
+ backgroundColor: colors.bgPrimary,
2775
+ border: `1px solid ${colors.borderPrimary}`,
2260
2776
  ...appearance?.elements?.card
2261
2777
  }, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
2262
2778
  /* @__PURE__ */ jsx("h2", { style: {
2263
2779
  textAlign: "center",
2264
2780
  marginBottom: "24px",
2265
- color: "#1f2937",
2781
+ color: colors.textPrimary,
2266
2782
  fontSize: "24px",
2267
2783
  fontWeight: 600,
2268
2784
  ...appearance?.elements?.headerTitle
@@ -2270,18 +2786,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
2270
2786
  error && /* @__PURE__ */ jsx("div", { style: {
2271
2787
  padding: "12px 16px",
2272
2788
  marginBottom: "20px",
2273
- backgroundColor: "#fee",
2274
- color: "#c33",
2275
- border: "1px solid #fcc",
2789
+ backgroundColor: colors.errorBg,
2790
+ color: colors.errorText,
2791
+ border: `1px solid ${colors.errorBorder}`,
2276
2792
  borderRadius: "8px",
2277
2793
  fontSize: "14px"
2278
2794
  }, children: error }),
2279
2795
  success && /* @__PURE__ */ jsx("div", { style: {
2280
2796
  padding: "12px 16px",
2281
2797
  marginBottom: "20px",
2282
- backgroundColor: "#efe",
2283
- color: "#3c3",
2284
- border: "1px solid #cfc",
2798
+ backgroundColor: colors.successBg,
2799
+ color: colors.successText,
2800
+ border: `1px solid ${colors.successBorder}`,
2285
2801
  borderRadius: "8px",
2286
2802
  fontSize: "14px"
2287
2803
  }, children: success }),
@@ -2290,7 +2806,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2290
2806
  display: "block",
2291
2807
  marginBottom: "8px",
2292
2808
  fontWeight: 500,
2293
- color: "#374151",
2809
+ color: colors.textSecondary,
2294
2810
  fontSize: "14px"
2295
2811
  }, children: "Full name" }),
2296
2812
  /* @__PURE__ */ jsx(
@@ -2300,15 +2816,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2300
2816
  type: "text",
2301
2817
  value: name,
2302
2818
  onChange: (e) => setName(e.target.value),
2819
+ onFocus: (e) => {
2820
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2821
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2822
+ },
2823
+ onBlur: (e) => {
2824
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2825
+ e.currentTarget.style.outline = "none";
2826
+ },
2303
2827
  required: true,
2304
2828
  disabled: isLoading,
2305
2829
  style: {
2306
2830
  width: "100%",
2307
2831
  padding: "12px 16px",
2308
- border: "1px solid #ddd",
2832
+ border: `1px solid ${colors.borderSecondary}`,
2309
2833
  borderRadius: "8px",
2310
2834
  fontSize: "16px",
2311
2835
  boxSizing: "border-box",
2836
+ backgroundColor: colors.bgSecondary,
2837
+ color: colors.textPrimary,
2838
+ transition: "all 0.2s ease",
2839
+ WebkitTextFillColor: colors.textPrimary,
2840
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2312
2841
  ...appearance?.elements?.formFieldInput
2313
2842
  },
2314
2843
  placeholder: "Enter your full name"
@@ -2320,7 +2849,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2320
2849
  display: "block",
2321
2850
  marginBottom: "8px",
2322
2851
  fontWeight: 500,
2323
- color: "#374151",
2852
+ color: colors.textSecondary,
2324
2853
  fontSize: "14px"
2325
2854
  }, children: "Email" }),
2326
2855
  /* @__PURE__ */ jsx(
@@ -2330,27 +2859,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
2330
2859
  type: "email",
2331
2860
  value: email,
2332
2861
  onChange: (e) => setEmail(e.target.value),
2333
- required: true,
2862
+ onFocus: (e) => {
2863
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2864
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2865
+ },
2866
+ onBlur: (e) => {
2867
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2868
+ e.currentTarget.style.outline = "none";
2869
+ },
2870
+ required: !phoneNumber,
2334
2871
  disabled: isLoading,
2335
2872
  style: {
2336
2873
  width: "100%",
2337
2874
  padding: "12px 16px",
2338
- border: "1px solid #ddd",
2875
+ border: `1px solid ${colors.borderSecondary}`,
2339
2876
  borderRadius: "8px",
2340
2877
  fontSize: "16px",
2341
2878
  boxSizing: "border-box",
2879
+ backgroundColor: colors.bgSecondary,
2880
+ color: colors.textPrimary,
2881
+ transition: "all 0.2s ease",
2882
+ WebkitTextFillColor: colors.textPrimary,
2883
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2342
2884
  ...appearance?.elements?.formFieldInput
2343
2885
  },
2344
2886
  placeholder: "Enter your email"
2345
2887
  }
2346
2888
  )
2347
2889
  ] }),
2890
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
2891
+ /* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
2892
+ display: "block",
2893
+ marginBottom: "8px",
2894
+ fontWeight: 500,
2895
+ color: colors.textSecondary,
2896
+ fontSize: "14px"
2897
+ }, children: "Phone Number (Optional)" }),
2898
+ /* @__PURE__ */ jsx(
2899
+ PhoneInput,
2900
+ {
2901
+ id: "phoneNumber",
2902
+ value: phoneNumber,
2903
+ onChange: setPhoneNumber,
2904
+ disabled: isLoading,
2905
+ placeholder: "1234567890",
2906
+ style: appearance?.elements?.formFieldInput
2907
+ }
2908
+ )
2909
+ ] }),
2348
2910
  /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
2349
2911
  /* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
2350
2912
  display: "block",
2351
2913
  marginBottom: "8px",
2352
2914
  fontWeight: 500,
2353
- color: "#374151",
2915
+ color: colors.textSecondary,
2354
2916
  fontSize: "14px"
2355
2917
  }, children: "Password" }),
2356
2918
  /* @__PURE__ */ jsx(
@@ -2360,16 +2922,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
2360
2922
  type: showPassword ? "text" : "password",
2361
2923
  value: password,
2362
2924
  onChange: (e) => setPassword(e.target.value),
2925
+ onFocus: (e) => {
2926
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
2927
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
2928
+ },
2929
+ onBlur: (e) => {
2930
+ e.currentTarget.style.borderColor = colors.borderSecondary;
2931
+ e.currentTarget.style.outline = "none";
2932
+ },
2363
2933
  required: true,
2364
2934
  disabled: isLoading,
2365
2935
  minLength: 6,
2366
2936
  style: {
2367
2937
  width: "100%",
2368
2938
  padding: "12px 16px",
2369
- border: "1px solid #ddd",
2939
+ border: `1px solid ${colors.borderSecondary}`,
2370
2940
  borderRadius: "8px",
2371
2941
  fontSize: "16px",
2372
2942
  boxSizing: "border-box",
2943
+ backgroundColor: colors.bgSecondary,
2944
+ color: colors.textPrimary,
2945
+ transition: "all 0.2s ease",
2946
+ WebkitTextFillColor: colors.textPrimary,
2947
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2373
2948
  ...appearance?.elements?.formFieldInput
2374
2949
  },
2375
2950
  placeholder: "Create a password"
@@ -2387,7 +2962,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2387
2962
  background: "none",
2388
2963
  border: "none",
2389
2964
  cursor: "pointer",
2390
- color: "#666",
2965
+ color: colors.textTertiary,
2391
2966
  fontSize: "14px"
2392
2967
  },
2393
2968
  children: showPassword ? "Hide" : "Show"
@@ -2396,7 +2971,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2396
2971
  password && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
2397
2972
  /* @__PURE__ */ jsx("div", { style: {
2398
2973
  height: "4px",
2399
- backgroundColor: "#eee",
2974
+ backgroundColor: colors.borderSecondary,
2400
2975
  borderRadius: "2px",
2401
2976
  overflow: "hidden"
2402
2977
  }, children: /* @__PURE__ */ jsx("div", { style: {
@@ -2421,7 +2996,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
2421
2996
  display: "block",
2422
2997
  marginBottom: "8px",
2423
2998
  fontWeight: 500,
2424
- color: "#374151",
2999
+ color: colors.textSecondary,
2425
3000
  fontSize: "14px"
2426
3001
  }, children: "Confirm password" }),
2427
3002
  /* @__PURE__ */ jsx(
@@ -2431,15 +3006,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
2431
3006
  type: showPassword ? "text" : "password",
2432
3007
  value: confirmPassword,
2433
3008
  onChange: (e) => setConfirmPassword(e.target.value),
3009
+ onFocus: (e) => {
3010
+ e.currentTarget.style.borderColor = colors.buttonPrimary;
3011
+ e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
3012
+ },
3013
+ onBlur: (e) => {
3014
+ e.currentTarget.style.borderColor = colors.borderSecondary;
3015
+ e.currentTarget.style.outline = "none";
3016
+ },
2434
3017
  required: true,
2435
3018
  disabled: isLoading,
2436
3019
  style: {
2437
3020
  width: "100%",
2438
3021
  padding: "12px 16px",
2439
- border: "1px solid #ddd",
3022
+ border: `1px solid ${colors.borderSecondary}`,
2440
3023
  borderRadius: "8px",
2441
3024
  fontSize: "16px",
2442
3025
  boxSizing: "border-box",
3026
+ backgroundColor: colors.bgSecondary,
3027
+ color: colors.textPrimary,
3028
+ transition: "all 0.2s ease",
3029
+ WebkitTextFillColor: colors.textPrimary,
3030
+ WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
2443
3031
  ...appearance?.elements?.formFieldInput
2444
3032
  },
2445
3033
  placeholder: "Confirm your password"
@@ -2451,16 +3039,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
2451
3039
  {
2452
3040
  type: "submit",
2453
3041
  disabled: isLoading,
3042
+ onMouseEnter: (e) => {
3043
+ if (!isLoading) {
3044
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
3045
+ }
3046
+ },
3047
+ onMouseLeave: (e) => {
3048
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3049
+ },
2454
3050
  style: {
2455
3051
  width: "100%",
2456
3052
  padding: "14px",
2457
- backgroundColor: "#007bff",
3053
+ backgroundColor: colors.buttonPrimary,
2458
3054
  color: "white",
2459
3055
  border: "none",
2460
3056
  borderRadius: "8px",
2461
3057
  fontSize: "16px",
2462
3058
  fontWeight: 600,
2463
- cursor: "pointer",
3059
+ cursor: isLoading ? "not-allowed" : "pointer",
3060
+ opacity: isLoading ? 0.6 : 1,
2464
3061
  transition: "all 0.2s ease",
2465
3062
  ...appearance?.elements?.formButtonPrimary
2466
3063
  },
@@ -2484,6 +3081,7 @@ var SignOut = ({ redirectUrl }) => {
2484
3081
  };
2485
3082
  var UserButton = ({ showName = false, appearance }) => {
2486
3083
  const { user, signOut } = useAuth2();
3084
+ const colors = useThemeColors();
2487
3085
  const [isOpen, setIsOpen] = useState(false);
2488
3086
  const dropdownRef = useRef(null);
2489
3087
  useEffect(() => {
@@ -2506,7 +3104,7 @@ var UserButton = ({ showName = false, appearance }) => {
2506
3104
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
2507
3105
  window.location.href = `${baseUrl}${redirect}`;
2508
3106
  };
2509
- return /* @__PURE__ */ jsxs("div", { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
3107
+ return /* @__PURE__ */ jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
2510
3108
  /* @__PURE__ */ jsxs(
2511
3109
  "button",
2512
3110
  {
@@ -2524,7 +3122,7 @@ var UserButton = ({ showName = false, appearance }) => {
2524
3122
  ...appearance?.elements?.userButtonTrigger
2525
3123
  },
2526
3124
  onMouseEnter: (e) => {
2527
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3125
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2528
3126
  },
2529
3127
  onMouseLeave: (e) => {
2530
3128
  e.currentTarget.style.backgroundColor = "transparent";
@@ -2534,15 +3132,15 @@ var UserButton = ({ showName = false, appearance }) => {
2534
3132
  width: "36px",
2535
3133
  height: "36px",
2536
3134
  borderRadius: "50%",
2537
- backgroundColor: "#007bff",
2538
- color: "white",
3135
+ backgroundColor: colors.buttonPrimary,
3136
+ color: colors.textPrimary,
2539
3137
  display: "flex",
2540
3138
  alignItems: "center",
2541
3139
  justifyContent: "center",
2542
3140
  fontSize: "14px",
2543
3141
  fontWeight: 600
2544
3142
  }, children: getInitials(user.name) }),
2545
- showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: "#333" }, children: user.name })
3143
+ showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
2546
3144
  ]
2547
3145
  }
2548
3146
  ),
@@ -2552,16 +3150,16 @@ var UserButton = ({ showName = false, appearance }) => {
2552
3150
  right: 0,
2553
3151
  marginTop: "8px",
2554
3152
  width: "240px",
2555
- backgroundColor: "white",
3153
+ backgroundColor: colors.bgPrimary,
2556
3154
  borderRadius: "12px",
2557
3155
  boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
2558
- border: "1px solid #eaeaea",
3156
+ border: `1px solid ${colors.borderPrimary}`,
2559
3157
  zIndex: 1e3,
2560
3158
  ...appearance?.elements?.userButtonPopoverCard
2561
3159
  }, children: [
2562
3160
  /* @__PURE__ */ jsx("div", { style: {
2563
3161
  padding: "16px",
2564
- borderBottom: "1px solid #eee"
3162
+ borderBottom: `1px solid ${colors.borderPrimary}`
2565
3163
  }, children: /* @__PURE__ */ jsxs("div", { style: {
2566
3164
  display: "flex",
2567
3165
  alignItems: "center",
@@ -2571,8 +3169,8 @@ var UserButton = ({ showName = false, appearance }) => {
2571
3169
  width: "48px",
2572
3170
  height: "48px",
2573
3171
  borderRadius: "50%",
2574
- backgroundColor: "#007bff",
2575
- color: "white",
3172
+ backgroundColor: colors.buttonPrimary,
3173
+ color: colors.textPrimary,
2576
3174
  display: "flex",
2577
3175
  alignItems: "center",
2578
3176
  justifyContent: "center",
@@ -2583,14 +3181,14 @@ var UserButton = ({ showName = false, appearance }) => {
2583
3181
  /* @__PURE__ */ jsx("div", { style: {
2584
3182
  fontSize: "14px",
2585
3183
  fontWeight: 600,
2586
- color: "#333",
3184
+ color: colors.textPrimary,
2587
3185
  overflow: "hidden",
2588
3186
  textOverflow: "ellipsis",
2589
3187
  whiteSpace: "nowrap"
2590
3188
  }, children: user.name }),
2591
3189
  /* @__PURE__ */ jsx("div", { style: {
2592
3190
  fontSize: "12px",
2593
- color: "#666",
3191
+ color: colors.textTertiary,
2594
3192
  overflow: "hidden",
2595
3193
  textOverflow: "ellipsis",
2596
3194
  whiteSpace: "nowrap"
@@ -2610,12 +3208,12 @@ var UserButton = ({ showName = false, appearance }) => {
2610
3208
  textAlign: "left",
2611
3209
  cursor: "pointer",
2612
3210
  fontSize: "14px",
2613
- color: "#333",
3211
+ color: colors.textPrimary,
2614
3212
  fontWeight: 500,
2615
3213
  transition: "background-color 0.2s"
2616
3214
  },
2617
3215
  onMouseEnter: (e) => {
2618
- e.currentTarget.style.backgroundColor = "#f5f5f5";
3216
+ e.currentTarget.style.backgroundColor = colors.bgHover;
2619
3217
  },
2620
3218
  onMouseLeave: (e) => {
2621
3219
  e.currentTarget.style.backgroundColor = "transparent";
@@ -3468,43 +4066,41 @@ var UserProfile = ({
3468
4066
  showEmailChange = true,
3469
4067
  showPasswordChange = true
3470
4068
  }) => {
3471
- const { user, updateProfile, updateAvatar, requestEmailChange } = useAuth2();
4069
+ const { user, updateProfile, requestEmailChange } = useAuth2();
4070
+ const colors = useThemeColors();
3472
4071
  const [name, setName] = useState(user?.name || "");
3473
- const [avatar, setAvatar] = useState("");
4072
+ const [avatar, setAvatar] = useState(user?.avatar || "");
4073
+ const [phoneNumber, setPhoneNumber] = useState(user?.phoneNumber || "");
3474
4074
  const [newEmail, setNewEmail] = useState("");
3475
4075
  const [isLoading, setIsLoading] = useState(false);
3476
4076
  const [error, setError] = useState(null);
3477
4077
  const [success, setSuccess] = useState(null);
3478
- const handleUpdateName = async (e) => {
4078
+ const handleUpdateProfile = async (e) => {
3479
4079
  e.preventDefault();
3480
4080
  setIsLoading(true);
3481
4081
  setError(null);
3482
4082
  setSuccess(null);
3483
4083
  try {
3484
- const response = await updateProfile({ name });
3485
- if (response.success) {
3486
- setSuccess("Name updated successfully!");
3487
- } else {
3488
- setError(response.message || "Failed to update name");
4084
+ const updates = {};
4085
+ if (name !== user?.name) {
4086
+ updates.name = name;
3489
4087
  }
3490
- } catch (err) {
3491
- setError(err instanceof Error ? err.message : "An error occurred");
3492
- } finally {
3493
- setIsLoading(false);
3494
- }
3495
- };
3496
- const handleUpdateAvatar = async (e) => {
3497
- e.preventDefault();
3498
- setIsLoading(true);
3499
- setError(null);
3500
- setSuccess(null);
3501
- try {
3502
- const response = await updateAvatar(avatar);
4088
+ if (showAvatar && avatar !== user?.avatar) {
4089
+ updates.avatar = avatar;
4090
+ }
4091
+ if (phoneNumber !== user?.phoneNumber) {
4092
+ updates.phoneNumber = phoneNumber;
4093
+ }
4094
+ if (Object.keys(updates).length === 0) {
4095
+ setError("No changes to save");
4096
+ setIsLoading(false);
4097
+ return;
4098
+ }
4099
+ const response = await updateProfile(updates);
3503
4100
  if (response.success) {
3504
- setSuccess("Avatar updated successfully!");
3505
- setAvatar("");
4101
+ setSuccess("Profile updated successfully!");
3506
4102
  } else {
3507
- setError(response.message || "Failed to update avatar");
4103
+ setError(response.message || "Failed to update profile");
3508
4104
  }
3509
4105
  } catch (err) {
3510
4106
  setError(err instanceof Error ? err.message : "An error occurred");
@@ -3533,173 +4129,220 @@ var UserProfile = ({
3533
4129
  };
3534
4130
  if (!user)
3535
4131
  return null;
3536
- return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "600px", margin: "0 auto", padding: "20px" }, children: [
3537
- /* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
4132
+ return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4133
+ /* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
3538
4134
  error && /* @__PURE__ */ jsx("div", { style: {
3539
4135
  padding: "12px 16px",
3540
4136
  marginBottom: "20px",
3541
- backgroundColor: "#fee",
3542
- color: "#c33",
3543
- border: "1px solid #fcc",
4137
+ backgroundColor: colors.errorBg,
4138
+ color: colors.errorText,
4139
+ border: `1px solid ${colors.errorBorder}`,
3544
4140
  borderRadius: "8px",
3545
4141
  fontSize: "14px"
3546
4142
  }, children: error }),
3547
4143
  success && /* @__PURE__ */ jsx("div", { style: {
3548
4144
  padding: "12px 16px",
3549
4145
  marginBottom: "20px",
3550
- backgroundColor: "#efe",
3551
- color: "#3c3",
3552
- border: "1px solid #cfc",
4146
+ backgroundColor: colors.successBg,
4147
+ color: colors.successText,
4148
+ border: `1px solid ${colors.successBorder}`,
3553
4149
  borderRadius: "8px",
3554
4150
  fontSize: "14px"
3555
4151
  }, children: success }),
3556
4152
  /* @__PURE__ */ jsxs("div", { style: {
3557
- padding: "20px",
3558
- backgroundColor: "#fff",
3559
- borderRadius: "8px",
4153
+ padding: "24px",
4154
+ backgroundColor: colors.bgPrimary,
4155
+ borderRadius: "12px",
3560
4156
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3561
- marginBottom: "20px"
4157
+ marginBottom: "24px",
4158
+ border: `1px solid ${colors.borderPrimary}`
3562
4159
  }, children: [
3563
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Name" }),
3564
- /* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateName, children: [
3565
- /* @__PURE__ */ jsx(
3566
- "input",
3567
- {
3568
- type: "text",
3569
- value: name,
3570
- onChange: (e) => setName(e.target.value),
3571
- required: true,
3572
- disabled: isLoading,
3573
- style: {
3574
- width: "100%",
3575
- padding: "12px 16px",
3576
- border: "1px solid #ddd",
3577
- borderRadius: "8px",
3578
- fontSize: "16px",
3579
- boxSizing: "border-box",
3580
- marginBottom: "12px"
3581
- },
3582
- placeholder: "Your name"
3583
- }
3584
- ),
4160
+ /* @__PURE__ */ jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
4161
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateProfile, children: [
4162
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
4163
+ /* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
4164
+ display: "block",
4165
+ marginBottom: "8px",
4166
+ fontWeight: 500,
4167
+ color: colors.textSecondary,
4168
+ fontSize: "14px"
4169
+ }, children: "Full Name" }),
4170
+ /* @__PURE__ */ jsx(
4171
+ "input",
4172
+ {
4173
+ id: "name",
4174
+ type: "text",
4175
+ value: name,
4176
+ onChange: (e) => setName(e.target.value),
4177
+ required: true,
4178
+ disabled: isLoading,
4179
+ style: {
4180
+ width: "100%",
4181
+ padding: "12px 16px",
4182
+ border: `1px solid ${colors.borderSecondary}`,
4183
+ borderRadius: "8px",
4184
+ fontSize: "16px",
4185
+ boxSizing: "border-box",
4186
+ backgroundColor: colors.bgSecondary,
4187
+ color: colors.textPrimary,
4188
+ transition: "all 0.2s ease"
4189
+ },
4190
+ placeholder: "Manish Batra"
4191
+ }
4192
+ )
4193
+ ] }),
4194
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
4195
+ /* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
4196
+ display: "block",
4197
+ marginBottom: "8px",
4198
+ fontWeight: 500,
4199
+ color: colors.textSecondary,
4200
+ fontSize: "14px"
4201
+ }, children: "Phone Number" }),
4202
+ /* @__PURE__ */ jsx(
4203
+ PhoneInput,
4204
+ {
4205
+ id: "phoneNumber",
4206
+ value: phoneNumber,
4207
+ onChange: setPhoneNumber,
4208
+ disabled: isLoading,
4209
+ placeholder: "1234567890"
4210
+ }
4211
+ )
4212
+ ] }),
4213
+ showAvatar && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
4214
+ /* @__PURE__ */ jsx("label", { htmlFor: "avatar", style: {
4215
+ display: "block",
4216
+ marginBottom: "8px",
4217
+ fontWeight: 500,
4218
+ color: colors.textSecondary,
4219
+ fontSize: "14px"
4220
+ }, children: "Avatar URL" }),
4221
+ /* @__PURE__ */ jsx(
4222
+ "input",
4223
+ {
4224
+ id: "avatar",
4225
+ type: "url",
4226
+ value: avatar,
4227
+ onChange: (e) => setAvatar(e.target.value),
4228
+ disabled: isLoading,
4229
+ style: {
4230
+ width: "100%",
4231
+ padding: "12px 16px",
4232
+ border: `1px solid ${colors.borderSecondary}`,
4233
+ borderRadius: "8px",
4234
+ fontSize: "16px",
4235
+ boxSizing: "border-box",
4236
+ backgroundColor: colors.bgSecondary,
4237
+ color: colors.textPrimary,
4238
+ transition: "all 0.2s ease"
4239
+ },
4240
+ placeholder: "https://example.com/avatar.jpg"
4241
+ }
4242
+ )
4243
+ ] }),
3585
4244
  /* @__PURE__ */ jsx(
3586
4245
  "button",
3587
4246
  {
3588
4247
  type: "submit",
3589
4248
  disabled: isLoading,
3590
- style: {
3591
- padding: "10px 20px",
3592
- backgroundColor: "#007bff",
3593
- color: "white",
3594
- border: "none",
3595
- borderRadius: "8px",
3596
- fontSize: "14px",
3597
- fontWeight: 600,
3598
- cursor: "pointer"
4249
+ onMouseEnter: (e) => {
4250
+ if (!isLoading) {
4251
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4252
+ }
3599
4253
  },
3600
- children: "Update Name"
3601
- }
3602
- )
3603
- ] })
3604
- ] }),
3605
- showAvatar && /* @__PURE__ */ jsxs("div", { style: {
3606
- padding: "20px",
3607
- backgroundColor: "#fff",
3608
- borderRadius: "8px",
3609
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3610
- marginBottom: "20px"
3611
- }, children: [
3612
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
3613
- /* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateAvatar, children: [
3614
- /* @__PURE__ */ jsx(
3615
- "input",
3616
- {
3617
- type: "url",
3618
- value: avatar,
3619
- onChange: (e) => setAvatar(e.target.value),
3620
- required: true,
3621
- disabled: isLoading,
3622
- style: {
3623
- width: "100%",
3624
- padding: "12px 16px",
3625
- border: "1px solid #ddd",
3626
- borderRadius: "8px",
3627
- fontSize: "16px",
3628
- boxSizing: "border-box",
3629
- marginBottom: "12px"
4254
+ onMouseLeave: (e) => {
4255
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
3630
4256
  },
3631
- placeholder: "Avatar URL"
3632
- }
3633
- ),
3634
- /* @__PURE__ */ jsx(
3635
- "button",
3636
- {
3637
- type: "submit",
3638
- disabled: isLoading,
3639
4257
  style: {
3640
- padding: "10px 20px",
3641
- backgroundColor: "#007bff",
4258
+ padding: "12px 24px",
4259
+ backgroundColor: colors.buttonPrimary,
3642
4260
  color: "white",
3643
4261
  border: "none",
3644
4262
  borderRadius: "8px",
3645
4263
  fontSize: "14px",
3646
4264
  fontWeight: 600,
3647
- cursor: "pointer"
4265
+ cursor: isLoading ? "not-allowed" : "pointer",
4266
+ opacity: isLoading ? 0.6 : 1,
4267
+ transition: "all 0.2s ease"
3648
4268
  },
3649
- children: "Update Avatar"
4269
+ children: isLoading ? "Saving..." : "Save Changes"
3650
4270
  }
3651
4271
  )
3652
4272
  ] })
3653
4273
  ] }),
3654
4274
  showEmailChange && /* @__PURE__ */ jsxs("div", { style: {
3655
- padding: "20px",
3656
- backgroundColor: "#fff",
3657
- borderRadius: "8px",
4275
+ padding: "24px",
4276
+ backgroundColor: colors.bgPrimary,
4277
+ borderRadius: "12px",
3658
4278
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3659
- marginBottom: "20px"
4279
+ marginBottom: "20px",
4280
+ border: `1px solid ${colors.borderPrimary}`
3660
4281
  }, children: [
3661
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
3662
- /* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color: "#666", marginBottom: "12px" }, children: [
4282
+ /* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
4283
+ /* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
3663
4284
  "Current email: ",
3664
4285
  /* @__PURE__ */ jsx("strong", { children: user.email })
3665
4286
  ] }),
3666
4287
  /* @__PURE__ */ jsxs("form", { onSubmit: handleRequestEmailChange, children: [
3667
- /* @__PURE__ */ jsx(
3668
- "input",
3669
- {
3670
- type: "email",
3671
- value: newEmail,
3672
- onChange: (e) => setNewEmail(e.target.value),
3673
- required: true,
3674
- disabled: isLoading,
3675
- style: {
3676
- width: "100%",
3677
- padding: "12px 16px",
3678
- border: "1px solid #ddd",
3679
- borderRadius: "8px",
3680
- fontSize: "16px",
3681
- boxSizing: "border-box",
3682
- marginBottom: "12px"
3683
- },
3684
- placeholder: "New email address"
3685
- }
3686
- ),
4288
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
4289
+ /* @__PURE__ */ jsx("label", { htmlFor: "newEmail", style: {
4290
+ display: "block",
4291
+ marginBottom: "8px",
4292
+ fontWeight: 500,
4293
+ color: colors.textSecondary,
4294
+ fontSize: "14px"
4295
+ }, children: "New Email Address" }),
4296
+ /* @__PURE__ */ jsx(
4297
+ "input",
4298
+ {
4299
+ id: "newEmail",
4300
+ type: "email",
4301
+ value: newEmail,
4302
+ onChange: (e) => setNewEmail(e.target.value),
4303
+ required: true,
4304
+ disabled: isLoading,
4305
+ style: {
4306
+ width: "100%",
4307
+ padding: "12px 16px",
4308
+ border: `1px solid ${colors.borderSecondary}`,
4309
+ borderRadius: "8px",
4310
+ fontSize: "16px",
4311
+ boxSizing: "border-box",
4312
+ backgroundColor: colors.bgSecondary,
4313
+ color: colors.textPrimary,
4314
+ transition: "all 0.2s ease"
4315
+ },
4316
+ placeholder: "newemail@example.com"
4317
+ }
4318
+ )
4319
+ ] }),
3687
4320
  /* @__PURE__ */ jsx(
3688
4321
  "button",
3689
4322
  {
3690
4323
  type: "submit",
3691
4324
  disabled: isLoading,
4325
+ onMouseEnter: (e) => {
4326
+ if (!isLoading) {
4327
+ e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
4328
+ }
4329
+ },
4330
+ onMouseLeave: (e) => {
4331
+ e.currentTarget.style.backgroundColor = colors.buttonPrimary;
4332
+ },
3692
4333
  style: {
3693
- padding: "10px 20px",
3694
- backgroundColor: "#007bff",
4334
+ padding: "12px 24px",
4335
+ backgroundColor: colors.buttonPrimary,
3695
4336
  color: "white",
3696
4337
  border: "none",
3697
4338
  borderRadius: "8px",
3698
4339
  fontSize: "14px",
3699
4340
  fontWeight: 600,
3700
- cursor: "pointer"
4341
+ cursor: isLoading ? "not-allowed" : "pointer",
4342
+ opacity: isLoading ? 0.6 : 1,
4343
+ transition: "all 0.2s ease"
3701
4344
  },
3702
- children: "Request Email Change"
4345
+ children: isLoading ? "Sending..." : "Request Email Change"
3703
4346
  }
3704
4347
  )
3705
4348
  ] })
@@ -3707,6 +4350,6 @@ var UserProfile = ({
3707
4350
  ] });
3708
4351
  };
3709
4352
 
3710
- export { AuthFlow, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
4353
+ export { AuthFlow, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
3711
4354
  //# sourceMappingURL=out.js.map
3712
4355
  //# sourceMappingURL=index.components.mjs.map