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