@nivaro/react 0.3.137 → 0.3.138

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 (49) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +95 -4
  4. package/dist/index.js +748 -743
  5. package/dist/shared/components/CollectionBrowserView.js +392 -389
  6. package/dist/shared/components/DelegateCoverLine.js +80 -87
  7. package/dist/shared/components/ItemEditForm.js +589 -588
  8. package/dist/shared/components/MyWorkView.js +284 -286
  9. package/dist/shared/components/NotificationBell.js +251 -205
  10. package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
  11. package/dist/shared/components/ai/AiPlanCard.js +164 -122
  12. package/dist/shared/components/ai/AiPlanUndo.js +291 -0
  13. package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
  14. package/dist/shared/components/ai/call-log/RawJson.js +126 -0
  15. package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
  16. package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
  17. package/dist/shared/components/ai/call-log/controls.js +364 -0
  18. package/dist/shared/components/ai/call-log/format.js +46 -0
  19. package/dist/shared/components/ai/call-log/url.js +105 -0
  20. package/dist/shared/components/chat/chat-core.js +422 -346
  21. package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
  22. package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
  23. package/dist/shared/components/integrations/console/api.js +11 -1
  24. package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
  25. package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
  26. package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
  27. package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
  28. package/dist/shared/components/item-edit/live-related.js +34 -18
  29. package/dist/shared/components/panels/RevisionsPanel.js +735 -683
  30. package/dist/shared/components/queue/QueueWorklist.js +323 -316
  31. package/dist/shared/components/support/SupportRequestDialog.js +198 -181
  32. package/dist/shared/components/trackers/use-tracker-link.js +74 -65
  33. package/dist/shared/lib/config-update-refresh.js +34 -0
  34. package/dist/shared/lib/config-watch.js +17 -17
  35. package/dist/shared/lib/gap-refresh.js +49 -0
  36. package/dist/shared/lib/integration-dots.js +8 -8
  37. package/dist/shared/lib/live-ops.js +26 -23
  38. package/dist/shared/lib/live-pickers.js +1 -1
  39. package/dist/shared/lib/live-queries.js +223 -195
  40. package/dist/shared/lib/live.js +56 -51
  41. package/dist/shared/lib/obligation-banner.js +11 -10
  42. package/dist/shared/lib/obligation-filters.js +22 -18
  43. package/dist/shared/lib/obligation-reason-text.js +18 -8
  44. package/dist/shared/lib/presence-hooks.js +133 -132
  45. package/dist/shared/lib/reconnect-resync.js +90 -0
  46. package/dist/shared/lib/record-room-holds.js +43 -0
  47. package/dist/shared/lib/socket-realtime.js +116 -105
  48. package/dist/shared/lib/user-sync.js +1 -6
  49. package/package.json +1 -1
@@ -1,34 +1,34 @@
1
- import { jsx as d, jsxs as u } from "react/jsx-runtime";
2
- import { useQueryClient as fe } from "@tanstack/react-query";
3
- import { EyeOff as he, ArrowLeft as ye, Trash2 as ge, Copy as be, FileUp as ve, Bot as xe, UploadCloud as I } from "lucide-react";
4
- import { useState as N, useRef as b, useEffect as Q } from "react";
1
+ import { jsx as d, jsxs as l } from "react/jsx-runtime";
2
+ import { useQueryClient as he } from "@tanstack/react-query";
3
+ import { EyeOff as ge, ArrowLeft as ye, Trash2 as be, Copy as ve, FileUp as xe, Bot as we, UploadCloud as I } from "lucide-react";
4
+ import { useState as R, useRef as x, useEffect as q } from "react";
5
5
  import { toast as B } from "sonner";
6
- import { useNivaroClient as we, useRecordSurface as ke, useItemEditAuth as Se } from "../../context.js";
7
- import { get as j, post as Ne } from "../../lib/commands.js";
8
- import { useLiveRecord as Re, useLiveEvent as ee, useLiveRecordEvent as re, LIVE_ASPECTS as m, batchTouches as Te } from "../../lib/live.js";
6
+ import { useNivaroClient as ke, useRecordSurface as Se, useItemEditAuth as Ne } from "../../context.js";
7
+ import { get as j, post as Re } from "../../lib/commands.js";
8
+ import { useLiveRecord as Te, useLiveEvent as ee, useLiveRecordEvent as re, LIVE_ASPECTS as c, batchTouches as Qe } from "../../lib/live.js";
9
9
  import { useOptionalRealtime as _e } from "../../lib/realtime.js";
10
- import { useRecordTabsSignal as Ke, useRecordTabs as Qe, otherTabNote as Ee } from "../../lib/record-tabs.js";
11
- import { userErrorMessage as qe } from "../../lib/safe-error.js";
10
+ import { useRecordTabsSignal as Ke, useRecordTabs as qe, otherTabNote as Ee } from "../../lib/record-tabs.js";
11
+ import { userErrorMessage as Oe } from "../../lib/safe-error.js";
12
12
  import { useRemoteUploads as Ae, UPLOAD_STATE_EVENT as te, uploadSentence as ne, applyRemoteUpload as De } from "../../lib/upload-presence.js";
13
- import { formatRelative as Oe, cn as se } from "../../lib/utils.js";
14
- import { CollectionImportBanner as $e } from "../CollectionImportBanner.js";
13
+ import { formatRelative as $e, cn as se } from "../../lib/utils.js";
14
+ import { CollectionImportBanner as Le } from "../CollectionImportBanner.js";
15
15
  import { markLiveRecordWrite as ae } from "./live-record-marks.js";
