@saas-support/react 0.2.0 → 0.3.1
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.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +6 -2
- package/dist/react.cjs +137 -2
- package/dist/react.d.ts +23 -1
- package/dist/react.js +1052 -637
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { SaaSSupport as
|
|
4
|
-
import { SaaSError as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
const H =
|
|
7
|
-
function
|
|
8
|
-
const s =
|
|
1
|
+
import { jsx as e, jsxs as i, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Y, useContext as K, useState as g, useEffect as L, useRef as R, useCallback as S, useMemo as A } from "react";
|
|
3
|
+
import { SaaSSupport as X, isMfaRequired as Z, BillingClient as ss, Transport as F, ReportClient as W } from "./index.js";
|
|
4
|
+
import { SaaSError as Xs } from "./index.js";
|
|
5
|
+
import { createPortal as es } from "react-dom";
|
|
6
|
+
const H = Y(null);
|
|
7
|
+
function k() {
|
|
8
|
+
const s = K(H);
|
|
9
9
|
if (!s)
|
|
10
10
|
throw new Error("useSaaSContext must be used within a <SaaSProvider>");
|
|
11
11
|
return s;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const [
|
|
15
|
-
return
|
|
13
|
+
function Bs({ publishableKey: s, apiKey: a, baseUrl: r, appearance: c, children: t }) {
|
|
14
|
+
const [d] = g(() => new X({ publishableKey: s, apiKey: a, baseUrl: r })), [l, u] = g(null), [o, n] = g(!1), [m, p] = g(null);
|
|
15
|
+
return L(() => {
|
|
16
16
|
let h = !1;
|
|
17
|
-
|
|
17
|
+
d.load().then(async () => {
|
|
18
18
|
if (h) return;
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const y = await d.auth.getUser(), b = await d.auth.getSettings();
|
|
20
|
+
u(y), p(b), n(!0);
|
|
21
21
|
});
|
|
22
|
-
const
|
|
23
|
-
h ||
|
|
22
|
+
const v = d.auth.onAuthStateChange((y) => {
|
|
23
|
+
h || u(y);
|
|
24
24
|
});
|
|
25
25
|
return () => {
|
|
26
|
-
h = !0,
|
|
26
|
+
h = !0, v(), d.destroy();
|
|
27
27
|
};
|
|
28
|
-
}, [
|
|
28
|
+
}, [d]), /* @__PURE__ */ e(H.Provider, { value: { client: d, user: l, isLoaded: o, appearance: c, settings: m }, children: t });
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const rs = {
|
|
31
31
|
colorPrimary: "#6366f1",
|
|
32
32
|
colorPrimaryHover: "#4f46e5",
|
|
33
33
|
colorBackground: "#ffffff",
|
|
@@ -40,7 +40,7 @@ const ss = {
|
|
|
40
40
|
colorWarning: "#f59e0b",
|
|
41
41
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
42
42
|
borderRadius: "8px"
|
|
43
|
-
},
|
|
43
|
+
}, as = {
|
|
44
44
|
colorPrimary: "#818cf8",
|
|
45
45
|
colorPrimaryHover: "#6366f1",
|
|
46
46
|
colorBackground: "#1e1e2e",
|
|
@@ -54,26 +54,26 @@ const ss = {
|
|
|
54
54
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
55
55
|
borderRadius: "8px"
|
|
56
56
|
};
|
|
57
|
-
function
|
|
58
|
-
const
|
|
57
|
+
function U(s) {
|
|
58
|
+
const a = (s == null ? void 0 : s.baseTheme) === "dark" ? as : rs, r = s == null ? void 0 : s.variables;
|
|
59
59
|
return {
|
|
60
|
-
colorPrimary: (r == null ? void 0 : r.colorPrimary) ??
|
|
61
|
-
colorPrimaryHover: r != null && r.colorPrimary ?
|
|
62
|
-
colorBackground: (r == null ? void 0 : r.colorBackground) ??
|
|
63
|
-
colorText: (r == null ? void 0 : r.colorText) ??
|
|
64
|
-
colorTextSecondary:
|
|
65
|
-
colorInputBackground: (r == null ? void 0 : r.colorInputBackground) ??
|
|
66
|
-
colorInputBorder: (r == null ? void 0 : r.colorInputBorder) ??
|
|
67
|
-
colorError: (r == null ? void 0 : r.colorError) ??
|
|
68
|
-
colorSuccess: (r == null ? void 0 : r.colorSuccess) ??
|
|
69
|
-
colorWarning: (r == null ? void 0 : r.colorWarning) ??
|
|
70
|
-
fontFamily: (r == null ? void 0 : r.fontFamily) ??
|
|
71
|
-
borderRadius: (r == null ? void 0 : r.borderRadius) ??
|
|
60
|
+
colorPrimary: (r == null ? void 0 : r.colorPrimary) ?? a.colorPrimary,
|
|
61
|
+
colorPrimaryHover: r != null && r.colorPrimary ? ns(r.colorPrimary, 10) : a.colorPrimaryHover,
|
|
62
|
+
colorBackground: (r == null ? void 0 : r.colorBackground) ?? a.colorBackground,
|
|
63
|
+
colorText: (r == null ? void 0 : r.colorText) ?? a.colorText,
|
|
64
|
+
colorTextSecondary: a.colorTextSecondary,
|
|
65
|
+
colorInputBackground: (r == null ? void 0 : r.colorInputBackground) ?? a.colorInputBackground,
|
|
66
|
+
colorInputBorder: (r == null ? void 0 : r.colorInputBorder) ?? a.colorInputBorder,
|
|
67
|
+
colorError: (r == null ? void 0 : r.colorError) ?? a.colorError,
|
|
68
|
+
colorSuccess: (r == null ? void 0 : r.colorSuccess) ?? a.colorSuccess,
|
|
69
|
+
colorWarning: (r == null ? void 0 : r.colorWarning) ?? a.colorWarning,
|
|
70
|
+
fontFamily: (r == null ? void 0 : r.fontFamily) ?? a.fontFamily,
|
|
71
|
+
borderRadius: (r == null ? void 0 : r.borderRadius) ?? a.borderRadius
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
const r = parseInt(s.replace("#", ""), 16), c = Math.max(0, (r >> 16) - Math.round(2.55 *
|
|
76
|
-
return `#${(c << 16 |
|
|
74
|
+
function ns(s, a) {
|
|
75
|
+
const r = parseInt(s.replace("#", ""), 16), c = Math.max(0, (r >> 16) - Math.round(2.55 * a)), t = Math.max(0, (r >> 8 & 255) - Math.round(2.55 * a)), d = Math.max(0, (r & 255) - Math.round(2.55 * a));
|
|
76
|
+
return `#${(c << 16 | t << 8 | d).toString(16).padStart(6, "0")}`;
|
|
77
77
|
}
|
|
78
78
|
function O(s) {
|
|
79
79
|
return `
|
|
@@ -668,53 +668,188 @@ function O(s) {
|
|
|
668
668
|
font-size: 12px;
|
|
669
669
|
color: ${s.colorTextSecondary};
|
|
670
670
|
}
|
|
671
|
+
|
|
672
|
+
/* Modal Overlay */
|
|
673
|
+
|
|
674
|
+
.ss-modal-overlay {
|
|
675
|
+
position: fixed;
|
|
676
|
+
top: 0;
|
|
677
|
+
left: 0;
|
|
678
|
+
right: 0;
|
|
679
|
+
bottom: 0;
|
|
680
|
+
background: rgba(0, 0, 0, 0.5);
|
|
681
|
+
display: flex;
|
|
682
|
+
align-items: center;
|
|
683
|
+
justify-content: center;
|
|
684
|
+
z-index: 99999;
|
|
685
|
+
animation: ss-fade-in 0.15s ease-out;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
@keyframes ss-fade-in {
|
|
689
|
+
from { opacity: 0; }
|
|
690
|
+
to { opacity: 1; }
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.ss-modal {
|
|
694
|
+
background: ${s.colorBackground};
|
|
695
|
+
border-radius: ${s.borderRadius};
|
|
696
|
+
padding: 32px;
|
|
697
|
+
width: 90%;
|
|
698
|
+
max-width: 480px;
|
|
699
|
+
max-height: 90vh;
|
|
700
|
+
overflow-y: auto;
|
|
701
|
+
box-shadow: 0 16px 64px rgba(0, 0, 0, 0.2);
|
|
702
|
+
border: 1px solid ${s.colorInputBorder};
|
|
703
|
+
animation: ss-scale-in 0.15s ease-out;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
@keyframes ss-scale-in {
|
|
707
|
+
from { transform: scale(0.95); opacity: 0; }
|
|
708
|
+
to { transform: scale(1); opacity: 1; }
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.ss-modal-header {
|
|
712
|
+
display: flex;
|
|
713
|
+
align-items: center;
|
|
714
|
+
justify-content: space-between;
|
|
715
|
+
margin-bottom: 24px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.ss-modal-title {
|
|
719
|
+
font-size: 18px;
|
|
720
|
+
font-weight: 700;
|
|
721
|
+
color: ${s.colorText};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.ss-modal-close {
|
|
725
|
+
background: none;
|
|
726
|
+
border: none;
|
|
727
|
+
font-size: 20px;
|
|
728
|
+
color: ${s.colorTextSecondary};
|
|
729
|
+
cursor: pointer;
|
|
730
|
+
padding: 4px;
|
|
731
|
+
line-height: 1;
|
|
732
|
+
border-radius: 4px;
|
|
733
|
+
transition: background 0.15s;
|
|
734
|
+
font-family: inherit;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
.ss-modal-close:hover {
|
|
738
|
+
background: ${s.colorInputBackground};
|
|
739
|
+
color: ${s.colorText};
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
.ss-modal-section {
|
|
743
|
+
padding-top: 20px;
|
|
744
|
+
margin-top: 20px;
|
|
745
|
+
border-top: 1px solid ${s.colorInputBorder};
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.ss-modal-section-title {
|
|
749
|
+
font-size: 15px;
|
|
750
|
+
font-weight: 600;
|
|
751
|
+
color: ${s.colorText};
|
|
752
|
+
margin-bottom: 16px;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.ss-avatar-preview {
|
|
756
|
+
width: 64px;
|
|
757
|
+
height: 64px;
|
|
758
|
+
border-radius: 50%;
|
|
759
|
+
background: ${s.colorPrimary};
|
|
760
|
+
color: #fff;
|
|
761
|
+
display: flex;
|
|
762
|
+
align-items: center;
|
|
763
|
+
justify-content: center;
|
|
764
|
+
font-size: 24px;
|
|
765
|
+
font-weight: 600;
|
|
766
|
+
margin-bottom: 16px;
|
|
767
|
+
overflow: hidden;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.ss-avatar-preview img {
|
|
771
|
+
width: 100%;
|
|
772
|
+
height: 100%;
|
|
773
|
+
object-fit: cover;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
.ss-input-readonly {
|
|
777
|
+
opacity: 0.6;
|
|
778
|
+
cursor: not-allowed;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/* Inline form (for org creation in dropdown) */
|
|
782
|
+
|
|
783
|
+
.ss-dropdown-divider {
|
|
784
|
+
height: 1px;
|
|
785
|
+
background: ${s.colorInputBorder};
|
|
786
|
+
margin: 4px 0;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.ss-inline-form {
|
|
790
|
+
padding: 12px 16px;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
.ss-inline-form .ss-field {
|
|
794
|
+
margin-bottom: 8px;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
.ss-inline-form .ss-input {
|
|
798
|
+
font-size: 13px;
|
|
799
|
+
padding: 6px 10px;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.ss-inline-form .ss-btn {
|
|
803
|
+
font-size: 13px;
|
|
804
|
+
padding: 6px 12px;
|
|
805
|
+
}
|
|
671
806
|
`;
|
|
672
807
|
}
|
|
673
|
-
function
|
|
674
|
-
const r =
|
|
675
|
-
|
|
676
|
-
var
|
|
808
|
+
function B({ children: s, appearance: a }) {
|
|
809
|
+
const r = R(null), [c, t] = g(null);
|
|
810
|
+
L(() => {
|
|
811
|
+
var m;
|
|
677
812
|
if (!r.current || r.current.shadowRoot) {
|
|
678
|
-
|
|
813
|
+
t(((m = r.current) == null ? void 0 : m.shadowRoot) ?? null);
|
|
679
814
|
return;
|
|
680
815
|
}
|
|
681
|
-
const l = r.current.attachShadow({ mode: "open" }),
|
|
682
|
-
o.textContent = O(
|
|
683
|
-
const
|
|
684
|
-
l.appendChild(
|
|
685
|
-
}, []),
|
|
816
|
+
const l = r.current.attachShadow({ mode: "open" }), u = U(a), o = document.createElement("style");
|
|
817
|
+
o.textContent = O(u), l.appendChild(o);
|
|
818
|
+
const n = document.createElement("div");
|
|
819
|
+
l.appendChild(n), t(l);
|
|
820
|
+
}, []), L(() => {
|
|
686
821
|
if (!c) return;
|
|
687
822
|
const l = c.querySelector("style");
|
|
688
823
|
if (l) {
|
|
689
|
-
const
|
|
690
|
-
l.textContent = O(
|
|
824
|
+
const u = U(a);
|
|
825
|
+
l.textContent = O(u);
|
|
691
826
|
}
|
|
692
|
-
}, [
|
|
693
|
-
const
|
|
694
|
-
return /* @__PURE__ */ e("div", { ref: r, style: { display: "contents" }, children:
|
|
827
|
+
}, [a, c]);
|
|
828
|
+
const d = (c == null ? void 0 : c.querySelector("div")) ?? null;
|
|
829
|
+
return /* @__PURE__ */ e("div", { ref: r, style: { display: "contents" }, children: d && es(s, d) });
|
|
695
830
|
}
|
|
696
|
-
function
|
|
697
|
-
const { client: s, user:
|
|
831
|
+
function j() {
|
|
832
|
+
const { client: s, user: a, isLoaded: r } = k();
|
|
698
833
|
return {
|
|
699
834
|
isLoaded: r,
|
|
700
|
-
isSignedIn: !!
|
|
701
|
-
user:
|
|
835
|
+
isSignedIn: !!a,
|
|
836
|
+
user: a,
|
|
702
837
|
signOut: S(() => s.auth.signOut(), [s]),
|
|
703
838
|
getToken: S(() => s.auth.getToken(), [s])
|
|
704
839
|
};
|
|
705
840
|
}
|
|
706
|
-
function
|
|
707
|
-
const { user: s, isLoaded:
|
|
708
|
-
return { user: s, isLoaded:
|
|
841
|
+
function zs() {
|
|
842
|
+
const { user: s, isLoaded: a } = k();
|
|
843
|
+
return { user: s, isLoaded: a };
|
|
709
844
|
}
|
|
710
845
|
function _() {
|
|
711
|
-
const { client: s } =
|
|
712
|
-
async (o,
|
|
713
|
-
r(!0),
|
|
846
|
+
const { client: s } = k(), [a, r] = g(!1), [c, t] = g(null), d = S(
|
|
847
|
+
async (o, n) => {
|
|
848
|
+
r(!0), t(null);
|
|
714
849
|
try {
|
|
715
|
-
return await s.auth.signIn(o,
|
|
716
|
-
} catch (
|
|
717
|
-
return
|
|
850
|
+
return await s.auth.signIn(o, n);
|
|
851
|
+
} catch (m) {
|
|
852
|
+
return t(m instanceof Error ? m.message : "Sign in failed"), null;
|
|
718
853
|
} finally {
|
|
719
854
|
r(!1);
|
|
720
855
|
}
|
|
@@ -722,133 +857,162 @@ function _() {
|
|
|
722
857
|
[s]
|
|
723
858
|
), l = S(
|
|
724
859
|
async (o) => {
|
|
725
|
-
r(!0),
|
|
860
|
+
r(!0), t(null);
|
|
726
861
|
try {
|
|
727
862
|
return await s.auth.signInWithOAuth(o);
|
|
728
|
-
} catch (
|
|
729
|
-
return
|
|
863
|
+
} catch (n) {
|
|
864
|
+
return t(n instanceof Error ? n.message : "OAuth sign in failed"), null;
|
|
730
865
|
} finally {
|
|
731
866
|
r(!1);
|
|
732
867
|
}
|
|
733
868
|
},
|
|
734
869
|
[s]
|
|
735
|
-
),
|
|
736
|
-
async (o,
|
|
737
|
-
r(!0),
|
|
870
|
+
), u = S(
|
|
871
|
+
async (o, n) => {
|
|
872
|
+
r(!0), t(null);
|
|
738
873
|
try {
|
|
739
|
-
return await s.auth.submitMfaCode(o,
|
|
740
|
-
} catch (
|
|
741
|
-
return
|
|
874
|
+
return await s.auth.submitMfaCode(o, n);
|
|
875
|
+
} catch (m) {
|
|
876
|
+
return t(m instanceof Error ? m.message : "MFA verification failed"), null;
|
|
742
877
|
} finally {
|
|
743
878
|
r(!1);
|
|
744
879
|
}
|
|
745
880
|
},
|
|
746
881
|
[s]
|
|
747
882
|
);
|
|
748
|
-
return { signIn:
|
|
883
|
+
return { signIn: d, signInWithOAuth: l, submitMfaCode: u, isLoading: a, error: c, setError: t };
|
|
749
884
|
}
|
|
750
|
-
function
|
|
751
|
-
const { client: s } =
|
|
885
|
+
function ts() {
|
|
886
|
+
const { client: s } = k(), [a, r] = g(!1), [c, t] = g(null);
|
|
752
887
|
return { signUp: S(
|
|
753
|
-
async (l,
|
|
754
|
-
r(!0),
|
|
888
|
+
async (l, u) => {
|
|
889
|
+
r(!0), t(null);
|
|
755
890
|
try {
|
|
756
|
-
return await s.auth.signUp(l,
|
|
891
|
+
return await s.auth.signUp(l, u);
|
|
757
892
|
} catch (o) {
|
|
758
|
-
return
|
|
893
|
+
return t(o instanceof Error ? o.message : "Sign up failed"), null;
|
|
759
894
|
} finally {
|
|
760
895
|
r(!1);
|
|
761
896
|
}
|
|
762
897
|
},
|
|
763
898
|
[s]
|
|
764
|
-
), isLoading:
|
|
899
|
+
), isLoading: a, error: c, setError: t };
|
|
765
900
|
}
|
|
766
|
-
function
|
|
767
|
-
const { client: s } =
|
|
768
|
-
o(!0),
|
|
901
|
+
function os() {
|
|
902
|
+
const { client: s } = k(), [a, r] = g([]), [c, t] = g(null), [d, l] = g([]), [u, o] = g(!1), [n, m] = g(null), p = S(async () => {
|
|
903
|
+
o(!0), m(null);
|
|
769
904
|
try {
|
|
770
|
-
const
|
|
771
|
-
r(
|
|
772
|
-
} catch (
|
|
773
|
-
|
|
905
|
+
const y = await s.auth.listOrgs();
|
|
906
|
+
r(y);
|
|
907
|
+
} catch (y) {
|
|
908
|
+
m(y instanceof Error ? y.message : "Failed to load organizations");
|
|
774
909
|
} finally {
|
|
775
910
|
o(!1);
|
|
776
911
|
}
|
|
777
912
|
}, [s]);
|
|
778
|
-
|
|
913
|
+
L(() => {
|
|
779
914
|
p();
|
|
780
915
|
}, [p]);
|
|
781
|
-
const h = S(async (
|
|
916
|
+
const h = S(async (y) => {
|
|
782
917
|
try {
|
|
783
|
-
const b = await s.auth.getOrg(
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
l(
|
|
918
|
+
const b = await s.auth.getOrg(y);
|
|
919
|
+
t(b);
|
|
920
|
+
const x = await s.auth.listMembers(y);
|
|
921
|
+
l(x);
|
|
787
922
|
} catch (b) {
|
|
788
|
-
|
|
923
|
+
m(b instanceof Error ? b.message : "Failed to load organization");
|
|
789
924
|
}
|
|
790
|
-
}, [s]),
|
|
925
|
+
}, [s]), v = S(async (y, b) => {
|
|
791
926
|
try {
|
|
792
|
-
const
|
|
793
|
-
return r((
|
|
794
|
-
} catch (
|
|
795
|
-
return
|
|
927
|
+
const x = await s.auth.createOrg(y, b);
|
|
928
|
+
return r((f) => [...f, x]), x;
|
|
929
|
+
} catch (x) {
|
|
930
|
+
return m(x instanceof Error ? x.message : "Failed to create organization"), null;
|
|
796
931
|
}
|
|
797
932
|
}, [s]);
|
|
798
|
-
return { orgs:
|
|
933
|
+
return { orgs: a, selectedOrg: c, members: d, isLoading: u, error: n, refresh: p, selectOrg: h, createOrg: v };
|
|
799
934
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
await
|
|
935
|
+
function G() {
|
|
936
|
+
const { client: s, user: a } = k(), [r, c] = g(!1), [t, d] = g(null), [l, u] = g(null), o = S(
|
|
937
|
+
async (m) => {
|
|
938
|
+
c(!0), d(null), u(null);
|
|
939
|
+
try {
|
|
940
|
+
const p = await s.auth.updateProfile(m);
|
|
941
|
+
return u("Profile updated"), p;
|
|
942
|
+
} catch (p) {
|
|
943
|
+
return d(p instanceof Error ? p.message : "Failed to update profile"), null;
|
|
944
|
+
} finally {
|
|
945
|
+
c(!1);
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
[s]
|
|
949
|
+
), n = S(
|
|
950
|
+
async (m, p) => {
|
|
951
|
+
c(!0), d(null), u(null);
|
|
952
|
+
try {
|
|
953
|
+
return await s.auth.changePassword(m, p), u("Password changed successfully"), !0;
|
|
954
|
+
} catch (h) {
|
|
955
|
+
return d(h instanceof Error ? h.message : "Failed to change password"), !1;
|
|
956
|
+
} finally {
|
|
957
|
+
c(!1);
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
[s]
|
|
961
|
+
);
|
|
962
|
+
return { user: a, updateProfile: o, changePassword: n, isLoading: r, error: t, success: l, setError: d, setSuccess: u };
|
|
963
|
+
}
|
|
964
|
+
const J = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>', Q = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" fill="currentColor"/></svg>';
|
|
965
|
+
function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
|
|
966
|
+
const { appearance: c, settings: t } = k(), { signIn: d, signInWithOAuth: l, submitMfaCode: u, isLoading: o, error: n, setError: m } = _(), p = s ?? c, [h, v] = g(""), [y, b] = g(""), [x, f] = g(!1), [N, w] = g(""), [$, E] = g(""), z = S(
|
|
967
|
+
async (q) => {
|
|
968
|
+
if (q.preventDefault(), x) {
|
|
969
|
+
await u(N, $);
|
|
806
970
|
return;
|
|
807
971
|
}
|
|
808
|
-
const
|
|
809
|
-
|
|
972
|
+
const P = await d(h, y);
|
|
973
|
+
P && Z(P) && (w(P.mfaToken), f(!0), m(null));
|
|
810
974
|
},
|
|
811
|
-
[h, x, N,
|
|
812
|
-
),
|
|
813
|
-
async (
|
|
814
|
-
await l(
|
|
975
|
+
[h, y, x, N, $, d, u, m]
|
|
976
|
+
), T = S(
|
|
977
|
+
async (q) => {
|
|
978
|
+
await l(q);
|
|
815
979
|
},
|
|
816
980
|
[l]
|
|
817
|
-
),
|
|
818
|
-
return /* @__PURE__ */ e(
|
|
981
|
+
), C = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled);
|
|
982
|
+
return /* @__PURE__ */ e(B, { appearance: p, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
|
|
819
983
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Sign in" }),
|
|
820
|
-
!
|
|
821
|
-
(
|
|
984
|
+
!x && /* @__PURE__ */ i(D, { children: [
|
|
985
|
+
(t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ i(
|
|
822
986
|
"button",
|
|
823
987
|
{
|
|
824
988
|
type: "button",
|
|
825
989
|
className: "ss-btn-social",
|
|
826
|
-
onClick: () =>
|
|
990
|
+
onClick: () => T("google"),
|
|
827
991
|
disabled: o,
|
|
828
992
|
children: [
|
|
829
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
993
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: J } }),
|
|
830
994
|
"Continue with Google"
|
|
831
995
|
]
|
|
832
996
|
}
|
|
833
997
|
),
|
|
834
|
-
(
|
|
998
|
+
(t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ i(
|
|
835
999
|
"button",
|
|
836
1000
|
{
|
|
837
1001
|
type: "button",
|
|
838
1002
|
className: "ss-btn-social",
|
|
839
|
-
onClick: () =>
|
|
1003
|
+
onClick: () => T("github"),
|
|
840
1004
|
disabled: o,
|
|
841
1005
|
children: [
|
|
842
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1006
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: Q } }),
|
|
843
1007
|
"Continue with GitHub"
|
|
844
1008
|
]
|
|
845
1009
|
}
|
|
846
1010
|
),
|
|
847
|
-
|
|
1011
|
+
C && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" })
|
|
848
1012
|
] }),
|
|
849
|
-
|
|
850
|
-
/* @__PURE__ */
|
|
851
|
-
|
|
1013
|
+
n && /* @__PURE__ */ e("div", { className: "ss-global-error", children: n }),
|
|
1014
|
+
/* @__PURE__ */ i("form", { onSubmit: z, children: [
|
|
1015
|
+
x ? /* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
852
1016
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-mfa-code", children: "Authentication code" }),
|
|
853
1017
|
/* @__PURE__ */ e(
|
|
854
1018
|
"input",
|
|
@@ -859,13 +1023,13 @@ function Ls({ appearance: s, signUpUrl: n, onSignUp: r }) {
|
|
|
859
1023
|
inputMode: "numeric",
|
|
860
1024
|
autoComplete: "one-time-code",
|
|
861
1025
|
placeholder: "Enter 6-digit code",
|
|
862
|
-
value:
|
|
863
|
-
onChange: (
|
|
1026
|
+
value: $,
|
|
1027
|
+
onChange: (q) => E(q.target.value),
|
|
864
1028
|
autoFocus: !0
|
|
865
1029
|
}
|
|
866
1030
|
)
|
|
867
|
-
] }) : /* @__PURE__ */
|
|
868
|
-
/* @__PURE__ */
|
|
1031
|
+
] }) : /* @__PURE__ */ i(D, { children: [
|
|
1032
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
869
1033
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-email", children: "Email" }),
|
|
870
1034
|
/* @__PURE__ */ e(
|
|
871
1035
|
"input",
|
|
@@ -876,12 +1040,12 @@ function Ls({ appearance: s, signUpUrl: n, onSignUp: r }) {
|
|
|
876
1040
|
autoComplete: "email",
|
|
877
1041
|
placeholder: "you@example.com",
|
|
878
1042
|
value: h,
|
|
879
|
-
onChange: (
|
|
1043
|
+
onChange: (q) => v(q.target.value),
|
|
880
1044
|
required: !0
|
|
881
1045
|
}
|
|
882
1046
|
)
|
|
883
1047
|
] }),
|
|
884
|
-
/* @__PURE__ */
|
|
1048
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
885
1049
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-password", children: "Password" }),
|
|
886
1050
|
/* @__PURE__ */ e(
|
|
887
1051
|
"input",
|
|
@@ -891,88 +1055,88 @@ function Ls({ appearance: s, signUpUrl: n, onSignUp: r }) {
|
|
|
891
1055
|
type: "password",
|
|
892
1056
|
autoComplete: "current-password",
|
|
893
1057
|
placeholder: "Enter your password",
|
|
894
|
-
value:
|
|
895
|
-
onChange: (
|
|
1058
|
+
value: y,
|
|
1059
|
+
onChange: (q) => b(q.target.value),
|
|
896
1060
|
required: !0
|
|
897
1061
|
}
|
|
898
1062
|
)
|
|
899
1063
|
] })
|
|
900
1064
|
] }),
|
|
901
|
-
/* @__PURE__ */
|
|
1065
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: o, children: [
|
|
902
1066
|
o && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
903
|
-
|
|
1067
|
+
x ? "Verify" : "Continue"
|
|
904
1068
|
] })
|
|
905
1069
|
] }),
|
|
906
|
-
|
|
1070
|
+
x && /* @__PURE__ */ e("div", { className: "ss-footer", children: /* @__PURE__ */ e(
|
|
907
1071
|
"span",
|
|
908
1072
|
{
|
|
909
1073
|
className: "ss-link",
|
|
910
1074
|
onClick: () => {
|
|
911
|
-
|
|
1075
|
+
f(!1), E(""), m(null);
|
|
912
1076
|
},
|
|
913
1077
|
children: "Back to sign in"
|
|
914
1078
|
}
|
|
915
1079
|
) }),
|
|
916
|
-
!
|
|
1080
|
+
!x && /* @__PURE__ */ i("div", { className: "ss-footer", children: [
|
|
917
1081
|
"Don't have an account?",
|
|
918
1082
|
" ",
|
|
919
|
-
r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign up" }) :
|
|
1083
|
+
r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign up" }) : a ? /* @__PURE__ */ e("a", { className: "ss-link", href: a, children: "Sign up" }) : /* @__PURE__ */ e("span", { className: "ss-link", children: "Sign up" })
|
|
920
1084
|
] })
|
|
921
1085
|
] }) });
|
|
922
1086
|
}
|
|
923
|
-
function
|
|
924
|
-
const { appearance: c, settings:
|
|
925
|
-
async (
|
|
926
|
-
if (
|
|
927
|
-
|
|
1087
|
+
function As({ appearance: s, signInUrl: a, onSignIn: r }) {
|
|
1088
|
+
const { appearance: c, settings: t } = k(), { signUp: d, isLoading: l, error: u, setError: o } = ts(), { signInWithOAuth: n } = _(), m = s ?? c, [p, h] = g(""), [v, y] = g(""), [b, x] = g(""), [f, N] = g(null), w = S(
|
|
1089
|
+
async (T) => {
|
|
1090
|
+
if (T.preventDefault(), N(null), v !== b) {
|
|
1091
|
+
N("Passwords do not match");
|
|
928
1092
|
return;
|
|
929
1093
|
}
|
|
930
|
-
const
|
|
931
|
-
if (
|
|
932
|
-
|
|
1094
|
+
const C = (t == null ? void 0 : t.passwordMinLength) ?? 8;
|
|
1095
|
+
if (v.length < C) {
|
|
1096
|
+
N(`Password must be at least ${C} characters`);
|
|
933
1097
|
return;
|
|
934
1098
|
}
|
|
935
|
-
await
|
|
1099
|
+
await d(p, v);
|
|
936
1100
|
},
|
|
937
|
-
[p,
|
|
938
|
-
),
|
|
939
|
-
async (
|
|
940
|
-
await
|
|
1101
|
+
[p, v, b, t, d]
|
|
1102
|
+
), $ = S(
|
|
1103
|
+
async (T) => {
|
|
1104
|
+
await n(T);
|
|
941
1105
|
},
|
|
942
|
-
[
|
|
943
|
-
),
|
|
944
|
-
return /* @__PURE__ */ e(
|
|
1106
|
+
[n]
|
|
1107
|
+
), E = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled), z = f || u;
|
|
1108
|
+
return /* @__PURE__ */ e(B, { appearance: m, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
|
|
945
1109
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Create account" }),
|
|
946
|
-
(
|
|
1110
|
+
(t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ i(
|
|
947
1111
|
"button",
|
|
948
1112
|
{
|
|
949
1113
|
type: "button",
|
|
950
1114
|
className: "ss-btn-social",
|
|
951
|
-
onClick: () =>
|
|
1115
|
+
onClick: () => $("google"),
|
|
952
1116
|
disabled: l,
|
|
953
1117
|
children: [
|
|
954
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1118
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: J } }),
|
|
955
1119
|
"Continue with Google"
|
|
956
1120
|
]
|
|
957
1121
|
}
|
|
958
1122
|
),
|
|
959
|
-
(
|
|
1123
|
+
(t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ i(
|
|
960
1124
|
"button",
|
|
961
1125
|
{
|
|
962
1126
|
type: "button",
|
|
963
1127
|
className: "ss-btn-social",
|
|
964
|
-
onClick: () =>
|
|
1128
|
+
onClick: () => $("github"),
|
|
965
1129
|
disabled: l,
|
|
966
1130
|
children: [
|
|
967
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1131
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: Q } }),
|
|
968
1132
|
"Continue with GitHub"
|
|
969
1133
|
]
|
|
970
1134
|
}
|
|
971
1135
|
),
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
/* @__PURE__ */
|
|
975
|
-
/* @__PURE__ */
|
|
1136
|
+
E && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" }),
|
|
1137
|
+
z && /* @__PURE__ */ e("div", { className: "ss-global-error", children: z }),
|
|
1138
|
+
/* @__PURE__ */ i("form", { onSubmit: w, children: [
|
|
1139
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
976
1140
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-email", children: "Email" }),
|
|
977
1141
|
/* @__PURE__ */ e(
|
|
978
1142
|
"input",
|
|
@@ -983,12 +1147,12 @@ function Bs({ appearance: s, signInUrl: n, onSignIn: r }) {
|
|
|
983
1147
|
autoComplete: "email",
|
|
984
1148
|
placeholder: "you@example.com",
|
|
985
1149
|
value: p,
|
|
986
|
-
onChange: (
|
|
1150
|
+
onChange: (T) => h(T.target.value),
|
|
987
1151
|
required: !0
|
|
988
1152
|
}
|
|
989
1153
|
)
|
|
990
1154
|
] }),
|
|
991
|
-
/* @__PURE__ */
|
|
1155
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
992
1156
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-password", children: "Password" }),
|
|
993
1157
|
/* @__PURE__ */ e(
|
|
994
1158
|
"input",
|
|
@@ -998,15 +1162,15 @@ function Bs({ appearance: s, signInUrl: n, onSignIn: r }) {
|
|
|
998
1162
|
type: "password",
|
|
999
1163
|
autoComplete: "new-password",
|
|
1000
1164
|
placeholder: "Create a password",
|
|
1001
|
-
value:
|
|
1002
|
-
onChange: (
|
|
1003
|
-
|
|
1165
|
+
value: v,
|
|
1166
|
+
onChange: (T) => {
|
|
1167
|
+
y(T.target.value), N(null);
|
|
1004
1168
|
},
|
|
1005
1169
|
required: !0
|
|
1006
1170
|
}
|
|
1007
1171
|
)
|
|
1008
1172
|
] }),
|
|
1009
|
-
/* @__PURE__ */
|
|
1173
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1010
1174
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-confirm", children: "Confirm password" }),
|
|
1011
1175
|
/* @__PURE__ */ e(
|
|
1012
1176
|
"input",
|
|
@@ -1017,53 +1181,67 @@ function Bs({ appearance: s, signInUrl: n, onSignIn: r }) {
|
|
|
1017
1181
|
autoComplete: "new-password",
|
|
1018
1182
|
placeholder: "Confirm your password",
|
|
1019
1183
|
value: b,
|
|
1020
|
-
onChange: (
|
|
1021
|
-
|
|
1184
|
+
onChange: (T) => {
|
|
1185
|
+
x(T.target.value), N(null);
|
|
1022
1186
|
},
|
|
1023
1187
|
required: !0
|
|
1024
1188
|
}
|
|
1025
1189
|
)
|
|
1026
1190
|
] }),
|
|
1027
|
-
/* @__PURE__ */
|
|
1191
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
|
|
1028
1192
|
l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1029
1193
|
"Create account"
|
|
1030
1194
|
] })
|
|
1031
1195
|
] }),
|
|
1032
|
-
/* @__PURE__ */
|
|
1196
|
+
/* @__PURE__ */ i("div", { className: "ss-footer", children: [
|
|
1033
1197
|
"Already have an account?",
|
|
1034
1198
|
" ",
|
|
1035
|
-
r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign in" }) :
|
|
1199
|
+
r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign in" }) : a ? /* @__PURE__ */ e("a", { className: "ss-link", href: a, children: "Sign in" }) : /* @__PURE__ */ e("span", { className: "ss-link", children: "Sign in" })
|
|
1036
1200
|
] })
|
|
1037
1201
|
] }) });
|
|
1038
1202
|
}
|
|
1039
|
-
function
|
|
1040
|
-
const { appearance:
|
|
1041
|
-
|
|
1203
|
+
function Ds({ appearance: s }) {
|
|
1204
|
+
const { appearance: a } = k(), { user: r, signOut: c } = j(), t = s ?? a, [d, l] = g(!1), [u, o] = g(!1), n = R(null), m = S((h) => {
|
|
1205
|
+
n.current && !h.composedPath().includes(n.current) && l(!1);
|
|
1042
1206
|
}, []);
|
|
1043
|
-
if (
|
|
1044
|
-
if (
|
|
1045
|
-
const
|
|
1046
|
-
document.addEventListener("click",
|
|
1207
|
+
if (L(() => {
|
|
1208
|
+
if (d) {
|
|
1209
|
+
const h = setTimeout(() => {
|
|
1210
|
+
document.addEventListener("click", m);
|
|
1047
1211
|
}, 0);
|
|
1048
1212
|
return () => {
|
|
1049
|
-
clearTimeout(
|
|
1213
|
+
clearTimeout(h), document.removeEventListener("click", m);
|
|
1050
1214
|
};
|
|
1051
1215
|
}
|
|
1052
|
-
}, [
|
|
1053
|
-
const
|
|
1054
|
-
return /* @__PURE__ */ e(
|
|
1216
|
+
}, [d, m]), !r) return null;
|
|
1217
|
+
const p = (r.name || r.email).charAt(0).toUpperCase();
|
|
1218
|
+
return /* @__PURE__ */ e(B, { appearance: t, children: /* @__PURE__ */ i("div", { className: "ss-user-btn", ref: n, children: [
|
|
1055
1219
|
/* @__PURE__ */ e(
|
|
1056
1220
|
"button",
|
|
1057
1221
|
{
|
|
1058
1222
|
type: "button",
|
|
1059
1223
|
className: "ss-avatar",
|
|
1060
|
-
onClick: () => l(!
|
|
1224
|
+
onClick: () => l(!d),
|
|
1061
1225
|
"aria-label": "User menu",
|
|
1062
|
-
children:
|
|
1226
|
+
children: r.avatarUrl ? /* @__PURE__ */ e("img", { src: r.avatarUrl, alt: "", style: { width: "100%", height: "100%", borderRadius: "50%", objectFit: "cover" } }) : p
|
|
1063
1227
|
}
|
|
1064
1228
|
),
|
|
1065
|
-
|
|
1066
|
-
/* @__PURE__ */
|
|
1229
|
+
d && /* @__PURE__ */ i("div", { className: "ss-dropdown", children: [
|
|
1230
|
+
/* @__PURE__ */ i("div", { className: "ss-dropdown-header", children: [
|
|
1231
|
+
r.name && /* @__PURE__ */ e("div", { style: { fontWeight: 600, fontSize: "14px", color: "inherit" }, children: r.name }),
|
|
1232
|
+
/* @__PURE__ */ e("div", { className: "ss-dropdown-email", children: r.email })
|
|
1233
|
+
] }),
|
|
1234
|
+
/* @__PURE__ */ e(
|
|
1235
|
+
"button",
|
|
1236
|
+
{
|
|
1237
|
+
type: "button",
|
|
1238
|
+
className: "ss-dropdown-item",
|
|
1239
|
+
onClick: () => {
|
|
1240
|
+
l(!1), o(!0);
|
|
1241
|
+
},
|
|
1242
|
+
children: "Profile"
|
|
1243
|
+
}
|
|
1244
|
+
),
|
|
1067
1245
|
/* @__PURE__ */ e(
|
|
1068
1246
|
"button",
|
|
1069
1247
|
{
|
|
@@ -1075,296 +1253,532 @@ function Ps({ appearance: s }) {
|
|
|
1075
1253
|
children: "Sign out"
|
|
1076
1254
|
}
|
|
1077
1255
|
)
|
|
1256
|
+
] }),
|
|
1257
|
+
u && /* @__PURE__ */ e(ls, { onClose: () => o(!1) })
|
|
1258
|
+
] }) });
|
|
1259
|
+
}
|
|
1260
|
+
function ls({ onClose: s }) {
|
|
1261
|
+
const { user: a, updateProfile: r, changePassword: c, isLoading: t, error: d, success: l, setError: u, setSuccess: o } = G(), [n, m] = g((a == null ? void 0 : a.name) ?? ""), [p, h] = g((a == null ? void 0 : a.avatarUrl) ?? ""), [v, y] = g(""), [b, x] = g(""), [f, N] = g(""), [w, $] = g(null), E = S(
|
|
1262
|
+
async (C) => {
|
|
1263
|
+
C.preventDefault(), u(null), o(null), await r({ name: n, avatarUrl: p });
|
|
1264
|
+
},
|
|
1265
|
+
[n, p, r, u, o]
|
|
1266
|
+
), z = S(
|
|
1267
|
+
async (C) => {
|
|
1268
|
+
if (C.preventDefault(), $(null), u(null), o(null), b !== f) {
|
|
1269
|
+
$("Passwords do not match");
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
if (b.length < 8) {
|
|
1273
|
+
$("Password must be at least 8 characters");
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
await c(v, b) && (y(""), x(""), N(""));
|
|
1277
|
+
},
|
|
1278
|
+
[v, b, f, c, u, o]
|
|
1279
|
+
), T = (a == null ? void 0 : a.provider) === "email";
|
|
1280
|
+
return /* @__PURE__ */ e("div", { className: "ss-modal-overlay", onClick: (C) => {
|
|
1281
|
+
C.target === C.currentTarget && s();
|
|
1282
|
+
}, children: /* @__PURE__ */ i("div", { className: "ss-modal", children: [
|
|
1283
|
+
/* @__PURE__ */ i("div", { className: "ss-modal-header", children: [
|
|
1284
|
+
/* @__PURE__ */ e("span", { className: "ss-modal-title", children: "Profile" }),
|
|
1285
|
+
/* @__PURE__ */ e("button", { type: "button", className: "ss-modal-close", onClick: s, children: "✕" })
|
|
1286
|
+
] }),
|
|
1287
|
+
d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
|
|
1288
|
+
l && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: l }),
|
|
1289
|
+
/* @__PURE__ */ e("div", { className: "ss-avatar-preview", children: p ? /* @__PURE__ */ e("img", { src: p, alt: "" }) : (n || (a == null ? void 0 : a.email) || "?").charAt(0).toUpperCase() }),
|
|
1290
|
+
/* @__PURE__ */ i("form", { onSubmit: E, children: [
|
|
1291
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1292
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Name" }),
|
|
1293
|
+
/* @__PURE__ */ e(
|
|
1294
|
+
"input",
|
|
1295
|
+
{
|
|
1296
|
+
className: "ss-input",
|
|
1297
|
+
type: "text",
|
|
1298
|
+
placeholder: "Your name",
|
|
1299
|
+
value: n,
|
|
1300
|
+
onChange: (C) => m(C.target.value)
|
|
1301
|
+
}
|
|
1302
|
+
)
|
|
1303
|
+
] }),
|
|
1304
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1305
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Avatar URL" }),
|
|
1306
|
+
/* @__PURE__ */ e(
|
|
1307
|
+
"input",
|
|
1308
|
+
{
|
|
1309
|
+
className: "ss-input",
|
|
1310
|
+
type: "url",
|
|
1311
|
+
placeholder: "https://example.com/avatar.jpg",
|
|
1312
|
+
value: p,
|
|
1313
|
+
onChange: (C) => h(C.target.value)
|
|
1314
|
+
}
|
|
1315
|
+
)
|
|
1316
|
+
] }),
|
|
1317
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1318
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
|
|
1319
|
+
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "email", value: (a == null ? void 0 : a.email) ?? "", disabled: !0, readOnly: !0 })
|
|
1320
|
+
] }),
|
|
1321
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1322
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
|
|
1323
|
+
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: (a == null ? void 0 : a.provider) ?? "", disabled: !0, readOnly: !0 })
|
|
1324
|
+
] }),
|
|
1325
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: t, children: [
|
|
1326
|
+
t && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1327
|
+
"Save changes"
|
|
1328
|
+
] })
|
|
1329
|
+
] }),
|
|
1330
|
+
T && /* @__PURE__ */ i("div", { className: "ss-modal-section", children: [
|
|
1331
|
+
/* @__PURE__ */ e("div", { className: "ss-modal-section-title", children: "Change password" }),
|
|
1332
|
+
w && /* @__PURE__ */ e("div", { className: "ss-global-error", children: w }),
|
|
1333
|
+
/* @__PURE__ */ i("form", { onSubmit: z, children: [
|
|
1334
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1335
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Current password" }),
|
|
1336
|
+
/* @__PURE__ */ e(
|
|
1337
|
+
"input",
|
|
1338
|
+
{
|
|
1339
|
+
className: "ss-input",
|
|
1340
|
+
type: "password",
|
|
1341
|
+
value: v,
|
|
1342
|
+
onChange: (C) => y(C.target.value),
|
|
1343
|
+
required: !0
|
|
1344
|
+
}
|
|
1345
|
+
)
|
|
1346
|
+
] }),
|
|
1347
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1348
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "New password" }),
|
|
1349
|
+
/* @__PURE__ */ e(
|
|
1350
|
+
"input",
|
|
1351
|
+
{
|
|
1352
|
+
className: "ss-input",
|
|
1353
|
+
type: "password",
|
|
1354
|
+
value: b,
|
|
1355
|
+
onChange: (C) => x(C.target.value),
|
|
1356
|
+
required: !0
|
|
1357
|
+
}
|
|
1358
|
+
)
|
|
1359
|
+
] }),
|
|
1360
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1361
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Confirm new password" }),
|
|
1362
|
+
/* @__PURE__ */ e(
|
|
1363
|
+
"input",
|
|
1364
|
+
{
|
|
1365
|
+
className: "ss-input",
|
|
1366
|
+
type: "password",
|
|
1367
|
+
value: f,
|
|
1368
|
+
onChange: (C) => N(C.target.value),
|
|
1369
|
+
required: !0
|
|
1370
|
+
}
|
|
1371
|
+
)
|
|
1372
|
+
] }),
|
|
1373
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: t, children: [
|
|
1374
|
+
t && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1375
|
+
"Update password"
|
|
1376
|
+
] })
|
|
1377
|
+
] })
|
|
1078
1378
|
] })
|
|
1079
1379
|
] }) });
|
|
1080
1380
|
}
|
|
1081
|
-
function
|
|
1082
|
-
const { appearance:
|
|
1083
|
-
|
|
1381
|
+
function Fs({ appearance: s }) {
|
|
1382
|
+
const { appearance: a } = k(), { user: r, signOut: c } = j(), { updateProfile: t, changePassword: d, isLoading: l, error: u, success: o, setError: n, setSuccess: m } = G(), p = s ?? a, [h, v] = g((r == null ? void 0 : r.name) ?? ""), [y, b] = g((r == null ? void 0 : r.avatarUrl) ?? ""), [x, f] = g(""), [N, w] = g(""), [$, E] = g(""), [z, T] = g(null), C = S(
|
|
1383
|
+
async (I) => {
|
|
1384
|
+
I.preventDefault(), n(null), m(null), await t({ name: h, avatarUrl: y });
|
|
1385
|
+
},
|
|
1386
|
+
[h, y, t, n, m]
|
|
1387
|
+
), q = S(
|
|
1388
|
+
async (I) => {
|
|
1389
|
+
if (I.preventDefault(), T(null), n(null), m(null), N !== $) {
|
|
1390
|
+
T("Passwords do not match");
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
if (N.length < 8) {
|
|
1394
|
+
T("Password must be at least 8 characters");
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
await d(x, N) && (f(""), w(""), E(""));
|
|
1398
|
+
},
|
|
1399
|
+
[x, N, $, d, n, m]
|
|
1400
|
+
);
|
|
1401
|
+
if (!r) return null;
|
|
1402
|
+
const P = r.provider === "email";
|
|
1403
|
+
return /* @__PURE__ */ e(B, { appearance: p, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
|
|
1084
1404
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Profile" }),
|
|
1085
|
-
/* @__PURE__ */
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
)
|
|
1405
|
+
u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
|
|
1406
|
+
o && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: o }),
|
|
1407
|
+
/* @__PURE__ */ e("div", { className: "ss-avatar-preview", style: { margin: "0 auto 16px" }, children: y ? /* @__PURE__ */ e("img", { src: y, alt: "" }) : (h || r.email).charAt(0).toUpperCase() }),
|
|
1408
|
+
/* @__PURE__ */ i("form", { onSubmit: C, children: [
|
|
1409
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1410
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Name" }),
|
|
1411
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "text", placeholder: "Your name", value: h, onChange: (I) => v(I.target.value) })
|
|
1412
|
+
] }),
|
|
1413
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1414
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Avatar URL" }),
|
|
1415
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "url", placeholder: "https://example.com/avatar.jpg", value: y, onChange: (I) => b(I.target.value) })
|
|
1416
|
+
] }),
|
|
1417
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1418
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
|
|
1419
|
+
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "email", value: r.email, disabled: !0, readOnly: !0 })
|
|
1420
|
+
] }),
|
|
1421
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1422
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
|
|
1423
|
+
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: r.provider, disabled: !0, readOnly: !0 })
|
|
1424
|
+
] }),
|
|
1425
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1426
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email verified" }),
|
|
1427
|
+
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: r.emailVerified ? "Yes" : "No", disabled: !0, readOnly: !0 })
|
|
1428
|
+
] }),
|
|
1429
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
|
|
1430
|
+
l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1431
|
+
"Save changes"
|
|
1432
|
+
] })
|
|
1101
1433
|
] }),
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
/* @__PURE__ */ e("
|
|
1104
|
-
/* @__PURE__ */ e(
|
|
1105
|
-
|
|
1106
|
-
{
|
|
1107
|
-
className: "ss-
|
|
1108
|
-
type: "
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1434
|
+
P && /* @__PURE__ */ i("div", { className: "ss-modal-section", children: [
|
|
1435
|
+
/* @__PURE__ */ e("div", { className: "ss-modal-section-title", children: "Change password" }),
|
|
1436
|
+
z && /* @__PURE__ */ e("div", { className: "ss-global-error", children: z }),
|
|
1437
|
+
/* @__PURE__ */ i("form", { onSubmit: q, children: [
|
|
1438
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1439
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Current password" }),
|
|
1440
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: x, onChange: (I) => f(I.target.value), required: !0 })
|
|
1441
|
+
] }),
|
|
1442
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1443
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "New password" }),
|
|
1444
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: N, onChange: (I) => w(I.target.value), required: !0 })
|
|
1445
|
+
] }),
|
|
1446
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1447
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Confirm new password" }),
|
|
1448
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: $, onChange: (I) => E(I.target.value), required: !0 })
|
|
1449
|
+
] }),
|
|
1450
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
|
|
1451
|
+
l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1452
|
+
"Update password"
|
|
1453
|
+
] })
|
|
1454
|
+
] })
|
|
1114
1455
|
] }),
|
|
1115
|
-
/* @__PURE__ */ e("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ e(
|
|
1116
|
-
|
|
1117
|
-
{
|
|
1118
|
-
type: "button",
|
|
1119
|
-
className: "ss-btn ss-btn-primary",
|
|
1120
|
-
onClick: () => c(),
|
|
1121
|
-
style: { background: "#ef4444" },
|
|
1122
|
-
children: "Sign out"
|
|
1123
|
-
}
|
|
1124
|
-
) })
|
|
1125
|
-
] }) }) : null;
|
|
1456
|
+
/* @__PURE__ */ e("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: () => c(), children: "Sign out" }) })
|
|
1457
|
+
] }) });
|
|
1126
1458
|
}
|
|
1127
|
-
function
|
|
1128
|
-
const { appearance: r } =
|
|
1129
|
-
|
|
1459
|
+
function Ms({ appearance: s, onOrgChange: a }) {
|
|
1460
|
+
const { appearance: r } = k(), { orgs: c, selectedOrg: t, selectOrg: d, createOrg: l, isLoading: u } = os(), o = s ?? r, [n, m] = g(!1), [p, h] = g(!1), [v, y] = g(""), [b, x] = g(""), [f, N] = g(null), [w, $] = g(!1), E = R(null), z = S((P) => {
|
|
1461
|
+
E.current && !P.composedPath().includes(E.current) && (m(!1), h(!1));
|
|
1130
1462
|
}, []);
|
|
1131
|
-
|
|
1132
|
-
if (
|
|
1133
|
-
const
|
|
1134
|
-
document.addEventListener("click",
|
|
1463
|
+
L(() => {
|
|
1464
|
+
if (n) {
|
|
1465
|
+
const P = setTimeout(() => {
|
|
1466
|
+
document.addEventListener("click", z);
|
|
1135
1467
|
}, 0);
|
|
1136
1468
|
return () => {
|
|
1137
|
-
clearTimeout(
|
|
1469
|
+
clearTimeout(P), document.removeEventListener("click", z);
|
|
1138
1470
|
};
|
|
1139
1471
|
}
|
|
1140
|
-
}, [
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1472
|
+
}, [n, z]);
|
|
1473
|
+
const T = S((P) => {
|
|
1474
|
+
y(P), x(P.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
|
|
1475
|
+
}, []), C = S(
|
|
1476
|
+
async (P) => {
|
|
1477
|
+
P.preventDefault(), N(null), $(!0);
|
|
1478
|
+
try {
|
|
1479
|
+
const I = await l(v, b);
|
|
1480
|
+
I && (await d(I.id), a == null || a(I), h(!1), y(""), x(""), m(!1));
|
|
1481
|
+
} catch (I) {
|
|
1482
|
+
N(I instanceof Error ? I.message : "Failed to create organization");
|
|
1483
|
+
} finally {
|
|
1484
|
+
$(!1);
|
|
1485
|
+
}
|
|
1486
|
+
},
|
|
1487
|
+
[v, b, l, d, a]
|
|
1488
|
+
);
|
|
1489
|
+
if (u) return null;
|
|
1490
|
+
const q = (t == null ? void 0 : t.name) ?? (c.length === 0 ? "No organization" : "Select organization");
|
|
1491
|
+
return /* @__PURE__ */ e(B, { appearance: o, children: /* @__PURE__ */ i("div", { className: "ss-user-btn", ref: E, children: [
|
|
1492
|
+
/* @__PURE__ */ i(
|
|
1144
1493
|
"button",
|
|
1145
1494
|
{
|
|
1146
1495
|
type: "button",
|
|
1147
1496
|
className: "ss-btn ss-btn-org-switcher",
|
|
1148
|
-
onClick: () =>
|
|
1497
|
+
onClick: () => m(!n),
|
|
1149
1498
|
children: [
|
|
1150
|
-
|
|
1151
|
-
/* @__PURE__ */ e("span", { className: "ss-chevron", children:
|
|
1499
|
+
q,
|
|
1500
|
+
/* @__PURE__ */ e("span", { className: "ss-chevron", children: n ? "▲" : "▼" })
|
|
1152
1501
|
]
|
|
1153
1502
|
}
|
|
1154
1503
|
),
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1504
|
+
n && /* @__PURE__ */ i("div", { className: "ss-dropdown ss-dropdown-org", children: [
|
|
1505
|
+
c.map((P) => /* @__PURE__ */ e(
|
|
1506
|
+
"button",
|
|
1507
|
+
{
|
|
1508
|
+
type: "button",
|
|
1509
|
+
className: `ss-dropdown-item ${(t == null ? void 0 : t.id) === P.id ? "ss-dropdown-item-active" : ""}`,
|
|
1510
|
+
onClick: async () => {
|
|
1511
|
+
m(!1), h(!1), await d(P.id), a == null || a(P);
|
|
1512
|
+
},
|
|
1513
|
+
children: P.name
|
|
1162
1514
|
},
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1515
|
+
P.id
|
|
1516
|
+
)),
|
|
1517
|
+
/* @__PURE__ */ e("div", { className: "ss-dropdown-divider" }),
|
|
1518
|
+
p ? /* @__PURE__ */ i("div", { className: "ss-inline-form", children: [
|
|
1519
|
+
f && /* @__PURE__ */ e("div", { className: "ss-global-error", style: { marginBottom: "8px", fontSize: "12px" }, children: f }),
|
|
1520
|
+
/* @__PURE__ */ i("form", { onSubmit: C, children: [
|
|
1521
|
+
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
1522
|
+
"input",
|
|
1523
|
+
{
|
|
1524
|
+
className: "ss-input",
|
|
1525
|
+
type: "text",
|
|
1526
|
+
placeholder: "Organization name",
|
|
1527
|
+
value: v,
|
|
1528
|
+
onChange: (P) => T(P.target.value),
|
|
1529
|
+
required: !0,
|
|
1530
|
+
autoFocus: !0
|
|
1531
|
+
}
|
|
1532
|
+
) }),
|
|
1533
|
+
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
1534
|
+
"input",
|
|
1535
|
+
{
|
|
1536
|
+
className: "ss-input",
|
|
1537
|
+
type: "text",
|
|
1538
|
+
placeholder: "org-slug",
|
|
1539
|
+
value: b,
|
|
1540
|
+
onChange: (P) => x(P.target.value),
|
|
1541
|
+
required: !0
|
|
1542
|
+
}
|
|
1543
|
+
) }),
|
|
1544
|
+
/* @__PURE__ */ i("div", { className: "ss-btn-group", style: { marginTop: "8px" }, children: [
|
|
1545
|
+
/* @__PURE__ */ e(
|
|
1546
|
+
"button",
|
|
1547
|
+
{
|
|
1548
|
+
type: "button",
|
|
1549
|
+
className: "ss-btn ss-btn-sm ss-btn-current",
|
|
1550
|
+
onClick: () => {
|
|
1551
|
+
h(!1), N(null);
|
|
1552
|
+
},
|
|
1553
|
+
children: "Cancel"
|
|
1554
|
+
}
|
|
1555
|
+
),
|
|
1556
|
+
/* @__PURE__ */ i(
|
|
1557
|
+
"button",
|
|
1558
|
+
{
|
|
1559
|
+
type: "submit",
|
|
1560
|
+
className: "ss-btn ss-btn-sm ss-btn-primary",
|
|
1561
|
+
disabled: w,
|
|
1562
|
+
children: [
|
|
1563
|
+
w && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1564
|
+
"Create"
|
|
1565
|
+
]
|
|
1566
|
+
}
|
|
1567
|
+
)
|
|
1568
|
+
] })
|
|
1569
|
+
] })
|
|
1570
|
+
] }) : /* @__PURE__ */ e(
|
|
1571
|
+
"button",
|
|
1572
|
+
{
|
|
1573
|
+
type: "button",
|
|
1574
|
+
className: "ss-dropdown-item",
|
|
1575
|
+
onClick: () => h(!0),
|
|
1576
|
+
style: { fontWeight: 500 },
|
|
1577
|
+
children: "+ Create organization"
|
|
1578
|
+
}
|
|
1579
|
+
)
|
|
1580
|
+
] })
|
|
1167
1581
|
] }) });
|
|
1168
1582
|
}
|
|
1169
|
-
function
|
|
1583
|
+
function is(s, a = "USD") {
|
|
1170
1584
|
return new Intl.NumberFormat("en-US", {
|
|
1171
1585
|
style: "currency",
|
|
1172
|
-
currency:
|
|
1586
|
+
currency: a,
|
|
1173
1587
|
minimumFractionDigits: s % 100 === 0 ? 0 : 2
|
|
1174
1588
|
}).format(s / 100);
|
|
1175
1589
|
}
|
|
1176
|
-
function
|
|
1177
|
-
const { appearance:
|
|
1178
|
-
return /* @__PURE__ */ e(
|
|
1179
|
-
const
|
|
1180
|
-
return /* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1590
|
+
function Us({ plans: s, currentPlanId: a, onSelectPlan: r, interval: c, appearance: t }) {
|
|
1591
|
+
const { appearance: d } = k(), l = t ?? d, u = c ? s.filter((o) => o.interval === c || o.isFree) : s;
|
|
1592
|
+
return /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ e("div", { className: "ss-pricing-grid", children: u.map((o) => {
|
|
1593
|
+
const n = o.id === a;
|
|
1594
|
+
return /* @__PURE__ */ i("div", { className: `ss-pricing-card ${n ? "ss-pricing-card-current" : ""}`, children: [
|
|
1595
|
+
/* @__PURE__ */ i("div", { className: "ss-pricing-header", children: [
|
|
1182
1596
|
/* @__PURE__ */ e("h3", { className: "ss-pricing-name", children: o.name }),
|
|
1183
|
-
o.trialDays > 0 && /* @__PURE__ */
|
|
1597
|
+
o.trialDays > 0 && /* @__PURE__ */ i("span", { className: "ss-badge ss-badge-trialing", children: [
|
|
1184
1598
|
o.trialDays,
|
|
1185
1599
|
"-day trial"
|
|
1186
1600
|
] }),
|
|
1187
1601
|
o.isFree && /* @__PURE__ */ e("span", { className: "ss-badge ss-badge-active", children: "Free" })
|
|
1188
1602
|
] }),
|
|
1189
|
-
/* @__PURE__ */ e("div", { className: "ss-pricing-price", children: o.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */ e("span", { className: "ss-pricing-amount", children:
|
|
1191
|
-
/* @__PURE__ */
|
|
1603
|
+
/* @__PURE__ */ e("div", { className: "ss-pricing-price", children: o.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */ i(D, { children: [
|
|
1604
|
+
/* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: is(o.amountCents, o.currency) }),
|
|
1605
|
+
/* @__PURE__ */ i("span", { className: "ss-pricing-interval", children: [
|
|
1192
1606
|
"/",
|
|
1193
1607
|
o.interval
|
|
1194
1608
|
] })
|
|
1195
1609
|
] }) }),
|
|
1196
1610
|
o.description && /* @__PURE__ */ e("p", { className: "ss-pricing-desc", children: o.description }),
|
|
1197
|
-
o.features.length > 0 && /* @__PURE__ */ e("ul", { className: "ss-pricing-features", children: o.features.map((
|
|
1611
|
+
o.features.length > 0 && /* @__PURE__ */ e("ul", { className: "ss-pricing-features", children: o.features.map((m, p) => /* @__PURE__ */ i("li", { className: "ss-pricing-feature", children: [
|
|
1198
1612
|
/* @__PURE__ */ e("span", { className: "ss-check", children: "✓" }),
|
|
1199
1613
|
" ",
|
|
1200
|
-
|
|
1614
|
+
m
|
|
1201
1615
|
] }, p)) }),
|
|
1202
1616
|
/* @__PURE__ */ e(
|
|
1203
1617
|
"button",
|
|
1204
1618
|
{
|
|
1205
1619
|
type: "button",
|
|
1206
|
-
className: `ss-btn ${
|
|
1207
|
-
disabled:
|
|
1620
|
+
className: `ss-btn ${n ? "ss-btn-current" : "ss-btn-primary"}`,
|
|
1621
|
+
disabled: n,
|
|
1208
1622
|
onClick: () => r(o.id),
|
|
1209
|
-
children:
|
|
1623
|
+
children: n ? "Current plan" : "Select plan"
|
|
1210
1624
|
}
|
|
1211
1625
|
)
|
|
1212
1626
|
] }, o.id);
|
|
1213
1627
|
}) }) });
|
|
1214
1628
|
}
|
|
1215
|
-
function
|
|
1216
|
-
const { client: s } =
|
|
1629
|
+
function Os() {
|
|
1630
|
+
const { client: s } = k();
|
|
1217
1631
|
return { billing: s.billing };
|
|
1218
1632
|
}
|
|
1219
|
-
function
|
|
1220
|
-
const { client:
|
|
1221
|
-
return
|
|
1633
|
+
function M(s) {
|
|
1634
|
+
const { client: a } = k();
|
|
1635
|
+
return A(() => {
|
|
1222
1636
|
if (s) {
|
|
1223
|
-
const r = new
|
|
1224
|
-
return new
|
|
1637
|
+
const r = new F("https://api.saas-support.com/v1", { type: "portalToken", token: s });
|
|
1638
|
+
return new ss(r);
|
|
1225
1639
|
}
|
|
1226
|
-
return
|
|
1227
|
-
}, [
|
|
1640
|
+
return a.billing;
|
|
1641
|
+
}, [a, s]);
|
|
1228
1642
|
}
|
|
1229
|
-
function
|
|
1230
|
-
const r =
|
|
1643
|
+
function cs(s, a) {
|
|
1644
|
+
const r = M(a), [c, t] = g(null), [d, l] = g(!0), [u, o] = g(null), n = S(async () => {
|
|
1231
1645
|
l(!0), o(null);
|
|
1232
1646
|
try {
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
} catch (
|
|
1236
|
-
o(
|
|
1647
|
+
const m = await r.getCustomer(s);
|
|
1648
|
+
t(m);
|
|
1649
|
+
} catch (m) {
|
|
1650
|
+
o(m instanceof Error ? m.message : "Failed to load subscription");
|
|
1237
1651
|
} finally {
|
|
1238
1652
|
l(!1);
|
|
1239
1653
|
}
|
|
1240
1654
|
}, [r, s]);
|
|
1241
|
-
return
|
|
1242
|
-
|
|
1243
|
-
}, [
|
|
1655
|
+
return L(() => {
|
|
1656
|
+
n();
|
|
1657
|
+
}, [n]), { customer: c, isLoading: d, error: u, refresh: n };
|
|
1244
1658
|
}
|
|
1245
|
-
function
|
|
1246
|
-
const r =
|
|
1659
|
+
function ds(s, a) {
|
|
1660
|
+
const r = M(a), [c, t] = g([]), [d, l] = g(!0), [u, o] = g(null), n = S(async () => {
|
|
1247
1661
|
l(!0), o(null);
|
|
1248
1662
|
try {
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
} catch (
|
|
1252
|
-
o(
|
|
1663
|
+
const m = await r.getInvoices(s);
|
|
1664
|
+
t(m);
|
|
1665
|
+
} catch (m) {
|
|
1666
|
+
o(m instanceof Error ? m.message : "Failed to load invoices");
|
|
1253
1667
|
} finally {
|
|
1254
1668
|
l(!1);
|
|
1255
1669
|
}
|
|
1256
1670
|
}, [r, s]);
|
|
1257
|
-
return
|
|
1258
|
-
|
|
1259
|
-
}, [
|
|
1671
|
+
return L(() => {
|
|
1672
|
+
n();
|
|
1673
|
+
}, [n]), { invoices: c, isLoading: d, error: u, refresh: n };
|
|
1260
1674
|
}
|
|
1261
|
-
function
|
|
1262
|
-
const r =
|
|
1675
|
+
function us(s, a) {
|
|
1676
|
+
const r = M(a), [c, t] = g([]), [d, l] = g(!0), [u, o] = g(null), n = S(async () => {
|
|
1263
1677
|
l(!0), o(null);
|
|
1264
1678
|
try {
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
} catch (
|
|
1268
|
-
o(
|
|
1679
|
+
const m = await r.getCurrentUsage(s);
|
|
1680
|
+
t(m);
|
|
1681
|
+
} catch (m) {
|
|
1682
|
+
o(m instanceof Error ? m.message : "Failed to load usage");
|
|
1269
1683
|
} finally {
|
|
1270
1684
|
l(!1);
|
|
1271
1685
|
}
|
|
1272
1686
|
}, [r, s]);
|
|
1273
|
-
return
|
|
1274
|
-
|
|
1275
|
-
}, [
|
|
1687
|
+
return L(() => {
|
|
1688
|
+
n();
|
|
1689
|
+
}, [n]), { usage: c, isLoading: d, error: u, refresh: n };
|
|
1276
1690
|
}
|
|
1277
|
-
const
|
|
1691
|
+
const ps = {
|
|
1278
1692
|
active: "ss-badge-active"
|
|
1279
1693
|
};
|
|
1280
|
-
function
|
|
1694
|
+
function ms({
|
|
1281
1695
|
customerId: s,
|
|
1282
|
-
portalToken:
|
|
1696
|
+
portalToken: a,
|
|
1283
1697
|
onChangePlan: r,
|
|
1284
1698
|
onCancel: c,
|
|
1285
|
-
appearance:
|
|
1699
|
+
appearance: t
|
|
1286
1700
|
}) {
|
|
1287
|
-
const { appearance:
|
|
1288
|
-
return /* @__PURE__ */ e(
|
|
1701
|
+
const { appearance: d } = k(), { customer: l, isLoading: u, error: o } = cs(s, a);
|
|
1702
|
+
return /* @__PURE__ */ e(B, { appearance: t ?? d, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
|
|
1289
1703
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Subscription" }),
|
|
1290
|
-
|
|
1704
|
+
u && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
|
|
1291
1705
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1292
1706
|
" Loading..."
|
|
1293
1707
|
] }),
|
|
1294
1708
|
o && /* @__PURE__ */ e("div", { className: "ss-global-error", children: o }),
|
|
1295
|
-
l && !
|
|
1296
|
-
/* @__PURE__ */
|
|
1709
|
+
l && !u && /* @__PURE__ */ i(D, { children: [
|
|
1710
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1297
1711
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Customer" }),
|
|
1298
1712
|
/* @__PURE__ */ e("input", { className: "ss-input", value: l.name || l.email, disabled: !0, readOnly: !0 })
|
|
1299
1713
|
] }),
|
|
1300
|
-
/* @__PURE__ */
|
|
1714
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1301
1715
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Status" }),
|
|
1302
|
-
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("span", { className: `ss-badge ${
|
|
1716
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("span", { className: `ss-badge ${ps.active}`, children: "Active" }) })
|
|
1303
1717
|
] }),
|
|
1304
|
-
/* @__PURE__ */
|
|
1718
|
+
/* @__PURE__ */ i("div", { className: "ss-btn-group", children: [
|
|
1305
1719
|
r && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-primary", onClick: r, children: "Change plan" }),
|
|
1306
1720
|
c && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: c, children: "Cancel subscription" })
|
|
1307
1721
|
] })
|
|
1308
1722
|
] })
|
|
1309
1723
|
] }) });
|
|
1310
1724
|
}
|
|
1311
|
-
const
|
|
1725
|
+
const gs = {
|
|
1312
1726
|
paid: "ss-badge-active",
|
|
1313
1727
|
open: "ss-badge-trialing",
|
|
1314
1728
|
draft: "ss-badge-paused",
|
|
1315
1729
|
void: "ss-badge-canceled",
|
|
1316
1730
|
uncollectible: "ss-badge-past-due"
|
|
1317
1731
|
};
|
|
1318
|
-
function
|
|
1732
|
+
function hs(s) {
|
|
1319
1733
|
return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
1320
1734
|
}
|
|
1321
|
-
function
|
|
1735
|
+
function bs(s) {
|
|
1322
1736
|
return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 2 }).format(s / 100);
|
|
1323
1737
|
}
|
|
1324
|
-
function
|
|
1325
|
-
const { appearance: c } =
|
|
1326
|
-
return /* @__PURE__ */ e(
|
|
1738
|
+
function fs({ customerId: s, portalToken: a, appearance: r }) {
|
|
1739
|
+
const { appearance: c } = k(), { invoices: t, isLoading: d, error: l } = ds(s, a), u = r ?? c, o = [...t].sort((n, m) => new Date(m.createdAt).getTime() - new Date(n.createdAt).getTime());
|
|
1740
|
+
return /* @__PURE__ */ e(B, { appearance: u, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
|
|
1327
1741
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Invoices" }),
|
|
1328
|
-
|
|
1742
|
+
d && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
|
|
1329
1743
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1330
1744
|
" Loading..."
|
|
1331
1745
|
] }),
|
|
1332
1746
|
l && /* @__PURE__ */ e("div", { className: "ss-global-error", children: l }),
|
|
1333
|
-
!
|
|
1334
|
-
!
|
|
1335
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
1747
|
+
!d && o.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No invoices yet." }),
|
|
1748
|
+
!d && o.length > 0 && /* @__PURE__ */ i("table", { className: "ss-table", children: [
|
|
1749
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
|
|
1336
1750
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "Date" }),
|
|
1337
1751
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "Amount" }),
|
|
1338
1752
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "Status" }),
|
|
1339
1753
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "PDF" })
|
|
1340
1754
|
] }) }),
|
|
1341
|
-
/* @__PURE__ */ e("tbody", { children: o.map((
|
|
1342
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children:
|
|
1343
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children:
|
|
1344
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${
|
|
1345
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children:
|
|
1346
|
-
] },
|
|
1755
|
+
/* @__PURE__ */ e("tbody", { children: o.map((n) => /* @__PURE__ */ i("tr", { className: "ss-tr", children: [
|
|
1756
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: hs(n.createdAt) }),
|
|
1757
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: bs(n.amountCents) }),
|
|
1758
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${gs[n.status] || ""}`, children: n.status }) }),
|
|
1759
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: n.pdfUrl ? /* @__PURE__ */ e("a", { className: "ss-link", href: n.pdfUrl, target: "_blank", rel: "noopener noreferrer", children: "Download" }) : "—" })
|
|
1760
|
+
] }, n.id)) })
|
|
1347
1761
|
] })
|
|
1348
1762
|
] }) });
|
|
1349
1763
|
}
|
|
1350
|
-
function
|
|
1351
|
-
const { appearance:
|
|
1352
|
-
return /* @__PURE__ */ e(
|
|
1764
|
+
function ys({ customerId: s, limits: a, portalToken: r, appearance: c }) {
|
|
1765
|
+
const { appearance: t } = k(), { usage: d, isLoading: l, error: u } = us(s, r);
|
|
1766
|
+
return /* @__PURE__ */ e(B, { appearance: c ?? t, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
|
|
1353
1767
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Usage" }),
|
|
1354
|
-
l && /* @__PURE__ */
|
|
1768
|
+
l && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
|
|
1355
1769
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1356
1770
|
" Loading..."
|
|
1357
1771
|
] }),
|
|
1358
|
-
|
|
1359
|
-
!l &&
|
|
1360
|
-
!l &&
|
|
1361
|
-
const
|
|
1362
|
-
return /* @__PURE__ */
|
|
1363
|
-
/* @__PURE__ */
|
|
1364
|
-
/* @__PURE__ */ e("span", { className: "ss-usage-metric", children:
|
|
1365
|
-
/* @__PURE__ */
|
|
1366
|
-
|
|
1367
|
-
|
|
1772
|
+
u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
|
|
1773
|
+
!l && d.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No usage data." }),
|
|
1774
|
+
!l && d.map((n) => {
|
|
1775
|
+
const m = a == null ? void 0 : a[n.metric], p = m ? Math.min(100, n.total / m * 100) : null;
|
|
1776
|
+
return /* @__PURE__ */ i("div", { className: "ss-usage-item", children: [
|
|
1777
|
+
/* @__PURE__ */ i("div", { className: "ss-usage-header", children: [
|
|
1778
|
+
/* @__PURE__ */ e("span", { className: "ss-usage-metric", children: n.metric }),
|
|
1779
|
+
/* @__PURE__ */ i("span", { className: "ss-usage-value", children: [
|
|
1780
|
+
n.total.toLocaleString(),
|
|
1781
|
+
m ? ` / ${m.toLocaleString()}` : ""
|
|
1368
1782
|
] })
|
|
1369
1783
|
] }),
|
|
1370
1784
|
p !== null && /* @__PURE__ */ e("div", { className: "ss-progress-bar", children: /* @__PURE__ */ e(
|
|
@@ -1374,20 +1788,20 @@ function bs({ customerId: s, limits: n, portalToken: r, appearance: c }) {
|
|
|
1374
1788
|
style: { width: `${p}%` }
|
|
1375
1789
|
}
|
|
1376
1790
|
) })
|
|
1377
|
-
] },
|
|
1791
|
+
] }, n.metric);
|
|
1378
1792
|
})
|
|
1379
1793
|
] }) });
|
|
1380
1794
|
}
|
|
1381
|
-
function
|
|
1795
|
+
function Rs({
|
|
1382
1796
|
customerId: s,
|
|
1383
|
-
portalToken:
|
|
1797
|
+
portalToken: a,
|
|
1384
1798
|
limits: r,
|
|
1385
1799
|
onChangePlan: c,
|
|
1386
|
-
onCancel:
|
|
1387
|
-
appearance:
|
|
1800
|
+
onCancel: t,
|
|
1801
|
+
appearance: d
|
|
1388
1802
|
}) {
|
|
1389
|
-
const { appearance: l } =
|
|
1390
|
-
return /* @__PURE__ */ e(
|
|
1803
|
+
const { appearance: l } = k(), u = d ?? l, [o, n] = g("subscription");
|
|
1804
|
+
return /* @__PURE__ */ e(B, { appearance: u, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
|
|
1391
1805
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Billing" }),
|
|
1392
1806
|
/* @__PURE__ */ e("div", { className: "ss-tab-group", children: [
|
|
1393
1807
|
{ id: "subscription", label: "Subscription" },
|
|
@@ -1398,46 +1812,46 @@ function Fs({
|
|
|
1398
1812
|
{
|
|
1399
1813
|
type: "button",
|
|
1400
1814
|
className: `ss-tab ${o === p.id ? "ss-tab-active" : ""}`,
|
|
1401
|
-
onClick: () =>
|
|
1815
|
+
onClick: () => n(p.id),
|
|
1402
1816
|
children: p.label
|
|
1403
1817
|
},
|
|
1404
1818
|
p.id
|
|
1405
1819
|
)) }),
|
|
1406
|
-
/* @__PURE__ */
|
|
1820
|
+
/* @__PURE__ */ i("div", { className: "ss-tab-content", children: [
|
|
1407
1821
|
o === "subscription" && /* @__PURE__ */ e(
|
|
1408
|
-
|
|
1822
|
+
ms,
|
|
1409
1823
|
{
|
|
1410
1824
|
customerId: s,
|
|
1411
|
-
portalToken:
|
|
1825
|
+
portalToken: a,
|
|
1412
1826
|
onChangePlan: c,
|
|
1413
|
-
onCancel:
|
|
1827
|
+
onCancel: t
|
|
1414
1828
|
}
|
|
1415
1829
|
),
|
|
1416
|
-
o === "invoices" && /* @__PURE__ */ e(
|
|
1417
|
-
o === "usage" && /* @__PURE__ */ e(
|
|
1830
|
+
o === "invoices" && /* @__PURE__ */ e(fs, { customerId: s, portalToken: a }),
|
|
1831
|
+
o === "usage" && /* @__PURE__ */ e(ys, { customerId: s, portalToken: a, limits: r })
|
|
1418
1832
|
] })
|
|
1419
1833
|
] }) });
|
|
1420
1834
|
}
|
|
1421
|
-
function
|
|
1422
|
-
const { appearance:
|
|
1423
|
-
if (
|
|
1424
|
-
|
|
1835
|
+
function Ws({ customerId: s, portalToken: a, onApplied: r, appearance: c }) {
|
|
1836
|
+
const { appearance: t } = k(), d = M(a), l = c ?? t, [u, o] = g(""), [n, m] = g(!1), [p, h] = g(null), [v, y] = g(null), b = S(async (x) => {
|
|
1837
|
+
if (x.preventDefault(), !!u.trim()) {
|
|
1838
|
+
m(!0), h(null), y(null);
|
|
1425
1839
|
try {
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
} catch (
|
|
1429
|
-
h(
|
|
1840
|
+
const f = await d.applyCoupon(s, u.trim());
|
|
1841
|
+
y(`Coupon applied! ${f.discountType === "percent" ? `${f.amount}% off` : `$${(f.amount / 100).toFixed(2)} off`}`), o(""), r == null || r(f);
|
|
1842
|
+
} catch (f) {
|
|
1843
|
+
h(f instanceof Error ? f.message : "Invalid coupon code");
|
|
1430
1844
|
} finally {
|
|
1431
|
-
|
|
1845
|
+
m(!1);
|
|
1432
1846
|
}
|
|
1433
1847
|
}
|
|
1434
|
-
}, [
|
|
1435
|
-
return /* @__PURE__ */ e(
|
|
1848
|
+
}, [d, s, u, r]);
|
|
1849
|
+
return /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
|
|
1436
1850
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Apply coupon" }),
|
|
1437
1851
|
p && /* @__PURE__ */ e("div", { className: "ss-global-error", children: p }),
|
|
1438
|
-
|
|
1439
|
-
/* @__PURE__ */
|
|
1440
|
-
/* @__PURE__ */
|
|
1852
|
+
v && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: v }),
|
|
1853
|
+
/* @__PURE__ */ i("form", { onSubmit: b, children: [
|
|
1854
|
+
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1441
1855
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-coupon-code", children: "Coupon code" }),
|
|
1442
1856
|
/* @__PURE__ */ e(
|
|
1443
1857
|
"input",
|
|
@@ -1446,96 +1860,96 @@ function Ms({ customerId: s, portalToken: n, onApplied: r, appearance: c }) {
|
|
|
1446
1860
|
className: "ss-input",
|
|
1447
1861
|
type: "text",
|
|
1448
1862
|
placeholder: "Enter coupon code",
|
|
1449
|
-
value:
|
|
1450
|
-
onChange: (
|
|
1863
|
+
value: u,
|
|
1864
|
+
onChange: (x) => o(x.target.value),
|
|
1451
1865
|
required: !0
|
|
1452
1866
|
}
|
|
1453
1867
|
)
|
|
1454
1868
|
] }),
|
|
1455
|
-
/* @__PURE__ */
|
|
1456
|
-
|
|
1869
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: n || !u.trim(), children: [
|
|
1870
|
+
n && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1457
1871
|
"Apply"
|
|
1458
1872
|
] })
|
|
1459
1873
|
] })
|
|
1460
1874
|
] }) });
|
|
1461
1875
|
}
|
|
1462
|
-
function
|
|
1463
|
-
const { client: s } =
|
|
1876
|
+
function Hs() {
|
|
1877
|
+
const { client: s } = k();
|
|
1464
1878
|
return { report: s.report };
|
|
1465
1879
|
}
|
|
1466
|
-
function
|
|
1467
|
-
const { client: s } =
|
|
1468
|
-
|
|
1880
|
+
function V() {
|
|
1881
|
+
const { client: s } = k(), [a, r] = g(null), [c, t] = g(!1), [d, l] = g(null), u = S(async (o) => {
|
|
1882
|
+
t(!0), l(null);
|
|
1469
1883
|
try {
|
|
1470
|
-
const
|
|
1471
|
-
return r(
|
|
1472
|
-
} catch (
|
|
1473
|
-
return l(
|
|
1884
|
+
const n = await s.report.executeQuery(o);
|
|
1885
|
+
return r(n), n;
|
|
1886
|
+
} catch (n) {
|
|
1887
|
+
return l(n instanceof Error ? n.message : "Query failed"), null;
|
|
1474
1888
|
} finally {
|
|
1475
|
-
|
|
1889
|
+
t(!1);
|
|
1476
1890
|
}
|
|
1477
1891
|
}, [s]);
|
|
1478
|
-
return { result:
|
|
1892
|
+
return { result: a, execute: u, isLoading: c, error: d };
|
|
1479
1893
|
}
|
|
1480
|
-
function
|
|
1481
|
-
const { client:
|
|
1482
|
-
|
|
1894
|
+
function xs(s) {
|
|
1895
|
+
const { client: a } = k(), [r, c] = g(null), [t, d] = g(!0), [l, u] = g(null), o = S(async () => {
|
|
1896
|
+
d(!0), u(null);
|
|
1483
1897
|
try {
|
|
1484
|
-
const
|
|
1485
|
-
c(
|
|
1486
|
-
} catch (
|
|
1487
|
-
|
|
1898
|
+
const n = await a.report.listQueries(s);
|
|
1899
|
+
c(n);
|
|
1900
|
+
} catch (n) {
|
|
1901
|
+
u(n instanceof Error ? n.message : "Failed to load queries");
|
|
1488
1902
|
} finally {
|
|
1489
|
-
|
|
1903
|
+
d(!1);
|
|
1490
1904
|
}
|
|
1491
|
-
}, [
|
|
1492
|
-
return
|
|
1905
|
+
}, [a, s]);
|
|
1906
|
+
return L(() => {
|
|
1493
1907
|
o();
|
|
1494
|
-
}, [o]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading:
|
|
1908
|
+
}, [o]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: t, error: l, refresh: o };
|
|
1495
1909
|
}
|
|
1496
|
-
function
|
|
1497
|
-
const { client:
|
|
1498
|
-
|
|
1910
|
+
function js(s) {
|
|
1911
|
+
const { client: a } = k(), [r, c] = g(null), [t, d] = g(!0), [l, u] = g(null), o = S(async () => {
|
|
1912
|
+
d(!0), u(null);
|
|
1499
1913
|
try {
|
|
1500
|
-
const
|
|
1501
|
-
c(
|
|
1502
|
-
} catch (
|
|
1503
|
-
|
|
1914
|
+
const n = await a.report.getDashboard(s);
|
|
1915
|
+
c(n);
|
|
1916
|
+
} catch (n) {
|
|
1917
|
+
u(n instanceof Error ? n.message : "Failed to load dashboard");
|
|
1504
1918
|
} finally {
|
|
1505
|
-
|
|
1919
|
+
d(!1);
|
|
1506
1920
|
}
|
|
1507
|
-
}, [
|
|
1508
|
-
return
|
|
1921
|
+
}, [a, s]);
|
|
1922
|
+
return L(() => {
|
|
1509
1923
|
o();
|
|
1510
|
-
}, [o]), { dashboard: r, isLoading:
|
|
1924
|
+
}, [o]), { dashboard: r, isLoading: t, error: l, refresh: o };
|
|
1511
1925
|
}
|
|
1512
|
-
function
|
|
1513
|
-
const c =
|
|
1514
|
-
const p = new
|
|
1515
|
-
return new
|
|
1516
|
-
}, [s, r]), [
|
|
1517
|
-
|
|
1926
|
+
function _s(s, a, r = "https://api.saas-support.com/v1") {
|
|
1927
|
+
const c = A(() => {
|
|
1928
|
+
const p = new F(r, { type: "embedToken", token: s });
|
|
1929
|
+
return new W(p);
|
|
1930
|
+
}, [s, r]), [t, d] = g(null), [l, u] = g(!0), [o, n] = g(null), m = S(async () => {
|
|
1931
|
+
u(!0), n(null);
|
|
1518
1932
|
try {
|
|
1519
|
-
const p = await c.getDashboard(
|
|
1520
|
-
|
|
1933
|
+
const p = await c.getDashboard(a);
|
|
1934
|
+
d(p);
|
|
1521
1935
|
} catch (p) {
|
|
1522
|
-
|
|
1936
|
+
n(p instanceof Error ? p.message : "Failed to load dashboard");
|
|
1523
1937
|
} finally {
|
|
1524
|
-
|
|
1938
|
+
u(!1);
|
|
1525
1939
|
}
|
|
1526
|
-
}, [c,
|
|
1527
|
-
return
|
|
1528
|
-
|
|
1529
|
-
}, [
|
|
1940
|
+
}, [c, a]);
|
|
1941
|
+
return L(() => {
|
|
1942
|
+
m();
|
|
1943
|
+
}, [m]), { dashboard: t, reportClient: c, isLoading: l, error: o, refresh: m };
|
|
1530
1944
|
}
|
|
1531
|
-
function
|
|
1532
|
-
const { appearance:
|
|
1533
|
-
if (
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
}, [
|
|
1537
|
-
return /* @__PURE__ */ e(
|
|
1538
|
-
|
|
1945
|
+
function Gs({ onResult: s, mode: a = "both", placeholder: r, appearance: c }) {
|
|
1946
|
+
const { appearance: t } = k(), { execute: d, isLoading: l, error: u } = V(), o = c ?? t, [n, m] = g(""), [p, h] = g(a === "sql" ? "sql" : "nl"), v = S(async (y) => {
|
|
1947
|
+
if (y.preventDefault(), !n.trim()) return;
|
|
1948
|
+
const x = await d(p === "sql" ? { sql: n } : { naturalLanguage: n });
|
|
1949
|
+
x && (s == null || s(x));
|
|
1950
|
+
}, [n, p, d, s]);
|
|
1951
|
+
return /* @__PURE__ */ e(B, { appearance: o, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
|
|
1952
|
+
a === "both" && /* @__PURE__ */ i("div", { className: "ss-tab-group ss-tab-group-sm", children: [
|
|
1539
1953
|
/* @__PURE__ */ e(
|
|
1540
1954
|
"button",
|
|
1541
1955
|
{
|
|
@@ -1555,237 +1969,237 @@ function Hs({ onResult: s, mode: n = "both", placeholder: r, appearance: c }) {
|
|
|
1555
1969
|
}
|
|
1556
1970
|
)
|
|
1557
1971
|
] }),
|
|
1558
|
-
|
|
1559
|
-
/* @__PURE__ */
|
|
1972
|
+
u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
|
|
1973
|
+
/* @__PURE__ */ i("form", { onSubmit: v, children: [
|
|
1560
1974
|
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
1561
1975
|
"textarea",
|
|
1562
1976
|
{
|
|
1563
1977
|
className: "ss-input ss-query-textarea",
|
|
1564
1978
|
placeholder: r ?? (p === "sql" ? "SELECT ..." : "Ask a question about your data..."),
|
|
1565
|
-
value:
|
|
1566
|
-
onChange: (
|
|
1979
|
+
value: n,
|
|
1980
|
+
onChange: (y) => m(y.target.value),
|
|
1567
1981
|
rows: 3
|
|
1568
1982
|
}
|
|
1569
1983
|
) }),
|
|
1570
|
-
/* @__PURE__ */
|
|
1984
|
+
/* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l || !n.trim(), children: [
|
|
1571
1985
|
l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1572
1986
|
"Run query"
|
|
1573
1987
|
] })
|
|
1574
1988
|
] })
|
|
1575
1989
|
] }) });
|
|
1576
1990
|
}
|
|
1577
|
-
function
|
|
1578
|
-
const { appearance:
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
if (
|
|
1582
|
-
if (
|
|
1583
|
-
if (typeof
|
|
1584
|
-
return
|
|
1585
|
-
const w = String(
|
|
1586
|
-
return
|
|
1587
|
-
}) :
|
|
1588
|
-
r && (
|
|
1991
|
+
function vs({ columns: s, rows: a, sortable: r = !0, maxRows: c, appearance: t }) {
|
|
1992
|
+
const { appearance: d } = k(), l = t ?? d, [u, o] = g(null), [n, m] = g("asc"), p = A(() => u ? [...a].sort((b, x) => {
|
|
1993
|
+
const f = b[u], N = x[u];
|
|
1994
|
+
if (f == null && N == null) return 0;
|
|
1995
|
+
if (f == null) return 1;
|
|
1996
|
+
if (N == null) return -1;
|
|
1997
|
+
if (typeof f == "number" && typeof N == "number")
|
|
1998
|
+
return n === "asc" ? f - N : N - f;
|
|
1999
|
+
const w = String(f), $ = String(N);
|
|
2000
|
+
return n === "asc" ? w.localeCompare($) : $.localeCompare(w);
|
|
2001
|
+
}) : a, [a, u, n]), h = c ? p.slice(0, c) : p, v = (b) => {
|
|
2002
|
+
r && (u === b ? m((x) => x === "asc" ? "desc" : "asc") : (o(b), m("asc")));
|
|
1589
2003
|
};
|
|
1590
|
-
function
|
|
2004
|
+
function y(b) {
|
|
1591
2005
|
return b == null ? "" : typeof b == "object" ? JSON.stringify(b) : String(b);
|
|
1592
2006
|
}
|
|
1593
|
-
return /* @__PURE__ */ e(
|
|
1594
|
-
/* @__PURE__ */
|
|
1595
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: s.map((b) => /* @__PURE__ */
|
|
2007
|
+
return /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ i("div", { className: "ss-table-container", children: [
|
|
2008
|
+
/* @__PURE__ */ i("table", { className: "ss-table", children: [
|
|
2009
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: s.map((b) => /* @__PURE__ */ i(
|
|
1596
2010
|
"th",
|
|
1597
2011
|
{
|
|
1598
|
-
className: `ss-th ${r ? "ss-th-sortable" : ""} ${
|
|
1599
|
-
onClick: () =>
|
|
2012
|
+
className: `ss-th ${r ? "ss-th-sortable" : ""} ${u === b ? n === "asc" ? "ss-sorted-asc" : "ss-sorted-desc" : ""}`,
|
|
2013
|
+
onClick: () => v(b),
|
|
1600
2014
|
children: [
|
|
1601
2015
|
b,
|
|
1602
|
-
|
|
2016
|
+
u === b && /* @__PURE__ */ e("span", { className: "ss-sort-indicator", children: n === "asc" ? " ▲" : " ▼" })
|
|
1603
2017
|
]
|
|
1604
2018
|
},
|
|
1605
2019
|
b
|
|
1606
2020
|
)) }) }),
|
|
1607
|
-
/* @__PURE__ */ e("tbody", { children: h.map((b,
|
|
2021
|
+
/* @__PURE__ */ e("tbody", { children: h.map((b, x) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: s.map((f) => /* @__PURE__ */ e("td", { className: "ss-td", children: y(b[f]) }, f)) }, x)) })
|
|
1608
2022
|
] }),
|
|
1609
|
-
c &&
|
|
2023
|
+
c && a.length > c && /* @__PURE__ */ i("div", { className: "ss-table-footer", children: [
|
|
1610
2024
|
"Showing ",
|
|
1611
2025
|
c,
|
|
1612
2026
|
" of ",
|
|
1613
|
-
|
|
2027
|
+
a.length,
|
|
1614
2028
|
" rows"
|
|
1615
2029
|
] })
|
|
1616
2030
|
] }) });
|
|
1617
2031
|
}
|
|
1618
|
-
function
|
|
1619
|
-
const r = parseInt(
|
|
1620
|
-
for (let
|
|
1621
|
-
const
|
|
1622
|
-
c.push(`hsl(${
|
|
2032
|
+
function Ns(s, a = "#6366f1") {
|
|
2033
|
+
const r = parseInt(a.replace("#", "").slice(0, 2), 16), c = [];
|
|
2034
|
+
for (let t = 0; t < s; t++) {
|
|
2035
|
+
const d = (r + t * Math.floor(360 / Math.max(s, 1))) % 360;
|
|
2036
|
+
c.push(`hsl(${d}, 65%, 55%)`);
|
|
1623
2037
|
}
|
|
1624
2038
|
return c;
|
|
1625
2039
|
}
|
|
1626
|
-
function
|
|
1627
|
-
const
|
|
1628
|
-
return /* @__PURE__ */
|
|
2040
|
+
function ws({ labels: s, values: a, w: r, h: c, colors: t }) {
|
|
2041
|
+
const d = Math.max(...a, 1), l = 40, u = r - l * 2, o = c - l * 2, n = Math.max(1, u / s.length - 4);
|
|
2042
|
+
return /* @__PURE__ */ i("g", { children: [
|
|
1629
2043
|
/* @__PURE__ */ e("line", { x1: l, y1: c - l, x2: r - l, y2: c - l, stroke: "#ccc", strokeWidth: 1 }),
|
|
1630
|
-
|
|
1631
|
-
const h =
|
|
1632
|
-
return /* @__PURE__ */
|
|
1633
|
-
/* @__PURE__ */ e("rect", { x:
|
|
1634
|
-
/* @__PURE__ */ e("text", { x:
|
|
2044
|
+
a.map((m, p) => {
|
|
2045
|
+
const h = m / d * o, v = l + u / s.length * p + 2, y = c - l - h;
|
|
2046
|
+
return /* @__PURE__ */ i("g", { children: [
|
|
2047
|
+
/* @__PURE__ */ e("rect", { x: v, y, width: n, height: h, fill: t[p % t.length], rx: 2 }),
|
|
2048
|
+
/* @__PURE__ */ e("text", { x: v + n / 2, y: c - l + 14, textAnchor: "middle", fontSize: 10, fill: "#666", children: s[p].length > 8 ? s[p].slice(0, 8) + "..." : s[p] })
|
|
1635
2049
|
] }, p);
|
|
1636
2050
|
})
|
|
1637
2051
|
] });
|
|
1638
2052
|
}
|
|
1639
|
-
function
|
|
1640
|
-
const
|
|
1641
|
-
const
|
|
1642
|
-
return `${
|
|
2053
|
+
function Ss({ labels: s, values: a, w: r, h: c, colors: t }) {
|
|
2054
|
+
const d = Math.max(...a, 1), l = 40, u = r - l * 2, o = c - l * 2, n = s.length > 1 ? u / (s.length - 1) : 0, m = a.map((p, h) => {
|
|
2055
|
+
const v = l + n * h, y = c - l - p / d * o;
|
|
2056
|
+
return `${v},${y}`;
|
|
1643
2057
|
});
|
|
1644
|
-
return /* @__PURE__ */
|
|
2058
|
+
return /* @__PURE__ */ i("g", { children: [
|
|
1645
2059
|
[0.25, 0.5, 0.75, 1].map((p) => {
|
|
1646
2060
|
const h = c - l - p * o;
|
|
1647
2061
|
return /* @__PURE__ */ e("line", { x1: l, y1: h, x2: r - l, y2: h, stroke: "#eee", strokeWidth: 1 }, p);
|
|
1648
2062
|
}),
|
|
1649
|
-
/* @__PURE__ */ e("polyline", { points:
|
|
1650
|
-
|
|
1651
|
-
const
|
|
1652
|
-
return /* @__PURE__ */ e("circle", { cx:
|
|
2063
|
+
/* @__PURE__ */ e("polyline", { points: m.join(" "), fill: "none", stroke: t[0], strokeWidth: 2 }),
|
|
2064
|
+
a.map((p, h) => {
|
|
2065
|
+
const v = l + n * h, y = c - l - p / d * o;
|
|
2066
|
+
return /* @__PURE__ */ e("circle", { cx: v, cy: y, r: 4, fill: t[0] }, h);
|
|
1653
2067
|
})
|
|
1654
2068
|
] });
|
|
1655
2069
|
}
|
|
1656
|
-
function
|
|
1657
|
-
const
|
|
1658
|
-
let
|
|
1659
|
-
const p =
|
|
1660
|
-
const
|
|
1661
|
-
return
|
|
2070
|
+
function $s({ labels: s, values: a, w: r, h: c, colors: t }) {
|
|
2071
|
+
const d = a.reduce((h, v) => h + v, 0) || 1, l = r / 2, u = c / 2 - 20, o = Math.min(r, c) / 2 - 40, n = 2 * Math.PI * o;
|
|
2072
|
+
let m = 0;
|
|
2073
|
+
const p = a.map((h, v) => {
|
|
2074
|
+
const y = h / d, b = y * n, x = { dash: b, offset: m, color: t[v % t.length], label: s[v], pct: y };
|
|
2075
|
+
return m += b, x;
|
|
1662
2076
|
});
|
|
1663
|
-
return /* @__PURE__ */
|
|
1664
|
-
p.map((h,
|
|
2077
|
+
return /* @__PURE__ */ i("g", { children: [
|
|
2078
|
+
p.map((h, v) => /* @__PURE__ */ e(
|
|
1665
2079
|
"circle",
|
|
1666
2080
|
{
|
|
1667
2081
|
cx: l,
|
|
1668
|
-
cy:
|
|
2082
|
+
cy: u,
|
|
1669
2083
|
r: o,
|
|
1670
2084
|
fill: "none",
|
|
1671
2085
|
stroke: h.color,
|
|
1672
2086
|
strokeWidth: o * 0.6,
|
|
1673
|
-
strokeDasharray: `${h.dash} ${
|
|
2087
|
+
strokeDasharray: `${h.dash} ${n - h.dash}`,
|
|
1674
2088
|
strokeDashoffset: -h.offset,
|
|
1675
|
-
transform: `rotate(-90 ${l} ${
|
|
2089
|
+
transform: `rotate(-90 ${l} ${u})`
|
|
1676
2090
|
},
|
|
1677
|
-
|
|
2091
|
+
v
|
|
1678
2092
|
)),
|
|
1679
|
-
/* @__PURE__ */ e("g", { transform: `translate(${l - s.length * 30}, ${c - 20})`, children: p.slice(0, 6).map((h,
|
|
2093
|
+
/* @__PURE__ */ e("g", { transform: `translate(${l - s.length * 30}, ${c - 20})`, children: p.slice(0, 6).map((h, v) => /* @__PURE__ */ i("g", { transform: `translate(${v * 60}, 0)`, children: [
|
|
1680
2094
|
/* @__PURE__ */ e("rect", { width: 10, height: 10, fill: h.color, rx: 2 }),
|
|
1681
2095
|
/* @__PURE__ */ e("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children: h.label.length > 6 ? h.label.slice(0, 6) + ".." : h.label })
|
|
1682
|
-
] },
|
|
2096
|
+
] }, v)) })
|
|
1683
2097
|
] });
|
|
1684
2098
|
}
|
|
1685
|
-
function
|
|
1686
|
-
const { appearance: l } =
|
|
1687
|
-
return /* @__PURE__ */ e(
|
|
2099
|
+
function ks({ type: s, data: a, title: r, width: c = 400, height: t = 300, appearance: d }) {
|
|
2100
|
+
const { appearance: l } = k(), u = d ?? l, o = A(() => Ns(a.labels.length), [a.labels.length]);
|
|
2101
|
+
return /* @__PURE__ */ e(B, { appearance: u, children: /* @__PURE__ */ i("div", { className: "ss-chart-container", children: [
|
|
1688
2102
|
r && /* @__PURE__ */ e("h3", { className: "ss-chart-title", children: r }),
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
s === "bar" && /* @__PURE__ */ e(
|
|
1691
|
-
s === "line" && /* @__PURE__ */ e(
|
|
1692
|
-
s === "pie" && /* @__PURE__ */ e(
|
|
2103
|
+
/* @__PURE__ */ i("svg", { viewBox: `0 0 ${c} ${t}`, width: "100%", style: { maxWidth: c }, children: [
|
|
2104
|
+
s === "bar" && /* @__PURE__ */ e(ws, { labels: a.labels, values: a.values, w: c, h: t, colors: o }),
|
|
2105
|
+
s === "line" && /* @__PURE__ */ e(Ss, { labels: a.labels, values: a.values, w: c, h: t, colors: o }),
|
|
2106
|
+
s === "pie" && /* @__PURE__ */ e($s, { labels: a.labels, values: a.values, w: c, h: t, colors: o })
|
|
1693
2107
|
] })
|
|
1694
2108
|
] }) });
|
|
1695
2109
|
}
|
|
1696
|
-
function
|
|
1697
|
-
const
|
|
1698
|
-
if (
|
|
1699
|
-
const
|
|
1700
|
-
return new
|
|
1701
|
-
}
|
|
1702
|
-
return
|
|
1703
|
-
}, [
|
|
1704
|
-
|
|
2110
|
+
function Js({ dashboardId: s, embedToken: a, baseUrl: r, refreshInterval: c, appearance: t }) {
|
|
2111
|
+
const d = k(), l = t ?? (d == null ? void 0 : d.appearance), u = A(() => {
|
|
2112
|
+
if (a) {
|
|
2113
|
+
const f = r ?? "https://api.saas-support.com/v1", N = new F(f, { type: "embedToken", token: a });
|
|
2114
|
+
return new W(N);
|
|
2115
|
+
}
|
|
2116
|
+
return d.client.report;
|
|
2117
|
+
}, [a, r, d]), [o, n] = g([]), [m, p] = g({}), [h, v] = g(!0), [y, b] = g(null), x = S(async () => {
|
|
2118
|
+
v(!0), b(null);
|
|
1705
2119
|
try {
|
|
1706
|
-
const
|
|
1707
|
-
|
|
2120
|
+
const f = await u.getDashboard(s), N = JSON.parse(f.layoutJson || "[]");
|
|
2121
|
+
n(N);
|
|
1708
2122
|
const w = {};
|
|
1709
|
-
for (const
|
|
2123
|
+
for (const $ of N)
|
|
1710
2124
|
try {
|
|
1711
|
-
const
|
|
1712
|
-
if (
|
|
1713
|
-
const
|
|
1714
|
-
w[
|
|
2125
|
+
const E = await u.listQueries({ search: $.queryId, perPage: 1 });
|
|
2126
|
+
if (E.data.length > 0 && E.data[0].generatedSql) {
|
|
2127
|
+
const z = await u.executeQuery({ sql: E.data[0].generatedSql });
|
|
2128
|
+
w[$.queryId] = z;
|
|
1715
2129
|
}
|
|
1716
2130
|
} catch {
|
|
1717
2131
|
}
|
|
1718
2132
|
p(w);
|
|
1719
|
-
} catch (
|
|
1720
|
-
b(
|
|
2133
|
+
} catch (f) {
|
|
2134
|
+
b(f instanceof Error ? f.message : "Failed to load dashboard");
|
|
1721
2135
|
} finally {
|
|
1722
|
-
|
|
2136
|
+
v(!1);
|
|
1723
2137
|
}
|
|
1724
|
-
}, [
|
|
1725
|
-
return
|
|
1726
|
-
|
|
1727
|
-
}, [
|
|
2138
|
+
}, [u, s]);
|
|
2139
|
+
return L(() => {
|
|
2140
|
+
x();
|
|
2141
|
+
}, [x]), L(() => {
|
|
1728
2142
|
if (!c || c <= 0) return;
|
|
1729
|
-
const
|
|
1730
|
-
return () => clearInterval(
|
|
1731
|
-
}, [c,
|
|
1732
|
-
h && /* @__PURE__ */
|
|
2143
|
+
const f = setInterval(x, c * 1e3);
|
|
2144
|
+
return () => clearInterval(f);
|
|
2145
|
+
}, [c, x]), /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ i("div", { className: "ss-dashboard-grid", children: [
|
|
2146
|
+
h && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
|
|
1733
2147
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1734
2148
|
" Loading dashboard..."
|
|
1735
2149
|
] }),
|
|
1736
|
-
|
|
1737
|
-
!h && o.map((
|
|
1738
|
-
const w =
|
|
2150
|
+
y && /* @__PURE__ */ e("div", { className: "ss-global-error", children: y }),
|
|
2151
|
+
!h && o.map((f, N) => {
|
|
2152
|
+
const w = m[f.queryId];
|
|
1739
2153
|
if (!w) return null;
|
|
1740
|
-
const
|
|
1741
|
-
labels: w.rows.map((
|
|
1742
|
-
values: w.rows.map((
|
|
2154
|
+
const $ = w.columns.length >= 2 ? {
|
|
2155
|
+
labels: w.rows.map((E) => String(E[w.columns[0]] ?? "")),
|
|
2156
|
+
values: w.rows.map((E) => Number(E[w.columns[1]] ?? 0))
|
|
1743
2157
|
} : { labels: [], values: [] };
|
|
1744
|
-
return /* @__PURE__ */
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
2158
|
+
return /* @__PURE__ */ i("div", { className: "ss-widget", children: [
|
|
2159
|
+
f.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: f.title }),
|
|
2160
|
+
f.chartType === "table" ? /* @__PURE__ */ e(vs, { columns: w.columns, rows: w.rows, maxRows: 50 }) : /* @__PURE__ */ e(
|
|
2161
|
+
ks,
|
|
1748
2162
|
{
|
|
1749
|
-
type:
|
|
1750
|
-
data:
|
|
1751
|
-
width:
|
|
1752
|
-
height:
|
|
2163
|
+
type: f.chartType || "bar",
|
|
2164
|
+
data: $,
|
|
2165
|
+
width: f.w,
|
|
2166
|
+
height: f.h
|
|
1753
2167
|
}
|
|
1754
2168
|
)
|
|
1755
|
-
] },
|
|
2169
|
+
] }, N);
|
|
1756
2170
|
})
|
|
1757
2171
|
] }) });
|
|
1758
2172
|
}
|
|
1759
|
-
function
|
|
2173
|
+
function Cs(s) {
|
|
1760
2174
|
return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
1761
2175
|
}
|
|
1762
|
-
function
|
|
1763
|
-
const { appearance: c } =
|
|
2176
|
+
function Qs({ onSelectQuery: s, onRunQuery: a, appearance: r }) {
|
|
2177
|
+
const { appearance: c } = k(), { queries: t, isLoading: d, error: l } = xs(), { execute: u, isLoading: o } = V(), n = r ?? c, m = S(async (p) => {
|
|
1764
2178
|
if (!p.generatedSql) return;
|
|
1765
|
-
const h = await
|
|
1766
|
-
h && (
|
|
1767
|
-
}, [
|
|
1768
|
-
return /* @__PURE__ */ e(
|
|
2179
|
+
const h = await u({ sql: p.generatedSql });
|
|
2180
|
+
h && (a == null || a(h));
|
|
2181
|
+
}, [u, a]);
|
|
2182
|
+
return /* @__PURE__ */ e(B, { appearance: n, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
|
|
1769
2183
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Saved Queries" }),
|
|
1770
|
-
|
|
2184
|
+
d && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
|
|
1771
2185
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1772
2186
|
" Loading..."
|
|
1773
2187
|
] }),
|
|
1774
2188
|
l && /* @__PURE__ */ e("div", { className: "ss-global-error", children: l }),
|
|
1775
|
-
!
|
|
1776
|
-
!
|
|
2189
|
+
!d && t.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No saved queries." }),
|
|
2190
|
+
!d && t.map((p) => /* @__PURE__ */ i(
|
|
1777
2191
|
"div",
|
|
1778
2192
|
{
|
|
1779
2193
|
className: "ss-saved-query-card",
|
|
1780
2194
|
onClick: () => s == null ? void 0 : s(p),
|
|
1781
2195
|
children: [
|
|
1782
|
-
/* @__PURE__ */
|
|
2196
|
+
/* @__PURE__ */ i("div", { className: "ss-saved-query-header", children: [
|
|
1783
2197
|
/* @__PURE__ */ e("span", { className: "ss-saved-query-name", children: p.name }),
|
|
1784
2198
|
p.chartType && /* @__PURE__ */ e("span", { className: "ss-badge", children: p.chartType })
|
|
1785
2199
|
] }),
|
|
1786
2200
|
p.naturalLanguage && /* @__PURE__ */ e("p", { className: "ss-saved-query-desc", children: p.naturalLanguage }),
|
|
1787
|
-
/* @__PURE__ */
|
|
1788
|
-
/* @__PURE__ */ e("span", { className: "ss-saved-query-date", children:
|
|
2201
|
+
/* @__PURE__ */ i("div", { className: "ss-saved-query-footer", children: [
|
|
2202
|
+
/* @__PURE__ */ e("span", { className: "ss-saved-query-date", children: Cs(p.createdAt) }),
|
|
1789
2203
|
/* @__PURE__ */ e(
|
|
1790
2204
|
"button",
|
|
1791
2205
|
{
|
|
@@ -1793,7 +2207,7 @@ function _s({ onSelectQuery: s, onRunQuery: n, appearance: r }) {
|
|
|
1793
2207
|
className: "ss-btn ss-btn-sm ss-btn-primary",
|
|
1794
2208
|
disabled: o || !p.generatedSql,
|
|
1795
2209
|
onClick: (h) => {
|
|
1796
|
-
h.stopPropagation(),
|
|
2210
|
+
h.stopPropagation(), m(p);
|
|
1797
2211
|
},
|
|
1798
2212
|
children: o ? /* @__PURE__ */ e("span", { className: "ss-spinner" }) : "Run"
|
|
1799
2213
|
}
|
|
@@ -1805,104 +2219,105 @@ function _s({ onSelectQuery: s, onRunQuery: n, appearance: r }) {
|
|
|
1805
2219
|
))
|
|
1806
2220
|
] }) });
|
|
1807
2221
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const
|
|
1810
|
-
const b = new
|
|
1811
|
-
return new
|
|
1812
|
-
}, [s, r]), [l,
|
|
1813
|
-
|
|
2222
|
+
function Vs({ embedToken: s, dashboardId: a, baseUrl: r = "https://api.saas-support.com/v1", refreshInterval: c, appearance: t }) {
|
|
2223
|
+
const d = A(() => {
|
|
2224
|
+
const b = new F(r, { type: "embedToken", token: s });
|
|
2225
|
+
return new W(b);
|
|
2226
|
+
}, [s, r]), [l, u] = g([]), [o, n] = g(!0), [m, p] = g(null), h = A(() => U(t), [t]), v = A(() => O(h), [h]), y = S(async () => {
|
|
2227
|
+
n(!0), p(null);
|
|
1814
2228
|
try {
|
|
1815
|
-
const b = await
|
|
1816
|
-
|
|
2229
|
+
const b = await d.getDashboard(a), x = JSON.parse(b.layoutJson || "[]"), f = await Promise.all(
|
|
2230
|
+
x.map(async (N) => {
|
|
1817
2231
|
try {
|
|
1818
|
-
const w = await
|
|
2232
|
+
const w = await d.listQueries({ search: N.queryId, perPage: 1 });
|
|
1819
2233
|
if (w.data.length > 0 && w.data[0].generatedSql) {
|
|
1820
|
-
const
|
|
1821
|
-
return { ...
|
|
2234
|
+
const $ = await d.executeQuery({ sql: w.data[0].generatedSql });
|
|
2235
|
+
return { ...N, result: $ };
|
|
1822
2236
|
}
|
|
1823
2237
|
} catch {
|
|
1824
2238
|
}
|
|
1825
|
-
return
|
|
2239
|
+
return N;
|
|
1826
2240
|
})
|
|
1827
2241
|
);
|
|
1828
|
-
|
|
2242
|
+
u(f);
|
|
1829
2243
|
} catch (b) {
|
|
1830
2244
|
p(b instanceof Error ? b.message : "Failed to load dashboard");
|
|
1831
2245
|
} finally {
|
|
1832
|
-
|
|
2246
|
+
n(!1);
|
|
1833
2247
|
}
|
|
1834
|
-
}, [
|
|
1835
|
-
return
|
|
1836
|
-
|
|
1837
|
-
}, [
|
|
2248
|
+
}, [d, a]);
|
|
2249
|
+
return L(() => {
|
|
2250
|
+
y();
|
|
2251
|
+
}, [y]), L(() => {
|
|
1838
2252
|
if (!c || c <= 0) return;
|
|
1839
|
-
const b = setInterval(
|
|
2253
|
+
const b = setInterval(y, c * 1e3);
|
|
1840
2254
|
return () => clearInterval(b);
|
|
1841
|
-
}, [c,
|
|
2255
|
+
}, [c, y]), /* @__PURE__ */ e(
|
|
1842
2256
|
"div",
|
|
1843
2257
|
{
|
|
1844
2258
|
ref: (b) => {
|
|
1845
2259
|
if (!b || b.shadowRoot) return;
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
const
|
|
1849
|
-
|
|
2260
|
+
const x = b.attachShadow({ mode: "open" }), f = document.createElement("style");
|
|
2261
|
+
f.textContent = v, x.appendChild(f);
|
|
2262
|
+
const N = document.createElement("div");
|
|
2263
|
+
x.appendChild(N);
|
|
1850
2264
|
},
|
|
1851
2265
|
style: { display: "contents" },
|
|
1852
|
-
children: /* @__PURE__ */
|
|
2266
|
+
children: /* @__PURE__ */ i("div", { className: "ss-dashboard-grid", children: [
|
|
1853
2267
|
o && /* @__PURE__ */ e("div", { className: "ss-loading", children: "Loading dashboard..." }),
|
|
1854
|
-
|
|
1855
|
-
!o && l.map((b,
|
|
2268
|
+
m && /* @__PURE__ */ e("div", { className: "ss-global-error", children: m }),
|
|
2269
|
+
!o && l.map((b, x) => {
|
|
1856
2270
|
if (!b.result) return null;
|
|
1857
|
-
const { columns:
|
|
1858
|
-
return /* @__PURE__ */
|
|
2271
|
+
const { columns: f, rows: N } = b.result;
|
|
2272
|
+
return /* @__PURE__ */ i("div", { className: "ss-widget", children: [
|
|
1859
2273
|
b.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: b.title }),
|
|
1860
|
-
/* @__PURE__ */
|
|
1861
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children:
|
|
1862
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
2274
|
+
/* @__PURE__ */ i("table", { className: "ss-table", children: [
|
|
2275
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: f.map((w) => /* @__PURE__ */ e("th", { className: "ss-th", children: w }, w)) }) }),
|
|
2276
|
+
/* @__PURE__ */ e("tbody", { children: N.slice(0, 50).map((w, $) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: f.map((E) => /* @__PURE__ */ e("td", { className: "ss-td", children: String(w[E] ?? "") }, E)) }, $)) })
|
|
1863
2277
|
] })
|
|
1864
|
-
] },
|
|
2278
|
+
] }, x);
|
|
1865
2279
|
})
|
|
1866
2280
|
] })
|
|
1867
2281
|
}
|
|
1868
2282
|
);
|
|
1869
2283
|
}
|
|
1870
2284
|
export {
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
2285
|
+
ks as Chart,
|
|
2286
|
+
Ws as CouponInput,
|
|
2287
|
+
Js as DashboardView,
|
|
2288
|
+
vs as DataTable,
|
|
2289
|
+
fs as InvoiceHistory,
|
|
2290
|
+
Ms as OrgSwitcher,
|
|
2291
|
+
Rs as PaymentPortal,
|
|
2292
|
+
Us as PricingTable,
|
|
2293
|
+
Gs as QueryInput,
|
|
2294
|
+
Vs as ReportEmbed,
|
|
1881
2295
|
H as SaaSContext,
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
2296
|
+
Xs as SaaSError,
|
|
2297
|
+
Bs as SaaSProvider,
|
|
2298
|
+
X as SaaSSupport,
|
|
2299
|
+
Qs as SavedQueryList,
|
|
2300
|
+
qs as SignIn,
|
|
2301
|
+
As as SignUp,
|
|
2302
|
+
ms as SubscriptionStatus,
|
|
2303
|
+
ys as UsageDisplay,
|
|
2304
|
+
Ds as UserButton,
|
|
2305
|
+
Fs as UserProfile,
|
|
2306
|
+
Z as isMfaRequired,
|
|
2307
|
+
j as useAuth,
|
|
2308
|
+
Os as useBilling,
|
|
2309
|
+
js as useDashboard,
|
|
2310
|
+
_s as useEmbedDashboard,
|
|
2311
|
+
ds as useInvoices,
|
|
2312
|
+
os as useOrg,
|
|
2313
|
+
G as useProfile,
|
|
2314
|
+
V as useQuery,
|
|
2315
|
+
Hs as useReport,
|
|
2316
|
+
k as useSaaSContext,
|
|
2317
|
+
xs as useSavedQueries,
|
|
1903
2318
|
_ as useSignIn,
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2319
|
+
ts as useSignUp,
|
|
2320
|
+
cs as useSubscription,
|
|
2321
|
+
us as useUsage,
|
|
2322
|
+
zs as useUser
|
|
1908
2323
|
};
|