@neetru/sdk 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/dist/ai.cjs +254 -391
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +254 -391
- package/dist/auth.cjs +3547 -4998
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +3544 -4995
- package/dist/build-guard.cjs +101 -119
- package/dist/build-guard.mjs +91 -109
- package/dist/catalog.cjs +152 -224
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +152 -224
- package/dist/checkout.cjs +237 -320
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +236 -319
- package/dist/db-react.cjs +59 -87
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db-react.mjs +56 -84
- package/dist/db.cjs +2055 -3013
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +2068 -3026
- package/dist/entitlements.cjs +12 -20
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +12 -20
- package/dist/errors.cjs +9 -12
- package/dist/errors.d.cts +37 -2
- package/dist/errors.d.ts +37 -2
- package/dist/errors.mjs +8 -12
- package/dist/firestore-compat.cjs +241 -297
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/firestore-compat.mjs +215 -271
- package/dist/index.cjs +3605 -5131
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +3710 -5236
- package/dist/mobile.cjs +238 -342
- package/dist/mobile.d.cts +1 -1
- package/dist/mobile.d.ts +1 -1
- package/dist/mobile.mjs +238 -342
- package/dist/mocks.cjs +312 -447
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.mjs +306 -441
- package/dist/notifications.cjs +226 -314
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +225 -313
- package/dist/react.cjs +522 -693
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +512 -683
- package/dist/support.cjs +329 -325
- package/dist/support.d.cts +25 -3
- package/dist/support.d.ts +25 -3
- package/dist/support.mjs +328 -325
- package/dist/telemetry.cjs +197 -301
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +197 -301
- package/dist/{types-Du_iioJ7.d.cts → types-Bx4kTLmk.d.cts} +26 -0
- package/dist/{types-BPATkXYu.d.ts → types-Dx0IrOSF.d.ts} +26 -0
- package/dist/usage.cjs +163 -227
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +163 -227
- package/dist/webhooks.cjs +258 -359
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +255 -356
- package/package.json +4 -3
- package/dist/ai.cjs.map +0 -1
- package/dist/ai.mjs.map +0 -1
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.mjs.map +0 -1
- package/dist/build-guard.cjs.map +0 -1
- package/dist/build-guard.mjs.map +0 -1
- package/dist/catalog.cjs.map +0 -1
- package/dist/catalog.mjs.map +0 -1
- package/dist/checkout.cjs.map +0 -1
- package/dist/checkout.mjs.map +0 -1
- package/dist/db-react.cjs.map +0 -1
- package/dist/db-react.mjs.map +0 -1
- package/dist/db.cjs.map +0 -1
- package/dist/db.mjs.map +0 -1
- package/dist/entitlements.cjs.map +0 -1
- package/dist/entitlements.mjs.map +0 -1
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.mjs.map +0 -1
- package/dist/firestore-compat.cjs.map +0 -1
- package/dist/firestore-compat.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/mobile.cjs.map +0 -1
- package/dist/mobile.mjs.map +0 -1
- package/dist/mocks.cjs.map +0 -1
- package/dist/mocks.mjs.map +0 -1
- package/dist/notifications.cjs.map +0 -1
- package/dist/notifications.mjs.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.mjs.map +0 -1
- package/dist/support.cjs.map +0 -1
- package/dist/support.mjs.map +0 -1
- package/dist/telemetry.cjs.map +0 -1
- package/dist/telemetry.mjs.map +0 -1
- package/dist/usage.cjs.map +0 -1
- package/dist/usage.mjs.map +0 -1
- package/dist/webhooks.cjs.map +0 -1
- package/dist/webhooks.mjs.map +0 -1
package/dist/react.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as l from 'react';
|
|
2
2
|
|
|
3
3
|
// src/react.ts
|
|
4
4
|
|
|
5
5
|
// src/errors.ts
|
|
6
|
-
var
|
|
6
|
+
var E = class e extends Error {
|
|
7
7
|
code;
|
|
8
8
|
status;
|
|
9
9
|
requestId;
|
|
@@ -16,23 +16,16 @@ var NeetruError = class _NeetruError extends Error {
|
|
|
16
16
|
* para um `NeetruDbErrorCode` mais específico (recuperável vs não).
|
|
17
17
|
*/
|
|
18
18
|
reason;
|
|
19
|
-
constructor(
|
|
20
|
-
super(
|
|
21
|
-
this.name = "NeetruError";
|
|
22
|
-
this.code = code;
|
|
23
|
-
this.status = status;
|
|
24
|
-
this.requestId = requestId;
|
|
25
|
-
this.reason = reason;
|
|
26
|
-
Object.setPrototypeOf(this, _NeetruError.prototype);
|
|
19
|
+
constructor(t, i, n, s, c) {
|
|
20
|
+
super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = s, this.reason = c, Object.setPrototypeOf(this, e.prototype);
|
|
27
21
|
}
|
|
28
22
|
};
|
|
29
23
|
|
|
30
24
|
// src/types.ts
|
|
31
|
-
var
|
|
25
|
+
var O = "https://api.neetru.com";
|
|
32
26
|
|
|
33
27
|
// src/account-bar.ts
|
|
34
|
-
var h =
|
|
35
|
-
var DEFAULT_LABELS = {
|
|
28
|
+
var h = l.createElement, Z = {
|
|
36
29
|
accountButton: "Abrir menu da conta",
|
|
37
30
|
appsButton: "Seus produtos Neetru",
|
|
38
31
|
appsTitle: "Trocar de produto",
|
|
@@ -42,186 +35,136 @@ var DEFAULT_LABELS = {
|
|
|
42
35
|
currentBadge: "Atual",
|
|
43
36
|
emptyProducts: "Nenhum outro produto dispon\xEDvel."
|
|
44
37
|
};
|
|
45
|
-
async function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const config = client.config;
|
|
50
|
-
const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
51
|
-
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
52
|
-
const url = `${baseUrl}/api/sdk/v1/account/bar`;
|
|
38
|
+
async function Q(e) {
|
|
39
|
+
let t = e.auth, i = typeof t?.getIdToken == "function" ? t.getIdToken() : null;
|
|
40
|
+
if (!i) return null;
|
|
41
|
+
let n = e.config, s = (n.baseUrl ?? O).replace(/\/+$/, ""), c = n.fetch ?? globalThis.fetch, r = `${s}/api/sdk/v1/account/bar`;
|
|
53
42
|
try {
|
|
54
|
-
|
|
55
|
-
headers: { authorization: `Bearer ${
|
|
43
|
+
let o = await c(r, {
|
|
44
|
+
headers: { authorization: `Bearer ${i}`, accept: "application/json" }
|
|
56
45
|
});
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
46
|
+
if (!o.ok) return null;
|
|
47
|
+
let f = await o.json();
|
|
48
|
+
return !f || typeof f != "object" || !f.account ? null : {
|
|
61
49
|
account: {
|
|
62
|
-
displayName: String(
|
|
63
|
-
email: String(
|
|
64
|
-
photoUrl:
|
|
50
|
+
displayName: String(f.account.displayName ?? ""),
|
|
51
|
+
email: String(f.account.email ?? ""),
|
|
52
|
+
photoUrl: f.account.photoUrl ?? null
|
|
65
53
|
},
|
|
66
|
-
accountUrl: String(
|
|
67
|
-
products: Array.isArray(
|
|
68
|
-
(
|
|
54
|
+
accountUrl: String(f.accountUrl ?? "https://minhaconta.neetru.com"),
|
|
55
|
+
products: Array.isArray(f.products) ? f.products.filter(
|
|
56
|
+
(u) => !!u && typeof u.slug == "string" && typeof u.url == "string"
|
|
69
57
|
) : []
|
|
70
58
|
};
|
|
71
59
|
} catch {
|
|
72
60
|
return null;
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
if (!
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (parts.length === 0) return local.slice(0, 1).toUpperCase();
|
|
81
|
-
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
82
|
-
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
63
|
+
function N(e) {
|
|
64
|
+
let t = (e ?? "").trim();
|
|
65
|
+
if (!t) return "?";
|
|
66
|
+
let i = t.includes("@") ? t.split("@")[0] : t, n = i.split(/[\s._-]+/).filter(Boolean);
|
|
67
|
+
return n.length === 0 ? i.slice(0, 1).toUpperCase() : n.length === 1 ? n[0].slice(0, 2).toUpperCase() : (n[0][0] + n[n.length - 1][0]).toUpperCase();
|
|
83
68
|
}
|
|
84
|
-
var
|
|
69
|
+
var b = {
|
|
85
70
|
bg: "#ffffff",
|
|
86
71
|
bgHover: "#f5f5f5",
|
|
87
72
|
fg: "#0a0a0a",
|
|
88
73
|
muted: "#666666",
|
|
89
74
|
border: "#0a0a0a",
|
|
90
75
|
borderSoft: "#e5e5e5"
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const dots = [0, 1, 2].flatMap((r) => [0, 1, 2].map((c) => ({ r, c })));
|
|
95
|
-
const gap = size / 3;
|
|
96
|
-
const dot = Math.max(2, size / 7);
|
|
76
|
+
}, M = 0;
|
|
77
|
+
function ee({ size: e = 18, color: t = b.fg }) {
|
|
78
|
+
let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((r) => ({ r: c, c: r }))), n = e / 3, s = Math.max(2, e / 7);
|
|
97
79
|
return h(
|
|
98
80
|
"svg",
|
|
99
|
-
{ width:
|
|
100
|
-
|
|
101
|
-
({ r, c }) => h("rect", {
|
|
102
|
-
key: `${
|
|
103
|
-
x:
|
|
104
|
-
y:
|
|
105
|
-
width:
|
|
106
|
-
height:
|
|
107
|
-
fill:
|
|
81
|
+
{ width: e, height: e, viewBox: `0 0 ${e} ${e}`, "aria-hidden": true, style: { display: "block" } },
|
|
82
|
+
i.map(
|
|
83
|
+
({ r: c, c: r }) => h("rect", {
|
|
84
|
+
key: `${c}-${r}`,
|
|
85
|
+
x: r * n + (n - s) / 2,
|
|
86
|
+
y: c * n + (n - s) / 2,
|
|
87
|
+
width: s,
|
|
88
|
+
height: s,
|
|
89
|
+
fill: t
|
|
108
90
|
})
|
|
109
91
|
)
|
|
110
92
|
);
|
|
111
93
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
container.querySelectorAll(
|
|
94
|
+
function H(e) {
|
|
95
|
+
return e ? Array.from(
|
|
96
|
+
e.querySelectorAll(
|
|
116
97
|
'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
117
98
|
)
|
|
118
|
-
).filter((
|
|
99
|
+
).filter((t) => t.offsetParent !== null || t === document.activeElement) : [];
|
|
119
100
|
}
|
|
120
|
-
function
|
|
121
|
-
client,
|
|
122
|
-
currentProductSlug,
|
|
123
|
-
settingsUrl,
|
|
124
|
-
onSignOut,
|
|
125
|
-
fetchBar,
|
|
126
|
-
labels,
|
|
127
|
-
className
|
|
101
|
+
function te({
|
|
102
|
+
client: e,
|
|
103
|
+
currentProductSlug: t,
|
|
104
|
+
settingsUrl: i,
|
|
105
|
+
onSignOut: n,
|
|
106
|
+
fetchBar: s,
|
|
107
|
+
labels: c,
|
|
108
|
+
className: r
|
|
128
109
|
}) {
|
|
129
|
-
|
|
130
|
-
const seedAccount = React2.useMemo(() => {
|
|
110
|
+
let o = { ...Z, ...c }, f = l.useMemo(() => {
|
|
131
111
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
112
|
+
let a = e.auth.getUser();
|
|
113
|
+
return a ? {
|
|
114
|
+
displayName: a.displayName || a.email || "",
|
|
115
|
+
email: a.email || "",
|
|
116
|
+
photoUrl: a.photoURL ?? null
|
|
117
|
+
} : null;
|
|
139
118
|
} catch {
|
|
140
119
|
return null;
|
|
141
120
|
}
|
|
142
|
-
}, [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const accountBtnRef = React2.useRef(null);
|
|
148
|
-
const appsBtnRef = React2.useRef(null);
|
|
149
|
-
const popoverRef = React2.useRef(null);
|
|
150
|
-
React2.useEffect(() => {
|
|
151
|
-
let cancelled = false;
|
|
152
|
-
const run = fetchBar ?? fetchNeetruAccountBar;
|
|
153
|
-
Promise.resolve(run(client)).then((res) => {
|
|
154
|
-
if (!cancelled && res) setData(res);
|
|
121
|
+
}, [e]), [u, m] = l.useState(null), [y, x] = l.useState(null), [T, R] = l.useState(false), p = l.useRef(null), d = l.useRef(null), g = l.useRef(null), S = l.useRef(null);
|
|
122
|
+
l.useEffect(() => {
|
|
123
|
+
let a = false, k = s ?? Q;
|
|
124
|
+
return Promise.resolve(k(e)).then((v) => {
|
|
125
|
+
!a && v && m(v);
|
|
155
126
|
}).catch(() => {
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
cancelled = true;
|
|
127
|
+
}), () => {
|
|
128
|
+
a = true;
|
|
159
129
|
};
|
|
160
|
-
}, [
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const products = data?.products ?? [];
|
|
164
|
-
const closeAndRefocus = React2.useCallback((which) => {
|
|
165
|
-
setOpen(null);
|
|
166
|
-
const trigger = which === "apps" ? appsBtnRef.current : accountBtnRef.current;
|
|
167
|
-
trigger?.focus();
|
|
130
|
+
}, [e, s]);
|
|
131
|
+
let C = u?.account ?? f, z = u?.accountUrl ?? "https://minhaconta.neetru.com", U = u?.products ?? [], L = l.useCallback((a) => {
|
|
132
|
+
x(null), (a === "apps" ? g.current : d.current)?.focus();
|
|
168
133
|
}, []);
|
|
169
|
-
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
175
|
-
setOpen(null);
|
|
176
|
-
}
|
|
134
|
+
l.useEffect(() => {
|
|
135
|
+
if (!y) return;
|
|
136
|
+
H(S.current)[0]?.focus();
|
|
137
|
+
let k = (v) => {
|
|
138
|
+
p.current && !p.current.contains(v.target) && x(null);
|
|
177
139
|
};
|
|
178
|
-
document.addEventListener("mousedown",
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
e.stopPropagation();
|
|
185
|
-
closeAndRefocus(open);
|
|
140
|
+
return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
|
|
141
|
+
}, [y]);
|
|
142
|
+
let P = l.useCallback(
|
|
143
|
+
(a) => {
|
|
144
|
+
if (a.key === "Escape") {
|
|
145
|
+
a.stopPropagation(), L(y);
|
|
186
146
|
return;
|
|
187
147
|
}
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (e.shiftKey && idx <= 0) {
|
|
193
|
-
e.preventDefault();
|
|
194
|
-
items[items.length - 1].focus();
|
|
195
|
-
} else if (!e.shiftKey && idx === items.length - 1) {
|
|
196
|
-
e.preventDefault();
|
|
197
|
-
items[0].focus();
|
|
198
|
-
}
|
|
199
|
-
} else if (e.key === "ArrowDown") {
|
|
200
|
-
e.preventDefault();
|
|
201
|
-
items[(idx + 1) % items.length].focus();
|
|
202
|
-
} else if (e.key === "ArrowUp") {
|
|
203
|
-
e.preventDefault();
|
|
204
|
-
items[(idx - 1 + items.length) % items.length].focus();
|
|
205
|
-
}
|
|
148
|
+
let k = H(S.current);
|
|
149
|
+
if (k.length === 0) return;
|
|
150
|
+
let v = k.indexOf(document.activeElement);
|
|
151
|
+
a.key === "Tab" ? a.shiftKey && v <= 0 ? (a.preventDefault(), k[k.length - 1].focus()) : !a.shiftKey && v === k.length - 1 && (a.preventDefault(), k[0].focus()) : a.key === "ArrowDown" ? (a.preventDefault(), k[(v + 1) % k.length].focus()) : a.key === "ArrowUp" && (a.preventDefault(), k[(v - 1 + k.length) % k.length].focus());
|
|
206
152
|
},
|
|
207
|
-
[
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
setOpen(null);
|
|
218
|
-
onSignOut?.();
|
|
153
|
+
[y, L]
|
|
154
|
+
), G = l.useCallback(async () => {
|
|
155
|
+
if (!T) {
|
|
156
|
+
R(true);
|
|
157
|
+
try {
|
|
158
|
+
await e.auth.signOut();
|
|
159
|
+
} catch {
|
|
160
|
+
} finally {
|
|
161
|
+
R(false), x(null), n?.();
|
|
162
|
+
}
|
|
219
163
|
}
|
|
220
|
-
}, [
|
|
221
|
-
if (!
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
src: account.photoUrl,
|
|
164
|
+
}, [e, T, n]);
|
|
165
|
+
if (!C) return null;
|
|
166
|
+
let I = N(C.displayName || C.email), K = C.photoUrl ? h("img", {
|
|
167
|
+
src: C.photoUrl,
|
|
225
168
|
alt: "",
|
|
226
169
|
width: 32,
|
|
227
170
|
height: 32,
|
|
@@ -236,74 +179,69 @@ function NeetruAccountBar({
|
|
|
236
179
|
display: "inline-flex",
|
|
237
180
|
alignItems: "center",
|
|
238
181
|
justifyContent: "center",
|
|
239
|
-
backgroundColor:
|
|
182
|
+
backgroundColor: b.fg,
|
|
240
183
|
color: "#ffffff",
|
|
241
184
|
fontSize: 13,
|
|
242
185
|
fontWeight: 700,
|
|
243
186
|
letterSpacing: "0.02em"
|
|
244
187
|
}
|
|
245
188
|
},
|
|
246
|
-
|
|
247
|
-
)
|
|
248
|
-
const iconBtnStyle = (active) => ({
|
|
189
|
+
I
|
|
190
|
+
), B = (a) => ({
|
|
249
191
|
display: "inline-flex",
|
|
250
192
|
alignItems: "center",
|
|
251
193
|
justifyContent: "center",
|
|
252
194
|
width: 36,
|
|
253
195
|
height: 36,
|
|
254
196
|
padding: 0,
|
|
255
|
-
borderRadius:
|
|
256
|
-
border: `1px solid ${
|
|
257
|
-
backgroundColor:
|
|
258
|
-
color:
|
|
197
|
+
borderRadius: M,
|
|
198
|
+
border: `1px solid ${a ? b.border : b.borderSoft}`,
|
|
199
|
+
backgroundColor: a ? b.bgHover : b.bg,
|
|
200
|
+
color: b.fg,
|
|
259
201
|
cursor: "pointer",
|
|
260
202
|
boxSizing: "border-box",
|
|
261
203
|
fontFamily: "inherit",
|
|
262
204
|
overflow: "hidden"
|
|
263
|
-
})
|
|
264
|
-
const appsButton = h(
|
|
205
|
+
}), V = h(
|
|
265
206
|
"button",
|
|
266
207
|
{
|
|
267
208
|
type: "button",
|
|
268
|
-
ref:
|
|
269
|
-
"aria-label":
|
|
209
|
+
ref: g,
|
|
210
|
+
"aria-label": o.appsButton,
|
|
270
211
|
"aria-haspopup": "menu",
|
|
271
|
-
"aria-expanded":
|
|
212
|
+
"aria-expanded": y === "apps",
|
|
272
213
|
"data-neetru-appswitcher-button": "true",
|
|
273
|
-
onClick: () =>
|
|
274
|
-
style:
|
|
214
|
+
onClick: () => x((a) => a === "apps" ? null : "apps"),
|
|
215
|
+
style: B(y === "apps")
|
|
275
216
|
},
|
|
276
|
-
h(
|
|
277
|
-
)
|
|
278
|
-
const accountButton = h(
|
|
217
|
+
h(ee, {})
|
|
218
|
+
), J = h(
|
|
279
219
|
"button",
|
|
280
220
|
{
|
|
281
221
|
type: "button",
|
|
282
|
-
ref:
|
|
283
|
-
"aria-label": `${
|
|
222
|
+
ref: d,
|
|
223
|
+
"aria-label": `${o.accountButton}${C.displayName ? ` (${C.displayName})` : ""}`,
|
|
284
224
|
"aria-haspopup": "menu",
|
|
285
|
-
"aria-expanded":
|
|
225
|
+
"aria-expanded": y === "account",
|
|
286
226
|
"data-neetru-account-button": "true",
|
|
287
|
-
onClick: () =>
|
|
288
|
-
style: { ...
|
|
227
|
+
onClick: () => x((a) => a === "account" ? null : "account"),
|
|
228
|
+
style: { ...B(y === "account"), width: 36, height: 36 }
|
|
289
229
|
},
|
|
290
|
-
|
|
291
|
-
)
|
|
292
|
-
const popoverStyle = {
|
|
230
|
+
K
|
|
231
|
+
), F = {
|
|
293
232
|
position: "absolute",
|
|
294
233
|
top: "calc(100% + 6px)",
|
|
295
234
|
right: 0,
|
|
296
235
|
minWidth: 260,
|
|
297
236
|
maxWidth: 320,
|
|
298
|
-
backgroundColor:
|
|
299
|
-
border: `1px solid ${
|
|
300
|
-
borderRadius:
|
|
237
|
+
backgroundColor: b.bg,
|
|
238
|
+
border: `1px solid ${b.border}`,
|
|
239
|
+
borderRadius: M,
|
|
301
240
|
zIndex: 1e3,
|
|
302
|
-
color:
|
|
241
|
+
color: b.fg,
|
|
303
242
|
fontFamily: "inherit"
|
|
304
243
|
// BMW: sem sombra/glassmorphism — borda sólida define o recorte.
|
|
305
|
-
}
|
|
306
|
-
const menuItemStyle = {
|
|
244
|
+
}, D = {
|
|
307
245
|
display: "flex",
|
|
308
246
|
alignItems: "center",
|
|
309
247
|
gap: 10,
|
|
@@ -311,8 +249,8 @@ function NeetruAccountBar({
|
|
|
311
249
|
padding: "10px 14px",
|
|
312
250
|
background: "transparent",
|
|
313
251
|
border: "none",
|
|
314
|
-
borderTop: `1px solid ${
|
|
315
|
-
color:
|
|
252
|
+
borderTop: `1px solid ${b.borderSoft}`,
|
|
253
|
+
color: b.fg,
|
|
316
254
|
fontSize: 14,
|
|
317
255
|
fontWeight: 400,
|
|
318
256
|
textAlign: "left",
|
|
@@ -320,24 +258,22 @@ function NeetruAccountBar({
|
|
|
320
258
|
cursor: "pointer",
|
|
321
259
|
boxSizing: "border-box",
|
|
322
260
|
fontFamily: "inherit"
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
e.currentTarget.style.backgroundColor = C.bgHover;
|
|
261
|
+
}, _ = {
|
|
262
|
+
onMouseEnter: (a) => {
|
|
263
|
+
a.currentTarget.style.backgroundColor = b.bgHover;
|
|
327
264
|
},
|
|
328
|
-
onMouseLeave: (
|
|
329
|
-
|
|
265
|
+
onMouseLeave: (a) => {
|
|
266
|
+
a.currentTarget.style.backgroundColor = "transparent";
|
|
330
267
|
}
|
|
331
|
-
}
|
|
332
|
-
const accountPopover = open === "account" ? h(
|
|
268
|
+
}, X = y === "account" ? h(
|
|
333
269
|
"div",
|
|
334
270
|
{
|
|
335
|
-
ref:
|
|
271
|
+
ref: S,
|
|
336
272
|
role: "menu",
|
|
337
|
-
"aria-label":
|
|
273
|
+
"aria-label": o.accountButton,
|
|
338
274
|
"data-neetru-account-menu": "true",
|
|
339
|
-
onKeyDown:
|
|
340
|
-
style:
|
|
275
|
+
onKeyDown: P,
|
|
276
|
+
style: F
|
|
341
277
|
},
|
|
342
278
|
// Header identidade
|
|
343
279
|
h(
|
|
@@ -355,19 +291,19 @@ function NeetruAccountBar({
|
|
|
355
291
|
alignItems: "center",
|
|
356
292
|
justifyContent: "center",
|
|
357
293
|
overflow: "hidden",
|
|
358
|
-
backgroundColor:
|
|
294
|
+
backgroundColor: C.photoUrl ? "transparent" : b.fg,
|
|
359
295
|
color: "#ffffff",
|
|
360
296
|
fontSize: 15,
|
|
361
297
|
fontWeight: 700
|
|
362
298
|
}
|
|
363
299
|
},
|
|
364
|
-
|
|
365
|
-
src:
|
|
300
|
+
C.photoUrl ? h("img", {
|
|
301
|
+
src: C.photoUrl,
|
|
366
302
|
alt: "",
|
|
367
303
|
width: 40,
|
|
368
304
|
height: 40,
|
|
369
305
|
style: { width: 40, height: 40, objectFit: "cover", display: "block" }
|
|
370
|
-
}) :
|
|
306
|
+
}) : I
|
|
371
307
|
),
|
|
372
308
|
h(
|
|
373
309
|
"span",
|
|
@@ -383,20 +319,20 @@ function NeetruAccountBar({
|
|
|
383
319
|
textOverflow: "ellipsis"
|
|
384
320
|
}
|
|
385
321
|
},
|
|
386
|
-
|
|
322
|
+
C.displayName || C.email
|
|
387
323
|
),
|
|
388
|
-
|
|
324
|
+
C.email ? h(
|
|
389
325
|
"span",
|
|
390
326
|
{
|
|
391
327
|
style: {
|
|
392
|
-
color:
|
|
328
|
+
color: b.muted,
|
|
393
329
|
fontSize: 12,
|
|
394
330
|
whiteSpace: "nowrap",
|
|
395
331
|
overflow: "hidden",
|
|
396
332
|
textOverflow: "ellipsis"
|
|
397
333
|
}
|
|
398
334
|
},
|
|
399
|
-
|
|
335
|
+
C.email
|
|
400
336
|
) : null
|
|
401
337
|
)
|
|
402
338
|
),
|
|
@@ -405,19 +341,19 @@ function NeetruAccountBar({
|
|
|
405
341
|
"a",
|
|
406
342
|
{
|
|
407
343
|
role: "menuitem",
|
|
408
|
-
href:
|
|
344
|
+
href: z,
|
|
409
345
|
target: "_blank",
|
|
410
346
|
rel: "noopener noreferrer",
|
|
411
|
-
style:
|
|
412
|
-
...
|
|
347
|
+
style: D,
|
|
348
|
+
..._
|
|
413
349
|
},
|
|
414
|
-
|
|
350
|
+
o.myAccount
|
|
415
351
|
),
|
|
416
352
|
// Configurações da conta (deste produto)
|
|
417
|
-
|
|
353
|
+
i ? h(
|
|
418
354
|
"a",
|
|
419
|
-
{ role: "menuitem", href:
|
|
420
|
-
|
|
355
|
+
{ role: "menuitem", href: i, style: D, ..._ },
|
|
356
|
+
o.accountSettings
|
|
421
357
|
) : null,
|
|
422
358
|
// Sair
|
|
423
359
|
h(
|
|
@@ -425,24 +361,23 @@ function NeetruAccountBar({
|
|
|
425
361
|
{
|
|
426
362
|
type: "button",
|
|
427
363
|
role: "menuitem",
|
|
428
|
-
onClick:
|
|
429
|
-
disabled:
|
|
364
|
+
onClick: G,
|
|
365
|
+
disabled: T,
|
|
430
366
|
"data-neetru-signout": "true",
|
|
431
|
-
style: { ...
|
|
432
|
-
...
|
|
367
|
+
style: { ...D, cursor: T ? "not-allowed" : "pointer" },
|
|
368
|
+
..._
|
|
433
369
|
},
|
|
434
|
-
|
|
370
|
+
T ? `${o.signOut}\u2026` : o.signOut
|
|
435
371
|
)
|
|
436
|
-
) : null
|
|
437
|
-
const appsPopover = open === "apps" ? h(
|
|
372
|
+
) : null, Y = y === "apps" ? h(
|
|
438
373
|
"div",
|
|
439
374
|
{
|
|
440
|
-
ref:
|
|
375
|
+
ref: S,
|
|
441
376
|
role: "menu",
|
|
442
|
-
"aria-label":
|
|
377
|
+
"aria-label": o.appsTitle,
|
|
443
378
|
"data-neetru-appswitcher-menu": "true",
|
|
444
|
-
onKeyDown:
|
|
445
|
-
style: { ...
|
|
379
|
+
onKeyDown: P,
|
|
380
|
+
style: { ...F, minWidth: 280 }
|
|
446
381
|
},
|
|
447
382
|
h(
|
|
448
383
|
"div",
|
|
@@ -453,15 +388,15 @@ function NeetruAccountBar({
|
|
|
453
388
|
fontWeight: 700,
|
|
454
389
|
letterSpacing: "0.08em",
|
|
455
390
|
textTransform: "uppercase",
|
|
456
|
-
color:
|
|
391
|
+
color: b.muted
|
|
457
392
|
}
|
|
458
393
|
},
|
|
459
|
-
|
|
394
|
+
o.appsTitle
|
|
460
395
|
),
|
|
461
|
-
|
|
396
|
+
U.length === 0 ? h(
|
|
462
397
|
"div",
|
|
463
|
-
{ style: { padding: "4px 14px 16px", fontSize: 13, color:
|
|
464
|
-
|
|
398
|
+
{ style: { padding: "4px 14px 16px", fontSize: 13, color: b.muted } },
|
|
399
|
+
o.emptyProducts
|
|
465
400
|
) : h(
|
|
466
401
|
"div",
|
|
467
402
|
{
|
|
@@ -470,21 +405,21 @@ function NeetruAccountBar({
|
|
|
470
405
|
gridTemplateColumns: "1fr 1fr",
|
|
471
406
|
gap: 1,
|
|
472
407
|
padding: 1,
|
|
473
|
-
backgroundColor:
|
|
408
|
+
backgroundColor: b.borderSoft
|
|
474
409
|
}
|
|
475
410
|
},
|
|
476
|
-
|
|
477
|
-
|
|
411
|
+
U.map((a) => {
|
|
412
|
+
let k = !!t && a.slug === t;
|
|
478
413
|
return h(
|
|
479
414
|
"a",
|
|
480
415
|
{
|
|
481
|
-
key:
|
|
416
|
+
key: a.slug,
|
|
482
417
|
role: "menuitem",
|
|
483
|
-
href:
|
|
484
|
-
"aria-current":
|
|
485
|
-
"data-neetru-product":
|
|
486
|
-
"data-current":
|
|
487
|
-
title:
|
|
418
|
+
href: a.url,
|
|
419
|
+
"aria-current": k ? "true" : void 0,
|
|
420
|
+
"data-neetru-product": a.slug,
|
|
421
|
+
"data-current": k ? "true" : void 0,
|
|
422
|
+
title: a.name,
|
|
488
423
|
style: {
|
|
489
424
|
display: "flex",
|
|
490
425
|
flexDirection: "column",
|
|
@@ -492,21 +427,21 @@ function NeetruAccountBar({
|
|
|
492
427
|
gap: 6,
|
|
493
428
|
padding: "14px 8px",
|
|
494
429
|
textDecoration: "none",
|
|
495
|
-
color:
|
|
496
|
-
backgroundColor:
|
|
430
|
+
color: b.fg,
|
|
431
|
+
backgroundColor: k ? b.bgHover : b.bg,
|
|
497
432
|
cursor: "pointer",
|
|
498
433
|
boxSizing: "border-box"
|
|
499
434
|
},
|
|
500
|
-
onMouseEnter: (
|
|
501
|
-
|
|
435
|
+
onMouseEnter: (v) => {
|
|
436
|
+
v.currentTarget.style.backgroundColor = b.bgHover;
|
|
502
437
|
},
|
|
503
|
-
onMouseLeave: (
|
|
504
|
-
|
|
438
|
+
onMouseLeave: (v) => {
|
|
439
|
+
v.currentTarget.style.backgroundColor = k ? b.bgHover : b.bg;
|
|
505
440
|
}
|
|
506
441
|
},
|
|
507
442
|
// Tile/ícone
|
|
508
|
-
|
|
509
|
-
src:
|
|
443
|
+
a.iconUrl ? h("img", {
|
|
444
|
+
src: a.iconUrl,
|
|
510
445
|
alt: "",
|
|
511
446
|
width: 32,
|
|
512
447
|
height: 32,
|
|
@@ -521,20 +456,20 @@ function NeetruAccountBar({
|
|
|
521
456
|
display: "inline-flex",
|
|
522
457
|
alignItems: "center",
|
|
523
458
|
justifyContent: "center",
|
|
524
|
-
backgroundColor:
|
|
459
|
+
backgroundColor: b.fg,
|
|
525
460
|
color: "#ffffff",
|
|
526
461
|
fontSize: 13,
|
|
527
462
|
fontWeight: 700
|
|
528
463
|
}
|
|
529
464
|
},
|
|
530
|
-
|
|
465
|
+
N(a.name)
|
|
531
466
|
),
|
|
532
467
|
h(
|
|
533
468
|
"span",
|
|
534
469
|
{
|
|
535
470
|
style: {
|
|
536
471
|
fontSize: 12,
|
|
537
|
-
fontWeight:
|
|
472
|
+
fontWeight: k ? 700 : 400,
|
|
538
473
|
textAlign: "center",
|
|
539
474
|
lineHeight: 1.2,
|
|
540
475
|
maxWidth: "100%",
|
|
@@ -544,9 +479,9 @@ function NeetruAccountBar({
|
|
|
544
479
|
width: "100%"
|
|
545
480
|
}
|
|
546
481
|
},
|
|
547
|
-
|
|
482
|
+
a.name
|
|
548
483
|
),
|
|
549
|
-
|
|
484
|
+
k ? h(
|
|
550
485
|
"span",
|
|
551
486
|
{
|
|
552
487
|
style: {
|
|
@@ -554,10 +489,10 @@ function NeetruAccountBar({
|
|
|
554
489
|
fontWeight: 700,
|
|
555
490
|
letterSpacing: "0.08em",
|
|
556
491
|
textTransform: "uppercase",
|
|
557
|
-
color:
|
|
492
|
+
color: b.muted
|
|
558
493
|
}
|
|
559
494
|
},
|
|
560
|
-
|
|
495
|
+
o.currentBadge
|
|
561
496
|
) : null
|
|
562
497
|
);
|
|
563
498
|
})
|
|
@@ -566,8 +501,8 @@ function NeetruAccountBar({
|
|
|
566
501
|
return h(
|
|
567
502
|
"div",
|
|
568
503
|
{
|
|
569
|
-
ref:
|
|
570
|
-
className,
|
|
504
|
+
ref: p,
|
|
505
|
+
className: r,
|
|
571
506
|
"data-neetru-account-bar": "true",
|
|
572
507
|
style: {
|
|
573
508
|
position: "relative",
|
|
@@ -579,234 +514,205 @@ function NeetruAccountBar({
|
|
|
579
514
|
fontFamily: "inherit"
|
|
580
515
|
}
|
|
581
516
|
},
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
517
|
+
V,
|
|
518
|
+
J,
|
|
519
|
+
X,
|
|
520
|
+
Y
|
|
586
521
|
);
|
|
587
522
|
}
|
|
588
523
|
|
|
589
524
|
// src/firestore-compat.ts
|
|
590
|
-
function
|
|
591
|
-
|
|
592
|
-
let
|
|
593
|
-
let limitValue;
|
|
594
|
-
for (const c of constraints) {
|
|
525
|
+
function A(e) {
|
|
526
|
+
let t = [], i, n;
|
|
527
|
+
for (let c of e)
|
|
595
528
|
if (c.__constraint === "where") {
|
|
596
|
-
|
|
597
|
-
|
|
529
|
+
let r = c;
|
|
530
|
+
t.push({ field: r.field, op: r.op, value: r.value });
|
|
598
531
|
} else if (c.__constraint === "orderBy") {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
} else
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
const out = {};
|
|
606
|
-
if (whereFilters.length > 0) out.where = whereFilters;
|
|
607
|
-
if (orderByClause) out.orderBy = orderByClause;
|
|
608
|
-
if (limitValue !== void 0) out.limit = limitValue;
|
|
609
|
-
return out;
|
|
610
|
-
}
|
|
611
|
-
function normalizeOp(op) {
|
|
612
|
-
return op;
|
|
532
|
+
let r = c;
|
|
533
|
+
i = { field: r.field, direction: r.direction };
|
|
534
|
+
} else c.__constraint === "limit" && (n = c.value);
|
|
535
|
+
let s = {};
|
|
536
|
+
return t.length > 0 && (s.where = t), i && (s.orderBy = i), n !== void 0 && (s.limit = n), s;
|
|
613
537
|
}
|
|
614
538
|
|
|
615
539
|
// src/react.ts
|
|
616
|
-
async function
|
|
617
|
-
|
|
540
|
+
async function ne(e, t) {
|
|
541
|
+
let i = await fetch(e, {
|
|
618
542
|
method: "POST",
|
|
619
543
|
headers: { "content-type": "application/json", accept: "application/json" },
|
|
620
544
|
credentials: "include",
|
|
621
|
-
body: JSON.stringify(
|
|
622
|
-
});
|
|
623
|
-
let payload = null;
|
|
545
|
+
body: JSON.stringify(t)
|
|
546
|
+
}), n = null;
|
|
624
547
|
try {
|
|
625
|
-
|
|
548
|
+
n = await i.json();
|
|
626
549
|
} catch {
|
|
627
|
-
|
|
550
|
+
n = null;
|
|
628
551
|
}
|
|
629
|
-
if (!
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
code,
|
|
636
|
-
typeof msg === "string" ? msg : `Checkout BFF respondeu HTTP ${res.status}`,
|
|
637
|
-
res.status
|
|
552
|
+
if (!i.ok) {
|
|
553
|
+
let r = n, o = r?.error, f = (o && typeof o == "object" && typeof o.code == "string" ? o.code : void 0) ?? "server_error", u = r && (typeof r.error == "object" && r.error?.message || typeof r.error == "string" && r.error || typeof r.message == "string" && r.message) || `Checkout BFF respondeu HTTP ${i.status}`;
|
|
554
|
+
throw new E(
|
|
555
|
+
f,
|
|
556
|
+
typeof u == "string" ? u : `Checkout BFF respondeu HTTP ${i.status}`,
|
|
557
|
+
i.status
|
|
638
558
|
);
|
|
639
559
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
throw new NeetruError(
|
|
560
|
+
let s = n?.intent ?? n ?? {}, c = n?.redirectUrl ?? s.redirectUrl;
|
|
561
|
+
if (!c || typeof c != "string")
|
|
562
|
+
throw new E(
|
|
644
563
|
"invalid_response",
|
|
645
564
|
"Resposta do route BFF de checkout sem `redirectUrl`."
|
|
646
565
|
);
|
|
647
|
-
}
|
|
648
566
|
return {
|
|
649
|
-
intentId: String(
|
|
650
|
-
redirectUrl,
|
|
651
|
-
status:
|
|
652
|
-
expiresAt: typeof
|
|
653
|
-
requiresKyc:
|
|
567
|
+
intentId: String(n?.intentId ?? s.intentId ?? ""),
|
|
568
|
+
redirectUrl: c,
|
|
569
|
+
status: n?.status ?? s.status ?? "pending",
|
|
570
|
+
expiresAt: typeof n?.expiresAt == "string" ? n.expiresAt : typeof s.expiresAt == "string" ? s.expiresAt : "",
|
|
571
|
+
requiresKyc: n?.requiresKyc === true || s.requiresKyc === true
|
|
654
572
|
};
|
|
655
573
|
}
|
|
656
|
-
function
|
|
657
|
-
|
|
658
|
-
|
|
574
|
+
function re(e) {
|
|
575
|
+
let t = globalThis.location;
|
|
576
|
+
t && typeof t.assign == "function" && t.assign(e);
|
|
659
577
|
}
|
|
660
|
-
function
|
|
661
|
-
client,
|
|
662
|
-
startPath,
|
|
663
|
-
productId,
|
|
664
|
-
planId,
|
|
665
|
-
callbackUrl,
|
|
666
|
-
tenantType,
|
|
667
|
-
tenantId,
|
|
668
|
-
children,
|
|
669
|
-
onIntentCreated,
|
|
670
|
-
onError,
|
|
671
|
-
noAutoRedirect,
|
|
672
|
-
...
|
|
578
|
+
function xe({
|
|
579
|
+
client: e,
|
|
580
|
+
startPath: t,
|
|
581
|
+
productId: i,
|
|
582
|
+
planId: n,
|
|
583
|
+
callbackUrl: s,
|
|
584
|
+
tenantType: c,
|
|
585
|
+
tenantId: r,
|
|
586
|
+
children: o,
|
|
587
|
+
onIntentCreated: f,
|
|
588
|
+
onError: u,
|
|
589
|
+
noAutoRedirect: m,
|
|
590
|
+
...y
|
|
673
591
|
}) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
592
|
+
let [x, T] = l.useState(false), R = e?.checkout, p = l.useCallback(
|
|
593
|
+
async (d) => {
|
|
594
|
+
if (d.preventDefault(), !x) {
|
|
595
|
+
if (t) {
|
|
596
|
+
T(true);
|
|
597
|
+
try {
|
|
598
|
+
let g = await ne(t, {
|
|
599
|
+
productId: i,
|
|
600
|
+
planId: n,
|
|
601
|
+
callbackUrl: s,
|
|
602
|
+
tenantType: c,
|
|
603
|
+
tenantId: r
|
|
604
|
+
});
|
|
605
|
+
f?.(g), m || re(g.redirectUrl);
|
|
606
|
+
} catch (g) {
|
|
607
|
+
u?.(g instanceof Error ? g : new Error(String(g)));
|
|
608
|
+
} finally {
|
|
609
|
+
T(false);
|
|
610
|
+
}
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (!R || typeof R.start != "function") {
|
|
614
|
+
u?.(
|
|
615
|
+
new Error(
|
|
616
|
+
"CheckoutLink: passe `startPath` (padr\xE3o BFF/cookie recomendado) OU um `client` com o namespace `checkout` (SDK 1.1+)."
|
|
617
|
+
)
|
|
618
|
+
);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
T(true);
|
|
682
622
|
try {
|
|
683
|
-
|
|
684
|
-
productId,
|
|
685
|
-
planId,
|
|
686
|
-
callbackUrl,
|
|
687
|
-
tenantType,
|
|
688
|
-
tenantId
|
|
623
|
+
let g = await R.start({
|
|
624
|
+
productId: i,
|
|
625
|
+
planId: n,
|
|
626
|
+
callbackUrl: s,
|
|
627
|
+
tenantType: c,
|
|
628
|
+
tenantId: r,
|
|
629
|
+
autoRedirect: !m
|
|
689
630
|
});
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
631
|
+
f?.(g);
|
|
632
|
+
} catch (g) {
|
|
633
|
+
u?.(g instanceof Error ? g : new Error(String(g)));
|
|
694
634
|
} finally {
|
|
695
|
-
|
|
635
|
+
T(false);
|
|
696
636
|
}
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
if (!checkout || typeof checkout.start !== "function") {
|
|
700
|
-
onError?.(
|
|
701
|
-
new Error(
|
|
702
|
-
"CheckoutLink: passe `startPath` (padr\xE3o BFF/cookie recomendado) OU um `client` com o namespace `checkout` (SDK 1.1+)."
|
|
703
|
-
)
|
|
704
|
-
);
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
setSubmitting(true);
|
|
708
|
-
try {
|
|
709
|
-
const result = await checkout.start({
|
|
710
|
-
productId,
|
|
711
|
-
planId,
|
|
712
|
-
callbackUrl,
|
|
713
|
-
tenantType,
|
|
714
|
-
tenantId,
|
|
715
|
-
autoRedirect: !noAutoRedirect
|
|
716
|
-
});
|
|
717
|
-
onIntentCreated?.(result);
|
|
718
|
-
} catch (err) {
|
|
719
|
-
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
720
|
-
} finally {
|
|
721
|
-
setSubmitting(false);
|
|
722
637
|
}
|
|
723
638
|
},
|
|
724
|
-
[
|
|
639
|
+
[x, R, t, i, n, s, c, r, m, f, u]
|
|
725
640
|
);
|
|
726
|
-
return
|
|
641
|
+
return l.createElement(
|
|
727
642
|
"a",
|
|
728
643
|
{
|
|
729
|
-
...
|
|
730
|
-
href:
|
|
731
|
-
onClick:
|
|
732
|
-
"aria-busy":
|
|
644
|
+
...y,
|
|
645
|
+
href: y.href ?? "#",
|
|
646
|
+
onClick: p,
|
|
647
|
+
"aria-busy": x || void 0,
|
|
733
648
|
"data-neetru-checkout-link": "true"
|
|
734
649
|
},
|
|
735
|
-
|
|
650
|
+
o
|
|
736
651
|
);
|
|
737
652
|
}
|
|
738
|
-
var
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
function NeetruFlameIcon({ fill, size = 16 }) {
|
|
742
|
-
return React2.createElement(
|
|
653
|
+
var oe = "M 281 5.163 C 240.659 26.308, 211.260 52.739, 187.750 89 C 177.297 105.123, 167.942 126.107, 162.988 144.543 C 154.486 176.188, 153.303 204.118, 159.101 236.317 C 161.553 249.934, 164.601 259.065, 171.539 273.568 C 179.323 289.843, 188.311 302.619, 205.856 322.343 C 216.993 334.865, 218.719 337.460, 223.536 348.944 C 233.797 373.403, 237.419 401.984, 232.417 419.032 C 229.111 430.300, 219.859 441.975, 210.427 446.779 C 186.006 459.218, 155.612 448.383, 142.319 422.500 C 128.813 396.204, 123.953 356.753, 129.495 318.395 C 131.172 306.786, 138.276 276.222, 140.080 272.850 C 140.675 271.738, 140.944 270.610, 140.676 270.343 C 139.995 269.662, 121.004 281.262, 112 287.859 C 100.565 296.237, 95.542 300.566, 83.993 312 C 44.470 351.127, 19.275 398.763, 8.623 454.500 C 4.302 477.115, 3.308 513.551, 6.332 538.569 C 9.164 562.011, 17.855 591.852, 27.324 610.648 C 37.693 631.233, 54.130 653.987, 71.900 672.357 C 80.540 681.289, 98.477 696.992, 104.478 700.878 C 106.690 702.310, 108.725 703.766, 109 704.114 C 109.836 705.172, 125.939 715.307, 135.539 720.817 C 152.923 730.795, 169.097 737.316, 200.500 747.009 C 204.454 748.230, 222.087 751.463, 234 753.153 C 246.383 754.909, 283.484 754.921, 296 753.173 C 310.006 751.217, 321.722 749.122, 328.500 747.360 C 384.024 732.928, 433.393 701.075, 469.555 656.351 C 491.448 629.275, 505.223 601.823, 514.391 567 C 519.380 548.047, 520.999 536.377, 521.686 514.410 C 523.126 468.370, 514.560 426.479, 494.812 383 C 471.567 331.818, 436.019 282.480, 379.951 223.582 C 354.302 196.638, 349.024 190.981, 341.670 182.551 C 318.918 156.471, 301.763 128.316, 293.505 103.500 C 286.625 82.826, 285.662 76.446, 285.578 51 C 285.500 27.576, 285.510 27.460, 288.750 15.129 C 290.538 8.326, 292 2.363, 292 1.879 C 292 0.197, 288.454 1.255, 281 5.163", ie = "0 0 527 760", se = 527 / 760;
|
|
654
|
+
function ae({ fill: e, size: t = 16 }) {
|
|
655
|
+
return l.createElement(
|
|
743
656
|
"svg",
|
|
744
657
|
{
|
|
745
|
-
viewBox:
|
|
746
|
-
width: Math.round(
|
|
747
|
-
height:
|
|
658
|
+
viewBox: ie,
|
|
659
|
+
width: Math.round(t * se),
|
|
660
|
+
height: t,
|
|
748
661
|
"aria-hidden": true,
|
|
749
662
|
style: { flexShrink: 0 }
|
|
750
663
|
},
|
|
751
|
-
|
|
664
|
+
l.createElement("path", { d: oe, fill: e })
|
|
752
665
|
);
|
|
753
666
|
}
|
|
754
|
-
var
|
|
667
|
+
var ce = {
|
|
755
668
|
dark: { bg: "#0a0a0a", bgHover: "#1a1a1a", fg: "#ffffff", border: "#0a0a0a" },
|
|
756
669
|
light: { bg: "#ffffff", bgHover: "#f5f5f5", fg: "#0a0a0a", border: "#0a0a0a" }
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
if (document.getElementById(NEETRU_LOGIN_FOCUS_STYLE_ID)) return;
|
|
763
|
-
const styleEl = document.createElement("style");
|
|
764
|
-
styleEl.id = NEETRU_LOGIN_FOCUS_STYLE_ID;
|
|
765
|
-
styleEl.textContent = NEETRU_LOGIN_FOCUS_CSS;
|
|
766
|
-
document.head.appendChild(styleEl);
|
|
670
|
+
}, W = "neetru-login-button-focus-style", le = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
|
|
671
|
+
function ue() {
|
|
672
|
+
if (typeof document > "u" || !document.head || document.getElementById(W)) return;
|
|
673
|
+
let e = document.createElement("style");
|
|
674
|
+
e.id = W, e.textContent = le, document.head.appendChild(e);
|
|
767
675
|
}
|
|
768
|
-
function
|
|
769
|
-
client,
|
|
770
|
-
redirectUri,
|
|
771
|
-
scope,
|
|
772
|
-
postLoginRedirect,
|
|
773
|
-
theme = "dark",
|
|
774
|
-
label = "Entrar com Neetru",
|
|
775
|
-
onError,
|
|
776
|
-
style,
|
|
777
|
-
disabled,
|
|
778
|
-
...
|
|
676
|
+
function we({
|
|
677
|
+
client: e,
|
|
678
|
+
redirectUri: t,
|
|
679
|
+
scope: i,
|
|
680
|
+
postLoginRedirect: n,
|
|
681
|
+
theme: s = "dark",
|
|
682
|
+
label: c = "Entrar com Neetru",
|
|
683
|
+
onError: r,
|
|
684
|
+
style: o,
|
|
685
|
+
disabled: f,
|
|
686
|
+
...u
|
|
779
687
|
}) {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
const isDisabled = Boolean(disabled) || isLoading;
|
|
784
|
-
React2.useEffect(() => {
|
|
785
|
-
ensureLoginFocusStyleInjected();
|
|
688
|
+
let [m, y] = l.useState(false), [x, T] = l.useState(false), R = ce[s], p = !!f || m;
|
|
689
|
+
l.useEffect(() => {
|
|
690
|
+
ue();
|
|
786
691
|
}, []);
|
|
787
|
-
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
692
|
+
let d = l.useCallback(async () => {
|
|
693
|
+
if (!p) {
|
|
694
|
+
y(true);
|
|
695
|
+
try {
|
|
696
|
+
let g = { redirectUri: t, scope: i, postLoginRedirect: n };
|
|
697
|
+
await e.auth.signIn(g);
|
|
698
|
+
} catch (g) {
|
|
699
|
+
r?.(g instanceof Error ? g : new Error(String(g)));
|
|
700
|
+
} finally {
|
|
701
|
+
y(false);
|
|
702
|
+
}
|
|
797
703
|
}
|
|
798
|
-
}, [
|
|
799
|
-
return
|
|
704
|
+
}, [e, t, i, n, p, r]);
|
|
705
|
+
return l.createElement(
|
|
800
706
|
"button",
|
|
801
707
|
{
|
|
802
|
-
...
|
|
708
|
+
...u,
|
|
803
709
|
type: "button",
|
|
804
|
-
onClick:
|
|
805
|
-
disabled:
|
|
806
|
-
onMouseEnter: () =>
|
|
807
|
-
onMouseLeave: () =>
|
|
808
|
-
"aria-label":
|
|
809
|
-
"aria-busy":
|
|
710
|
+
onClick: d,
|
|
711
|
+
disabled: p,
|
|
712
|
+
onMouseEnter: () => T(true),
|
|
713
|
+
onMouseLeave: () => T(false),
|
|
714
|
+
"aria-label": u["aria-label"] ?? c,
|
|
715
|
+
"aria-busy": m || void 0,
|
|
810
716
|
"data-neetru-login-button": "true",
|
|
811
717
|
style: {
|
|
812
718
|
display: "inline-flex",
|
|
@@ -817,346 +723,269 @@ function NeetruLoginButton({
|
|
|
817
723
|
height: "48px",
|
|
818
724
|
padding: "0 20px",
|
|
819
725
|
borderRadius: 0,
|
|
820
|
-
border: `1px solid ${
|
|
821
|
-
backgroundColor:
|
|
822
|
-
color:
|
|
726
|
+
border: `1px solid ${R.border}`,
|
|
727
|
+
backgroundColor: x && !p ? R.bgHover : R.bg,
|
|
728
|
+
color: R.fg,
|
|
823
729
|
fontSize: "14px",
|
|
824
730
|
fontWeight: 700,
|
|
825
731
|
textTransform: "uppercase",
|
|
826
732
|
letterSpacing: "0.08em",
|
|
827
733
|
fontFamily: "inherit",
|
|
828
734
|
lineHeight: 1,
|
|
829
|
-
cursor:
|
|
830
|
-
opacity:
|
|
735
|
+
cursor: p ? "not-allowed" : "pointer",
|
|
736
|
+
opacity: p && !m ? 0.6 : 1,
|
|
831
737
|
transition: "background-color 150ms ease",
|
|
832
738
|
boxSizing: "border-box",
|
|
833
739
|
// Cor do ring de foco de teclado (:focus-visible) — ver
|
|
834
740
|
// NEETRU_LOGIN_FOCUS_CSS. Usa a cor do texto (contraste AA garantido).
|
|
835
|
-
"--neetru-login-focus-ring":
|
|
836
|
-
...
|
|
741
|
+
"--neetru-login-focus-ring": R.fg,
|
|
742
|
+
...o
|
|
837
743
|
}
|
|
838
744
|
},
|
|
839
|
-
|
|
840
|
-
|
|
745
|
+
l.createElement(ae, { fill: R.fg }),
|
|
746
|
+
l.createElement("span", null, m ? "Entrando\u2026" : c)
|
|
841
747
|
);
|
|
842
748
|
}
|
|
843
|
-
var
|
|
749
|
+
var j = l.createContext({
|
|
844
750
|
readonly: false
|
|
845
751
|
});
|
|
846
|
-
function
|
|
847
|
-
return
|
|
752
|
+
function Ce() {
|
|
753
|
+
return l.useContext(j);
|
|
848
754
|
}
|
|
849
|
-
function
|
|
850
|
-
client,
|
|
851
|
-
feature,
|
|
852
|
-
productSlug,
|
|
853
|
-
mode = "block",
|
|
854
|
-
fallback,
|
|
855
|
-
loading,
|
|
856
|
-
children
|
|
755
|
+
function Se({
|
|
756
|
+
client: e,
|
|
757
|
+
feature: t,
|
|
758
|
+
productSlug: i,
|
|
759
|
+
mode: n = "block",
|
|
760
|
+
fallback: s,
|
|
761
|
+
loading: c,
|
|
762
|
+
children: r
|
|
857
763
|
}) {
|
|
858
|
-
|
|
764
|
+
let [o, f] = l.useState({
|
|
859
765
|
status: "loading"
|
|
860
|
-
});
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
let cancelled = false;
|
|
865
|
-
const run = async () => {
|
|
766
|
+
}), u = i ?? e.config.productId ?? "", m = e.config.tenantId;
|
|
767
|
+
if (l.useEffect(() => {
|
|
768
|
+
let R = false;
|
|
769
|
+
return (async () => {
|
|
866
770
|
try {
|
|
867
|
-
let
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
tenantId: resolvedTenantId
|
|
771
|
+
let d, g = e.usage;
|
|
772
|
+
if (g && typeof g.check == "function" && m) {
|
|
773
|
+
let S = await g.check(t, {
|
|
774
|
+
productId: u,
|
|
775
|
+
tenantId: m
|
|
873
776
|
});
|
|
874
|
-
|
|
875
|
-
allowed:
|
|
876
|
-
reason:
|
|
877
|
-
limit:
|
|
878
|
-
currentUsage:
|
|
879
|
-
behavior:
|
|
777
|
+
d = {
|
|
778
|
+
allowed: S.allowed === !0,
|
|
779
|
+
reason: S.reason,
|
|
780
|
+
limit: S.limit,
|
|
781
|
+
currentUsage: S.currentUsage,
|
|
782
|
+
behavior: S.behavior
|
|
880
783
|
};
|
|
881
|
-
} else
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
if (!cancelled) setState({ status: "ready", result: result2 });
|
|
890
|
-
} catch (err) {
|
|
891
|
-
if (!cancelled) {
|
|
892
|
-
setState({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } });
|
|
893
|
-
}
|
|
894
|
-
if (typeof console !== "undefined") console.warn("[EntitlementGate] check failed \u2014 fail-open", err);
|
|
784
|
+
} else
|
|
785
|
+
typeof console < "u" && console.warn(
|
|
786
|
+
"[EntitlementGate] tenantId ausente em client.config \u2014 n\xE3o \xE9 poss\xEDvel verificar entitlement (client.entitlements.check() est\xE1 deprecado, ver src/entitlements.ts). Configure tenantId no createNeetruClient() ou passe via props. Bloqueando por padr\xE3o (fail-closed)."
|
|
787
|
+
), d = { allowed: !1, reason: "tenant_id_required" };
|
|
788
|
+
R || f({ status: "ready", result: d });
|
|
789
|
+
} catch (d) {
|
|
790
|
+
R || f({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } }), typeof console < "u" && console.warn("[EntitlementGate] check failed \u2014 fail-open", d);
|
|
895
791
|
}
|
|
792
|
+
})(), () => {
|
|
793
|
+
R = true;
|
|
896
794
|
};
|
|
897
|
-
|
|
898
|
-
return (
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
if (state.status === "loading") {
|
|
903
|
-
return React2.createElement(React2.Fragment, null, loading ?? null);
|
|
904
|
-
}
|
|
905
|
-
const result = state.result;
|
|
906
|
-
const allowed = result?.allowed === true;
|
|
907
|
-
const isReadonly = !allowed && (mode === "readonly" || result?.behavior === "readonly");
|
|
908
|
-
if (!allowed && mode === "block" && !isReadonly) {
|
|
909
|
-
return React2.createElement(React2.Fragment, null, fallback ?? null);
|
|
910
|
-
}
|
|
911
|
-
return React2.createElement(
|
|
912
|
-
EntitlementContext.Provider,
|
|
795
|
+
}, [e, t, u, m]), o.status === "loading")
|
|
796
|
+
return l.createElement(l.Fragment, null, c ?? null);
|
|
797
|
+
let y = o.result, x = y?.allowed === true, T = !x && (n === "readonly" || y?.behavior === "readonly");
|
|
798
|
+
return !x && n === "block" && !T ? l.createElement(l.Fragment, null, s ?? null) : l.createElement(
|
|
799
|
+
j.Provider,
|
|
913
800
|
{
|
|
914
801
|
value: {
|
|
915
|
-
readonly:
|
|
916
|
-
reason:
|
|
917
|
-
limit:
|
|
918
|
-
currentUsage:
|
|
802
|
+
readonly: T,
|
|
803
|
+
reason: y?.reason,
|
|
804
|
+
limit: y?.limit,
|
|
805
|
+
currentUsage: y?.currentUsage
|
|
919
806
|
}
|
|
920
807
|
},
|
|
921
|
-
|
|
808
|
+
r
|
|
922
809
|
);
|
|
923
810
|
}
|
|
924
|
-
var
|
|
925
|
-
function
|
|
926
|
-
return typeof document
|
|
811
|
+
var $ = 5e3;
|
|
812
|
+
function q() {
|
|
813
|
+
return typeof document < "u" && document.hidden === true;
|
|
927
814
|
}
|
|
928
|
-
function
|
|
929
|
-
if (!
|
|
930
|
-
if (
|
|
931
|
-
return `collection:${
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
return `query:${source.collection}:${JSON.stringify(dbQuery)}`;
|
|
815
|
+
function de(e) {
|
|
816
|
+
if (!e) return null;
|
|
817
|
+
if (e.__kind === "collection")
|
|
818
|
+
return `collection:${e.id}`;
|
|
819
|
+
let t = A(e.constraints);
|
|
820
|
+
return `query:${e.collection}:${JSON.stringify(t)}`;
|
|
935
821
|
}
|
|
936
|
-
function
|
|
937
|
-
return
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
return { ...rest, id: d.id };
|
|
822
|
+
function pe(e) {
|
|
823
|
+
return e.docs.map((t) => {
|
|
824
|
+
let i = t.data, { id: n, ...s } = i;
|
|
825
|
+
return { ...s, id: t.id };
|
|
941
826
|
});
|
|
942
827
|
}
|
|
943
|
-
function
|
|
944
|
-
|
|
945
|
-
if (!
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
return { ...rest, id };
|
|
828
|
+
function ge(e, t) {
|
|
829
|
+
let i = e?.docs[0];
|
|
830
|
+
if (!i) return null;
|
|
831
|
+
let n = i.data, { id: s, ...c } = n;
|
|
832
|
+
return { ...c, id: t };
|
|
949
833
|
}
|
|
950
|
-
function
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
source
|
|
955
|
-
);
|
|
956
|
-
const [state, setState] = React2.useState({
|
|
834
|
+
function ve(e, t) {
|
|
835
|
+
let i = t?.intervalMs ?? $, n = t?.poll ?? false, s = de(
|
|
836
|
+
e
|
|
837
|
+
), [c, r] = l.useState({
|
|
957
838
|
data: null,
|
|
958
|
-
isLoading:
|
|
839
|
+
isLoading: s !== null,
|
|
959
840
|
error: null,
|
|
960
841
|
isStale: false,
|
|
961
842
|
lastUpdated: null
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
if (!current || sourceKey === null) {
|
|
970
|
-
setState({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null });
|
|
971
|
-
return () => {
|
|
972
|
-
mountedRef.current = false;
|
|
843
|
+
}), o = l.useRef(true), f = l.useRef(e);
|
|
844
|
+
return f.current = e, l.useEffect(() => {
|
|
845
|
+
o.current = true;
|
|
846
|
+
let u = f.current;
|
|
847
|
+
if (!u || s === null)
|
|
848
|
+
return r({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
|
|
849
|
+
o.current = false;
|
|
973
850
|
};
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
const col = current.db.collection(collectionName);
|
|
979
|
-
const applySnap = (snap) => {
|
|
980
|
-
if (!mountedRef.current) return;
|
|
981
|
-
setState({
|
|
982
|
-
data: rowsFromList(snap),
|
|
851
|
+
r((d) => ({ ...d, isLoading: d.data === null }));
|
|
852
|
+
let m = u.__kind === "query" ? u.collection : u.id, y = u.__kind === "query" ? A(u.constraints) : void 0, x = u.db.collection(m), T = (d) => {
|
|
853
|
+
o.current && r({
|
|
854
|
+
data: pe(d),
|
|
983
855
|
isLoading: false,
|
|
984
856
|
error: null,
|
|
985
|
-
isStale:
|
|
857
|
+
isStale: d.stale === true,
|
|
986
858
|
lastUpdated: Date.now()
|
|
987
859
|
});
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
setState((prev) => ({
|
|
992
|
-
...prev,
|
|
860
|
+
}, R = (d) => {
|
|
861
|
+
o.current && r((g) => ({
|
|
862
|
+
...g,
|
|
993
863
|
// Mantém o último data bom — não limpa em erro de refresh.
|
|
994
864
|
isLoading: false,
|
|
995
|
-
error:
|
|
865
|
+
error: d instanceof Error ? d : new Error(String(d)),
|
|
996
866
|
isStale: true
|
|
997
867
|
}));
|
|
998
868
|
};
|
|
999
|
-
if (
|
|
1000
|
-
let
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
}
|
|
869
|
+
if (n) {
|
|
870
|
+
let d = false, g = async () => {
|
|
871
|
+
if (!(d || q()))
|
|
872
|
+
try {
|
|
873
|
+
let C = await x.list(y);
|
|
874
|
+
d || T(C);
|
|
875
|
+
} catch (C) {
|
|
876
|
+
d || R(C);
|
|
877
|
+
}
|
|
1009
878
|
};
|
|
1010
|
-
|
|
1011
|
-
|
|
879
|
+
g();
|
|
880
|
+
let S = setInterval(g, i);
|
|
1012
881
|
return () => {
|
|
1013
|
-
|
|
1014
|
-
clearInterval(timer);
|
|
1015
|
-
mountedRef.current = false;
|
|
882
|
+
d = true, clearInterval(S), o.current = false;
|
|
1016
883
|
};
|
|
1017
884
|
}
|
|
1018
|
-
let
|
|
885
|
+
let p;
|
|
1019
886
|
try {
|
|
1020
|
-
|
|
1021
|
-
} catch (
|
|
1022
|
-
|
|
887
|
+
p = x.onSnapshot(y, T);
|
|
888
|
+
} catch (d) {
|
|
889
|
+
R(d);
|
|
1023
890
|
}
|
|
1024
891
|
return () => {
|
|
1025
|
-
|
|
1026
|
-
unsub?.();
|
|
892
|
+
o.current = false, p?.();
|
|
1027
893
|
};
|
|
1028
|
-
}, [
|
|
1029
|
-
return state;
|
|
894
|
+
}, [s, i, n]), c;
|
|
1030
895
|
}
|
|
1031
|
-
function
|
|
1032
|
-
|
|
1033
|
-
const poll = options?.poll ?? false;
|
|
1034
|
-
const refKey = ref && ref.id ? `${ref.collection}/${ref.id}` : null;
|
|
1035
|
-
const [state, setState] = React2.useState({
|
|
896
|
+
function Ee(e, t) {
|
|
897
|
+
let i = t?.intervalMs ?? $, n = t?.poll ?? false, s = e && e.id ? `${e.collection}/${e.id}` : null, [c, r] = l.useState({
|
|
1036
898
|
data: null,
|
|
1037
|
-
isLoading:
|
|
899
|
+
isLoading: s !== null,
|
|
1038
900
|
error: null,
|
|
1039
901
|
isStale: false,
|
|
1040
902
|
lastUpdated: null
|
|
1041
|
-
});
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
if (!current || refKey === null) {
|
|
1049
|
-
setState({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null });
|
|
1050
|
-
return () => {
|
|
1051
|
-
mountedRef.current = false;
|
|
903
|
+
}), o = l.useRef(true), f = l.useRef(e);
|
|
904
|
+
return f.current = e, l.useEffect(() => {
|
|
905
|
+
o.current = true;
|
|
906
|
+
let u = f.current;
|
|
907
|
+
if (!u || s === null)
|
|
908
|
+
return r({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
|
|
909
|
+
o.current = false;
|
|
1052
910
|
};
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
const applySnap = (snap) => {
|
|
1058
|
-
if (!mountedRef.current) return;
|
|
1059
|
-
setState({
|
|
1060
|
-
data: rowFromGet(snap, id),
|
|
911
|
+
r((p) => ({ ...p, isLoading: p.data === null }));
|
|
912
|
+
let m = u.db.collection(u.collection).doc(u.id), y = u.id, x = (p) => {
|
|
913
|
+
o.current && r({
|
|
914
|
+
data: ge(p, y),
|
|
1061
915
|
isLoading: false,
|
|
1062
916
|
error: null,
|
|
1063
|
-
isStale:
|
|
917
|
+
isStale: p?.stale === true,
|
|
1064
918
|
lastUpdated: Date.now()
|
|
1065
919
|
});
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
setState((prev) => ({
|
|
1070
|
-
...prev,
|
|
920
|
+
}, T = (p) => {
|
|
921
|
+
o.current && r((d) => ({
|
|
922
|
+
...d,
|
|
1071
923
|
isLoading: false,
|
|
1072
|
-
error:
|
|
924
|
+
error: p instanceof Error ? p : new Error(String(p)),
|
|
1073
925
|
isStale: true
|
|
1074
926
|
}));
|
|
1075
927
|
};
|
|
1076
|
-
if (
|
|
1077
|
-
let
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
928
|
+
if (n) {
|
|
929
|
+
let p = false, d = async () => {
|
|
930
|
+
if (!(p || q()))
|
|
931
|
+
try {
|
|
932
|
+
let S = await m.get();
|
|
933
|
+
p || x(S);
|
|
934
|
+
} catch (S) {
|
|
935
|
+
p || T(S);
|
|
936
|
+
}
|
|
1086
937
|
};
|
|
1087
|
-
|
|
1088
|
-
|
|
938
|
+
d();
|
|
939
|
+
let g = setInterval(d, i);
|
|
1089
940
|
return () => {
|
|
1090
|
-
|
|
1091
|
-
clearInterval(timer);
|
|
1092
|
-
mountedRef.current = false;
|
|
941
|
+
p = true, clearInterval(g), o.current = false;
|
|
1093
942
|
};
|
|
1094
943
|
}
|
|
1095
|
-
let
|
|
944
|
+
let R;
|
|
1096
945
|
try {
|
|
1097
|
-
|
|
1098
|
-
} catch (
|
|
1099
|
-
|
|
946
|
+
R = m.onSnapshot(x);
|
|
947
|
+
} catch (p) {
|
|
948
|
+
T(p);
|
|
1100
949
|
}
|
|
1101
950
|
return () => {
|
|
1102
|
-
|
|
1103
|
-
unsub?.();
|
|
951
|
+
o.current = false, R?.();
|
|
1104
952
|
};
|
|
1105
|
-
}, [
|
|
1106
|
-
return state;
|
|
953
|
+
}, [s, i, n]), c;
|
|
1107
954
|
}
|
|
1108
|
-
function
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
return maybe.auth;
|
|
1112
|
-
}
|
|
1113
|
-
return input;
|
|
955
|
+
function fe(e) {
|
|
956
|
+
let t = e;
|
|
957
|
+
return t.auth && typeof t.auth.onAuthStateChanged == "function" ? t.auth : e;
|
|
1114
958
|
}
|
|
1115
|
-
function
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
const [state, setState] = React2.useState(() => {
|
|
1119
|
-
let seeded = null;
|
|
959
|
+
function De(e, t) {
|
|
960
|
+
let i = t?.timeoutMs ?? 8e3, n = fe(e), [s, c] = l.useState(() => {
|
|
961
|
+
let o = null;
|
|
1120
962
|
try {
|
|
1121
|
-
|
|
963
|
+
o = n.getUser();
|
|
1122
964
|
} catch {
|
|
1123
|
-
|
|
965
|
+
o = null;
|
|
1124
966
|
}
|
|
1125
|
-
return { user:
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
if (!mountedRef.current || settled) return;
|
|
1133
|
-
setState((prev) => prev.isLoading ? { ...prev, isLoading: false } : prev);
|
|
1134
|
-
}, timeoutMs);
|
|
1135
|
-
let unsub;
|
|
967
|
+
return { user: o, isLoading: o === null, error: null };
|
|
968
|
+
}), r = l.useRef(true);
|
|
969
|
+
return l.useEffect(() => {
|
|
970
|
+
r.current = true;
|
|
971
|
+
let o = false, f = setTimeout(() => {
|
|
972
|
+
!r.current || o || c((m) => m.isLoading ? { ...m, isLoading: false } : m);
|
|
973
|
+
}, i), u;
|
|
1136
974
|
try {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
975
|
+
u = n.onAuthStateChanged((m) => {
|
|
976
|
+
r.current && (o = !0, c({ user: m ?? null, isLoading: !1, error: null }));
|
|
977
|
+
});
|
|
978
|
+
} catch (m) {
|
|
979
|
+
r.current && c({
|
|
980
|
+
user: null,
|
|
981
|
+
isLoading: false,
|
|
982
|
+
error: m instanceof Error ? m : new Error(String(m))
|
|
1141
983
|
});
|
|
1142
|
-
} catch (e) {
|
|
1143
|
-
if (mountedRef.current) {
|
|
1144
|
-
setState({
|
|
1145
|
-
user: null,
|
|
1146
|
-
isLoading: false,
|
|
1147
|
-
error: e instanceof Error ? e : new Error(String(e))
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
984
|
}
|
|
1151
985
|
return () => {
|
|
1152
|
-
|
|
1153
|
-
clearTimeout(timer);
|
|
1154
|
-
unsub?.();
|
|
986
|
+
r.current = false, clearTimeout(f), u?.();
|
|
1155
987
|
};
|
|
1156
|
-
}, [
|
|
1157
|
-
return state;
|
|
988
|
+
}, [n, i]), s;
|
|
1158
989
|
}
|
|
1159
990
|
|
|
1160
|
-
export { CheckoutLink, EntitlementGate, NeetruAccountBar, NeetruLoginButton, fetchNeetruAccountBar, initialsFrom, useCollection, useDoc, useEntitlementContext, useUser };
|
|
1161
|
-
//# sourceMappingURL=react.mjs.map
|
|
1162
|
-
//# sourceMappingURL=react.mjs.map
|
|
991
|
+
export { xe as CheckoutLink, Se as EntitlementGate, te as NeetruAccountBar, we as NeetruLoginButton, Q as fetchNeetruAccountBar, N as initialsFrom, ve as useCollection, Ee as useDoc, Ce as useEntitlementContext, De as useUser };
|