@nivaro/react 0.3.51 → 0.3.53

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 (34) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +3885 -3847
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +600 -549
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  14. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  15. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  16. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  17. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  18. package/dist/shared/components/item-edit/SummaryPanel.js +351 -337
  19. package/dist/shared/components/item-edit/line-qty.js +115 -53
  20. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  21. package/dist/shared/components/item-edit/usePersonalDefaults.js +210 -207
  22. package/dist/shared/components/panels/CommentPanel.js +204 -197
  23. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  24. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  25. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  26. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  27. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  28. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  29. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  30. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  31. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  32. package/dist/shared/lib/activity-sentence.js +236 -227
  33. package/dist/shared/lib/record-ref.js +43 -34
  34. package/package.json +1 -1
@@ -1,26 +1,26 @@
1
- import { jsxs as l, jsx as t, Fragment as j } from "react/jsx-runtime";
1
+ import { jsxs as l, jsx as t, Fragment as L } from "react/jsx-runtime";
2
2
  import { useQuery as B, useQueryClient as ee, useMutation as Q } from "@tanstack/react-query";
3
3
  import { Clock as Y, Search as Se, X as Ce, CalendarClock as _e, GitCompareArrows as Te, ChevronDown as Re, ChevronRight as je, MessageSquare as Ae, RotateCcw as de, ArrowRight as Le } from "lucide-react";
4
- import { useState as v, useRef as $e, useMemo as L, createContext as Oe, useEffect as qe, useContext as ce } from "react";
5
- import { toast as A } from "sonner";
4
+ import { useState as v, useRef as $e, useMemo as A, createContext as Oe, useEffect as qe, useContext as ce } from "react";
5
+ import { toast as j } from "sonner";
6
6
  import { useNivaroClient as F } from "../../context.js";
7
- import { activityPredicate as De, activityWhy as Fe, actorName as Ee } from "../../lib/activity-sentence.js";
7
+ import { o2mSentence as De, activityPredicate as Fe, activityWhy as Ee, actorName as Pe } from "../../lib/activity-sentence.js";
8
8
  import { get as D, post as K } from "../../lib/commands.js";
9
- import { useLiveRecordQueries as Pe } from "../../lib/live.js";
9
+ import { useLiveRecordQueries as Be } from "../../lib/live.js";
10
10
  import { restoreSkippedNote as se } from "../../lib/restore-skipped.js";
11
- import { cn as T, titleCase as me, toLocalDateString as Be } from "../../lib/utils.js";
12
- import { useActivityLabels as Ie } from "../ActivityEntry.js";
13
- import { AgentBadge as Ke } from "../AgentBadge.js";
14
- import { RelatedItemLabel as Me } from "../item-edit/RelationCombobox.js";
11
+ import { cn as T, titleCase as me, toLocalDateString as Ie } from "../../lib/utils.js";
12
+ import { useActivityLabels as Ke } from "../ActivityEntry.js";
13
+ import { AgentBadge as Me } from "../AgentBadge.js";
14
+ import { RelatedItemLabel as Ue } from "../item-edit/RelationCombobox.js";
15
15
  import { UserAvatar as pe } from "../UserAvatar.js";
16
16
  import { Button as M } from "../ui/button.js";