16
- import { ADDENDUM_DETAIL_KEYS as Le, wideSpreadDelay as Ce, actionQueryOfRecord as Me, fileQueryOfRecord as Ue, resolvedPathQueryOfRecord as Be, relatedQueryOfRecord as je } from "./live-related.js";
17
- function Fe(e, t, c) {
18
- var g;
19
- if (c.active)
20
- return { text: e ? `${e} moved this to ${t}` : `This record moved to ${t}` };
21
- const v = ((g = c.label) == null ? void 0 : g.trim()) || "A record in your tabs";
16
+ import { ADDENDUM_DETAIL_KEYS as Ce, wideSpreadDelay as Me, actionQueryOfRecord as Ue, obligationQueryOfRecord as Be, proposalQueryOfRecord as je, integrationQueryOfRecord as Fe, fileQueryOfRecord as Pe, resolvedPathQueryOfRecord as Ye, relatedQueryOfRecord as Ve } from "./live-related.js";
17
+ function We(e, r, u) {
18
+ var v;
19
+ if (u.active)
20
+ return { text: e ? `${e} moved this to ${r}` : `This record moved to ${r}` };
21
+ const g = ((v = u.label) == null ? void 0 : v.trim()) || "A record in your tabs";
22
22
  return {
23
- text: e ? `${e} moved ${v} to ${t}` : `${v} moved to ${t}`,
24
- open: c.open
23
+ text: e ? `${e} moved ${g} to ${r}` : `${g} moved to ${r}`,
24
+ open: u.open
25
25
  };
26
26
  }
27
- function Pe(e, t) {
28
- const c = e == null ? void 0 : e.user_id;
29
- return typeof c == "string" && !!t && c.toUpperCase() === String(t).toUpperCase();
27
+ function He(e, r) {
28
+ const u = e == null ? void 0 : e.user_id;
29
+ return typeof u == "string" && !!r && u.toUpperCase() === String(r).toUpperCase();
30
30
  }
31
- const Ye = 8e3, ie = [
31
+ const ze = 8e3, ie = [
32
32
  "item",
33
33
  "rrv-record",
34
34
  "revisions",
@@ -53,35 +53,40 @@ const Ye = 8e3, ie = [
53
53
  "item-actions",
54
54
  "ext-item-actions",
55
55
  // The SLA clock (SlaClock.tsx slaStatusKey).
56
- "sla-breach"
56
+ "sla-breach",
57
+ // rt-fix C: the Change proposals panel, the partner's external ids, dynamic attributes.
58
+ "change-proposals",
59
+ "record-external-ids",
60
+ "attribute-values"
57
61
  ];
58
- function Ve(e, t, c) {
59
- const v = new Set(ie), g = String(c);
60
- e.removeQueries({
61
- predicate: (l) => v.has(l.queryKey[0]) && l.queryKey[1] === t && String(l.queryKey[2]) === g
62
- });
62
+ function oe(e, r, u, g) {
63
+ return e[0] === "integration-obligations" ? e[1] === "record" && e[2] === u && g.has(String(e[3])) : r.has(e[0]) && e[1] === u && g.has(String(e[2]));
64
+ }
65
+ function Ge(e, r, u) {
66
+ const g = new Set(ie), v = /* @__PURE__ */ new Set([String(u)]);
67
+ e.removeQueries({ predicate: (b) => oe(b.queryKey, g, r, v) });
63
68
  }
64
- function cr(e, t, c) {
65
- if (!t || c.length === 0) return;
66
- const v = new Set(ie), g = new Set(c.map(String));
69
+ function fr(e, r, u) {
70
+ if (!r || u.length === 0) return;
71
+ const g = new Set(ie), v = new Set(u.map(String));
67
72
  e.invalidateQueries({
68
- predicate: (l) => v.has(l.queryKey[0]) && l.queryKey[1] === t && g.has(String(l.queryKey[2]))
73
+ predicate: (b) => oe(b.queryKey, g, r, v)
69
74
  });
70
75
  }
71
- function We({ onBack: e }) {
72
- return /* @__PURE__ */ d("div", { className: "p-6", children: /* @__PURE__ */ u(
76
+ function Je({ onBack: e }) {
77
+ return /* @__PURE__ */ d("div", { className: "p-6", children: /* @__PURE__ */ l(
73
78
  "div",
74
79
  {
75
80
  "data-record-gone": "access",
76
81
  role: "alert",
77
82
  className: "flex items-center gap-3 rounded-lg border border-amber-300 bg-amber-50 px-3.5 py-2.5 dark:border-amber-500/40 dark:bg-amber-500/10",
78
83
  children: [
79
- /* @__PURE__ */ d(he, { className: "h-4 w-4 shrink-0 text-amber-500" }),
80
- /* @__PURE__ */ u("p", { className: "min-w-0 flex-1 text-[12px] text-amber-800 dark:text-amber-300", children: [
84
+ /* @__PURE__ */ d(ge, { className: "h-4 w-4 shrink-0 text-amber-500" }),
85
+ /* @__PURE__ */ l("p", { className: "min-w-0 flex-1 text-[12px] text-amber-800 dark:text-amber-300", children: [
81
86
  /* @__PURE__ */ d("span", { className: "font-semibold", children: "You no longer have access to this record." }),
82
87
  " A role, scope or filter change hid it while you had it open."
83
88
  ] }),
84
- /* @__PURE__ */ u(
89
+ /* @__PURE__ */ l(
85
90
  "button",
86
91
  {
87
92
  type: "button",
@@ -98,257 +103,264 @@ function We({ onBack: e }) {
98
103
  }
99
104
  ) });
100
105
  }
101
- const He = (e) => {
102
- var t;
103
- return (e == null ? void 0 : e.status) ?? ((t = e == null ? void 0 : e.response) == null ? void 0 : t.status);
106
+ const Xe = (e) => {
107
+ var r;
108
+ return (e == null ? void 0 : e.status) ?? ((r = e == null ? void 0 : e.response) == null ? void 0 : r.status);
104
109
  };
105
- function lr({
110
+ function hr({
106
111
  collection: e,
107
- itemId: t,
108
- dirty: c = !1,
109
- loadDenied: v = !1,
110
- onGoneChange: g
112
+ itemId: r,
113
+ dirty: u = !1,
114
+ loadDenied: g = !1,
115
+ onGoneChange: v
111
116
  }) {
112
- const l = _e(), E = we(), p = fe(), [O, F] = N(!1), [oe, de] = N(null), x = Ae(e, String(t), "unclaimed"), [o, ue] = N(null), [ce, $] = N({}), [P, Y] = N(!1), [V, W] = N(!1), R = b(null), T = b(null), _ = b(null), q = b(Date.now()), L = b(null), A = b(g);
113
- A.current = g;
114
- const w = b(null), H = ke(), z = b(H);
117
+ const b = _e(), E = ke(), m = he(), [$, F] = R(!1), [de, ue] = R(null), w = Ae(e, String(r), "unclaimed"), [o, ce] = R(null), [le, L] = R({}), [P, Y] = R(!1), [V, W] = R(!1), T = x(null), Q = x(null), _ = x(null), O = x(Date.now()), C = x(null), A = x(v);
118
+ A.current = v;
119
+ const k = x(null), H = Se(), z = x(H);
115
120
  z.current = H;
116
- const K = (r) => {
121
+ const K = (t) => {
117
122
  var n;
118
- w.current = r, ue(r), (n = A.current) == null || n.call(A, r), (r == null ? void 0 : r.kind) === "access" && setTimeout(() => Ve(p, e, t), 0);
123
+ k.current = t, ce(t), (n = A.current) == null || n.call(A, t), (t == null ? void 0 : t.kind) === "access" && setTimeout(() => Ge(m, e, r), 0);
119
124
  };
120
- Q(() => {
121
- q.current = Date.now(), L.current = null, $({}), w.current && K(null);
122
- }, [e, t]);
123
- const f = (r) => {
124
- for (const n of r) p.invalidateQueries({ queryKey: n });
125
- }, C = async (r) => {
125
+ q(() => {
126
+ O.current = Date.now(), C.current = null, L({}), k.current && K(null);
127
+ }, [e, r]);
128
+ const h = (t) => {
129
+ for (const n of t) m.invalidateQueries({ queryKey: n });
130
+ }, M = async (t) => {
126
131
  let n = null;
127
132
  try {
128
133
  n = (await E.request(
129
- j("/trash/record", { collection: e, item: t })
134
+ j("/trash/record", { collection: e, item: r })
130
135
  )).data;
131
136
  } catch {
132
137
  n = null;
133
138
  }
134
- const i = !!(n != null && n.deleted_at) && new Date(n.deleted_at).getTime() >= q.current - 6e4;
135
- K(i || r === "deleted" && !n ? {
139
+ const i = !!(n != null && n.deleted_at) && new Date(n.deleted_at).getTime() >= O.current - 6e4;
140
+ K(i || t === "deleted" && !n ? {
136
141
  kind: "deleted",
137
142
  by: (n == null ? void 0 : n.deleted_by_name) ?? null,
138
143
  at: (n == null ? void 0 : n.deleted_at) ?? (/* @__PURE__ */ new Date()).toISOString(),
139
144
  trashId: (n == null ? void 0 : n.trash_id) ?? null,
140
145
  canRestore: !!(n != null && n.can_restore)
141
146
  } : { kind: "access" });
142
- }, le = async () => {
143
- var r;
147
+ }, me = async () => {
148
+ var t;
144
149
  try {
145
150
  const n = (await E.request(
146
- j(`/pipelines/instance/${e}/${t}`)
147
- )).data, i = (r = n == null ? void 0 : n.history) == null ? void 0 : r[0];
148
- if (!i || i.id === L.current || i.timestamp && new Date(i.timestamp).getTime() < q.current - 5e3 || (L.current = i.id, typeof document < "u" && document.visibilityState === "hidden")) return;
149
- const h = [i.first_name, i.last_name].filter(Boolean).join(" ") || i.user_email || null, y = i.to_state_label ?? "a new state", a = Fe(h, y, z.current);
151
+ j(`/pipelines/instance/${e}/${r}`)
152
+ )).data, i = (t = n == null ? void 0 : n.history) == null ? void 0 : t[0];
153
+ if (!i || i.id === C.current || i.timestamp && new Date(i.timestamp).getTime() < O.current - 5e3 || (C.current = i.id, typeof document < "u" && document.visibilityState === "hidden")) return;
154
+ const p = [i.first_name, i.last_name].filter(Boolean).join(" ") || i.user_email || null, f = i.to_state_label ?? "a new state", a = We(p, f, z.current);
150
155
  B.info(
151
156
  a.text,
152
157
  a.open ? { action: { label: "Open", onClick: a.open } } : {}
153
158
  );
154
159
  } catch {
155
160
  }
156
- }, me = (r) => {
157
- var i, h, y, a;
158
- if (r.deleted) {
159
- C("deleted");
161
+ }, pe = (t) => {
162
+ var i, p, f, a;
163
+ if (t.deleted) {
164
+ M("deleted");
160
165
  return;
161
166
  }
162
- if (w.current) return;
163
- r.events.some((s) => s.source === "import" && !s.own) && (W(!0), R.current && clearTimeout(R.current), R.current = setTimeout(() => W(!1), Ye));
164
- const n = (s) => Te(r, s);
165
- if (n(m.state)) {
166
- f([
167
- ["pipeline-instance", e, t],
168
- ["pipeline-all-owners", e, t],
169
- ["pipeline-instance-owners", e, t],
170
- ["pipeline-owners-resolved", e, t],
171
- ["approval-brief", e, t]
167
+ if (k.current) return;
168
+ t.events.some((s) => s.source === "import" && !s.own) && (W(!0), T.current && clearTimeout(T.current), T.current = setTimeout(() => W(!1), ze));
169
+ const n = (s) => Qe(t, s);
170
+ if (n(c.state)) {
171
+ h([
172
+ ["pipeline-instance", e, r],
173
+ ["pipeline-all-owners", e, r],
174
+ ["pipeline-instance-owners", e, r],
175
+ ["pipeline-owners-resolved", e, r],
176
+ ["approval-brief", e, r]
172
177
  ]);
173
- const s = Me(e, String(t));
174
- p.invalidateQueries({ predicate: (k) => s(k.queryKey) }), (i = r.changedFields) != null && i.includes(m.state) && le();
178
+ const s = Ue(e, String(r));
179
+ m.invalidateQueries({ predicate: (S) => s(S.queryKey) });
180
+ const y = Be(e, String(r));
181
+ m.invalidateQueries({ predicate: (S) => y(S.queryKey) }), (i = t.changedFields) != null && i.includes(c.state) && me();
175
182
  }
176
- if (n(m.owners) && !n(m.state) && f([
177
- ["pipeline-all-owners", e, t],
178
- ["pipeline-instance-owners", e, t],
179
- ["pipeline-owners-resolved", e, t],
180
- ["approval-brief", e, t]
181
- ]), !(r.aspectsOnly && ((h = r.changedFields) != null && h.every((s) => s === m.owners)))) {
182
- if (n(m.addendums) && f([["addendums", e, t], ...Le.map((s) => [...s])]), n(m.comments) ? f([
183
- ["comments", e, t],
184
- ["comments-related", e, t]
185
- ]) : (n(m.state) || n(m.integrations) || n(m.addendums) || !r.aspectsOnly) && f([["comments-related", e, t]]), n(m.tasks) && f([["tasks", e, t]]), n(m.integrations) && f([
186
- ["erp-submissions", e, t],
187
- ["record-integrations", e, t]
188
- ]), n(m.files)) {
189
- const s = Ue(e, String(t));
190
- p.invalidateQueries({ predicate: (k) => s(k.queryKey) });
183
+ if (n(c.owners) && !n(c.state) && h([
184
+ ["pipeline-all-owners", e, r],
185
+ ["pipeline-instance-owners", e, r],
186
+ ["pipeline-owners-resolved", e, r],
187
+ ["approval-brief", e, r]
188
+ ]), !(t.aspectsOnly && ((p = t.changedFields) != null && p.every((s) => s === c.owners)))) {
189
+ if (n(c.addendums) && h([["addendums", e, r], ...Ce.map((s) => [...s])]), n(c.comments) && h([
190
+ ["comments", e, r],
191
+ ["comments-related", e, r]
192
+ ]), n(c.proposals) || n(c.comments)) {
193
+ const s = je(e, String(r));
194
+ m.invalidateQueries({ predicate: (y) => s(y.queryKey) });
195
+ } else (n(c.state) || n(c.integrations) || n(c.addendums) || !t.aspectsOnly) && h([["comments-related", e, r]]);
196
+ if (n(c.tasks) && h([["tasks", e, r]]), n(c.integrations)) {
197
+ const s = Fe(e, String(r));
198
+ m.invalidateQueries({ predicate: (y) => s(y.queryKey) });
199
+ }
200
+ if (n(c.files)) {
201
+ const s = Pe(e, String(r));
202
+ m.invalidateQueries({ predicate: (y) => s(y.queryKey) });
191
203
  }
192
- if (n(m.related)) {
193
- const s = je(e, String(t)), k = () => void p.invalidateQueries({ predicate: (U) => s(U.queryKey) });
194
- r.ids.length > 0 && r.ids.every((U) => U === "*") ? (_.current && clearTimeout(_.current), _.current = setTimeout(k, Ce())) : k();
204
+ if (n(c.related) || n(c.attributes)) {
205
+ const s = Ve(e, String(r)), y = () => void m.invalidateQueries({ predicate: (S) => s(S.queryKey) });
206
+ t.ids.length > 0 && t.ids.every((S) => S === "*") ? (_.current && clearTimeout(_.current), _.current = setTimeout(y, Me())) : y();
195
207
  }
196
- if (p.invalidateQueries({
197
- predicate: (s) => (s.queryKey[0] === "child-summary" || s.queryKey[0] === "field-lineage") && s.queryKey[1] === e && String(s.queryKey[2]) === String(t)
198
- }), (y = r.changedFields) != null && y.includes(m.related) && p.invalidateQueries({
199
- predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === String(t)
200
- }), !r.aspectsOnly) {
201
- if (r.ids.length > 0 && r.ids.every((s) => s === "*")) {
202
- f([
203
- ["item", e, t],
204
- ["pipeline-instance", e, t]
208
+ if (m.invalidateQueries({
209
+ predicate: (s) => (s.queryKey[0] === "child-summary" || s.queryKey[0] === "field-lineage") && s.queryKey[1] === e && String(s.queryKey[2]) === String(r)
210
+ }), (f = t.changedFields) != null && f.includes(c.related) && m.invalidateQueries({
211
+ predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === String(r)
212
+ }), !t.aspectsOnly) {
213
+ if (t.ids.length > 0 && t.ids.every((s) => s === "*")) {
214
+ h([
215
+ ["item", e, r],
216
+ ["pipeline-instance", e, r]
205
217
  ]);
206
218
  return;
207
219
  }
208
- p.invalidateQueries({
209
- predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === String(t) || s.queryKey[0] === "o2m-compare"
220
+ m.invalidateQueries({
221
+ predicate: (s) => s.queryKey[0] === "o2m-rows" && String(s.queryKey[3]) === String(r) || s.queryKey[0] === "o2m-compare"
210
222
  }), ae(
211
223
  e,
212
- t,
213
- ((a = r.changedFields) == null ? void 0 : a.filter((s) => !s.startsWith("$"))) ?? null
224
+ r,
225
+ ((a = t.changedFields) == null ? void 0 : a.filter((s) => !s.startsWith("$"))) ?? null
214
226
  ), G(!0);
215
227
  }
216
228
  }
217
- }, G = async (r) => {
218
- f([
219
- ["item", e, t],
229
+ }, G = async (t) => {
230
+ h([
231
+ ["item", e, r],
220
232
  // Summary mode reads its own copy (#1869) — it diffs + highlights.
221
- ["rrv-record", e, t],
222
- ["field-touch", e, t],
223
- ["revisions", e, t]
233
+ ["rrv-record", e, r],
234
+ ["field-touch", e, r],
235
+ ["revisions", e, r]
224
236
  ]);
225
- const n = Be(e, String(t));
226
- p.invalidateQueries({ predicate: (a) => n(a.queryKey) });
227
- const i = ["last-touch", e, String(t)];
228
- await p.invalidateQueries({ queryKey: i }).catch(() => {
237
+ const n = Ye(e, String(r));
238
+ m.invalidateQueries({ predicate: (a) => n(a.queryKey) });
239
+ const i = ["last-touch", e, String(r)];
240
+ await m.invalidateQueries({ queryKey: i }).catch(() => {
229
241
  });
230
- const h = p.getQueryData(i);
231
- if (!r || Pe(h, J.current)) return;
232
- const y = h == null ? void 0 : h.user_name;
233
- de(typeof y == "string" && y.trim() ? y.trim() : null), F(!0), T.current && clearTimeout(T.current), T.current = setTimeout(() => F(!1), 4e3);
242
+ const p = m.getQueryData(i);
243
+ if (!t || He(p, J.current)) return;
244
+ const f = p == null ? void 0 : p.user_name;
245
+ ue(typeof f == "string" && f.trim() ? f.trim() : null), F(!0), Q.current && clearTimeout(Q.current), Q.current = setTimeout(() => F(!1), 4e3);
234
246
  };
235
- Re(e, t, me);
236
- const { userId: D } = Se(), J = b(D);
237
- J.current = D, Ke(D, "saved", e, t, ({ fields: r }) => {
238
- w.current || (r && ae(e, String(t), r), G(!1), f([
239
- ["pipeline-instance", e, t],
240
- ["comments", e, t],
241
- ["tasks", e, t],
247
+ Te(e, r, pe);
248
+ const { userId: D } = Ne(), J = x(D);
249
+ J.current = D, Ke(D, "saved", e, r, ({ fields: t }) => {
250
+ k.current || (t && ae(e, String(r), t), G(!1), h([
251
+ ["pipeline-instance", e, r],
252
+ ["comments", e, r],
253
+ ["tasks", e, r],
242
254
  // Lines and links saved with it (the keys are per relation, not per record).
243
255
  ["o2m-rows"],
244
256
  ["m2m-items"]
245
257
  ]));
246
- }), Q(
258
+ }), q(
247
259
  () => () => {
248
- T.current && clearTimeout(T.current), R.current && clearTimeout(R.current), _.current && clearTimeout(_.current);
260
+ Q.current && clearTimeout(Q.current), T.current && clearTimeout(T.current), _.current && clearTimeout(_.current);
249
261
  },
250
262
  []
251
263
  ), ee(
252
264
  "owners:changed",
253
- (r) => {
254
- w.current || r != null && r.checked || r != null && r.queues || Array.isArray(r == null ? void 0 : r.collections) && !r.collections.includes(e) || f([
255
- ["pipeline-instance-owners", e, t],
256
- ["pipeline-owners-resolved", e, t],
257
- ["pipeline-all-owners", e, t],
258
- ["approval-brief", e, t]
265
+ (t) => {
266
+ k.current || t != null && t.checked || t != null && t.queues || Array.isArray(t == null ? void 0 : t.collections) && !t.collections.includes(e) || h([
267
+ ["pipeline-instance-owners", e, r],
268
+ ["pipeline-owners-resolved", e, r],
269
+ ["pipeline-all-owners", e, r],
270
+ ["approval-brief", e, r]
259
271
  ]);
260
272
  },
261
273
  { debounceMs: 400 }
262
274
  ), re(
263
275
  "record:integrity",
264
276
  e,
265
- t,
266
- () => f([["record-integrity", e, t]])
277
+ r,
278
+ () => h([["record-integrity", e, r]])
267
279
  );
268
- const X = b(/* @__PURE__ */ new Map());
269
- re("record:automation", e, t, (r) => {
270
- const n = String((r == null ? void 0 : r.flow_id) ?? "");
280
+ const X = x(/* @__PURE__ */ new Map());
281
+ re("record:automation", e, r, (t) => {
282
+ const n = String((t == null ? void 0 : t.flow_id) ?? "");
271
283
  if (!n) return;
272
- const i = X.current, h = i.get(n);
273
- h && clearTimeout(h), i.delete(n);
274
- const y = () => $((a) => {
275
- const { [n]: s, ...k } = a;
276
- return k;
284
+ const i = X.current, p = i.get(n);
285
+ p && clearTimeout(p), i.delete(n);
286
+ const f = () => L((a) => {
287
+ const { [n]: s, ...y } = a;
288
+ return y;
277
289
  });
278
- if ((r == null ? void 0 : r.state) === "end") {
279
- y();
290
+ if ((t == null ? void 0 : t.state) === "end") {
291
+ f();
280
292
  return;
281
293
  }
282
- $((a) => ({ ...a, [n]: String((r == null ? void 0 : r.flow_name) || "An automation") })), i.set(n, setTimeout(y, 5 * 6e4));
283
- }), Q(() => {
284
- const r = X.current;
294
+ L((a) => ({ ...a, [n]: String((t == null ? void 0 : t.flow_name) || "An automation") })), i.set(n, setTimeout(f, 5 * 6e4));
295
+ }), q(() => {
296
+ const t = X.current;
285
297
  return () => {
286
- for (const n of r.values()) clearTimeout(n);
287
- r.clear();
298
+ for (const n of t.values()) clearTimeout(n);
299
+ t.clear();
288
300
  };
289
301
  }, []), ee(
290
302
  "access:changed",
291
303
  () => {
292
304
  setTimeout(
293
305
  () => {
294
- var r;
295
- ((r = w.current) == null ? void 0 : r.kind) !== "deleted" && E.request(j(`/items/${e}/${t}`, { fields: "id" })).then(() => {
306
+ var t;
307
+ ((t = k.current) == null ? void 0 : t.kind) !== "deleted" && E.request(j(`/items/${e}/${r}`, { fields: "id" })).then(() => {
296
308
  var n;
297
- ((n = w.current) == null ? void 0 : n.kind) === "access" && (K(null), f([["item", e, t]]));
309
+ ((n = k.current) == null ? void 0 : n.kind) === "access" && (K(null), h([["item", e, r]]));
298
310
  }).catch((n) => {
299
- const i = He(n);
300
- (i === 403 || i === 404) && C("access");
311
+ const i = Xe(n);
312
+ (i === 403 || i === 404) && M("access");
301
313
  });
302
314
  },
303
315
  Math.floor(Math.random() * 1500)
304
316
  );
305
317
  },
306
318
  { debounceMs: 300 }
307
- ), Q(() => {
308
- v && !w.current && C("access");
309
- }, [v]);
310
- const Z = Qe(e, t, c, D), S = o ? null : Ee({ otherDirty: Z.otherDirty, dirty: c });
311
- Q(() => {
312
- if (!l) return;
313
- const r = (a) => {
319
+ ), q(() => {
320
+ g && !k.current && M("access");
321
+ }, [g]);
322
+ const Z = qe(e, r, u, D), N = o ? null : Ee({ otherDirty: Z.otherDirty, dirty: u });
323
+ q(() => {
324
+ if (!b) return;
325
+ const t = (a) => {
314
326
  const s = a.detail;
315
- s != null && s.name && (s.collection && (s.collection !== e || String(s.item) !== String(t)) || l.emit("record:uploading", { ...s, collection: e, item: String(t) }));
327
+ s != null && s.name && (s.collection && (s.collection !== e || String(s.item) !== String(r)) || b.emit("record:uploading", { ...s, collection: e, item: String(r) }));
316
328
  };
317
- window.addEventListener(te, r);
329
+ window.addEventListener(te, t);
318
330
  const n = (a) => {
319
- (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(t) || De(a);
320
- }, i = l.on("record:uploading", n), h = l.on("record:comment", (a) => {
321
- (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(t) || (p.invalidateQueries({ queryKey: ["comments", e, t] }), p.invalidateQueries({ queryKey: ["comments-related", e, t] }));
322
- }), y = (a) => n(a.detail);
323
- return window.addEventListener("nvr:record-uploading", y), () => {
324
- window.removeEventListener(te, r), window.removeEventListener("nvr:record-uploading", y), i(), h();
331
+ (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(r) || De(a);
332
+ }, i = b.on("record:uploading", n), p = b.on("record:comment", (a) => {
333
+ (a == null ? void 0 : a.collection) !== e || String(a == null ? void 0 : a.item) !== String(r) || (m.invalidateQueries({ queryKey: ["comments", e, r] }), m.invalidateQueries({ queryKey: ["comments-related", e, r] }));
334
+ }), f = (a) => n(a.detail);
335
+ return window.addEventListener("nvr:record-uploading", f), () => {
336
+ window.removeEventListener(te, t), window.removeEventListener("nvr:record-uploading", f), i(), p();
325
337
  };
326
- }, [l, e, t, p]);
327
- const pe = async () => {
338
+ }, [b, e, r, m]);
339
+ const fe = async () => {
328
340
  if (o != null && o.trashId) {
329
341
  Y(!0);
330
342
  try {
331
- await E.request(Ne(`/trash/${o.trashId}/restore`, {})), K(null), q.current = Date.now(), f([["item", e, t]]), B.success("Record restored");
332
- } catch (r) {
333
- B.error(qe(r, "Restore failed"));
343
+ await E.request(Re(`/trash/${o.trashId}/restore`, {})), K(null), O.current = Date.now(), h([["item", e, r]]), B.success("Record restored");
344
+ } catch (t) {
345
+ B.error(Oe(t, "Restore failed"));
334
346
  } finally {
335
347
  Y(!1);
336
348
  }
337
349
  }
338
- }, M = Object.values(ce);
339
- return !o && M.length === 0 && !S && !V && (!l || !O && x.length === 0) ? null : /* @__PURE__ */ u("div", { className: "space-y-2", children: [
340
- (o == null ? void 0 : o.kind) === "deleted" && /* @__PURE__ */ u(
350
+ }, U = Object.values(le);
351
+ return !o && U.length === 0 && !N && !V && (!b || !$ && w.length === 0) ? null : /* @__PURE__ */ l("div", { className: "space-y-2", children: [
352
+ (o == null ? void 0 : o.kind) === "deleted" && /* @__PURE__ */ l(
341
353
  "div",
342
354
  {
343
355
  "data-record-gone": "deleted",
344
356
  role: "alert",
345
357
  className: "flex items-center gap-3 rounded-lg border border-rose-300 bg-rose-50 px-3.5 py-2.5 dark:border-rose-500/40 dark:bg-rose-500/10",
346
358
  children: [
347
- /* @__PURE__ */ d(ge, { className: "h-4 w-4 shrink-0 text-rose-500" }),
348
- /* @__PURE__ */ u("p", { className: "min-w-0 flex-1 text-[12px] text-rose-800 dark:text-rose-300", children: [
359
+ /* @__PURE__ */ d(be, { className: "h-4 w-4 shrink-0 text-rose-500" }),
360
+ /* @__PURE__ */ l("p", { className: "min-w-0 flex-1 text-[12px] text-rose-800 dark:text-rose-300", children: [
349
361
  /* @__PURE__ */ d("span", { className: "font-semibold", children: "This record was deleted" }),
350
362
  o.by ? ` by ${o.by}` : "",
351
- o.at ? ` ${Oe(o.at)}` : "",
363
+ o.at ? ` ${$e(o.at)}` : "",
352
364
  ". Saving is turned off",
353
365
  o.canRestore ? " — restore it to keep working." : "."
354
366
  ] }),
@@ -356,7 +368,7 @@ function lr({
356
368
  "button",
357
369
  {
358
370
  type: "button",
359
- onClick: () => void pe(),
371
+ onClick: () => void fe(),
360
372
  disabled: P,
361
373
  className: "h-7 shrink-0 rounded-md border border-rose-300 bg-white px-2.5 text-[11.5px] font-medium text-rose-700 hover:bg-rose-100 disabled:opacity-50 dark:border-rose-500/40 dark:bg-transparent dark:text-rose-300 dark:hover:bg-rose-500/10",
362
374
  children: P ? "Restoring…" : "Restore"
@@ -365,28 +377,28 @@ function lr({
365
377
  ]
366
378
  }
367
379
  ),
368
- (o == null ? void 0 : o.kind) === "access" && !g && /* @__PURE__ */ d(We, { onBack: () => window.history.back() }),
369
- S && /* @__PURE__ */ u(
380
+ (o == null ? void 0 : o.kind) === "access" && !v && /* @__PURE__ */ d(Je, { onBack: () => window.history.back() }),
381
+ N && /* @__PURE__ */ l(
370
382
  "p",
371
383
  {
372
- "data-record-other-tab": S.tone,
384
+ "data-record-other-tab": N.tone,
373
385
  role: "status",
374
386
  className: se(
375
387
  "flex flex-wrap items-center gap-x-2 gap-y-0.5 px-0.5 text-[11.5px] leading-5",
376
- S.tone === "both" ? "text-amber-800 dark:text-amber-300" : "text-muted-foreground"
388
+ N.tone === "both" ? "text-amber-800 dark:text-amber-300" : "text-muted-foreground"
377
389
  ),
378
390
  children: [
379
391
  /* @__PURE__ */ d(
380
- be,
392
+ ve,
381
393
  {
382
394
  className: se(
383
395
  "h-3.5 w-3.5 shrink-0",
384
- S.tone === "both" ? "text-amber-500" : "text-muted-foreground/70"
396
+ N.tone === "both" ? "text-amber-500" : "text-muted-foreground/70"
385
397
  ),
386
398
  "aria-hidden": !0
387
399
  }
388
400
  ),
389
- /* @__PURE__ */ d("span", { className: "min-w-0", children: S.text }),
401
+ /* @__PURE__ */ d("span", { className: "min-w-0", children: N.text }),
390
402
  /* @__PURE__ */ d(
391
403
  "button",
392
404
  {
@@ -399,62 +411,62 @@ function lr({
399
411
  ]
400
412
  }
401
413
  ),
402
- V && !o && /* @__PURE__ */ u(
414
+ V && !o && /* @__PURE__ */ l(
403
415
  "div",
404
416
  {
405
417
  "data-record-importing": !0,
406
418
  role: "status",
407
419
  className: "flex items-center gap-3 rounded-lg border border-amber-300 bg-amber-50 px-3.5 py-2.5 dark:border-amber-500/40 dark:bg-amber-500/10",
408
420
  children: [
409
- /* @__PURE__ */ d(ve, { className: "h-4 w-4 shrink-0 animate-pulse text-amber-500" }),
410
- /* @__PURE__ */ u("p", { className: "min-w-0 flex-1 text-[12px] text-amber-800 dark:text-amber-300", children: [
421
+ /* @__PURE__ */ d(xe, { className: "h-4 w-4 shrink-0 animate-pulse text-amber-500" }),
422
+ /* @__PURE__ */ l("p", { className: "min-w-0 flex-1 text-[12px] text-amber-800 dark:text-amber-300", children: [
411
423
  /* @__PURE__ */ d("span", { className: "font-semibold", children: "An import is updating this record" }),
412
424
  " — the changed fields refresh here as it goes.",
413
- c ? " Your unsaved edits may be out of date; check them before saving." : ""
425
+ u ? " Your unsaved edits may be out of date; check them before saving." : ""
414
426
  ] })
415
427
  ]
416
428
  }
417
429
  ),
418
- !o && /* @__PURE__ */ d($e, { collection: e, scope: "record" }),
419
- M.length > 0 && !o && /* @__PURE__ */ u(
430
+ !o && /* @__PURE__ */ d(Le, { collection: e, scope: "record" }),
431
+ U.length > 0 && !o && /* @__PURE__ */ l(
420
432
  "div",
421
433
  {
422
434
  "data-record-automation": !0,
423
435
  role: "status",
424
436
  className: "flex items-center gap-3 rounded-lg border border-nvr-cyan/40 bg-nvr-cyan/10 px-3.5 py-2.5",
425
437
  children: [
426
- /* @__PURE__ */ d(xe, { className: "h-4 w-4 shrink-0 animate-pulse text-nvr-cyan" }),
427
- /* @__PURE__ */ u("p", { className: "min-w-0 flex-1 text-[12px] text-[#0e7490] dark:text-slate-200", children: [
438
+ /* @__PURE__ */ d(we, { className: "h-4 w-4 shrink-0 animate-pulse text-nvr-cyan" }),
439
+ /* @__PURE__ */ l("p", { className: "min-w-0 flex-1 text-[12px] text-[#0e7490] dark:text-slate-200", children: [
428
440
  /* @__PURE__ */ d("span", { className: "font-semibold", children: "Automation is updating this record" }),
429
441
  " —",
430
442
  " ",
431
- M.join(", "),
443
+ U.join(", "),
432
444
  ". Its changes appear here when it finishes."
433
445
  ] })
434
446
  ]
435
447
  }
436
448
  ),
437
- l && (O || x.length > 0) && /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-2", children: [
438
- O && /* @__PURE__ */ u(
449
+ b && ($ || w.length > 0) && /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-2", children: [
450
+ $ && /* @__PURE__ */ l(
439
451
  "span",
440
452
  {
441
453
  "data-record-updated-by": !0,
442
454
  className: "inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-nvr-cyan/40 bg-nvr-cyan/10 px-2.5 py-0.5 text-[11px] font-medium text-[#0e7490] dark:text-slate-200",
443
455
  children: [
444
456
  /* @__PURE__ */ d("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-nvr-cyan" }),
445
- /* @__PURE__ */ u("span", { className: "min-w-0", children: [
457
+ /* @__PURE__ */ l("span", { className: "min-w-0", children: [
446
458
  "Updated just now by ",
447
- oe ?? "someone else"
459
+ de ?? "someone else"
448
460
  ] })
449
461
  ]
450
462
  }
451
463
  ),
452
- (x.length > 2 ? [] : x).map((r) => {
453
- const n = ne({ ...r, pct: null });
454
- return /* @__PURE__ */ u(
464
+ (w.length > 2 ? [] : w).map((t) => {
465
+ const n = ne({ ...t, pct: null });
466
+ return /* @__PURE__ */ l(
455
467
  "span",
456
468
  {
457
- "data-remote-upload-chip": r.key,
469
+ "data-remote-upload-chip": t.key,
458
470
  "data-tip": n,
459
471
  className: "inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border border-slate-200 bg-white px-2.5 py-0.5 text-[11px] text-slate-600 dark:border-border dark:bg-card dark:text-slate-300",
460
472
  children: [
@@ -466,20 +478,20 @@ function lr({
466
478
  }
467
479
  ),
468
480
  /* @__PURE__ */ d("span", { className: "min-w-0 truncate", children: n }),
469
- r.pct != null && r.pct > 0 && r.pct < 100 && /* @__PURE__ */ u("span", { className: "shrink-0 tabular-nums text-slate-500 dark:text-slate-400", children: [
470
- r.pct,
481
+ t.pct != null && t.pct > 0 && t.pct < 100 && /* @__PURE__ */ l("span", { className: "shrink-0 tabular-nums text-slate-500 dark:text-slate-400", children: [
482
+ t.pct,
471
483
  "%"
472
484
  ] })
473
485
  ]
474
486
  },
475
- r.key
487
+ t.key
476
488
  );
477
489
  }),
478
- x.length > 2 && /* @__PURE__ */ u(
490
+ w.length > 2 && /* @__PURE__ */ l(
479
491
  "span",
480
492
  {
481
493
  "data-remote-upload-chip": "many",
482
- "data-tip": x.map((r) => ne(r)).join(`
494
+ "data-tip": w.map((t) => ne(t)).join(`
483
495
  `),
484
496
  className: "inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border border-slate-200 bg-white px-2.5 py-0.5 text-[11px] text-slate-600 dark:border-border dark:bg-card dark:text-slate-300",
485
497
  children: [
@@ -490,11 +502,11 @@ function lr({
490
502
  "aria-hidden": !0
491
503
  }
492
504
  ),
493
- /* @__PURE__ */ u("span", { className: "min-w-0 truncate", children: [
494
- x.length,
505
+ /* @__PURE__ */ l("span", { className: "min-w-0 truncate", children: [
506
+ w.length,
495
507
  " uploads in progress ·",
496
508
  " ",
497
- [...new Set(x.map((r) => r.user))].join(", ")
509
+ [...new Set(w.map((t) => t.user))].join(", ")
498
510
  ] })
499
511
  ]
500
512
  }
@@ -504,10 +516,10 @@ function lr({
504
516
  }
505
517
  export {
506
518
  ie as RECORD_QUERY_HEADS,
507
- We as RecordAccessLostPanel,
508
- lr as RecordLiveSync,
509
- cr as invalidateRecordQueries,
510
- Fe as moveNotice,
511
- Ve as purgeRecordQueries,
512
- Pe as writtenBySelf
519
+ Je as RecordAccessLostPanel,
520
+ hr as RecordLiveSync,
521
+ fr as invalidateRecordQueries,
522
+ We as moveNotice,
523
+ Ge as purgeRecordQueries,
524
+ He as writtenBySelf
513
525
  };