@nivaro/react 0.3.8 → 0.3.10

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 (60) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/replayUploadQueue.js +107 -93
  4. package/dist/hooks/useNivaroForm.js +129 -126
  5. package/dist/hooks/useSessionRecorder.js +103 -101
  6. package/dist/index.d.ts +115 -2
  7. package/dist/index.js +466 -447
  8. package/dist/shared/components/CollectionBrowserView.js +1058 -1059
  9. package/dist/shared/components/ConformanceView.js +36 -35
  10. package/dist/shared/components/DataTable.js +230 -223
  11. package/dist/shared/components/ForceReloadBanner.js +58 -34
  12. package/dist/shared/components/ItemEditForm.js +3687 -3580
  13. package/dist/shared/components/JsonMapEditor.js +18 -17
  14. package/dist/shared/components/MatrixEditor.js +8 -7
  15. package/dist/shared/components/MyWorkView.js +32 -31
  16. package/dist/shared/components/PageRenderer.js +146 -145
  17. package/dist/shared/components/QueryTable.js +49 -49
  18. package/dist/shared/components/RecordGridEditor.js +76 -75
  19. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  20. package/dist/shared/components/ai/AskPanel.js +55 -54
  21. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  22. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  23. package/dist/shared/components/chat/ChatPanel.js +288 -287
  24. package/dist/shared/components/chat/SlashCommands.js +30 -29
  25. package/dist/shared/components/chat/chat-outbox.js +76 -75
  26. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  27. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  28. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/InlineTableField.js +301 -300
  31. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  34. package/dist/shared/components/item-edit/staged-links.js +86 -0
  35. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  36. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  37. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  38. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  39. package/dist/shared/components/panels/CommentPanel.js +237 -236
  40. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  41. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  42. package/dist/shared/components/profile/usePersonPresence.js +42 -37
  43. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  44. package/dist/shared/components/queue/QueueWorklist.js +597 -598
  45. package/dist/shared/lib/client-version.js +63 -0
  46. package/dist/shared/lib/force-reload.js +36 -0
  47. package/dist/shared/lib/load-error.js +11 -10
  48. package/dist/shared/lib/presence-live.js +73 -0
  49. package/dist/shared/lib/presence-state.js +39 -31
  50. package/dist/shared/lib/record-outbox.js +76 -75
  51. package/dist/shared/lib/request-gate.js +120 -102
  52. package/dist/shared/lib/rum.js +45 -36
  53. package/dist/shared/lib/safe-error.js +39 -0
  54. package/dist/shared/lib/server-clock.js +11 -7
  55. package/dist/shared/lib/signed-out.js +114 -0
  56. package/dist/shared/lib/socket-realtime.js +19 -17
  57. package/dist/shared/lib/unsaved-work.js +62 -0
  58. package/dist/shared/lib/use-online-users.js +11 -10
  59. package/dist/shared/lib/worker-socket.js +89 -79
  60. package/package.json +1 -1
@@ -5,33 +5,34 @@ import { useState as c, useEffect as y, useRef as R } from "react";
5
5
  import { createPortal as Ae } from "react-dom";
6
6
  import { useNivaroClient as $e, useNavigation as Ce } from "../../context.js";
7
7
  import { get as De } from "../../lib/commands.js";
8
- import { useAiStream as Re } from "../../lib/use-ai-stream.js";
8
+ import { userErrorMessage as Re } from "../../lib/safe-error.js";
9
+ import { useAiStream as qe } from "../../lib/use-ai-stream.js";
9
10
  import { cn as se } from "../../lib/utils.js";
10
- import { AiFeedbackButtons as qe } from "./AiFeedbackButtons.js";
11
+ import { AiFeedbackButtons as Ee } from "./AiFeedbackButtons.js";
11
12
  import { AiMarkdown as ae } from "./AiMarkdown.js";