17
- import { Sheet as Ue, SheetTrigger as We, SheetContent as Ve, SheetHeader as ze, SheetTitle as He } from "../ui/sheet.js";
18
- import { Skeleton as Je } from "../ui/skeleton.js";
19
- import { IntegrationActivitySection as Qe } from "./IntegrationActivitySection.js";
20
- const G = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), Ye = (e) => !G(e), O = (e) => {
17
+ import { Sheet as We, SheetTrigger as Ve, SheetContent as ze, SheetHeader as He, SheetTitle as Je } from "../ui/sheet.js";
18
+ import { Skeleton as Qe } from "../ui/skeleton.js";
19
+ import { IntegrationActivitySection as Ye } from "./IntegrationActivitySection.js";
20
+ const G = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), Ge = (e) => !G(e), O = (e) => {
21
21
  var s;
22
22
  return e.id != null ? `r${e.id}` : `e${((s = e.event) == null ? void 0 : s.history_id) ?? ""}-${e.activity ?? ""}-${e.timestamp ?? ""}`;
23
- }, Ge = /* @__PURE__ */ new Set([
23
+ }, Xe = /* @__PURE__ */ new Set([
24
24
  "id",
25
25
  "created",
26
26
  "changed",
@@ -50,7 +50,7 @@ function ue(e, s) {
50
50
  return { fields: o, relations: d };
51
51
  }
52
52
  });
53
- return L(() => {
53
+ return A(() => {
54
54
  const o = /* @__PURE__ */ new Map(), d = (n) => {
55
55
  const r = ((a == null ? void 0 : a.relations) ?? []).find(
56
56
  (m) => m.many_collection === e && m.many_field === n && m.junction_field == null
@@ -60,7 +60,7 @@ function ue(e, s) {
60
60
  for (const n of (a == null ? void 0 : a.fields) ?? [])
61
61
  n.field.startsWith("__") || o.set(n.field, {
62
62
  label: n.label || me(n.field.replace(/_/g, " ")),
63
- system: Ge.has(n.field),
63
+ system: Xe.has(n.field),
64
64
  // layout_assigned is only stamped when the collection HAS an active
65
65
  // layout — absent means there's no layout to be off of.
66
66
  onLayout: n.layout_assigned !== !1,
@@ -78,7 +78,7 @@ function y(e, s) {
78
78
  onLayout: !1
79
79
  };
80
80
  }
81
- function Xe({ map: e, field: s }) {
81
+ function Ze({ map: e, field: s }) {
82
82
  const i = y(e, s);
83
83
  return /* @__PURE__ */ t(
84
84
  "span",
@@ -90,12 +90,12 @@ function Xe({ map: e, field: s }) {
90
90
  }
91
91
  );
92
92
  }
93
- const ne = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/, Ze = /^\d{4}-\d{2}-\d{2}(?:T00:00:00(?:\.0+)?Z)?$/;
94
- function et(e, s = !1) {
93
+ const ne = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/, et = /^\d{4}-\d{2}-\d{2}(?:T00:00:00(?:\.0+)?Z)?$/;
94
+ function tt(e, s = !1) {
95
95
  if (e == null || e === "") return "";
96
96
  if (typeof e == "boolean") return e ? "Yes" : "No";
97
- if (typeof e == "string" && (Ze.test(e) || s && ne.test(e)))
98
- return Be(e);
97
+ if (typeof e == "string" && (et.test(e) || s && ne.test(e)))
98
+ return Ie(e);
99
99
  if (typeof e == "string" && ne.test(e)) {
100
100
  const i = new Date(e);
101
101
  if (!Number.isNaN(i.getTime())) return i.toLocaleString();
@@ -105,7 +105,7 @@ function et(e, s = !1) {
105
105
  function U(e) {
106
106
  return e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e);
107
107
  }
108
- function tt({ collection: e, id: s }) {
108
+ function at({ collection: e, id: s }) {
109
109
  const i = F(), { data: a } = B({
110
110
  queryKey: ["col-meta", e],
111
111
  queryFn: () => i.request(D(`/collections/${e}`)).then((o) => o.data),
@@ -113,7 +113,7 @@ function tt({ collection: e, id: s }) {
113
113
  retry: !1
114
114
  });
115
115
  return /* @__PURE__ */ t("span", { title: `${e} #${String(s)}`, children: /* @__PURE__ */ t(
116
- Me,
116
+ Ue,
117
117
  {
118
118
  collection: e,
119
119
  id: s,
@@ -121,7 +121,7 @@ function tt({ collection: e, id: s }) {
121
121
  }
122
122
  ) });
123
123
  }
124
- function at(e) {
124
+ function rt(e) {
125
125
  return Z(e).join(" ");
126
126
  }
127
127
  const le = 160;
@@ -130,7 +130,7 @@ function ie({
130
130
  tone: s,
131
131
  dateOnly: i
132
132
  }) {
133
- const [a, o] = v(!1), d = et(e, i);
133
+ const [a, o] = v(!1), d = tt(e, i);
134
134
  if (d === "")
135
135
  return /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" });
136
136
  const n = d.length > le, r = a || !n ? d : `${d.slice(0, le)}…`;
@@ -161,7 +161,7 @@ function I(e) {
161
161
  }
162
162
  return null;
163
163
  }
164
- function rt({
164
+ function st({
165
165
  before: e,
166
166
  after: s
167
167
  }) {
@@ -181,7 +181,7 @@ function rt({
181
181
  r !== void 0 ? /* @__PURE__ */ t("span", { className: "text-emerald-700 dark:text-emerald-400", children: o(r) }) : /* @__PURE__ */ t("span", { className: "italic text-slate-400", children: " (removed)" })
182
182
  ] }, d)) });
183
183
  }
184
- function st({ field: e, ctl: s }) {
184
+ function nt({ field: e, ctl: s }) {
185
185
  return s.confirmField === e ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1", "data-revert-field-confirm": e, children: [
186
186
  /* @__PURE__ */ t("span", { className: "text-[10.5px] text-slate-500", children: "Revert?" }),
187
187
  /* @__PURE__ */ t(
@@ -224,7 +224,7 @@ function X(e) {
224
224
  function Z(e) {
225
225
  return String(e ?? "").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").split(/\s+/).filter(Boolean);
226
226
  }
227
- function nt(e, s) {
227
+ function lt(e, s) {
228
228
  const a = Z(e).slice(0, 600), o = Z(s).slice(0, 600), d = a.length, n = o.length, r = Array.from({ length: d + 1 }, () => new Array(n + 1).fill(0));
229
229
  for (let g = d - 1; g >= 0; g--)
230
230
  for (let c = n - 1; c >= 0; c--)
@@ -240,8 +240,8 @@ function nt(e, s) {
240
240
  for (; u < n; ) h("ins", o[u++]);
241
241
  return m;
242
242
  }
243
- function lt({ before: e, after: s }) {
244
- const i = nt(e, s);
243
+ function it({ before: e, after: s }) {
244
+ const i = lt(e, s);
245
245
  return /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: i.map(
246
246
  (a, o) => a.type === "same" ? (
247
247
  // biome-ignore lint/suspicious/noArrayIndexKey: static segment list
@@ -278,12 +278,12 @@ function lt({ before: e, after: s }) {
278
278
  )
279
279
  ) });
280
280
  }
281
- const it = {
281
+ const ot = {
282
282
  added: "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400",
283
283
  removed: "bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400",
284
284
  changed: "bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400"
285
285
  };
286
- function ot(e, s, i) {
286
+ function dt(e, s, i) {
287
287
  const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])), o = (r) => r == null || r === "", d = a.map((r) => {
288
288
  const m = !(r in e) || o(e[r]), h = !(r in s) || o(s[r]);
289
289
  if (m && h) return null;
@@ -308,9 +308,9 @@ function q({
308
308
  meta: s,
309
309
  tone: i
310
310
  }) {
311
- return e == null || e === "" ? /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" }) : s.relatedCollection && (typeof e == "string" || typeof e == "number") ? /* @__PURE__ */ t("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(tt, { collection: s.relatedCollection, id: e }) }) : X(e) ? /* @__PURE__ */ t(ie, { value: at(e), tone: i }) : /* @__PURE__ */ t(ie, { value: e, tone: i, dateOnly: s.dateOnly });
311
+ return e == null || e === "" ? /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" }) : s.relatedCollection && (typeof e == "string" || typeof e == "number") ? /* @__PURE__ */ t("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(at, { collection: s.relatedCollection, id: e }) }) : X(e) ? /* @__PURE__ */ t(ie, { value: rt(e), tone: i }) : /* @__PURE__ */ t(ie, { value: e, tone: i, dateOnly: s.dateOnly });
312
312
  }
313
- function dt({
313
+ function ct({
314
314
  row: e,
315
315
  meta: s,
316
316
  fieldRevert: i,
@@ -328,21 +328,21 @@ function dt({
328
328
  "data-field-row": e.field,
329
329
  children: [
330
330
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
331
- /* @__PURE__ */ t(Xe, { map: s, field: e.field }),
331
+ /* @__PURE__ */ t(Ze, { map: s, field: e.field }),
332
332
  e.status !== "unchanged" && !o && /* @__PURE__ */ t(
333
333
  "span",
334
334
  {
335
335
  className: T(
336
336
  "rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide",
337
- it[e.status]
337
+ ot[e.status]
338
338
  ),
339
339
  children: e.status === "added" ? "set" : e.status
340
340
  }
341
341
  ),
342
- (e.status === "changed" || a === "changes" && e.status === "added") && i && e.field !== "id" && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(st, { field: e.field, ctl: i }) })
342
+ (e.status === "changed" || a === "changes" && e.status === "added") && i && e.field !== "id" && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(nt, { field: e.field, ctl: i }) })
343
343
  ] }),
344
- /* @__PURE__ */ t("div", { className: "mt-1", children: d ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(lt, { before: e.before, after: e.after }) }) : n ? /* @__PURE__ */ t(
345
- rt,
344
+ /* @__PURE__ */ t("div", { className: "mt-1", children: d ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(it, { before: e.before, after: e.after }) }) : n ? /* @__PURE__ */ t(
345
+ st,
346
346
  {
347
347
  before: I(e.before),
348
348
  after: I(e.after)
@@ -356,7 +356,7 @@ function dt({
356
356
  }
357
357
  );
358
358
  }
359
- function ct({
359
+ function mt({
360
360
  before: e,
361
361
  after: s,
362
362
  meta: i,
@@ -364,7 +364,7 @@ function ct({
364
364
  mode: o,
365
365
  hideStatusChips: d
366
366
  }) {
367
- const [n, r] = v(!1), m = L(() => ot(e, s, i), [e, s, i]), h = o === "changes" ? m.filter((x) => x.status !== "unchanged") : m, p = n ? h : h.filter((x) => !x.system), u = h.length - p.length;
367
+ const [n, r] = v(!1), m = A(() => dt(e, s, i), [e, s, i]), h = o === "changes" ? m.filter((x) => x.status !== "unchanged") : m, p = n ? h : h.filter((x) => !x.system), u = h.length - p.length;
368
368
  if (h.length === 0)
369
369
  return /* @__PURE__ */ t("p", { className: "px-3 py-3 text-[12px] text-slate-400", children: o === "changes" ? "No field changes recorded." : "No snapshot data available." });
370
370
  const g = p.findIndex(
@@ -379,7 +379,7 @@ function ct({
379
379
  /* @__PURE__ */ t("p", { className: "text-[10.5px] text-slate-400", children: "Not on the form — written automatically by rules, computed fields or integrations." })
380
380
  ] }),
381
381
  /* @__PURE__ */ t(
382
- dt,
382
+ ct,
383
383
  {
384
384
  row: x,
385
385
  meta: i,
@@ -416,7 +416,7 @@ function ct({
416
416
  )
417
417
  ] });
418
418
  }
419
- const mt = {
419
+ const pt = {
420
420
  create: "bg-emerald-500",
421
421
  restore: "bg-emerald-500",
422
422
  update: "bg-nvr-cyan",
@@ -424,16 +424,16 @@ const mt = {
424
424
  }, te = Oe(void 0);
425
425
  function P(e, s) {
426
426
  var i;
427
- return e.actor && e.actor.kind !== "person" ? Ee(e, s) : e.first_name || e.last_name ? [e.first_name, e.last_name].filter(Boolean).join(" ") : e.user_email ?? ((i = e.user_id) == null ? void 0 : i.slice(0, 8)) ?? "System";
427
+ return e.actor && e.actor.kind !== "person" ? Pe(e, s) : e.first_name || e.last_name ? [e.first_name, e.last_name].filter(Boolean).join(" ") : e.user_email ?? ((i = e.user_id) == null ? void 0 : i.slice(0, 8)) ?? "System";
428
428
  }
429
- function pt(e, s, i) {
429
+ function ut(e, s, i) {
430
430
  return e.action === "create" ? "created this record" : e.action === "restore" ? "restored this record from trash" : e.action === "delete" ? "deleted this record" : s > 0 ? `changed ${s} field${s === 1 ? "" : "s"}` : i > 0 ? "updated system fields" : "saved this record";
431
431
  }
432
- function ut({ revision: e, isLast: s }) {
432
+ function ht({ revision: e, isLast: s }) {
433
433
  var h, p, u;
434
434
  const i = ce(te), a = e.event, o = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", d = !o && ((h = a == null ? void 0 : a.on_behalf_of) != null && h.name) ? a.on_behalf_of.name : null, n = o ? "Automatic rule" : d ? `${P(e, i)}, for ${d}` : P(e, i);
435
435
  let r;
436
- (a == null ? void 0 : a.kind) === "transition" && a.addendum ? r = /* @__PURE__ */ l(j, { children: [
436
+ (a == null ? void 0 : a.kind) === "transition" && a.addendum ? r = /* @__PURE__ */ l(L, { children: [
437
437
  "moved",
438
438
  " ",
439
439
  /* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-slate-200", "data-revision-addendum": !0, children: [
@@ -443,7 +443,7 @@ function ut({ revision: e, isLast: s }) {
443
443
  ] }),
444
444
  ":",
445
445
  " ",
446
- a.from_label && /* @__PURE__ */ l(j, { children: [
446
+ a.from_label && /* @__PURE__ */ l(L, { children: [
447
447
  /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: a.from_label }),
448
448
  " ",
449
449
  "→",
@@ -454,10 +454,10 @@ function ut({ revision: e, isLast: s }) {
454
454
  " · ",
455
455
  a.transition_label
456
456
  ] })
457
- ] }) : (a == null ? void 0 : a.kind) === "transition" ? r = /* @__PURE__ */ l(j, { children: [
457
+ ] }) : (a == null ? void 0 : a.kind) === "transition" ? r = /* @__PURE__ */ l(L, { children: [
458
458
  "moved it",
459
459
  " ",
460
- a.from_label && /* @__PURE__ */ l(j, { children: [
460
+ a.from_label && /* @__PURE__ */ l(L, { children: [
461
461
  "from",
462
462
  " ",
463
463
  /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: a.from_label }),
@@ -470,20 +470,15 @@ function ut({ revision: e, isLast: s }) {
470
470
  " · ",
471
471
  a.transition_label
472
472
  ] })
473
- ] }) : (a == null ? void 0 : a.kind) === "start" && a.to_label ? r = /* @__PURE__ */ l(j, { children: [
473
+ ] }) : (a == null ? void 0 : a.kind) === "start" && a.to_label ? r = /* @__PURE__ */ l(L, { children: [
474
474
  "started it in",
475
475
  " ",
476
476
  /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: a.to_label })
477
- ] }) : (a == null ? void 0 : a.kind) === "start" ? r = /* @__PURE__ */ l(j, { children: [
477
+ ] }) : (a == null ? void 0 : a.kind) === "start" ? r = /* @__PURE__ */ l(L, { children: [
478
478
  "started the pipeline",
479
479
  e.comment ? ` — ${e.comment.replace(/^Started pipeline\s*[—-]?\s*/i, "")}` : ""
480
- ] }) : (p = e.action) != null && p.startsWith("o2m-") ? r = /* @__PURE__ */ l(j, { children: [
481
- e.action === "o2m-create" ? "added" : e.action === "o2m-delete" ? "removed" : "changed",
482
- " ",
483
- "related rows",
484
- e.comment ? ` — ${e.comment}` : ""
485
- ] }) : r = /* @__PURE__ */ l(j, { children: [
486
- De({ ...e, item: null }, i),
480
+ ] }) : (p = e.action) != null && p.startsWith("o2m-") ? r = /* @__PURE__ */ t("span", { "data-revision-o2m": !0, children: e.o2m ? De(e.o2m) : `${e.action === "o2m-create" ? "added" : e.action === "o2m-delete" ? "removed" : "changed"} related rows` }) : r = /* @__PURE__ */ l(L, { children: [
481
+ Fe({ ...e, item: null }, i),
487
482
  e.comment ? ` — ${e.comment}` : ""
488
483
  ] });
489
484
  const m = e.timestamp ? new Date(e.timestamp).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "—";
@@ -550,7 +545,7 @@ function ut({ revision: e, isLast: s }) {
550
545
  }
551
546
  );
552
547
  }
553
- function ht({
548
+ function xt({
554
549
  revision: e,
555
550
  previousData: s,
556
551
  meta: i,
@@ -558,7 +553,7 @@ function ht({
558
553
  inlineTableFields: o,
559
554
  isLast: d
560
555
  }) {
561
- const n = F(), r = ce(te), m = Fe(e).reason, [h, p] = v(!1), [u, g] = v(!1), [c, x] = v("changes"), [R, b] = v(!1), [N, S] = v(null), w = e.action === "update", C = e.action === "create" || e.action === "restore", W = e.action === "delete", k = W ? e.data ?? {} : C ? {} : s ?? {}, $ = W ? {} : e.data ?? {}, { humanDelta: V, systemDelta: he } = L(() => {
556
+ const n = F(), r = ce(te), m = Ee(e).reason, [h, p] = v(!1), [u, g] = v(!1), [c, x] = v("changes"), [R, b] = v(!1), [N, S] = v(null), w = e.action === "update", C = e.action === "create" || e.action === "restore", W = e.action === "delete", k = W ? e.data ?? {} : C ? {} : s ?? {}, $ = W ? {} : e.data ?? {}, { humanDelta: V, systemDelta: he } = A(() => {
562
557
  const f = e.delta ?? {};
563
558
  let _ = 0, E = 0;
564
559
  for (const J of Object.keys(f)) {
@@ -569,9 +564,9 @@ function ht({
569
564
  }, [e, s, i, w]), xe = w || C, [z, fe] = v(null), be = ee(), [ge, ae] = v(null), re = Q({
570
565
  mutationFn: (f) => n.request(K(`/revisions/${e.id}/revert-field`, { field: f })),
571
566
  onSuccess: (f, _) => {
572
- ae(null), A.success(`Reverted ${y(i, _).label} to this revision's value`), be.invalidateQueries({ queryKey: ["revisions", e.collection, e.item] }), a == null || a();
567
+ ae(null), j.success(`Reverted ${y(i, _).label} to this revision's value`), be.invalidateQueries({ queryKey: ["revisions", e.collection, e.item] }), a == null || a();
573
568
  },
574
- onError: () => A.error("Failed to revert field")
569
+ onError: () => j.error("Failed to revert field")
575
570
  }), ye = w || C ? {
576
571
  confirmField: ge,
577
572
  setConfirmField: ae,
@@ -580,11 +575,11 @@ function ht({
580
575
  } : void 0, H = Q({
581
576
  mutationFn: () => n.request(K(`/revisions/${e.id}/rollback`, {})),
582
577
  onSuccess: (f) => {
583
- g(!1), A.success("Rolled back to this revision");
578
+ g(!1), j.success("Rolled back to this revision");
584
579
  const _ = se(f);
585
- _ && A.warning(_, { duration: 1e4 }), o != null && o.length && e.timestamp && fe(e.timestamp), a == null || a();
580
+ _ && j.warning(_, { duration: 1e4 }), o != null && o.length && e.timestamp && fe(e.timestamp), a == null || a();
586
581
  },
587
- onError: () => A.error("Failed to rollback")
582
+ onError: () => j.error("Failed to rollback")
588
583
  });
589
584
  async function Ne(f) {
590
585
  if (z) {
@@ -598,11 +593,11 @@ function ht({
598
593
  target_timestamp: z
599
594
  })
600
595
  );
601
- A.success(`Restored ${f.label}`);
596
+ j.success(`Restored ${f.label}`);
602
597
  const E = se(_);
603
- E && A.warning(E, { duration: 1e4 });
598
+ E && j.warning(E, { duration: 1e4 });
604
599
  } catch {
605
- A.error(`Failed to restore ${f.label}`);
600
+ j.error(`Failed to restore ${f.label}`);
606
601
  } finally {
607
602
  S(null);
608
603
  }
@@ -615,7 +610,7 @@ function ht({
615
610
  {
616
611
  className: T(
617
612
  "absolute left-[11px] top-[18px] h-2.5 w-2.5 rounded-full ring-4 ring-white dark:ring-card",
618
- mt[e.action ?? ""] ?? "bg-slate-300"
613
+ pt[e.action ?? ""] ?? "bg-slate-300"
619
614
  ),
620
615
  "aria-hidden": !0
621
616
  }
@@ -645,7 +640,7 @@ function ht({
645
640
  /* @__PURE__ */ l("span", { className: "min-w-0 flex-1 truncate text-[12.5px] text-slate-700 dark:text-slate-200", children: [
646
641
  /* @__PURE__ */ t("span", { className: "font-medium", children: P(e, r) }),
647
642
  " ",
648
- /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: pt(e, V, he) }),
643
+ /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ut(e, V, he) }),
649
644
  m && /* @__PURE__ */ l(
650
645
  "span",
651
646
  {
@@ -659,7 +654,7 @@ function ht({
659
654
  }
660
655
  )
661
656
  ] }),
662
- /* @__PURE__ */ t(Ke, { label: e.via_agent }),
657
+ /* @__PURE__ */ t(Me, { label: e.via_agent }),
663
658
  /* @__PURE__ */ t(
664
659
  "span",
665
660
  {
@@ -746,9 +741,9 @@ function ht({
746
741
  ))
747
742
  ] })
748
743
  ] }),
749
- R && /* @__PURE__ */ t(yt, { revisionId: e.id ?? "" }),
744
+ R && /* @__PURE__ */ t(Nt, { revisionId: e.id ?? "" }),
750
745
  /* @__PURE__ */ t(
751
- ct,
746
+ mt,
752
747
  {
753
748
  before: k,
754
749
  after: $,
@@ -777,12 +772,12 @@ function ht({
777
772
  ] })
778
773
  ] });
779
774
  }
780
- function xt({ data: e, meta: s }) {
781
- const [i, a] = v(null), [o, d] = v(""), [n, r] = v(""), [m, h] = v(""), p = L(() => {
775
+ function ft({ data: e, meta: s }) {
776
+ const [i, a] = v(null), [o, d] = v(""), [n, r] = v(""), [m, h] = v(""), p = A(() => {
782
777
  if (!o || !e) return null;
783
778
  const c = (/* @__PURE__ */ new Date(`${o}T23:59:59`)).getTime();
784
779
  return e.find((x) => x.timestamp && new Date(x.timestamp).getTime() <= c) ?? null;
785
- }, [o, e]), u = L(() => {
780
+ }, [o, e]), u = A(() => {
786
781
  if (!n || !m || !e) return null;
787
782
  const c = (/* @__PURE__ */ new Date(`${n}T23:59:59`)).getTime(), x = (/* @__PURE__ */ new Date(`${m}T23:59:59`)).getTime();
788
783
  if (x <= c) return { error: "The second date must be after the first" };
@@ -969,7 +964,7 @@ function xt({ data: e, meta: s }) {
969
964
  ] })
970
965
  ] });
971
966
  }
972
- function ft(e) {
967
+ function bt(e) {
973
968
  return e ? new Date(e).toLocaleDateString([], {
974
969
  weekday: "short",
975
970
  month: "short",
@@ -977,7 +972,7 @@ function ft(e) {
977
972
  year: "numeric"
978
973
  }) : "Unknown date";
979
974
  }
980
- function bt({
975
+ function gt({
981
976
  collection: e,
982
977
  item: s,
983
978
  onRollback: i,
@@ -988,37 +983,37 @@ function bt({
988
983
  queryFn: () => o.request(D("/revisions", { collection: e, item: s })).then((b) => b.data ?? []),
989
984
  staleTime: 3e4
990
985
  }), m = ee();
991
- Pe(e, s, [["revisions", e, s]], { client: m });
992
- const h = $e(null), p = L(() => {
986
+ Be(e, s, [["revisions", e, s]], { client: m });
987
+ const h = $e(null), p = A(() => {
993
988
  if (!n) return /* @__PURE__ */ new Set();
994
989
  const b = n.map(O);
995
990
  if (!h.current)
996
991
  return h.current = new Set(b), /* @__PURE__ */ new Set();
997
992
  const N = h.current;
998
993
  return new Set(b.filter((S) => !N.has(S)));
999
- }, [n]), u = (n == null ? void 0 : n.length) ?? 0, g = L(() => (n ?? []).filter(G), [n]), c = L(
994
+ }, [n]), u = (n == null ? void 0 : n.length) ?? 0, g = A(() => (n ?? []).filter(G), [n]), c = A(
1000
995
  () => (n ?? []).filter((b) => b.actor && b.actor.kind !== "person").map((b) => ({ action: b.action, user: b.user_id, actor: b.actor })),
1001
996
  [n]
1002
- ), x = Ie(c, { enabled: c.length > 0 }), R = L(() => {
997
+ ), x = Ke(c, { enabled: c.length > 0 }), R = A(() => {
1003
998
  const b = [];
1004
999
  for (const N of n ?? []) {
1005
- const S = ft(N.timestamp), w = b[b.length - 1];
1000
+ const S = bt(N.timestamp), w = b[b.length - 1];
1006
1001
  w && w.day === S ? w.revisions.push(N) : b.push({ day: S, revisions: [N] });
1007
1002
  }
1008
1003
  return b;
1009
1004
  }, [n]);
1010
- return r ? /* @__PURE__ */ t("div", { className: "space-y-2 pt-3", children: [1, 2, 3, 4].map((b) => /* @__PURE__ */ t(Je, { className: "h-11 rounded-md" }, b)) }) : u === 0 ? /* @__PURE__ */ l("div", { className: "flex flex-col items-center py-16 text-center", children: [
1005
+ return r ? /* @__PURE__ */ t("div", { className: "space-y-2 pt-3", children: [1, 2, 3, 4].map((b) => /* @__PURE__ */ t(Qe, { className: "h-11 rounded-md" }, b)) }) : u === 0 ? /* @__PURE__ */ l("div", { className: "flex flex-col items-center py-16 text-center", children: [
1011
1006
  /* @__PURE__ */ t(Y, { className: "mb-2 h-8 w-8 text-slate-300 dark:text-slate-600" }),
1012
1007
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No history yet" }),
1013
1008
  /* @__PURE__ */ t("p", { className: "mt-1 max-w-[38ch] text-[12px] text-slate-400", children: "Every save records who changed what — the trail will appear here." })
1014
1009
  ] }) : /* @__PURE__ */ t(te.Provider, { value: x, children: /* @__PURE__ */ l("div", { className: "space-y-3 pt-3", children: [
1015
- /* @__PURE__ */ t(xt, { data: g, meta: d }),
1016
- g.length >= 3 && /* @__PURE__ */ t(Nt, { revisions: g, meta: d }),
1010
+ /* @__PURE__ */ t(ft, { data: g, meta: d }),
1011
+ g.length >= 3 && /* @__PURE__ */ t(kt, { revisions: g, meta: d }),
1017
1012
  /* @__PURE__ */ t("div", { children: R.map((b) => /* @__PURE__ */ l("div", { children: [
1018
1013
  /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-6 border-b border-slate-100 bg-white px-6 py-1.5 dark:border-border/60 dark:bg-card", children: /* @__PURE__ */ t("span", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: b.day }) }),
1019
1014
  b.revisions.map((N) => {
1020
1015
  const S = (n ?? []).indexOf(N), w = S === ((n == null ? void 0 : n.length) ?? 1) - 1;
1021
- if (Ye(N))
1016
+ if (Ge(N))
1022
1017
  return /* @__PURE__ */ l(
1023
1018
  "div",
1024
1019
  {
@@ -1028,7 +1023,7 @@ function bt({
1028
1023
  ),
1029
1024
  children: [
1030
1025
  p.has(O(N)) && /* @__PURE__ */ t(oe, {}),
1031
- /* @__PURE__ */ t(ut, { revision: N, isLast: w })
1026
+ /* @__PURE__ */ t(ht, { revision: N, isLast: w })
1032
1027
  ]
1033
1028
  },
1034
1029
  O(N)
@@ -1044,7 +1039,7 @@ function bt({
1044
1039
  children: [
1045
1040
  p.has(O(N)) && /* @__PURE__ */ t(oe, {}),
1046
1041
  /* @__PURE__ */ t(
1047
- ht,
1042
+ xt,
1048
1043
  {
1049
1044
  revision: N,
1050
1045
  previousData: (C == null ? void 0 : C.data) ?? null,
@@ -1075,7 +1070,7 @@ function oe() {
1075
1070
  )
1076
1071
  );
1077
1072
  }
1078
- function It({
1073
+ function Kt({
1079
1074
  collection: e,
1080
1075
  item: s,
1081
1076
  onRollback: i,
@@ -1085,8 +1080,8 @@ function It({
1085
1080
  onOpenChange: n,
1086
1081
  compact: r
1087
1082
  }) {
1088
- return /* @__PURE__ */ l(Ue, { open: d, onOpenChange: n, children: [
1089
- !(d !== void 0) && /* @__PURE__ */ t(We, { asChild: !0, children: /* @__PURE__ */ l(
1083
+ return /* @__PURE__ */ l(We, { open: d, onOpenChange: n, children: [
1084
+ !(d !== void 0) && /* @__PURE__ */ t(Ve, { asChild: !0, children: /* @__PURE__ */ l(
1090
1085
  M,
1091
1086
  {
1092
1087
  variant: r ? "ghost" : "outline",
@@ -1100,18 +1095,18 @@ function It({
1100
1095
  ]
1101
1096
  }
1102
1097
  ) }),
1103
- /* @__PURE__ */ t(Ve, { className: "w-[720px] overflow-y-auto p-0 sm:max-w-[92vw]", children: /* @__PURE__ */ l("div", { className: "p-6", children: [
1104
- /* @__PURE__ */ l(ze, { children: [
1105
- /* @__PURE__ */ l(He, { className: "flex items-center gap-2 text-base", children: [
1098
+ /* @__PURE__ */ t(ze, { className: "w-[720px] overflow-y-auto p-0 sm:max-w-[92vw]", children: /* @__PURE__ */ l("div", { className: "p-6", children: [
1099
+ /* @__PURE__ */ l(He, { children: [
1100
+ /* @__PURE__ */ l(Je, { className: "flex items-center gap-2 text-base", children: [
1106
1101
  /* @__PURE__ */ t(Y, { className: "h-4 w-4 text-slate-400" }),
1107
1102
  "Revision history"
1108
1103
  ] }),
1109
1104
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Who changed what, when — expand any entry to see the exact values, revert a single field, or restore the whole version." })
1110
1105
  ] }),
1111
- /* @__PURE__ */ t(gt, { collection: e, item: s }),
1112
- /* @__PURE__ */ t(Qe, { collection: e, item: String(s) }),
1106
+ /* @__PURE__ */ t(yt, { collection: e, item: s }),
1107
+ /* @__PURE__ */ t(Ye, { collection: e, item: String(s) }),
1113
1108
  /* @__PURE__ */ t(
1114
- bt,
1109
+ gt,
1115
1110
  {
1116
1111
  collection: e,
1117
1112
  item: s,
@@ -1122,7 +1117,7 @@ function It({
1122
1117
  ] }) })
1123
1118
  ] });
1124
1119
  }
1125
- function gt({ collection: e, item: s }) {
1120
+ function yt({ collection: e, item: s }) {
1126
1121
  const i = F(), a = ue(e, !0), [o, d] = v(""), [n, r] = v(""), { data: m, isFetching: h } = B({
1127
1122
  queryKey: ["rev-value-search", e, s, n],
1128
1123
  queryFn: () => i.request(D("/revisions/value-search", { collection: e, item: s, q: n })).then((p) => p.data),
@@ -1160,7 +1155,7 @@ function gt({ collection: e, item: s }) {
1160
1155
  "“",
1161
1156
  n,
1162
1157
  "” never appears in this record’s recorded changes."
1163
- ] }) : /* @__PURE__ */ l(j, { children: [
1158
+ ] }) : /* @__PURE__ */ l(L, { children: [
1164
1159
  m == null ? void 0 : m.matches.map((p) => /* @__PURE__ */ l("div", { className: "text-[11.5px]", children: [
1165
1160
  /* @__PURE__ */ t("p", { className: "text-slate-600 dark:text-slate-300", children: p.fields.map((u) => /* @__PURE__ */ l("span", { children: [
1166
1161
  /* @__PURE__ */ t("span", { className: "font-medium", title: u.field, children: y(a, u.field).label }),
@@ -1183,7 +1178,7 @@ function gt({ collection: e, item: s }) {
1183
1178
  ] }) })
1184
1179
  ] });
1185
1180
  }
1186
- function yt({ revisionId: e }) {
1181
+ function Nt({ revisionId: e }) {
1187
1182
  const s = F(), i = ee(), [a, o] = v(""), { data: d = [] } = B({
1188
1183
  queryKey: ["revision-notes", String(e)],
1189
1184
  queryFn: () => s.request(D("/comments", { collection: "nivaro_revisions", item: String(e) })).then((r) => r.data ?? []).catch(() => []),
@@ -1195,7 +1190,7 @@ function yt({ revisionId: e }) {
1195
1190
  onSuccess: () => {
1196
1191
  o(""), i.invalidateQueries({ queryKey: ["revision-notes", String(e)] });
1197
1192
  },
1198
- onError: () => A.error("Note failed")
1193
+ onError: () => j.error("Note failed")
1199
1194
  });
1200
1195
  return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-100 bg-slate-50/60 p-2 dark:border-border/60 dark:bg-muted/30", children: [
1201
1196
  d.map((r) => /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: [
@@ -1239,7 +1234,7 @@ function yt({ revisionId: e }) {
1239
1234
  )
1240
1235
  ] });
1241
1236
  }
1242
- function Nt({
1237
+ function kt({
1243
1238
  revisions: e,
1244
1239
  meta: s
1245
1240
  }) {
@@ -1299,6 +1294,6 @@ function Nt({
1299
1294
  ] });
1300
1295
  }
1301
1296
  export {
1302
- It as RevisionsPanel,
1303
- et as displayValue
1297
+ Kt as RevisionsPanel,
1298
+ tt as displayValue
1304
1299
  };