@neetru/sdk 3.7.0 → 3.8.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/CHANGELOG.md +75 -0
- package/README.md +66 -1
- package/dist/ai.cjs +221 -177
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +221 -177
- package/dist/auth.cjs +1051 -868
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +1048 -865
- package/dist/catalog.cjs +164 -97
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +164 -97
- package/dist/checkout.cjs +182 -115
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +181 -114
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +437 -345
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +455 -363
- package/dist/entitlements.cjs +17 -10
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +17 -10
- package/dist/errors.cjs +15 -8
- package/dist/errors.d.cts +24 -3
- package/dist/errors.d.ts +24 -3
- package/dist/errors.mjs +14 -7
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +1544 -1190
- package/dist/index.d.cts +177 -3
- package/dist/index.d.ts +177 -3
- package/dist/index.mjs +1676 -1329
- package/dist/mobile.cjs +400 -181
- package/dist/mobile.d.cts +59 -4
- package/dist/mobile.d.ts +59 -4
- package/dist/mobile.mjs +400 -181
- package/dist/mocks.cjs +9 -2
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.mjs +9 -2
- package/dist/notifications.cjs +197 -130
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +196 -129
- package/dist/react.cjs +303 -282
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +295 -274
- package/dist/support.cjs +299 -229
- package/dist/support.d.cts +8 -4
- package/dist/support.d.ts +8 -4
- package/dist/support.mjs +298 -228
- package/dist/telemetry.cjs +234 -167
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +234 -167
- package/dist/{types-Dx0IrOSF.d.ts → types-BYPk_3HR.d.ts} +104 -17
- package/dist/{types-Bx4kTLmk.d.cts → types-yv3EDKg2.d.cts} +104 -17
- package/dist/usage.cjs +183 -116
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +183 -116
- package/dist/webhooks.cjs +215 -148
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +212 -145
- package/package.json +2 -1
package/dist/react.cjs
CHANGED
|
@@ -38,16 +38,37 @@ var E = class e extends Error {
|
|
|
38
38
|
* para um `NeetruDbErrorCode` mais específico (recuperável vs não).
|
|
39
39
|
*/
|
|
40
40
|
reason;
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* 3.8.0: `x-correlation-id` da requisição que falhou. O SDK gera um UUID por
|
|
43
|
+
* chamada (ou usa o que o chamador passou) e manda no header; o Core grava o
|
|
44
|
+
* mesmo id nos logs/auditoria — cite-o ao abrir um ticket de suporte.
|
|
45
|
+
* `undefined` em erros que acontecem antes de qualquer requisição.
|
|
46
|
+
*/
|
|
47
|
+
correlationId;
|
|
48
|
+
constructor(t, i, n, s, c, o) {
|
|
49
|
+
super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = s, this.reason = c, this.correlationId = o, Object.setPrototypeOf(this, e.prototype);
|
|
43
50
|
}
|
|
44
51
|
};
|
|
45
52
|
|
|
46
53
|
// src/types.ts
|
|
47
54
|
var O = "https://api.neetru.com";
|
|
48
55
|
|
|
56
|
+
// src/end-user-token.ts
|
|
57
|
+
var ee = /* @__PURE__ */ new WeakMap();
|
|
58
|
+
function te(e) {
|
|
59
|
+
return ee.get(e);
|
|
60
|
+
}
|
|
61
|
+
async function M(e) {
|
|
62
|
+
try {
|
|
63
|
+
let t = te(e), i = e.auth, n = t ? await t.getIdToken() : typeof i?.getIdToken == "function" ? await i.getIdToken() : null;
|
|
64
|
+
return typeof n == "string" && n.length > 0 ? n : null;
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
// src/account-bar.ts
|
|
50
|
-
var
|
|
71
|
+
var y = l__namespace.createElement, ne = {
|
|
51
72
|
accountButton: "Abrir menu da conta",
|
|
52
73
|
appsButton: "Seus produtos Neetru",
|
|
53
74
|
appsTitle: "Trocar de produto",
|
|
@@ -57,25 +78,25 @@ var h = l__namespace.createElement, Z = {
|
|
|
57
78
|
currentBadge: "Atual",
|
|
58
79
|
emptyProducts: "Nenhum outro produto dispon\xEDvel."
|
|
59
80
|
};
|
|
60
|
-
async function
|
|
61
|
-
let t =
|
|
62
|
-
if (!
|
|
63
|
-
let
|
|
81
|
+
async function W(e) {
|
|
82
|
+
let t = await M(e);
|
|
83
|
+
if (!t) return null;
|
|
84
|
+
let i = e.config, n = (i.baseUrl ?? O).replace(/\/+$/, ""), s = i.fetch ?? globalThis.fetch, c = `${n}/api/sdk/v1/account/bar`;
|
|
64
85
|
try {
|
|
65
|
-
let o = await c
|
|
66
|
-
headers: { authorization: `Bearer ${
|
|
86
|
+
let o = await s(c, {
|
|
87
|
+
headers: { authorization: `Bearer ${t}`, accept: "application/json" }
|
|
67
88
|
});
|
|
68
89
|
if (!o.ok) return null;
|
|
69
|
-
let
|
|
70
|
-
return !
|
|
90
|
+
let r = await o.json();
|
|
91
|
+
return !r || typeof r != "object" || !r.account ? null : {
|
|
71
92
|
account: {
|
|
72
|
-
displayName: String(
|
|
73
|
-
email: String(
|
|
74
|
-
photoUrl:
|
|
93
|
+
displayName: String(r.account.displayName ?? ""),
|
|
94
|
+
email: String(r.account.email ?? ""),
|
|
95
|
+
photoUrl: r.account.photoUrl ?? null
|
|
75
96
|
},
|
|
76
|
-
accountUrl: String(
|
|
77
|
-
products: Array.isArray(
|
|
78
|
-
(
|
|
97
|
+
accountUrl: String(r.accountUrl ?? "https://minhaconta.neetru.com"),
|
|
98
|
+
products: Array.isArray(r.products) ? r.products.filter(
|
|
99
|
+
(b) => !!b && typeof b.slug == "string" && typeof b.url == "string"
|
|
79
100
|
) : []
|
|
80
101
|
};
|
|
81
102
|
} catch {
|
|
@@ -88,23 +109,23 @@ function N(e) {
|
|
|
88
109
|
let i = t.includes("@") ? t.split("@")[0] : t, n = i.split(/[\s._-]+/).filter(Boolean);
|
|
89
110
|
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();
|
|
90
111
|
}
|
|
91
|
-
var
|
|
112
|
+
var h = {
|
|
92
113
|
bg: "#ffffff",
|
|
93
114
|
bgHover: "#f5f5f5",
|
|
94
115
|
fg: "#0a0a0a",
|
|
95
116
|
muted: "#666666",
|
|
96
117
|
border: "#0a0a0a",
|
|
97
118
|
borderSoft: "#e5e5e5"
|
|
98
|
-
},
|
|
99
|
-
function
|
|
100
|
-
let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((
|
|
101
|
-
return
|
|
119
|
+
}, H = 0;
|
|
120
|
+
function re({ size: e = 18, color: t = h.fg }) {
|
|
121
|
+
let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((o) => ({ r: c, c: o }))), n = e / 3, s = Math.max(2, e / 7);
|
|
122
|
+
return y(
|
|
102
123
|
"svg",
|
|
103
124
|
{ width: e, height: e, viewBox: `0 0 ${e} ${e}`, "aria-hidden": true, style: { display: "block" } },
|
|
104
125
|
i.map(
|
|
105
|
-
({ r: c, c:
|
|
106
|
-
key: `${c}-${
|
|
107
|
-
x:
|
|
126
|
+
({ r: c, c: o }) => y("rect", {
|
|
127
|
+
key: `${c}-${o}`,
|
|
128
|
+
x: o * n + (n - s) / 2,
|
|
108
129
|
y: c * n + (n - s) / 2,
|
|
109
130
|
width: s,
|
|
110
131
|
height: s,
|
|
@@ -113,23 +134,23 @@ function ee({ size: e = 18, color: t = b.fg }) {
|
|
|
113
134
|
)
|
|
114
135
|
);
|
|
115
136
|
}
|
|
116
|
-
function
|
|
137
|
+
function Q(e) {
|
|
117
138
|
return e ? Array.from(
|
|
118
139
|
e.querySelectorAll(
|
|
119
140
|
'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
120
141
|
)
|
|
121
142
|
).filter((t) => t.offsetParent !== null || t === document.activeElement) : [];
|
|
122
143
|
}
|
|
123
|
-
function
|
|
144
|
+
function oe({
|
|
124
145
|
client: e,
|
|
125
146
|
currentProductSlug: t,
|
|
126
147
|
settingsUrl: i,
|
|
127
148
|
onSignOut: n,
|
|
128
149
|
fetchBar: s,
|
|
129
150
|
labels: c,
|
|
130
|
-
className:
|
|
151
|
+
className: o
|
|
131
152
|
}) {
|
|
132
|
-
let
|
|
153
|
+
let r = { ...ne, ...c }, b = l__namespace.useMemo(() => {
|
|
133
154
|
try {
|
|
134
155
|
let a = e.auth.getUser();
|
|
135
156
|
return a ? {
|
|
@@ -140,58 +161,58 @@ function te({
|
|
|
140
161
|
} catch {
|
|
141
162
|
return null;
|
|
142
163
|
}
|
|
143
|
-
}, [e]), [u,
|
|
164
|
+
}, [e]), [u, f] = l__namespace.useState(null), [m, w] = l__namespace.useState(null), [T, R] = l__namespace.useState(false), p = l__namespace.useRef(null), d = l__namespace.useRef(null), g = l__namespace.useRef(null), C = l__namespace.useRef(null);
|
|
144
165
|
l__namespace.useEffect(() => {
|
|
145
|
-
let a = false, k = s ??
|
|
146
|
-
return Promise.resolve(k(e)).then((
|
|
147
|
-
!a &&
|
|
166
|
+
let a = false, k = s ?? W;
|
|
167
|
+
return Promise.resolve(k(e)).then((S) => {
|
|
168
|
+
!a && S && f(S);
|
|
148
169
|
}).catch(() => {
|
|
149
170
|
}), () => {
|
|
150
171
|
a = true;
|
|
151
172
|
};
|
|
152
173
|
}, [e, s]);
|
|
153
|
-
let
|
|
154
|
-
|
|
174
|
+
let v = u?.account ?? b, G = u?.accountUrl ?? "https://minhaconta.neetru.com", A = u?.products ?? [], L = l__namespace.useCallback((a) => {
|
|
175
|
+
w(null), (a === "apps" ? g.current : d.current)?.focus();
|
|
155
176
|
}, []);
|
|
156
177
|
l__namespace.useEffect(() => {
|
|
157
|
-
if (!
|
|
158
|
-
|
|
159
|
-
let k = (
|
|
160
|
-
p.current && !p.current.contains(
|
|
178
|
+
if (!m) return;
|
|
179
|
+
Q(C.current)[0]?.focus();
|
|
180
|
+
let k = (S) => {
|
|
181
|
+
p.current && !p.current.contains(S.target) && w(null);
|
|
161
182
|
};
|
|
162
183
|
return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
|
|
163
|
-
}, [
|
|
184
|
+
}, [m]);
|
|
164
185
|
let P = l__namespace.useCallback(
|
|
165
186
|
(a) => {
|
|
166
187
|
if (a.key === "Escape") {
|
|
167
|
-
a.stopPropagation(), L(
|
|
188
|
+
a.stopPropagation(), L(m);
|
|
168
189
|
return;
|
|
169
190
|
}
|
|
170
|
-
let k =
|
|
191
|
+
let k = Q(C.current);
|
|
171
192
|
if (k.length === 0) return;
|
|
172
|
-
let
|
|
173
|
-
a.key === "Tab" ? a.shiftKey &&
|
|
193
|
+
let S = k.indexOf(document.activeElement);
|
|
194
|
+
a.key === "Tab" ? a.shiftKey && S <= 0 ? (a.preventDefault(), k[k.length - 1].focus()) : !a.shiftKey && S === k.length - 1 && (a.preventDefault(), k[0].focus()) : a.key === "ArrowDown" ? (a.preventDefault(), k[(S + 1) % k.length].focus()) : a.key === "ArrowUp" && (a.preventDefault(), k[(S - 1 + k.length) % k.length].focus());
|
|
174
195
|
},
|
|
175
|
-
[
|
|
176
|
-
),
|
|
196
|
+
[m, L]
|
|
197
|
+
), K = l__namespace.useCallback(async () => {
|
|
177
198
|
if (!T) {
|
|
178
199
|
R(true);
|
|
179
200
|
try {
|
|
180
201
|
await e.auth.signOut();
|
|
181
202
|
} catch {
|
|
182
203
|
} finally {
|
|
183
|
-
R(false),
|
|
204
|
+
R(false), w(null), n?.();
|
|
184
205
|
}
|
|
185
206
|
}
|
|
186
207
|
}, [e, T, n]);
|
|
187
|
-
if (!
|
|
188
|
-
let I = N(
|
|
189
|
-
src:
|
|
208
|
+
if (!v) return null;
|
|
209
|
+
let I = N(v.displayName || v.email), V = v.photoUrl ? y("img", {
|
|
210
|
+
src: v.photoUrl,
|
|
190
211
|
alt: "",
|
|
191
212
|
width: 32,
|
|
192
213
|
height: 32,
|
|
193
214
|
style: { width: 32, height: 32, objectFit: "cover", display: "block" }
|
|
194
|
-
}) :
|
|
215
|
+
}) : y(
|
|
195
216
|
"span",
|
|
196
217
|
{
|
|
197
218
|
"aria-hidden": true,
|
|
@@ -201,7 +222,7 @@ function te({
|
|
|
201
222
|
display: "inline-flex",
|
|
202
223
|
alignItems: "center",
|
|
203
224
|
justifyContent: "center",
|
|
204
|
-
backgroundColor:
|
|
225
|
+
backgroundColor: h.fg,
|
|
205
226
|
color: "#ffffff",
|
|
206
227
|
fontSize: 13,
|
|
207
228
|
fontWeight: 700,
|
|
@@ -216,51 +237,51 @@ function te({
|
|
|
216
237
|
width: 36,
|
|
217
238
|
height: 36,
|
|
218
239
|
padding: 0,
|
|
219
|
-
borderRadius:
|
|
220
|
-
border: `1px solid ${a ?
|
|
221
|
-
backgroundColor: a ?
|
|
222
|
-
color:
|
|
240
|
+
borderRadius: H,
|
|
241
|
+
border: `1px solid ${a ? h.border : h.borderSoft}`,
|
|
242
|
+
backgroundColor: a ? h.bgHover : h.bg,
|
|
243
|
+
color: h.fg,
|
|
223
244
|
cursor: "pointer",
|
|
224
245
|
boxSizing: "border-box",
|
|
225
246
|
fontFamily: "inherit",
|
|
226
247
|
overflow: "hidden"
|
|
227
|
-
}),
|
|
248
|
+
}), J = y(
|
|
228
249
|
"button",
|
|
229
250
|
{
|
|
230
251
|
type: "button",
|
|
231
252
|
ref: g,
|
|
232
|
-
"aria-label":
|
|
253
|
+
"aria-label": r.appsButton,
|
|
233
254
|
"aria-haspopup": "menu",
|
|
234
|
-
"aria-expanded":
|
|
255
|
+
"aria-expanded": m === "apps",
|
|
235
256
|
"data-neetru-appswitcher-button": "true",
|
|
236
|
-
onClick: () =>
|
|
237
|
-
style: B(
|
|
257
|
+
onClick: () => w((a) => a === "apps" ? null : "apps"),
|
|
258
|
+
style: B(m === "apps")
|
|
238
259
|
},
|
|
239
|
-
|
|
240
|
-
),
|
|
260
|
+
y(re, {})
|
|
261
|
+
), X = y(
|
|
241
262
|
"button",
|
|
242
263
|
{
|
|
243
264
|
type: "button",
|
|
244
265
|
ref: d,
|
|
245
|
-
"aria-label": `${
|
|
266
|
+
"aria-label": `${r.accountButton}${v.displayName ? ` (${v.displayName})` : ""}`,
|
|
246
267
|
"aria-haspopup": "menu",
|
|
247
|
-
"aria-expanded":
|
|
268
|
+
"aria-expanded": m === "account",
|
|
248
269
|
"data-neetru-account-button": "true",
|
|
249
|
-
onClick: () =>
|
|
250
|
-
style: { ...B(
|
|
270
|
+
onClick: () => w((a) => a === "account" ? null : "account"),
|
|
271
|
+
style: { ...B(m === "account"), width: 36, height: 36 }
|
|
251
272
|
},
|
|
252
|
-
|
|
273
|
+
V
|
|
253
274
|
), F = {
|
|
254
275
|
position: "absolute",
|
|
255
276
|
top: "calc(100% + 6px)",
|
|
256
277
|
right: 0,
|
|
257
278
|
minWidth: 260,
|
|
258
279
|
maxWidth: 320,
|
|
259
|
-
backgroundColor:
|
|
260
|
-
border: `1px solid ${
|
|
261
|
-
borderRadius:
|
|
280
|
+
backgroundColor: h.bg,
|
|
281
|
+
border: `1px solid ${h.border}`,
|
|
282
|
+
borderRadius: H,
|
|
262
283
|
zIndex: 1e3,
|
|
263
|
-
color:
|
|
284
|
+
color: h.fg,
|
|
264
285
|
fontFamily: "inherit"
|
|
265
286
|
// BMW: sem sombra/glassmorphism — borda sólida define o recorte.
|
|
266
287
|
}, D = {
|
|
@@ -271,8 +292,8 @@ function te({
|
|
|
271
292
|
padding: "10px 14px",
|
|
272
293
|
background: "transparent",
|
|
273
294
|
border: "none",
|
|
274
|
-
borderTop: `1px solid ${
|
|
275
|
-
color:
|
|
295
|
+
borderTop: `1px solid ${h.borderSoft}`,
|
|
296
|
+
color: h.fg,
|
|
276
297
|
fontSize: 14,
|
|
277
298
|
fontWeight: 400,
|
|
278
299
|
textAlign: "left",
|
|
@@ -282,26 +303,26 @@ function te({
|
|
|
282
303
|
fontFamily: "inherit"
|
|
283
304
|
}, _ = {
|
|
284
305
|
onMouseEnter: (a) => {
|
|
285
|
-
a.currentTarget.style.backgroundColor =
|
|
306
|
+
a.currentTarget.style.backgroundColor = h.bgHover;
|
|
286
307
|
},
|
|
287
308
|
onMouseLeave: (a) => {
|
|
288
309
|
a.currentTarget.style.backgroundColor = "transparent";
|
|
289
310
|
}
|
|
290
|
-
},
|
|
311
|
+
}, Y = m === "account" ? y(
|
|
291
312
|
"div",
|
|
292
313
|
{
|
|
293
|
-
ref:
|
|
314
|
+
ref: C,
|
|
294
315
|
role: "menu",
|
|
295
|
-
"aria-label":
|
|
316
|
+
"aria-label": r.accountButton,
|
|
296
317
|
"data-neetru-account-menu": "true",
|
|
297
318
|
onKeyDown: P,
|
|
298
319
|
style: F
|
|
299
320
|
},
|
|
300
321
|
// Header identidade
|
|
301
|
-
|
|
322
|
+
y(
|
|
302
323
|
"div",
|
|
303
324
|
{ style: { display: "flex", gap: 12, alignItems: "center", padding: 14 } },
|
|
304
|
-
|
|
325
|
+
y(
|
|
305
326
|
"span",
|
|
306
327
|
{
|
|
307
328
|
"aria-hidden": true,
|
|
@@ -313,24 +334,24 @@ function te({
|
|
|
313
334
|
alignItems: "center",
|
|
314
335
|
justifyContent: "center",
|
|
315
336
|
overflow: "hidden",
|
|
316
|
-
backgroundColor:
|
|
337
|
+
backgroundColor: v.photoUrl ? "transparent" : h.fg,
|
|
317
338
|
color: "#ffffff",
|
|
318
339
|
fontSize: 15,
|
|
319
340
|
fontWeight: 700
|
|
320
341
|
}
|
|
321
342
|
},
|
|
322
|
-
|
|
323
|
-
src:
|
|
343
|
+
v.photoUrl ? y("img", {
|
|
344
|
+
src: v.photoUrl,
|
|
324
345
|
alt: "",
|
|
325
346
|
width: 40,
|
|
326
347
|
height: 40,
|
|
327
348
|
style: { width: 40, height: 40, objectFit: "cover", display: "block" }
|
|
328
349
|
}) : I
|
|
329
350
|
),
|
|
330
|
-
|
|
351
|
+
y(
|
|
331
352
|
"span",
|
|
332
353
|
{ style: { display: "flex", flexDirection: "column", minWidth: 0 } },
|
|
333
|
-
|
|
354
|
+
y(
|
|
334
355
|
"span",
|
|
335
356
|
{
|
|
336
357
|
style: {
|
|
@@ -341,67 +362,67 @@ function te({
|
|
|
341
362
|
textOverflow: "ellipsis"
|
|
342
363
|
}
|
|
343
364
|
},
|
|
344
|
-
|
|
365
|
+
v.displayName || v.email
|
|
345
366
|
),
|
|
346
|
-
|
|
367
|
+
v.email ? y(
|
|
347
368
|
"span",
|
|
348
369
|
{
|
|
349
370
|
style: {
|
|
350
|
-
color:
|
|
371
|
+
color: h.muted,
|
|
351
372
|
fontSize: 12,
|
|
352
373
|
whiteSpace: "nowrap",
|
|
353
374
|
overflow: "hidden",
|
|
354
375
|
textOverflow: "ellipsis"
|
|
355
376
|
}
|
|
356
377
|
},
|
|
357
|
-
|
|
378
|
+
v.email
|
|
358
379
|
) : null
|
|
359
380
|
)
|
|
360
381
|
),
|
|
361
382
|
// Minha conta Neetru
|
|
362
|
-
|
|
383
|
+
y(
|
|
363
384
|
"a",
|
|
364
385
|
{
|
|
365
386
|
role: "menuitem",
|
|
366
|
-
href:
|
|
387
|
+
href: G,
|
|
367
388
|
target: "_blank",
|
|
368
389
|
rel: "noopener noreferrer",
|
|
369
390
|
style: D,
|
|
370
391
|
..._
|
|
371
392
|
},
|
|
372
|
-
|
|
393
|
+
r.myAccount
|
|
373
394
|
),
|
|
374
395
|
// Configurações da conta (deste produto)
|
|
375
|
-
i ?
|
|
396
|
+
i ? y(
|
|
376
397
|
"a",
|
|
377
398
|
{ role: "menuitem", href: i, style: D, ..._ },
|
|
378
|
-
|
|
399
|
+
r.accountSettings
|
|
379
400
|
) : null,
|
|
380
401
|
// Sair
|
|
381
|
-
|
|
402
|
+
y(
|
|
382
403
|
"button",
|
|
383
404
|
{
|
|
384
405
|
type: "button",
|
|
385
406
|
role: "menuitem",
|
|
386
|
-
onClick:
|
|
407
|
+
onClick: K,
|
|
387
408
|
disabled: T,
|
|
388
409
|
"data-neetru-signout": "true",
|
|
389
410
|
style: { ...D, cursor: T ? "not-allowed" : "pointer" },
|
|
390
411
|
..._
|
|
391
412
|
},
|
|
392
|
-
T ? `${
|
|
413
|
+
T ? `${r.signOut}\u2026` : r.signOut
|
|
393
414
|
)
|
|
394
|
-
) : null,
|
|
415
|
+
) : null, Z = m === "apps" ? y(
|
|
395
416
|
"div",
|
|
396
417
|
{
|
|
397
|
-
ref:
|
|
418
|
+
ref: C,
|
|
398
419
|
role: "menu",
|
|
399
|
-
"aria-label":
|
|
420
|
+
"aria-label": r.appsTitle,
|
|
400
421
|
"data-neetru-appswitcher-menu": "true",
|
|
401
422
|
onKeyDown: P,
|
|
402
423
|
style: { ...F, minWidth: 280 }
|
|
403
424
|
},
|
|
404
|
-
|
|
425
|
+
y(
|
|
405
426
|
"div",
|
|
406
427
|
{
|
|
407
428
|
style: {
|
|
@@ -410,16 +431,16 @@ function te({
|
|
|
410
431
|
fontWeight: 700,
|
|
411
432
|
letterSpacing: "0.08em",
|
|
412
433
|
textTransform: "uppercase",
|
|
413
|
-
color:
|
|
434
|
+
color: h.muted
|
|
414
435
|
}
|
|
415
436
|
},
|
|
416
|
-
|
|
437
|
+
r.appsTitle
|
|
417
438
|
),
|
|
418
|
-
|
|
439
|
+
A.length === 0 ? y(
|
|
419
440
|
"div",
|
|
420
|
-
{ style: { padding: "4px 14px 16px", fontSize: 13, color:
|
|
421
|
-
|
|
422
|
-
) :
|
|
441
|
+
{ style: { padding: "4px 14px 16px", fontSize: 13, color: h.muted } },
|
|
442
|
+
r.emptyProducts
|
|
443
|
+
) : y(
|
|
423
444
|
"div",
|
|
424
445
|
{
|
|
425
446
|
style: {
|
|
@@ -427,12 +448,12 @@ function te({
|
|
|
427
448
|
gridTemplateColumns: "1fr 1fr",
|
|
428
449
|
gap: 1,
|
|
429
450
|
padding: 1,
|
|
430
|
-
backgroundColor:
|
|
451
|
+
backgroundColor: h.borderSoft
|
|
431
452
|
}
|
|
432
453
|
},
|
|
433
|
-
|
|
454
|
+
A.map((a) => {
|
|
434
455
|
let k = !!t && a.slug === t;
|
|
435
|
-
return
|
|
456
|
+
return y(
|
|
436
457
|
"a",
|
|
437
458
|
{
|
|
438
459
|
key: a.slug,
|
|
@@ -449,26 +470,26 @@ function te({
|
|
|
449
470
|
gap: 6,
|
|
450
471
|
padding: "14px 8px",
|
|
451
472
|
textDecoration: "none",
|
|
452
|
-
color:
|
|
453
|
-
backgroundColor: k ?
|
|
473
|
+
color: h.fg,
|
|
474
|
+
backgroundColor: k ? h.bgHover : h.bg,
|
|
454
475
|
cursor: "pointer",
|
|
455
476
|
boxSizing: "border-box"
|
|
456
477
|
},
|
|
457
|
-
onMouseEnter: (
|
|
458
|
-
|
|
478
|
+
onMouseEnter: (S) => {
|
|
479
|
+
S.currentTarget.style.backgroundColor = h.bgHover;
|
|
459
480
|
},
|
|
460
|
-
onMouseLeave: (
|
|
461
|
-
|
|
481
|
+
onMouseLeave: (S) => {
|
|
482
|
+
S.currentTarget.style.backgroundColor = k ? h.bgHover : h.bg;
|
|
462
483
|
}
|
|
463
484
|
},
|
|
464
485
|
// Tile/ícone
|
|
465
|
-
a.iconUrl ?
|
|
486
|
+
a.iconUrl ? y("img", {
|
|
466
487
|
src: a.iconUrl,
|
|
467
488
|
alt: "",
|
|
468
489
|
width: 32,
|
|
469
490
|
height: 32,
|
|
470
491
|
style: { width: 32, height: 32, objectFit: "cover", display: "block" }
|
|
471
|
-
}) :
|
|
492
|
+
}) : y(
|
|
472
493
|
"span",
|
|
473
494
|
{
|
|
474
495
|
"aria-hidden": true,
|
|
@@ -478,7 +499,7 @@ function te({
|
|
|
478
499
|
display: "inline-flex",
|
|
479
500
|
alignItems: "center",
|
|
480
501
|
justifyContent: "center",
|
|
481
|
-
backgroundColor:
|
|
502
|
+
backgroundColor: h.fg,
|
|
482
503
|
color: "#ffffff",
|
|
483
504
|
fontSize: 13,
|
|
484
505
|
fontWeight: 700
|
|
@@ -486,7 +507,7 @@ function te({
|
|
|
486
507
|
},
|
|
487
508
|
N(a.name)
|
|
488
509
|
),
|
|
489
|
-
|
|
510
|
+
y(
|
|
490
511
|
"span",
|
|
491
512
|
{
|
|
492
513
|
style: {
|
|
@@ -503,7 +524,7 @@ function te({
|
|
|
503
524
|
},
|
|
504
525
|
a.name
|
|
505
526
|
),
|
|
506
|
-
k ?
|
|
527
|
+
k ? y(
|
|
507
528
|
"span",
|
|
508
529
|
{
|
|
509
530
|
style: {
|
|
@@ -511,20 +532,20 @@ function te({
|
|
|
511
532
|
fontWeight: 700,
|
|
512
533
|
letterSpacing: "0.08em",
|
|
513
534
|
textTransform: "uppercase",
|
|
514
|
-
color:
|
|
535
|
+
color: h.muted
|
|
515
536
|
}
|
|
516
537
|
},
|
|
517
|
-
|
|
538
|
+
r.currentBadge
|
|
518
539
|
) : null
|
|
519
540
|
);
|
|
520
541
|
})
|
|
521
542
|
)
|
|
522
543
|
) : null;
|
|
523
|
-
return
|
|
544
|
+
return y(
|
|
524
545
|
"div",
|
|
525
546
|
{
|
|
526
547
|
ref: p,
|
|
527
|
-
className:
|
|
548
|
+
className: o,
|
|
528
549
|
"data-neetru-account-bar": "true",
|
|
529
550
|
style: {
|
|
530
551
|
position: "relative",
|
|
@@ -536,30 +557,30 @@ function te({
|
|
|
536
557
|
fontFamily: "inherit"
|
|
537
558
|
}
|
|
538
559
|
},
|
|
539
|
-
V,
|
|
540
560
|
J,
|
|
541
561
|
X,
|
|
542
|
-
Y
|
|
562
|
+
Y,
|
|
563
|
+
Z
|
|
543
564
|
);
|
|
544
565
|
}
|
|
545
566
|
|
|
546
567
|
// src/firestore-compat.ts
|
|
547
|
-
function
|
|
568
|
+
function U(e) {
|
|
548
569
|
let t = [], i, n;
|
|
549
570
|
for (let c of e)
|
|
550
571
|
if (c.__constraint === "where") {
|
|
551
|
-
let
|
|
552
|
-
t.push({ field:
|
|
572
|
+
let o = c;
|
|
573
|
+
t.push({ field: o.field, op: o.op, value: o.value });
|
|
553
574
|
} else if (c.__constraint === "orderBy") {
|
|
554
|
-
let
|
|
555
|
-
i = { field:
|
|
575
|
+
let o = c;
|
|
576
|
+
i = { field: o.field, direction: o.direction };
|
|
556
577
|
} else c.__constraint === "limit" && (n = c.value);
|
|
557
578
|
let s = {};
|
|
558
579
|
return t.length > 0 && (s.where = t), i && (s.orderBy = i), n !== void 0 && (s.limit = n), s;
|
|
559
580
|
}
|
|
560
581
|
|
|
561
582
|
// src/react.ts
|
|
562
|
-
async function
|
|
583
|
+
async function ie(e, t) {
|
|
563
584
|
let i = await fetch(e, {
|
|
564
585
|
method: "POST",
|
|
565
586
|
headers: { "content-type": "application/json", accept: "application/json" },
|
|
@@ -572,9 +593,9 @@ async function ne(e, t) {
|
|
|
572
593
|
n = null;
|
|
573
594
|
}
|
|
574
595
|
if (!i.ok) {
|
|
575
|
-
let
|
|
596
|
+
let o = n, r = o?.error, b = (r && typeof r == "object" && typeof r.code == "string" ? r.code : void 0) ?? "server_error", u = o && (typeof o.error == "object" && o.error?.message || typeof o.error == "string" && o.error || typeof o.message == "string" && o.message) || `Checkout BFF respondeu HTTP ${i.status}`;
|
|
576
597
|
throw new E(
|
|
577
|
-
|
|
598
|
+
b,
|
|
578
599
|
typeof u == "string" ? u : `Checkout BFF respondeu HTTP ${i.status}`,
|
|
579
600
|
i.status
|
|
580
601
|
);
|
|
@@ -593,38 +614,38 @@ async function ne(e, t) {
|
|
|
593
614
|
requiresKyc: n?.requiresKyc === true || s.requiresKyc === true
|
|
594
615
|
};
|
|
595
616
|
}
|
|
596
|
-
function
|
|
617
|
+
function se(e) {
|
|
597
618
|
let t = globalThis.location;
|
|
598
619
|
t && typeof t.assign == "function" && t.assign(e);
|
|
599
620
|
}
|
|
600
|
-
function
|
|
621
|
+
function Ee({
|
|
601
622
|
client: e,
|
|
602
623
|
startPath: t,
|
|
603
624
|
productId: i,
|
|
604
625
|
planId: n,
|
|
605
626
|
callbackUrl: s,
|
|
606
627
|
tenantType: c,
|
|
607
|
-
tenantId:
|
|
608
|
-
children:
|
|
609
|
-
onIntentCreated:
|
|
628
|
+
tenantId: o,
|
|
629
|
+
children: r,
|
|
630
|
+
onIntentCreated: b,
|
|
610
631
|
onError: u,
|
|
611
|
-
noAutoRedirect:
|
|
612
|
-
...
|
|
632
|
+
noAutoRedirect: f,
|
|
633
|
+
...m
|
|
613
634
|
}) {
|
|
614
|
-
let [
|
|
635
|
+
let [w, T] = l__namespace.useState(false), R = e?.checkout, p = l__namespace.useCallback(
|
|
615
636
|
async (d) => {
|
|
616
|
-
if (d.preventDefault(), !
|
|
637
|
+
if (d.preventDefault(), !w) {
|
|
617
638
|
if (t) {
|
|
618
639
|
T(true);
|
|
619
640
|
try {
|
|
620
|
-
let g = await
|
|
641
|
+
let g = await ie(t, {
|
|
621
642
|
productId: i,
|
|
622
643
|
planId: n,
|
|
623
644
|
callbackUrl: s,
|
|
624
645
|
tenantType: c,
|
|
625
|
-
tenantId:
|
|
646
|
+
tenantId: o
|
|
626
647
|
});
|
|
627
|
-
|
|
648
|
+
b?.(g), f || se(g.redirectUrl);
|
|
628
649
|
} catch (g) {
|
|
629
650
|
u?.(g instanceof Error ? g : new Error(String(g)));
|
|
630
651
|
} finally {
|
|
@@ -647,10 +668,10 @@ function xe({
|
|
|
647
668
|
planId: n,
|
|
648
669
|
callbackUrl: s,
|
|
649
670
|
tenantType: c,
|
|
650
|
-
tenantId:
|
|
651
|
-
autoRedirect: !
|
|
671
|
+
tenantId: o,
|
|
672
|
+
autoRedirect: !f
|
|
652
673
|
});
|
|
653
|
-
|
|
674
|
+
b?.(g);
|
|
654
675
|
} catch (g) {
|
|
655
676
|
u?.(g instanceof Error ? g : new Error(String(g)));
|
|
656
677
|
} finally {
|
|
@@ -658,72 +679,72 @@ function xe({
|
|
|
658
679
|
}
|
|
659
680
|
}
|
|
660
681
|
},
|
|
661
|
-
[
|
|
682
|
+
[w, R, t, i, n, s, c, o, f, b, u]
|
|
662
683
|
);
|
|
663
684
|
return l__namespace.createElement(
|
|
664
685
|
"a",
|
|
665
686
|
{
|
|
666
|
-
...
|
|
667
|
-
href:
|
|
687
|
+
...m,
|
|
688
|
+
href: m.href ?? "#",
|
|
668
689
|
onClick: p,
|
|
669
|
-
"aria-busy":
|
|
690
|
+
"aria-busy": w || void 0,
|
|
670
691
|
"data-neetru-checkout-link": "true"
|
|
671
692
|
},
|
|
672
|
-
|
|
693
|
+
r
|
|
673
694
|
);
|
|
674
695
|
}
|
|
675
|
-
var
|
|
676
|
-
function
|
|
696
|
+
var ae = "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", ce = "0 0 527 760", le = 527 / 760;
|
|
697
|
+
function ue({ fill: e, size: t = 16 }) {
|
|
677
698
|
return l__namespace.createElement(
|
|
678
699
|
"svg",
|
|
679
700
|
{
|
|
680
|
-
viewBox:
|
|
681
|
-
width: Math.round(t *
|
|
701
|
+
viewBox: ce,
|
|
702
|
+
width: Math.round(t * le),
|
|
682
703
|
height: t,
|
|
683
704
|
"aria-hidden": true,
|
|
684
705
|
style: { flexShrink: 0 }
|
|
685
706
|
},
|
|
686
|
-
l__namespace.createElement("path", { d:
|
|
707
|
+
l__namespace.createElement("path", { d: ae, fill: e })
|
|
687
708
|
);
|
|
688
709
|
}
|
|
689
|
-
var
|
|
710
|
+
var de = {
|
|
690
711
|
dark: { bg: "#0a0a0a", bgHover: "#1a1a1a", fg: "#ffffff", border: "#0a0a0a" },
|
|
691
712
|
light: { bg: "#ffffff", bgHover: "#f5f5f5", fg: "#0a0a0a", border: "#0a0a0a" }
|
|
692
|
-
},
|
|
693
|
-
function
|
|
694
|
-
if (typeof document > "u" || !document.head || document.getElementById(
|
|
713
|
+
}, j = "neetru-login-button-focus-style", pe = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
|
|
714
|
+
function ge() {
|
|
715
|
+
if (typeof document > "u" || !document.head || document.getElementById(j)) return;
|
|
695
716
|
let e = document.createElement("style");
|
|
696
|
-
e.id =
|
|
717
|
+
e.id = j, e.textContent = pe, document.head.appendChild(e);
|
|
697
718
|
}
|
|
698
|
-
function
|
|
719
|
+
function De({
|
|
699
720
|
client: e,
|
|
700
721
|
redirectUri: t,
|
|
701
722
|
scope: i,
|
|
702
723
|
postLoginRedirect: n,
|
|
703
724
|
theme: s = "dark",
|
|
704
725
|
label: c = "Entrar com Neetru",
|
|
705
|
-
onError:
|
|
706
|
-
style:
|
|
707
|
-
disabled:
|
|
726
|
+
onError: o,
|
|
727
|
+
style: r,
|
|
728
|
+
disabled: b,
|
|
708
729
|
...u
|
|
709
730
|
}) {
|
|
710
|
-
let [
|
|
731
|
+
let [f, m] = l__namespace.useState(false), [w, T] = l__namespace.useState(false), R = de[s], p = !!b || f;
|
|
711
732
|
l__namespace.useEffect(() => {
|
|
712
|
-
|
|
733
|
+
ge();
|
|
713
734
|
}, []);
|
|
714
735
|
let d = l__namespace.useCallback(async () => {
|
|
715
736
|
if (!p) {
|
|
716
|
-
|
|
737
|
+
m(true);
|
|
717
738
|
try {
|
|
718
739
|
let g = { redirectUri: t, scope: i, postLoginRedirect: n };
|
|
719
740
|
await e.auth.signIn(g);
|
|
720
741
|
} catch (g) {
|
|
721
|
-
|
|
742
|
+
o?.(g instanceof Error ? g : new Error(String(g)));
|
|
722
743
|
} finally {
|
|
723
|
-
|
|
744
|
+
m(false);
|
|
724
745
|
}
|
|
725
746
|
}
|
|
726
|
-
}, [e, t, i, n, p,
|
|
747
|
+
}, [e, t, i, n, p, o]);
|
|
727
748
|
return l__namespace.createElement(
|
|
728
749
|
"button",
|
|
729
750
|
{
|
|
@@ -734,7 +755,7 @@ function we({
|
|
|
734
755
|
onMouseEnter: () => T(true),
|
|
735
756
|
onMouseLeave: () => T(false),
|
|
736
757
|
"aria-label": u["aria-label"] ?? c,
|
|
737
|
-
"aria-busy":
|
|
758
|
+
"aria-busy": f || void 0,
|
|
738
759
|
"data-neetru-login-button": "true",
|
|
739
760
|
style: {
|
|
740
761
|
display: "inline-flex",
|
|
@@ -746,7 +767,7 @@ function we({
|
|
|
746
767
|
padding: "0 20px",
|
|
747
768
|
borderRadius: 0,
|
|
748
769
|
border: `1px solid ${R.border}`,
|
|
749
|
-
backgroundColor:
|
|
770
|
+
backgroundColor: w && !p ? R.bgHover : R.bg,
|
|
750
771
|
color: R.fg,
|
|
751
772
|
fontSize: "14px",
|
|
752
773
|
fontWeight: 700,
|
|
@@ -755,132 +776,132 @@ function we({
|
|
|
755
776
|
fontFamily: "inherit",
|
|
756
777
|
lineHeight: 1,
|
|
757
778
|
cursor: p ? "not-allowed" : "pointer",
|
|
758
|
-
opacity: p && !
|
|
779
|
+
opacity: p && !f ? 0.6 : 1,
|
|
759
780
|
transition: "background-color 150ms ease",
|
|
760
781
|
boxSizing: "border-box",
|
|
761
782
|
// Cor do ring de foco de teclado (:focus-visible) — ver
|
|
762
783
|
// NEETRU_LOGIN_FOCUS_CSS. Usa a cor do texto (contraste AA garantido).
|
|
763
784
|
"--neetru-login-focus-ring": R.fg,
|
|
764
|
-
...
|
|
785
|
+
...r
|
|
765
786
|
}
|
|
766
787
|
},
|
|
767
|
-
l__namespace.createElement(
|
|
768
|
-
l__namespace.createElement("span", null,
|
|
788
|
+
l__namespace.createElement(ue, { fill: R.fg }),
|
|
789
|
+
l__namespace.createElement("span", null, f ? "Entrando\u2026" : c)
|
|
769
790
|
);
|
|
770
791
|
}
|
|
771
|
-
var
|
|
792
|
+
var $ = l__namespace.createContext({
|
|
772
793
|
readonly: false
|
|
773
794
|
});
|
|
774
|
-
function
|
|
775
|
-
return l__namespace.useContext(
|
|
795
|
+
function _e() {
|
|
796
|
+
return l__namespace.useContext($);
|
|
776
797
|
}
|
|
777
|
-
function
|
|
798
|
+
function Ne({
|
|
778
799
|
client: e,
|
|
779
800
|
feature: t,
|
|
780
801
|
productSlug: i,
|
|
781
802
|
mode: n = "block",
|
|
782
803
|
fallback: s,
|
|
783
804
|
loading: c,
|
|
784
|
-
children:
|
|
805
|
+
children: o
|
|
785
806
|
}) {
|
|
786
|
-
let [
|
|
807
|
+
let [r, b] = l__namespace.useState({
|
|
787
808
|
status: "loading"
|
|
788
|
-
}), u = i ?? e.config.productId ?? "",
|
|
809
|
+
}), u = i ?? e.config.productId ?? "", f = e.config.tenantId;
|
|
789
810
|
if (l__namespace.useEffect(() => {
|
|
790
811
|
let R = false;
|
|
791
812
|
return (async () => {
|
|
792
813
|
try {
|
|
793
814
|
let d, g = e.usage;
|
|
794
|
-
if (g && typeof g.check == "function" &&
|
|
795
|
-
let
|
|
815
|
+
if (g && typeof g.check == "function" && f) {
|
|
816
|
+
let C = await g.check(t, {
|
|
796
817
|
productId: u,
|
|
797
|
-
tenantId:
|
|
818
|
+
tenantId: f
|
|
798
819
|
});
|
|
799
820
|
d = {
|
|
800
|
-
allowed:
|
|
801
|
-
reason:
|
|
802
|
-
limit:
|
|
803
|
-
currentUsage:
|
|
804
|
-
behavior:
|
|
821
|
+
allowed: C.allowed === !0,
|
|
822
|
+
reason: C.reason,
|
|
823
|
+
limit: C.limit,
|
|
824
|
+
currentUsage: C.currentUsage,
|
|
825
|
+
behavior: C.behavior
|
|
805
826
|
};
|
|
806
827
|
} else
|
|
807
828
|
typeof console < "u" && console.warn(
|
|
808
829
|
"[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)."
|
|
809
830
|
), d = { allowed: !1, reason: "tenant_id_required" };
|
|
810
|
-
R ||
|
|
831
|
+
R || b({ status: "ready", result: d });
|
|
811
832
|
} catch (d) {
|
|
812
|
-
R ||
|
|
833
|
+
R || b({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } }), typeof console < "u" && console.warn("[EntitlementGate] check failed \u2014 fail-open", d);
|
|
813
834
|
}
|
|
814
835
|
})(), () => {
|
|
815
836
|
R = true;
|
|
816
837
|
};
|
|
817
|
-
}, [e, t, u,
|
|
838
|
+
}, [e, t, u, f]), r.status === "loading")
|
|
818
839
|
return l__namespace.createElement(l__namespace.Fragment, null, c ?? null);
|
|
819
|
-
let
|
|
820
|
-
return !
|
|
821
|
-
|
|
840
|
+
let m = r.result, w = m?.allowed === true, T = !w && (n === "readonly" || m?.behavior === "readonly");
|
|
841
|
+
return !w && n === "block" && !T ? l__namespace.createElement(l__namespace.Fragment, null, s ?? null) : l__namespace.createElement(
|
|
842
|
+
$.Provider,
|
|
822
843
|
{
|
|
823
844
|
value: {
|
|
824
845
|
readonly: T,
|
|
825
|
-
reason:
|
|
826
|
-
limit:
|
|
827
|
-
currentUsage:
|
|
846
|
+
reason: m?.reason,
|
|
847
|
+
limit: m?.limit,
|
|
848
|
+
currentUsage: m?.currentUsage
|
|
828
849
|
}
|
|
829
850
|
},
|
|
830
|
-
|
|
851
|
+
o
|
|
831
852
|
);
|
|
832
853
|
}
|
|
833
|
-
var
|
|
834
|
-
function
|
|
854
|
+
var q = 5e3;
|
|
855
|
+
function z() {
|
|
835
856
|
return typeof document < "u" && document.hidden === true;
|
|
836
857
|
}
|
|
837
|
-
function
|
|
858
|
+
function fe(e) {
|
|
838
859
|
if (!e) return null;
|
|
839
860
|
if (e.__kind === "collection")
|
|
840
861
|
return `collection:${e.id}`;
|
|
841
|
-
let t =
|
|
862
|
+
let t = U(e.constraints);
|
|
842
863
|
return `query:${e.collection}:${JSON.stringify(t)}`;
|
|
843
864
|
}
|
|
844
|
-
function
|
|
865
|
+
function me(e) {
|
|
845
866
|
return e.docs.map((t) => {
|
|
846
867
|
let i = t.data, { id: n, ...s } = i;
|
|
847
868
|
return { ...s, id: t.id };
|
|
848
869
|
});
|
|
849
870
|
}
|
|
850
|
-
function
|
|
871
|
+
function ye(e, t) {
|
|
851
872
|
let i = e?.docs[0];
|
|
852
873
|
if (!i) return null;
|
|
853
874
|
let n = i.data, { id: s, ...c } = n;
|
|
854
875
|
return { ...c, id: t };
|
|
855
876
|
}
|
|
856
|
-
function
|
|
857
|
-
let i = t?.intervalMs ??
|
|
877
|
+
function Ue(e, t) {
|
|
878
|
+
let i = t?.intervalMs ?? q, n = t?.poll ?? false, s = fe(
|
|
858
879
|
e
|
|
859
|
-
), [c,
|
|
880
|
+
), [c, o] = l__namespace.useState({
|
|
860
881
|
data: null,
|
|
861
882
|
isLoading: s !== null,
|
|
862
883
|
error: null,
|
|
863
884
|
isStale: false,
|
|
864
885
|
lastUpdated: null
|
|
865
|
-
}),
|
|
866
|
-
return
|
|
867
|
-
|
|
868
|
-
let u =
|
|
886
|
+
}), r = l__namespace.useRef(true), b = l__namespace.useRef(e);
|
|
887
|
+
return b.current = e, l__namespace.useEffect(() => {
|
|
888
|
+
r.current = true;
|
|
889
|
+
let u = b.current;
|
|
869
890
|
if (!u || s === null)
|
|
870
|
-
return
|
|
871
|
-
|
|
891
|
+
return o({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
|
|
892
|
+
r.current = false;
|
|
872
893
|
};
|
|
873
|
-
|
|
874
|
-
let
|
|
875
|
-
|
|
876
|
-
data:
|
|
894
|
+
o((d) => ({ ...d, isLoading: d.data === null }));
|
|
895
|
+
let f = u.__kind === "query" ? u.collection : u.id, m = u.__kind === "query" ? U(u.constraints) : void 0, w = u.db.collection(f), T = (d) => {
|
|
896
|
+
r.current && o({
|
|
897
|
+
data: me(d),
|
|
877
898
|
isLoading: false,
|
|
878
899
|
error: null,
|
|
879
900
|
isStale: d.stale === true,
|
|
880
901
|
lastUpdated: Date.now()
|
|
881
902
|
});
|
|
882
903
|
}, R = (d) => {
|
|
883
|
-
|
|
904
|
+
r.current && o((g) => ({
|
|
884
905
|
...g,
|
|
885
906
|
// Mantém o último data bom — não limpa em erro de refresh.
|
|
886
907
|
isLoading: false,
|
|
@@ -890,57 +911,57 @@ function ve(e, t) {
|
|
|
890
911
|
};
|
|
891
912
|
if (n) {
|
|
892
913
|
let d = false, g = async () => {
|
|
893
|
-
if (!(d ||
|
|
914
|
+
if (!(d || z()))
|
|
894
915
|
try {
|
|
895
|
-
let
|
|
896
|
-
d || T(
|
|
897
|
-
} catch (
|
|
898
|
-
d || R(
|
|
916
|
+
let v = await w.list(m);
|
|
917
|
+
d || T(v);
|
|
918
|
+
} catch (v) {
|
|
919
|
+
d || R(v);
|
|
899
920
|
}
|
|
900
921
|
};
|
|
901
922
|
g();
|
|
902
|
-
let
|
|
923
|
+
let C = setInterval(g, i);
|
|
903
924
|
return () => {
|
|
904
|
-
d = true, clearInterval(
|
|
925
|
+
d = true, clearInterval(C), r.current = false;
|
|
905
926
|
};
|
|
906
927
|
}
|
|
907
928
|
let p;
|
|
908
929
|
try {
|
|
909
|
-
p =
|
|
930
|
+
p = w.onSnapshot(m, T);
|
|
910
931
|
} catch (d) {
|
|
911
932
|
R(d);
|
|
912
933
|
}
|
|
913
934
|
return () => {
|
|
914
|
-
|
|
935
|
+
r.current = false, p?.();
|
|
915
936
|
};
|
|
916
937
|
}, [s, i, n]), c;
|
|
917
938
|
}
|
|
918
|
-
function
|
|
919
|
-
let i = t?.intervalMs ??
|
|
939
|
+
function Ae(e, t) {
|
|
940
|
+
let i = t?.intervalMs ?? q, n = t?.poll ?? false, s = e && e.id ? `${e.collection}/${e.id}` : null, [c, o] = l__namespace.useState({
|
|
920
941
|
data: null,
|
|
921
942
|
isLoading: s !== null,
|
|
922
943
|
error: null,
|
|
923
944
|
isStale: false,
|
|
924
945
|
lastUpdated: null
|
|
925
|
-
}),
|
|
926
|
-
return
|
|
927
|
-
|
|
928
|
-
let u =
|
|
946
|
+
}), r = l__namespace.useRef(true), b = l__namespace.useRef(e);
|
|
947
|
+
return b.current = e, l__namespace.useEffect(() => {
|
|
948
|
+
r.current = true;
|
|
949
|
+
let u = b.current;
|
|
929
950
|
if (!u || s === null)
|
|
930
|
-
return
|
|
931
|
-
|
|
951
|
+
return o({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
|
|
952
|
+
r.current = false;
|
|
932
953
|
};
|
|
933
|
-
|
|
934
|
-
let
|
|
935
|
-
|
|
936
|
-
data:
|
|
954
|
+
o((p) => ({ ...p, isLoading: p.data === null }));
|
|
955
|
+
let f = u.db.collection(u.collection).doc(u.id), m = u.id, w = (p) => {
|
|
956
|
+
r.current && o({
|
|
957
|
+
data: ye(p, m),
|
|
937
958
|
isLoading: false,
|
|
938
959
|
error: null,
|
|
939
960
|
isStale: p?.stale === true,
|
|
940
961
|
lastUpdated: Date.now()
|
|
941
962
|
});
|
|
942
963
|
}, T = (p) => {
|
|
943
|
-
|
|
964
|
+
r.current && o((d) => ({
|
|
944
965
|
...d,
|
|
945
966
|
isLoading: false,
|
|
946
967
|
error: p instanceof Error ? p : new Error(String(p)),
|
|
@@ -949,74 +970,74 @@ function Ee(e, t) {
|
|
|
949
970
|
};
|
|
950
971
|
if (n) {
|
|
951
972
|
let p = false, d = async () => {
|
|
952
|
-
if (!(p ||
|
|
973
|
+
if (!(p || z()))
|
|
953
974
|
try {
|
|
954
|
-
let
|
|
955
|
-
p ||
|
|
956
|
-
} catch (
|
|
957
|
-
p || T(
|
|
975
|
+
let C = await f.get();
|
|
976
|
+
p || w(C);
|
|
977
|
+
} catch (C) {
|
|
978
|
+
p || T(C);
|
|
958
979
|
}
|
|
959
980
|
};
|
|
960
981
|
d();
|
|
961
982
|
let g = setInterval(d, i);
|
|
962
983
|
return () => {
|
|
963
|
-
p = true, clearInterval(g),
|
|
984
|
+
p = true, clearInterval(g), r.current = false;
|
|
964
985
|
};
|
|
965
986
|
}
|
|
966
987
|
let R;
|
|
967
988
|
try {
|
|
968
|
-
R =
|
|
989
|
+
R = f.onSnapshot(w);
|
|
969
990
|
} catch (p) {
|
|
970
991
|
T(p);
|
|
971
992
|
}
|
|
972
993
|
return () => {
|
|
973
|
-
|
|
994
|
+
r.current = false, R?.();
|
|
974
995
|
};
|
|
975
996
|
}, [s, i, n]), c;
|
|
976
997
|
}
|
|
977
|
-
function
|
|
998
|
+
function he(e) {
|
|
978
999
|
let t = e;
|
|
979
1000
|
return t.auth && typeof t.auth.onAuthStateChanged == "function" ? t.auth : e;
|
|
980
1001
|
}
|
|
981
|
-
function
|
|
982
|
-
let i = t?.timeoutMs ?? 8e3, n =
|
|
983
|
-
let
|
|
1002
|
+
function Le(e, t) {
|
|
1003
|
+
let i = t?.timeoutMs ?? 8e3, n = he(e), [s, c] = l__namespace.useState(() => {
|
|
1004
|
+
let r = null;
|
|
984
1005
|
try {
|
|
985
|
-
|
|
1006
|
+
r = n.getUser();
|
|
986
1007
|
} catch {
|
|
987
|
-
|
|
1008
|
+
r = null;
|
|
988
1009
|
}
|
|
989
|
-
return { user:
|
|
990
|
-
}),
|
|
1010
|
+
return { user: r, isLoading: r === null, error: null };
|
|
1011
|
+
}), o = l__namespace.useRef(true);
|
|
991
1012
|
return l__namespace.useEffect(() => {
|
|
992
|
-
|
|
993
|
-
let
|
|
994
|
-
!
|
|
1013
|
+
o.current = true;
|
|
1014
|
+
let r = false, b = setTimeout(() => {
|
|
1015
|
+
!o.current || r || c((f) => f.isLoading ? { ...f, isLoading: false } : f);
|
|
995
1016
|
}, i), u;
|
|
996
1017
|
try {
|
|
997
|
-
u = n.onAuthStateChanged((
|
|
998
|
-
|
|
1018
|
+
u = n.onAuthStateChanged((f) => {
|
|
1019
|
+
o.current && (r = !0, c({ user: f ?? null, isLoading: !1, error: null }));
|
|
999
1020
|
});
|
|
1000
|
-
} catch (
|
|
1001
|
-
|
|
1021
|
+
} catch (f) {
|
|
1022
|
+
o.current && c({
|
|
1002
1023
|
user: null,
|
|
1003
1024
|
isLoading: false,
|
|
1004
|
-
error:
|
|
1025
|
+
error: f instanceof Error ? f : new Error(String(f))
|
|
1005
1026
|
});
|
|
1006
1027
|
}
|
|
1007
1028
|
return () => {
|
|
1008
|
-
|
|
1029
|
+
o.current = false, clearTimeout(b), u?.();
|
|
1009
1030
|
};
|
|
1010
1031
|
}, [n, i]), s;
|
|
1011
1032
|
}
|
|
1012
1033
|
|
|
1013
|
-
exports.CheckoutLink =
|
|
1014
|
-
exports.EntitlementGate =
|
|
1015
|
-
exports.NeetruAccountBar =
|
|
1016
|
-
exports.NeetruLoginButton =
|
|
1017
|
-
exports.fetchNeetruAccountBar =
|
|
1034
|
+
exports.CheckoutLink = Ee;
|
|
1035
|
+
exports.EntitlementGate = Ne;
|
|
1036
|
+
exports.NeetruAccountBar = oe;
|
|
1037
|
+
exports.NeetruLoginButton = De;
|
|
1038
|
+
exports.fetchNeetruAccountBar = W;
|
|
1018
1039
|
exports.initialsFrom = N;
|
|
1019
|
-
exports.useCollection =
|
|
1020
|
-
exports.useDoc =
|
|
1021
|
-
exports.useEntitlementContext =
|
|
1022
|
-
exports.useUser =
|
|
1040
|
+
exports.useCollection = Ue;
|
|
1041
|
+
exports.useDoc = Ae;
|
|
1042
|
+
exports.useEntitlementContext = _e;
|
|
1043
|
+
exports.useUser = Le;
|