12
- import { AiStepList as Ee } from "./AiStepList.js";
13
- import { useAskHost as le, readDroppedRecord as Se, askContextBody as Oe } from "./ask-context.js";
14
- const Te = ".pdf,.docx,.xlsx,.xls,.xlsm,.csv,.txt,.md,.eml,.html,.htm", Ie = 20, q = 5;
15
- function We({
13
+ import { AiStepList as Se } from "./AiStepList.js";
14
+ import { useAskHost as le, readDroppedRecord as Oe, askContextBody as Te } from "./ask-context.js";
15
+ const Ie = ".pdf,.docx,.xlsx,.xls,.xlsm,.csv,.txt,.md,.eml,.html,.htm", je = 20, q = 5;
16
+ function Ve({
16
17
  subscribe: E,
17
18
  connected: S,
18
19
  askPath: O = "/ask"
19
20
  }) {
20
- const s = le(), [p, T] = c(!1);
21
+ const s = le(), [f, T] = c(!1);
21
22
  return y(() => {
22
23
  s != null && s.open && T(!0);
23
- }, [s == null ? void 0 : s.open]), !s || !p || typeof document > "u" ? null : Ae(
24
- /* @__PURE__ */ t(je, { subscribe: E, connected: S, askPath: O }),
24
+ }, [s == null ? void 0 : s.open]), !s || !f || typeof document > "u" ? null : Ae(
25
+ /* @__PURE__ */ t(_e, { subscribe: E, connected: S, askPath: O }),
25
26
  document.body
26
27
  );
27
28
  }
28
- function je({
29
+ function _e({
29
30
  subscribe: E,
30
31
  connected: S,
31
32
  askPath: O
32
33
  }) {
33
34
  var Z, ee, te;
34
- const s = le(), p = $e(), { navigate: T } = Ce(), n = s.page, [h, v] = c([]), [k, N] = c(""), [I, M] = c(null), [x, B] = c(/* @__PURE__ */ new Set()), [Q, j] = c([]), [w, _] = c([]), [P, z] = c(0), [X, J] = c([]), [U, F] = c(!1), [W, g] = c(null), H = R(null), K = R(null), G = R(null), V = R(null);
35
+ const s = le(), f = $e(), { navigate: T } = Ce(), n = s.page, [h, v] = c([]), [k, N] = c(""), [I, M] = c(null), [x, B] = c(/* @__PURE__ */ new Set()), [Q, j] = c([]), [w, _] = c([]), [P, z] = c(0), [X, J] = c([]), [U, F] = c(!1), [W, g] = c(null), H = R(null), K = R(null), G = R(null), V = R(null);
35
36
  V.current = I;
36
37
  const ie = JSON.stringify(n ?? {});
37
38
  y(() => {
@@ -47,13 +48,13 @@ function je({
47
48
  }, [s.open]);
48
49
  const d = n != null && n.record && !x.has("record") ? n.record : null, { data: A } = he({
49
50
  queryKey: ["ask-panel-record-files", d == null ? void 0 : d.collection, d == null ? void 0 : d.id],
50
- queryFn: () => p.request(
51
+ queryFn: () => f.request(
51
52
  De("/ai/ask/record-files", { collection: d.collection, id: d.id })
52
53
  ).then((e) => e.data),
53
54
  enabled: !!d,
54
55
  staleTime: 6e4,
55
56
  retry: !1
56
- }), l = Re(p, {
57
+ }), a = qe(f, {
57
58
  subscribe: E,
58
59
  connected: S,
59
60
  onDone: (e) => {
@@ -78,19 +79,19 @@ function je({
78
79
  y(() => {
79
80
  var e;
80
81
  (e = K.current) == null || e.scrollTo({ top: K.current.scrollHeight });
81
- }, [h.length, l.text, l.steps.length]);
82
+ }, [h.length, a.text, a.steps.length]);
82
83
  const b = ((ee = [...h].reverse().find((e) => e.role === "user")) == null ? void 0 : ee.content) ?? "";
83
84
  function $(e, r = {}) {
84
85
  const o = (e ?? k).trim();
85
- if (!o || l.active) return;
86
+ if (!o || a.active) return;
86
87
  g(null), v((m) => [...m, { role: "user", content: o }]), e === void 0 && N("");
87
- const a = Oe(n, {
88
+ const l = Te(n, {
88
89
  dismissed: x,
89
90
  records: Q,
90
91
  attachments: w.map((m) => m.id),
91
92
  recordFiles: X
92
93
  }), u = V.current, D = u ? [] : h.slice(-18).map((m) => ({ role: m.role, content: m.content.slice(0, 4e3) }));
93
- l.start({
94
+ a.start({
94
95
  messages: [...D, { role: "user", content: o }],
95
96
  ...u ? { conversation_id: u } : { save: !0 },
96
97
  ...r.fresh ? { fresh: !0 } : {},
@@ -98,39 +99,39 @@ function je({
98
99
  try_harder: !0,
99
100
  ...r.tryHarder.retryOf ? { retry_of: r.tryHarder.retryOf } : {}
100
101
  } : {},
101
- ...a ? { context: a } : {}
102
+ ...l ? { context: l } : {}
102
103
  });
103
104
  }
104
105
  async function Y(e) {
105
106
  const r = q - w.length;
106
107
  for (const o of e.slice(0, Math.max(0, r))) {
107
- z((a) => a + 1);
108
+ z((l) => l + 1);
108
109
  try {
109
- const a = new FormData();
110
- a.append("file", o, o.name);
111
- const u = p.getToken(), D = await fetch(`${p.url}/api/ai/ask/attachments`, {
110
+ const l = new FormData();
111
+ l.append("file", o, o.name);
112
+ const u = f.getToken(), D = await fetch(`${f.url}/api/ai/ask/attachments`, {
112
113
  method: "POST",
113
114
  headers: u ? { Authorization: `Bearer ${u}` } : {},
114
115
  credentials: u ? "omit" : "include",
115
- body: a
116
+ body: l
116
117
  }), m = await D.json().catch(() => ({}));
117
118
  if (!D.ok || !m.data) throw new Error(m.error || `Could not read ${o.name}`);
118
- const fe = m.data;
119
- _((pe) => [...pe, fe]);
120
- } catch (a) {
121
- g(a instanceof Error ? a.message : `Could not read ${o.name}`);
119
+ const pe = m.data;
120
+ _((fe) => [...fe, pe]);
121
+ } catch (l) {
122
+ g(Re(l, `Could not read ${o.name}`));
122
123
  } finally {
123
- z((a) => a - 1);
124
+ z((l) => l - 1);
124
125
  }
125
126
  }
126
127
  e.length > r && g(`At most ${q} files per conversation`);
127
128
  }
128
129
  function de(e) {
129
130
  e.preventDefault(), F(!1);
130
- const r = Se(e.dataTransfer);
131
+ const r = Oe(e.dataTransfer);
131
132
  if (r) {
132
133
  j(
133
- (a) => a.some((u) => u.collection === r.collection && u.id === r.id) || a.length >= Ie ? a : [...a, r]
134
+ (l) => l.some((u) => u.collection === r.collection && u.id === r.id) || l.length >= je ? l : [...l, r]
134
135
  );
135
136
  return;
136
137
  }
@@ -150,43 +151,43 @@ function je({
150
151
  e.preventDefault(), N(b);
151
152
  return;
152
153
  }
153
- e.key === "Escape" && (e.preventDefault(), l.active ? l.stop() : s.setOpen(!1));
154
+ e.key === "Escape" && (e.preventDefault(), a.active ? a.stop() : s.setOpen(!1));
154
155
  }
155
156
  function me() {
156
157
  var e;
157
- l.active || (v([]), M(null), j([]), _([]), g(null), (e = H.current) == null || e.focus());
158
+ a.active || (v([]), M(null), j([]), _([]), g(null), (e = H.current) == null || e.focus());
158
159
  }
159
- const f = [], C = (e) => B((r) => new Set(r).add(e));
160
- n != null && n.record && !x.has("record") && f.push({
160
+ const p = [], C = (e) => B((r) => new Set(r).add(e));
161
+ n != null && n.record && !x.has("record") && p.push({
161
162
  key: "record",
162
163
  icon: /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
163
164
  label: n.record.label || `${n.record.collection} ${n.record.id}`,
164
165
  onRemove: () => C("record")
165
- }), n != null && n.list && !x.has("list") && f.push({
166
+ }), n != null && n.list && !x.has("list") && p.push({
166
167
  key: "list",
167
168
  icon: /* @__PURE__ */ t(xe, { className: "h-3 w-3" }),
168
169
  label: `${n.list.label || n.list.collection} · ${n.list.ids.length} on screen${n.list.filters.length ? ` · ${n.list.filters.length} filter(s)` : ""}`,
169
170
  onRemove: () => C("list")
170
- }), n != null && n.queue && !x.has("queue") && f.push({
171
+ }), n != null && n.queue && !x.has("queue") && p.push({
171
172
  key: "queue",
172
173
  icon: /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
173
174
  label: `${n.queue.label || "Queue"} · ${n.queue.items.length} on screen`,
174
175
  onRemove: () => C("queue")
175
- }), n != null && n.report && !x.has("report") && f.push({
176
+ }), n != null && n.report && !x.has("report") && p.push({
176
177
  key: "report",
177
178
  icon: /* @__PURE__ */ t(ge, { className: "h-3 w-3" }),
178
179
  label: `${n.report.label || "Report"}${(te = n.report.entity_filters) != null && te.length ? ` · ${n.report.entity_filters.length} filter(s)` : ""}`,
179
180
  onRemove: () => C("report")
180
181
  });
181
182
  for (const e of Q)
182
- f.push({
183
+ p.push({
183
184
  key: `rec:${e.collection}:${e.id}`,
184
185
  icon: /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
185
186
  label: e.label || `${e.collection} ${e.id}`,
186
187
  onRemove: () => j((r) => r.filter((o) => !(o.collection === e.collection && o.id === e.id)))
187
188
  });
188
189
  for (const e of w)
189
- f.push({
190
+ p.push({
190
191
  key: `doc:${e.id}`,
191
192
  icon: /* @__PURE__ */ t(L, { className: "h-3 w-3" }),
192
193
  label: `${e.name}${e.truncated ? " (long — first part)" : ""}`,
@@ -236,7 +237,7 @@ function je({
236
237
  {
237
238
  type: "button",
238
239
  onClick: me,
239
- disabled: l.active,
240
+ disabled: a.active,
240
241
  "aria-label": "New conversation",
241
242
  "data-tip": "New conversation",
242
243
  className: "inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",
@@ -261,7 +262,7 @@ function je({
261
262
  ref: K,
262
263
  className: "min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-3 py-3",
263
264
  children: [
264
- h.length === 0 && !l.active && /* @__PURE__ */ i("div", { className: "space-y-2 pt-6 text-center text-[12.5px] text-muted-foreground", children: [
265
+ h.length === 0 && !a.active && /* @__PURE__ */ i("div", { className: "space-y-2 pt-6 text-center text-[12.5px] text-muted-foreground", children: [
265
266
  /* @__PURE__ */ t("p", { children: "Ask about what is on this page — the chips below say what rides along." }),
266
267
  /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: "Drop records or a PDF, Word or Excel file here to ask about them too." })
267
268
  ] }),
@@ -282,22 +283,22 @@ function je({
282
283
  "data-ask-panel-try-harder": !0,
283
284
  "data-tip": "Quick answer from a smaller model — ask the main one",
284
285
  className: "text-[11px] text-muted-foreground underline decoration-dotted underline-offset-2 hover:text-foreground disabled:opacity-40",
285
- disabled: l.active,
286
+ disabled: a.active,
286
287
  onClick: () => $(b, { tryHarder: { retryOf: e.requestId ?? null } }),
287
288
  children: "Try harder"
288
289
  }
289
290
  ),
290
- /* @__PURE__ */ t(qe, { requestId: e.requestId })
291
+ /* @__PURE__ */ t(Ee, { requestId: e.requestId })
291
292
  ] })
292
293
  ] }, r)
293
294
  )
294
295
  ),
295
- l.active && /* @__PURE__ */ i("div", { "data-ask-panel-streaming": !0, className: "space-y-1.5", children: [
296
- /* @__PURE__ */ t(Ee, { steps: l.steps, folded: !!l.text }),
297
- l.text ? /* @__PURE__ */ t(ae, { content: l.text, className: "text-[13px]" }) : /* @__PURE__ */ i("p", { className: "flex items-center gap-1.5 text-[12px] text-muted-foreground", children: [
296
+ a.active && /* @__PURE__ */ i("div", { "data-ask-panel-streaming": !0, className: "space-y-1.5", children: [
297
+ /* @__PURE__ */ t(Se, { steps: a.steps, folded: !!a.text }),
298
+ a.text ? /* @__PURE__ */ t(ae, { content: a.text, className: "text-[13px]" }) : /* @__PURE__ */ i("p", { className: "flex items-center gap-1.5 text-[12px] text-muted-foreground", children: [
298
299
  /* @__PURE__ */ t(oe, { className: "h-3.5 w-3.5 animate-spin" }),
299
300
  " ",
300
- l.status ?? "Thinking…"
301
+ a.status ?? "Thinking…"
301
302
  ] })
302
303
  ] }),
303
304
  W && /* @__PURE__ */ t("p", { className: "rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-[12px] text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300", children: W })
@@ -305,8 +306,8 @@ function je({
305
306
  }
306
307
  ),
307
308
  /* @__PURE__ */ i("footer", { className: "shrink-0 space-y-2 border-t border-border px-3 py-2.5", children: [
308
- (f.length > 0 || P > 0) && /* @__PURE__ */ i("div", { className: "flex flex-wrap gap-1.5", "data-ask-panel-chips": !0, children: [
309
- f.map((e) => /* @__PURE__ */ i(
309
+ (p.length > 0 || P > 0) && /* @__PURE__ */ i("div", { className: "flex flex-wrap gap-1.5", "data-ask-panel-chips": !0, children: [
310
+ p.map((e) => /* @__PURE__ */ i(
310
311
  "span",
311
312
  {
312
313
  className: "inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[11.5px]",
@@ -342,7 +343,7 @@ function je({
342
343
  type: "button",
343
344
  "aria-pressed": r,
344
345
  onClick: () => J(
345
- (o) => r ? o.filter((a) => a !== e.id) : o.length >= q ? o : [...o, e.id]
346
+ (o) => r ? o.filter((l) => l !== e.id) : o.length >= q ? o : [...o, e.id]
346
347
  ),
347
348
  className: se(
348
349
  "inline-flex max-w-full items-center gap-1 rounded-full border px-2 py-0.5 text-[11.5px]",
@@ -378,7 +379,7 @@ function je({
378
379
  {
379
380
  ref: G,
380
381
  type: "file",
381
- accept: Te,
382
+ accept: Ie,
382
383
  multiple: !0,
383
384
  className: "hidden",
384
385
  onChange: (e) => {
@@ -400,11 +401,11 @@ function je({
400
401
  className: "min-h-[38px] flex-1 resize-none rounded-md border border-border bg-background px-2.5 py-2 text-[13px] outline-none focus:border-nvr-cyan"
401
402
  }
402
403
  ),
403
- l.active ? /* @__PURE__ */ t(
404
+ a.active ? /* @__PURE__ */ t(
404
405
  "button",
405
406
  {
406
407
  type: "button",
407
- onClick: () => void l.stop(),
408
+ onClick: () => void a.stop(),
408
409
  "aria-label": "Stop the answer",
409
410
  className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border hover:bg-muted",
410
411
  children: /* @__PURE__ */ t(Ne, { className: "h-3.5 w-3.5" })
@@ -428,5 +429,5 @@ function je({
428
429
  );
429
430
  }
430
431
  export {
431
- We as AskPanel
432
+ Ve as AskPanel
432
433
  };
@@ -6,14 +6,15 @@ import { toast as j } from "sonner";
6
6
  import { useNivaroClient as z } from "../../context.js";
7
7
  import { newBulkProgressId as X, startBulkProgress as Y, endBulkProgress as Z } from "../../lib/bulk-progress.js";
8
8
  import { get as D, post as O } from "../../lib/commands.js";
9
+ import { userErrorMessage as ee } from "../../lib/safe-error.js";
9
10
  import { cn as R } from "../../lib/utils.js";
10
- import { Popover as ee, PopoverTrigger as te, PopoverContent as re } from "../ui/popover.js";
11
- import { PushBulkButtons as ne } from "./PushBulkButtons.js";
11
+ import { Popover as te, PopoverTrigger as re, PopoverContent as ne } from "../ui/popover.js";
12
+ import { PushBulkButtons as oe } from "./PushBulkButtons.js";
12
13
  function k(t) {
13
14
  return t === !0 || t === 1 || t === "1" || t === "true" ? "true" : t === !1 || t === 0 || t === "0" || t === "false" ? "false" : String(t ?? "");
14
15
  }
15
16
  const U = (t) => t == null || t === "";
16
- function ke(t, i) {
17
+ function we(t, i) {
17
18
  for (const n of t ?? []) {
18
19
  if (!n || typeof n.field != "string") continue;
19
20
  if (!(n.field in i)) return null;
@@ -65,13 +66,13 @@ function G(t) {
65
66
  function K(t, i, n) {
66
67
  return t ? t.includes(n) || t.includes(`${i}:${n}`) : !0;
67
68
  }
68
- function xe(t, i) {
69
+ function ye(t, i) {
69
70
  const { data: n } = G(t), s = !!n && Object.values(n).some((o) => o.some((c) => c.source === "builtin"));
70
71
  return (o) => s ? t.some(
71
72
  (c) => ((n == null ? void 0 : n[c]) ?? []).some((g) => g.source === "builtin" && g.key === o) && K(i, c, o)
72
73
  ) : !0;
73
74
  }
74
- function oe(t, i, n) {
75
+ function se(t, i, n) {
75
76
  const s = /* @__PURE__ */ new Map();
76
77
  for (const o of i)
77
78
  for (const c of (t == null ? void 0 : t[o]) ?? []) {
@@ -81,18 +82,18 @@ function oe(t, i, n) {
81
82
  }
82
83
  return [...s.values()];
83
84
  }
84
- function se(t, i, n) {
85
+ function ie(t, i, n) {
85
86
  const s = [`${i.succeeded} done`];
86
87
  return i.skipped && s.push(`${i.skipped} skipped`), i.failed && s.push(`${i.failed} failed`), `${t}: ${s.join(" · ")}${n !== i.succeeded + i.skipped + i.failed ? ` of ${n}` : ""}`;
87
88
  }
88
- function we({
89
+ function ve({
89
90
  targets: t,
90
91
  enabledKeys: i,
91
92
  tone: n = "light",
92
93
  disabled: s,
93
94
  onDone: o
94
95
  }) {
95
- const c = z(), g = [...new Set(t.map((e) => e.collection))], { data: x } = G(g), S = oe(x, g, i), [L, $] = y(null), [N, _] = y(""), [P, C] = y(null), [A, B] = y({}), [E, T] = y(!1), Q = async (e) => {
96
+ const c = z(), g = [...new Set(t.map((e) => e.collection))], { data: x } = G(g), S = se(x, g, i), [L, $] = y(null), [N, _] = y(""), [P, C] = y(null), [A, B] = y({}), [E, M] = y(!1), Q = async (e) => {
96
97
  const u = `${e.source}:${e.key}`;
97
98
  if (e.source === "db") {
98
99
  B((a) => ({ ...a, [u]: "loading" }));
@@ -111,18 +112,18 @@ function we({
111
112
  B((a) => ({ ...a, [u]: null }));
112
113
  }
113
114
  }
114
- }, F = /* @__PURE__ */ f(
115
- ne,
115
+ }, T = /* @__PURE__ */ f(
116
+ oe,
116
117
  {
117
118
  targets: t,
118
119
  enabledKeys: i,
119
120
  tone: n,
120
121
  disabled: s || !!P,
121
- onDone: (e) => o == null ? void 0 : o({ ...e, action: ie })
122
+ onDone: (e) => o == null ? void 0 : o({ ...e, action: le })
122
123
  }
123
124
  );
124
- if (S.length === 0) return F;
125
- const I = async (e) => {
125
+ if (S.length === 0) return T;
126
+ const F = async (e) => {
126
127
  const u = `${e.source}:${e.key}`;
127
128
  C(u);
128
129
  const a = { succeeded: 0, failed: 0, skipped: 0, errors: [] };
@@ -141,12 +142,12 @@ function we({
141
142
  )).data ?? {};
142
143
  a.succeeded += v.succeeded ?? (e.source === "extension" ? b.length : 0), a.failed += v.failed ?? 0, a.skipped += v.skipped ?? 0, a.errors.push(...v.errors ?? []);
143
144
  }
144
- const d = se(e.label, a, h), m = a.errors.slice(0, 3).map((r) => `#${r.item}: ${r.error}`).join(`
145
+ const d = ie(e.label, a, h), m = a.errors.slice(0, 3).map((r) => `#${r.item}: ${r.error}`).join(`
145
146
  `);
146
147
  a.failed > 0 ? j.warning(d, { description: m || void 0, duration: 8e3 }) : j.success(d, { duration: 4e3 }), o == null || o({ ...a, action: e }), $(null), _("");
147
148
  } catch (d) {
148
149
  const m = d.response;
149
- j.error((m == null ? void 0 : m.error) ?? (d instanceof Error ? d.message : `${e.label} failed`));
150
+ j.error((m == null ? void 0 : m.error) ?? ee(d, `${e.label} failed`));
150
151
  } finally {
151
152
  C(null);
152
153
  }
@@ -163,14 +164,14 @@ function we({
163
164
  S.map((e) => {
164
165
  const u = `${e.source}:${e.key}`, a = L === u, h = P === u, d = t.filter((r) => e.collections.includes(r.collection)).length, m = d > 0 && (!e.require_reason || N.trim().length > 0) && !h;
165
166
  return /* @__PURE__ */ p(
166
- ee,
167
+ te,
167
168
  {
168
169
  open: a,
169
170
  onOpenChange: (r) => {
170
- $(r ? u : null), r ? (T(!1), Q(e)) : _("");
171
+ $(r ? u : null), r ? (M(!1), Q(e)) : _("");
171
172
  },
172
173
  children: [
173
- /* @__PURE__ */ f(te, { asChild: !0, children: /* @__PURE__ */ f(
174
+ /* @__PURE__ */ f(re, { asChild: !0, children: /* @__PURE__ */ f(
174
175
  "button",
175
176
  {
176
177
  type: "button",
@@ -182,7 +183,7 @@ function we({
182
183
  }
183
184
  ) }),
184
185
  /* @__PURE__ */ p(
185
- re,
186
+ ne,
186
187
  {
187
188
  align: "center",
188
189
  side: "top",
@@ -224,14 +225,14 @@ function we({
224
225
  " would change",
225
226
  b.length > 0 && /* @__PURE__ */ p("span", { className: "font-normal text-slate-500", children: [
226
227
  " · ",
227
- [...w.entries()].map(([l, M]) => `${M} ${l}`).join(" · ")
228
+ [...w.entries()].map(([l, I]) => `${I} ${l}`).join(" · ")
228
229
  ] })
229
230
  ] }),
230
231
  b.length > 0 && /* @__PURE__ */ p(
231
232
  "button",
232
233
  {
233
234
  type: "button",
234
- onClick: () => T((l) => !l),
235
+ onClick: () => M((l) => !l),
235
236
  className: "mt-0.5 text-[11px] text-slate-500 underline-offset-2 hover:underline",
236
237
  "data-bulk-preview-toggle": !0,
237
238
  children: [
@@ -262,7 +263,7 @@ function we({
262
263
  value: N,
263
264
  onChange: (r) => _(r.target.value),
264
265
  onKeyDown: (r) => {
265
- r.key === "Enter" && (r.metaKey || r.ctrlKey) && m && I(e);
266
+ r.key === "Enter" && (r.metaKey || r.ctrlKey) && m && F(e);
266
267
  },
267
268
  rows: 2,
268
269
  placeholder: "Recorded on every record’s history",
@@ -284,7 +285,7 @@ function we({
284
285
  "button",
285
286
  {
286
287
  type: "button",
287
- onClick: () => void I(e),
288
+ onClick: () => void F(e),
288
289
  disabled: !m,
289
290
  "data-bulk-action-run": !0,
290
291
  className: R(
@@ -306,10 +307,10 @@ function we({
306
307
  u
307
308
  );
308
309
  }),
309
- F
310
+ T
310
311
  ] });
311
312
  }
312
- const ie = {
313
+ const le = {
313
314
  key: "push",
314
315
  source: "builtin",
315
316
  collection: null,
@@ -322,10 +323,10 @@ const ie = {
322
323
  summary: "Integration push"
323
324
  };
324
325
  export {
325
- we as BulkActionButtons,
326
+ ve as BulkActionButtons,
326
327
  K as bulkActionEnabled,
327
- ke as guardMatches,
328
- oe as mergeBulkActions,
328
+ we as guardMatches,
329
+ se as mergeBulkActions,
329
330
  G as useAvailableBulkActions,
330
- xe as useBuiltinGate
331
+ ye as useBuiltinGate
331
332
  };