@nivaro/react 0.3.46 → 0.3.47

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 (57) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +248 -16
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/CollectionBrowserView.js +813 -826
  6. package/dist/shared/components/ErrorNotice.js +169 -0
  7. package/dist/shared/components/ErrorSurface.js +23 -17
  8. package/dist/shared/components/ListLoadError.js +8 -29
  9. package/dist/shared/components/LoadErrorNote.js +38 -21
  10. package/dist/shared/components/QueryErrorState.js +8 -11
  11. package/dist/shared/components/ReportView.js +1320 -1291
  12. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  13. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  14. package/dist/shared/components/chat/ChatPanel.js +368 -367
  15. package/dist/shared/components/command-center/PeekPanel.js +33 -32
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
  17. package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
  18. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  19. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  20. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  21. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  22. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  23. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  24. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  25. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  26. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  27. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  28. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  29. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  30. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  31. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  32. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  33. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  34. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  35. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  36. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  37. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  38. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  39. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  40. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  41. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  42. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  43. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  44. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  45. package/dist/shared/components/panels/SlaClock.js +35 -36
  46. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  47. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  48. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  49. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  50. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  51. package/dist/shared/components/support/SupportView.js +94 -87
  52. package/dist/shared/lib/autofill-poll.js +21 -18
  53. package/dist/shared/lib/error-actions.js +85 -0
  54. package/dist/shared/lib/error-message.js +223 -82
  55. package/dist/shared/lib/error-toast.js +71 -13
  56. package/dist/shared/lib/safe-error.js +136 -38
  57. package/package.json +1 -1
@@ -7,10 +7,11 @@ import { toast as H } from "sonner";
7
7
  import { useNivaroClient as M } from "../../context.js";
8
8
  import { get as J, post as X } from "../../lib/commands.js";
9
9
  import { applyLayoutOps as f, isCanvasSlot as Z, GROUP_PATCH_KEYS as ee, PLACEMENT_PATCH_KEYS as te } from "../../lib/layout-ops.js";
10
+ import { plainErrorText as se } from "../../lib/safe-error.js";
10
11
  const C = {
11
12
  bundle: (n) => ["layout-editor", "bundle", n],
12
13
  versions: (n) => ["layout-editor", "versions", n]
13
- }, se = /* @__PURE__ */ new Set([
14
+ }, re = /* @__PURE__ */ new Set([
14
15
  "name",
15
16
  "slug",
16
17
  "create_label",
@@ -23,40 +24,44 @@ const C = {
23
24
  "parent_layout_id",
24
25
  "tab_mode"
25
26
  ]);
26
- function qe(n) {
27
+ function Ee(n) {
27
28
  return n ? n.some(
28
- (e) => e.op === "layout_update" && Object.keys(e.patch ?? {}).some((t) => se.has(t))
29
+ (e) => e.op === "layout_update" && Object.keys(e.patch ?? {}).some((t) => re.has(t))
29
30
  ) : !0;
30
31
  }
31
- const re = 600, ne = "Someone else changed this layout — reloaded", ie = (n) => `Someone else saved — your ${n} ${n === 1 ? "change was" : "changes were"} kept on top; Save again`, oe = "Someone else saved this layout and some of your changes no longer fit", ae = (n) => `Someone else saved — your ${n === 1 ? "change was" : `${n} changes were`} replayed on top of theirs`, E = (n, e) => `Someone else saved — ${n} of your changes kept, ${e} no longer ${e === 1 ? "fits" : "fit"}: redo ${e === 1 ? "it" : "them"} by hand`, w = 250;
32
+ const ne = 600, ie = "Someone else changed this layout — reloaded", oe = (n) => `Someone else saved — your ${n} ${n === 1 ? "change was" : "changes were"} kept on top; Save again`, ae = "Someone else saved this layout and some of your changes no longer fit", ue = (n) => `Someone else saved — your ${n === 1 ? "change was" : `${n} changes were`} replayed on top of theirs`, E = (n, e) => `Someone else saved — ${n} of your changes kept, ${e} no longer ${e === 1 ? "fits" : "fit"}: redo ${e === 1 ? "it" : "them"} by hand`, w = 250;
32
33
  function $(n) {
33
34
  if (n.length === 0) return "Save";
34
35
  if (n.length === 1) return n[0].slice(0, w);
35
36
  const e = `${n.length} changes: ${n.join(", ")}`;
36
37
  return e.length > w ? `${e.slice(0, w - 1)}…` : e;
37
38
  }
38
- const ue = 100;
39
+ const he = 100;
39
40
  function q(n) {
40
41
  const e = (s) => !!s && typeof s == "object" && Array.isArray(s.groups) && Array.isArray(s.placements) && typeof s.rev == "string";
41
42
  if (e(n)) return n;
42
43
  const t = n == null ? void 0 : n.data;
43
44
  return e(t) ? t : null;
44
45
  }
45
- function he(n) {
46
+ function ce(n) {
46
47
  return /^No group "/.test(n) ? "That section is no longer on this form" : /^"[^"]*" is not placed in /.test(n) ? "That field is no longer where it was" : /^"[^"]*" is already in /.test(n) ? "That field is already there" : /^"[^"]*" is not on this form/.test(n) ? "That item is no longer on this form" : /^"[^"]*" is not a container/.test(n) ? "Tabs can only go inside a tab group" : /^"[^"]*" is a reserved name/.test(n) ? "That name is reserved" : /^A group "[^"]*" already exists/.test(n) ? "A section with that key already exists" : /^Unknown setting "/.test(n) ? "That setting can’t be saved on this form" : n;
47
48
  }
48
49
  function F(n, e = "The layout could not be saved") {
49
50
  var o, u;
50
51
  const t = n, s = (t == null ? void 0 : t.status) ?? ((o = t == null ? void 0 : t.response) == null ? void 0 : o.status) ?? null, r = ((u = t == null ? void 0 : t.response) == null ? void 0 : u.data) ?? (t == null ? void 0 : t.response), a = typeof (r == null ? void 0 : r.error) == "string" && r.error || typeof (r == null ? void 0 : r.message) == "string" && r.message || typeof (t == null ? void 0 : t.message) == "string" && t.message || e;
51
- return { status: s, message: he(a), bundle: q(r == null ? void 0 : r.bundle) };
52
+ return {
53
+ status: s,
54
+ message: se(ce(a), e, s),
55
+ bundle: q(r == null ? void 0 : r.bundle)
56
+ };
52
57
  }
53
- const ce = (n) => f(n, [{ op: "layout_update", patch: {} }]), S = (n, e) => n.placements.find((t) => t.field === e.field && t.group_key === (e.group_key ?? null));
58
+ const de = (n) => f(n, [{ op: "layout_update", patch: {} }]), S = (n, e) => n.placements.find((t) => t.field === e.field && t.group_key === (e.group_key ?? null));
54
59
  function A(n) {
55
60
  const e = {};
56
61
  for (const t of te) e[t] = n[t];
57
62
  return e;
58
63
  }
59
- function de(n) {
64
+ function le(n) {
60
65
  const e = {};
61
66
  for (const t of ee) e[t] = n[t];
62
67
  return e;
@@ -66,7 +71,7 @@ function x(n, e) {
66
71
  for (const s of Object.keys(e)) t[s] = n[s] === void 0 ? null : n[s];
67
72
  return t;
68
73
  }
69
- function le(n, e) {
74
+ function pe(n, e) {
70
75
  switch (e.op) {
71
76
  case "place":
72
77
  return [{ op: "remove", at: { field: e.field, group_key: e.group_key ?? null } }];
@@ -132,7 +137,7 @@ function le(n, e) {
132
137
  group_type: t.type,
133
138
  parent_key: t.parent_key,
134
139
  index: t.sort,
135
- patch: de(t)
140
+ patch: le(t)
136
141
  }
137
142
  ];
138
143
  return n.groups.filter((o) => o.parent_key === t.key).sort((o, u) => o.sort - u.sort).forEach((o, u) => {
@@ -155,8 +160,8 @@ function le(n, e) {
155
160
  return [];
156
161
  }
157
162
  }
158
- const pe = (n, e) => JSON.stringify(n ?? null) === JSON.stringify(e ?? null), T = (n, e) => Object.entries(e ?? {}).every(([t, s]) => pe(n[t], s));
159
- function fe(n, e) {
163
+ const fe = (n, e) => JSON.stringify(n ?? null) === JSON.stringify(e ?? null), T = (n, e) => Object.entries(e ?? {}).every(([t, s]) => fe(n[t], s));
164
+ function ve(n, e) {
160
165
  return e.length === 0 ? !1 : e.every((t) => {
161
166
  if (t.op === "update_placement") {
162
167
  const s = S(n, t.at);
@@ -170,12 +175,12 @@ function fe(n, e) {
170
175
  });
171
176
  }
172
177
  function g(n, e) {
173
- let t = ce(n), s = [];
178
+ let t = de(n), s = [];
174
179
  for (const r of e)
175
- s = [...le(t, r), ...s], t = f(t, [r]);
180
+ s = [...pe(t, r), ...s], t = f(t, [r]);
176
181
  return s;
177
182
  }
178
- function ve(n) {
183
+ function ke(n) {
179
184
  const e = [];
180
185
  for (const t of n)
181
186
  if (t.op === "update_placement")
@@ -197,7 +202,7 @@ function ve(n) {
197
202
  return e;
198
203
  }
199
204
  const y = (n) => n instanceof Error ? n.message : String(n);
200
- class ke {
205
+ class ye {
201
206
  constructor(e, t = {}) {
202
207
  c(this, "server", null);
203
208
  c(this, "draft", null);
@@ -237,7 +242,7 @@ class ke {
237
242
  }
238
243
  apply(e, t) {
239
244
  if (!this.draft || e.length === 0) return;
240
- const s = (t == null ? void 0 : t.label) ?? "Edit", r = t != null && t.text ? ve(e) : null;
245
+ const s = (t == null ? void 0 : t.label) ?? "Edit", r = t != null && t.text ? ke(e) : null;
241
246
  if (r) return this.autosave ? this.applyText(r, s) : this.stageText(r, s);
242
247
  this.flushText(), this.markCheckpoint();
243
248
  const a = this.draft;
@@ -388,7 +393,7 @@ class ke {
388
393
  for (const { key: r, op: a } of e) {
389
394
  const o = this.text.get(r);
390
395
  o && clearTimeout(o.timer);
391
- const u = setTimeout(() => this.flushTextKey(r), re), i = (o == null ? void 0 : o.inverse) ?? g(s, [a])[0];
396
+ const u = setTimeout(() => this.flushTextKey(r), ne), i = (o == null ? void 0 : o.inverse) ?? g(s, [a])[0];
392
397
  this.text.set(r, { op: a, inverse: i, label: t, timer: u });
393
398
  }
394
399
  this.redoStack = [], this.refresh();
@@ -453,7 +458,7 @@ class ke {
453
458
  return this.queue.push(r), r;
454
459
  }
455
460
  pushUndo(e) {
456
- this.undoStack.push(e), this.undoStack.length > ue && this.undoStack.shift();
461
+ this.undoStack.push(e), this.undoStack.length > he && this.undoStack.shift();
457
462
  }
458
463
  pending() {
459
464
  return this.inFlight || this.queue.length > 0 || this.text.size > 0;
@@ -506,7 +511,7 @@ class ke {
506
511
  */
507
512
  rebaseUndo(e, t, s) {
508
513
  this.undoStack = this.undoStack.filter(
509
- (r) => t.has(r.batchId) || !s.has(r.batchId) && fe(e, r.forward)
514
+ (r) => t.has(r.batchId) || !s.has(r.batchId) && ve(e, r.forward)
510
515
  );
511
516
  for (const r of this.undoStack) r.inverse = t.get(r.batchId) ?? r.inverse;
512
517
  this.redoStack = [];
@@ -519,12 +524,12 @@ class ke {
519
524
  conflict(e) {
520
525
  if (!e) {
521
526
  for (const s of this.text.values()) clearTimeout(s.timer);
522
- this.text.clear(), this.queue = [], this.undoStack = [], this.redoStack = [], this.transport.reload(), this.outcome = "conflict", this.error = null, this.transport.notify(ne);
527
+ this.text.clear(), this.queue = [], this.undoStack = [], this.redoStack = [], this.transport.reload(), this.outcome = "conflict", this.error = null, this.transport.notify(ie);
523
528
  return;
524
529
  }
525
530
  const t = this.refold(e, this.queue);
526
531
  this.queue = t.kept, this.server = e, this.transport.saved(e, null), this.rebaseUndo(e, t.inverses, new Set(t.dropped.map((s) => s.id))), this.dropped = [...this.dropped, ...t.dropped.map((s) => s.note)], this.outcome = "idle", this.error = null, this.transport.notify(
527
- t.dropped.length === 0 ? ae(t.kept.length) : E(t.kept.length, t.dropped.length)
532
+ t.dropped.length === 0 ? ue(t.kept.length) : E(t.kept.length, t.dropped.length)
528
533
  );
529
534
  }
530
535
  /**
@@ -539,12 +544,12 @@ class ke {
539
544
  ...this.unsaved
540
545
  ];
541
546
  if (this.queue = [], this.unsaved = t, this.checkpoint = null, this.closeText(), !e) {
542
- this.transport.reload(), this.outcome = "conflict", this.error = oe;
547
+ this.transport.reload(), this.outcome = "conflict", this.error = ae;
543
548
  return;
544
549
  }
545
550
  const s = this.refold(e, t);
546
551
  this.unsaved = s.kept, this.server = e, this.transport.saved(e, null), this.rebaseUndo(e, s.inverses, new Set(s.dropped.map((r) => r.id))), this.dropped = [...this.dropped, ...s.dropped.map((r) => r.note)], this.outcome = "idle", this.error = null, this.transport.notify(
547
- s.dropped.length === 0 ? ie(s.kept.length) : E(s.kept.length, s.dropped.length)
552
+ s.dropped.length === 0 ? oe(s.kept.length) : E(s.kept.length, s.dropped.length)
548
553
  );
549
554
  }
550
555
  /** Draft = server bundle + queued batches + unsaved steps + typed text; then send the next batch. */
@@ -630,12 +635,12 @@ class ke {
630
635
  }
631
636
  }
632
637
  const I = /* @__PURE__ */ new WeakMap();
633
- function ye(n, e, t) {
638
+ function ge(n, e, t) {
634
639
  let s = I.get(e.qc);
635
640
  s || (s = /* @__PURE__ */ new Map(), I.set(e.qc, s));
636
641
  const r = s.get(n);
637
642
  if (r != null && r.engine.isBusy()) return r;
638
- const a = C.bundle(n), o = { current: e }, i = { engine: new ke(
643
+ const a = C.bundle(n), o = { current: e }, i = { engine: new ye(
639
644
  {
640
645
  send: async (h, v, k, d) => {
641
646
  const _ = await o.current.client.request(
@@ -665,7 +670,7 @@ function ye(n, e, t) {
665
670
  ), live: o };
666
671
  return s.set(n, i), i;
667
672
  }
668
- function ge(n, e = !0) {
673
+ function me(n, e = !0) {
669
674
  const t = M();
670
675
  return z({
671
676
  queryKey: C.bundle(n ?? 0),
@@ -679,12 +684,12 @@ function ge(n, e = !0) {
679
684
  refetchOnWindowFocus: !1
680
685
  });
681
686
  }
682
- function Oe(n, e = {}) {
683
- const t = M(), s = P(), r = ge(n), [a, o] = Q(e.autosave ?? !1), u = Y(null);
687
+ function $e(n, e = {}) {
688
+ const t = M(), s = P(), r = me(n), [a, o] = Q(e.autosave ?? !1), u = Y(null);
684
689
  (!u.current || u.current.id !== n || u.current.qc !== s) && (u.current = {
685
690
  id: n,
686
691
  qc: s,
687
- ...ye(n, { client: t, qc: s, onSaved: e.onSaved }, a)
692
+ ...ge(n, { client: t, qc: s, onSaved: e.onSaved }, a)
688
693
  }), u.current.live.current = { client: t, qc: s, onSaved: e.onSaved };
689
694
  const i = u.current.engine, h = G(i.subscribe, i.getView, i.getView);
690
695
  b(() => {
@@ -721,21 +726,21 @@ function Oe(n, e = {}) {
721
726
  };
722
727
  }
723
728
  export {
724
- ne as CONFLICT_MESSAGE,
725
- ke as LayoutDraftEngine,
726
- oe as REBASE_FAILED_MESSAGE,
727
- re as TEXT_DEBOUNCE_MS,
728
- he as humanizeOpError,
729
+ ie as CONFLICT_MESSAGE,
730
+ ye as LayoutDraftEngine,
731
+ ae as REBASE_FAILED_MESSAGE,
732
+ ne as TEXT_DEBOUNCE_MS,
733
+ ce as humanizeOpError,
729
734
  g as inverseOps,
730
735
  C as layoutDraftKeys,
731
736
  q as parseBundle,
732
737
  F as parseSaveFailure,
733
738
  E as partlyRebasedMessage,
734
- ie as rebasedMessage,
735
- ae as replayedMessage,
739
+ oe as rebasedMessage,
740
+ ue as replayedMessage,
736
741
  $ as saveNote,
737
- fe as stillMine,
738
- qe as touchesOverview,
739
- ge as useLayoutBundle,
740
- Oe as useLayoutDraft
742
+ ve as stillMine,
743
+ Ee as touchesOverview,
744
+ me as useLayoutBundle,
745
+ $e as useLayoutDraft
741
746
  };
@@ -4,6 +4,7 @@ import { RotateCw as se, Search as le, UserX as oe, ChevronDown as V, ChevronRig
4
4
  import { useState as f, useMemo as A, useCallback as de } from "react";
5
5
  import { useNivaroClient as z, useNavigation as G, useItemNavigation as J } from "../../context.js";
6
6
  import { get as I, post as Y } from "../../lib/commands.js";
7
+ import { userErrorMessage as K } from "../../lib/safe-error.js";
7
8
  import { cn as E, formatRelative as ie } from "../../lib/utils.js";
8
9
  import { UserAvatar as ce } from "../UserAvatar.js";
9
10
  const T = {
@@ -22,8 +23,8 @@ const T = {
22
23
  anonymised: "bg-[#ffe4e6] text-[#9f1239] dark:bg-[#3d1a20] dark:text-[#f4a3ad]",
23
24
  placeholder: "bg-[#e2e8f0] text-[#334155] dark:bg-[#2c3038] dark:text-[#cbd5e1]"
24
25
  }, g = (l) => l.toLocaleString();
25
- function we({ className: l }) {
26
- var Q, M;
26
+ function Ce({ className: l }) {
27
+ var Q;
27
28
  const n = z(), o = ne(), [b, C] = f(!0), [v, d] = f(!1), [u, y] = f(!1), [i, x] = f(!0), [p, $] = f(null), [h, S] = f(""), [_, O] = f(null), [q, j] = f(0), c = B({
28
29
  queryKey: ["inactive-user-links", q],
29
30
  queryFn: () => n.request(I(`/inactive-user-links${q ? "?fresh=1" : ""}`)).then((t) => t.data),
@@ -55,7 +56,7 @@ function we({ className: l }) {
55
56
  const t = { suspended: 0, redacted: 0, anonymised: 0, placeholder: 0 };
56
57
  for (const R of m) t[R.user.reason]++;
57
58
  return t;
58
- }, [m]), k = p ? m.filter((t) => t.user.reason === p) : m, K = A(() => {
59
+ }, [m]), k = p ? m.filter((t) => t.user.reason === p) : m, M = A(() => {
59
60
  var w;
60
61
  let t = 0, R = 0;
61
62
  for (const P of k)
@@ -82,11 +83,11 @@ function we({ className: l }) {
82
83
  /* @__PURE__ */ e("dt", { children: k.length === 1 ? "person" : "people" })
83
84
  ] }),
84
85
  /* @__PURE__ */ a("div", { className: "flex items-baseline gap-1.5", children: [
85
- /* @__PURE__ */ e("dd", { className: "text-[20px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: c.isLoading ? "—" : g(K.records) }),
86
+ /* @__PURE__ */ e("dd", { className: "text-[20px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: c.isLoading ? "—" : g(M.records) }),
86
87
  /* @__PURE__ */ e("dt", { children: b ? "links on open records" : "record links" })
87
88
  ] }),
88
89
  /* @__PURE__ */ a("div", { className: "flex items-baseline gap-1.5", children: [
89
- /* @__PURE__ */ e("dd", { className: "text-[20px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: c.isLoading ? "—" : g(K.seats) }),
90
+ /* @__PURE__ */ e("dd", { className: "text-[20px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: c.isLoading ? "—" : g(M.seats) }),
90
91
  /* @__PURE__ */ e("dt", { children: "owner seats and team places" })
91
92
  ] })
92
93
  ] }),
@@ -196,7 +197,7 @@ function we({ className: l }) {
196
197
  t
197
198
  )) }) : c.isError ? /* @__PURE__ */ a("p", { className: "p-6 text-[12.5px] text-rose-700 dark:text-rose-300", children: [
198
199
  "The scan failed. ",
199
- (M = c.error) == null ? void 0 : M.message
200
+ K(c.error, "")
200
201
  ] }) : k.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-1 flex-col items-center justify-center gap-2 p-10 text-center", children: [
201
202
  /* @__PURE__ */ e(oe, { className: "h-6 w-6 text-slate-400" }),
202
203
  /* @__PURE__ */ e("p", { className: "text-[13px] font-medium text-slate-800 dark:text-foreground", children: b ? "Nobody inactive is named on open work" : "Nothing matches" }),
@@ -411,7 +412,7 @@ function te({
411
412
  ), y(!1), v();
412
413
  } catch (s) {
413
414
  const k = s.response;
414
- j((k == null ? void 0 : k.error) ?? s.message);
415
+ j((k == null ? void 0 : k.error) ?? K(s, ""));
415
416
  } finally {
416
417
  S(!1);
417
418
  }
@@ -525,7 +526,7 @@ function he({
525
526
  `${g(m.data.removed)} removed${m.data.failed.length ? ` · ${g(m.data.failed.length)} refused` : ""}`
526
527
  ), y(/* @__PURE__ */ new Set()), x(!1), b();
527
528
  } catch (m) {
528
- S(((r = m.response) == null ? void 0 : r.error) ?? m.message);
529
+ S(((r = m.response) == null ? void 0 : r.error) ?? K(m, ""));
529
530
  } finally {
530
531
  $(!1);
531
532
  }
@@ -659,5 +660,5 @@ function he({
659
660
  ] });
660
661
  }
661
662
  export {
662
- we as InactiveUserLinksView
663
+ Ce as InactiveUserLinksView
663
664
  };
@@ -1,45 +1,44 @@
1
1
  import { jsxs as n, jsx as a } from "react/jsx-runtime";
2
- import { useQuery as F, useQueryClient as L, useMutation as j } from "@tanstack/react-query";
3
- import { Clock3 as T } from "lucide-react";
2
+ import { useQuery as F, useQueryClient as E, useMutation as j } from "@tanstack/react-query";
3
+ import { Clock3 as L } from "lucide-react";
4
4
  import { useState as h } from "react";
5
5
  import { useNivaroClient as P } from "../../context.js";
6
- import { get as E, post as H, del as K } from "../../lib/commands.js";
7
- import { humanHours as l, formatRelative as Q } from "../../lib/utils.js";
8
- import { invalidateRecordNotes as B } from "../item-edit/RecordInsights.js";
9
- import { Popover as O, PopoverTrigger as z, PopoverContent as M } from "../ui/popover.js";
10
- function S(r) {
11
- var e;
12
- const t = r;
13
- return ((e = t == null ? void 0 : t.response) == null ? void 0 : e.error) ?? (t == null ? void 0 : t.message) ?? null;
6
+ import { get as T, post as H, del as K } from "../../lib/commands.js";
7
+ import { userErrorMessage as Q } from "../../lib/safe-error.js";
8
+ import { humanHours as l, formatRelative as B } from "../../lib/utils.js";
9
+ import { invalidateRecordNotes as M } from "../item-edit/RecordInsights.js";
10
+ import { Popover as O, PopoverTrigger as z, PopoverContent as U } from "../ui/popover.js";
11
+ function S(t) {
12
+ return t ? Q(t, "Could not load the deadline") : null;
14
13
  }
15
- function q(r, t) {
16
- return ["sla-breach", r, t];
14
+ function q(t, r) {
15
+ return ["sla-breach", t, r];
17
16
  }
18
- function U(r, t) {
17
+ function W(t, r) {
19
18
  const e = P();
20
19
  return F({
21
- queryKey: q(r, String(t ?? "")),
22
- queryFn: () => e.request(E(`/sla/status/${r}/${t}`)).then((o) => o).catch(() => null),
23
- enabled: !!t,
20
+ queryKey: q(t, String(r ?? "")),
21
+ queryFn: () => e.request(T(`/sla/status/${t}/${r}`)).then((o) => o).catch(() => null),
22
+ enabled: !!r,
24
23
  staleTime: 6e4
25
24
  });
26
25
  }
27
- function W(r) {
28
- const t = r.set_by_name ? ` by ${r.set_by_name}` : "";
29
- return `Clock adjusted to ${l(r.duration_hours)} (rule: ${l(r.rule_duration_hours)})${t}, ${Q(r.set_at)}`;
26
+ function D(t) {
27
+ const r = t.set_by_name ? ` by ${t.set_by_name}` : "";
28
+ return `Clock adjusted to ${l(t.duration_hours)} (rule: ${l(t.rule_duration_hours)})${r}, ${B(t.set_at)}`;
30
29
  }
31
- function D({
32
- collection: r,
33
- itemId: t,
30
+ function G({
31
+ collection: t,
32
+ itemId: r,
34
33
  data: e,
35
34
  tone: o = "neutral"
36
35
  }) {
37
36
  var w;
38
- const m = P(), u = L(), [A, x] = h(!1), [b, y] = h(""), [i, f] = h(""), [N, c] = h(null), k = ((w = e.sla_rule) == null ? void 0 : w.duration_hours) ?? null, _ = e.elapsed_hours ?? 0, $ = () => {
39
- u.invalidateQueries({ queryKey: q(r, t) }), B(u, r, t);
37
+ const m = P(), u = E(), [A, x] = h(!1), [b, y] = h(""), [i, f] = h(""), [N, c] = h(null), k = ((w = e.sla_rule) == null ? void 0 : w.duration_hours) ?? null, _ = e.elapsed_hours ?? 0, $ = () => {
38
+ u.invalidateQueries({ queryKey: q(t, r) }), M(u, t, r);
40
39
  }, g = j({
41
40
  mutationFn: () => m.request(
42
- H(`/sla/override/${r}/${t}`, {
41
+ H(`/sla/override/${t}/${r}`, {
43
42
  duration_hours: Number(b),
44
43
  reason: i.trim()
45
44
  })
@@ -51,7 +50,7 @@ function D({
51
50
  }), v = j({
52
51
  mutationFn: () => m.request(
53
52
  K(
54
- `/sla/override/${r}/${t}${i.trim() ? `?reason=${encodeURIComponent(i.trim())}` : ""}`
53
+ `/sla/override/${t}/${r}${i.trim() ? `?reason=${encodeURIComponent(i.trim())}` : ""}`
55
54
  )
56
55
  ),
57
56
  onSuccess: () => {
@@ -77,7 +76,7 @@ function D({
77
76
  children: "Adjust clock"
78
77
  }
79
78
  ) }),
80
- /* @__PURE__ */ n(M, { align: "end", className: "w-[320px] space-y-3 p-3", "data-sla-adjust-panel": !0, children: [
79
+ /* @__PURE__ */ n(U, { align: "end", className: "w-[320px] space-y-3 p-3", "data-sla-adjust-panel": !0, children: [
81
80
  /* @__PURE__ */ n("div", { children: [
82
81
  /* @__PURE__ */ a("p", { className: "text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Adjust this record's SLA clock" }),
83
82
  /* @__PURE__ */ n("p", { className: "mt-0.5 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
@@ -147,13 +146,13 @@ function D({
147
146
  }
148
147
  );
149
148
  }
150
- function re({ collection: r, itemId: t }) {
149
+ function se({ collection: t, itemId: r }) {
151
150
  var u;
152
- const { data: e } = U(r, t);
151
+ const { data: e } = W(t, r);
153
152
  if (!(e != null && e.status) || e.status === "none" || e.total_hours == null) return null;
154
153
  const o = e.total_hours - (e.elapsed_hours ?? 0), m = e.status === "breached" ? "text-red-700 dark:text-red-300" : e.status === "warning" ? "text-amber-700 dark:text-amber-300" : "text-slate-600 dark:text-slate-300";
155
154
  return /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", "data-sla-clock-line": e.status, children: [
156
- /* @__PURE__ */ a(T, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
155
+ /* @__PURE__ */ a(L, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
157
156
  /* @__PURE__ */ n("p", { className: `min-w-0 flex-1 text-[12px] ${m}`, children: [
158
157
  /* @__PURE__ */ a("span", { className: "font-medium", children: "SLA" }),
159
158
  (u = e.sla_rule) != null && u.name ? ` · ${e.sla_rule.name}` : "",
@@ -168,18 +167,18 @@ function re({ collection: r, itemId: t }) {
168
167
  "data-sla-override": !0,
169
168
  children: [
170
169
  "· ",
171
- W(e.override)
170
+ D(e.override)
172
171
  ]
173
172
  }
174
173
  )
175
174
  ] }),
176
- e.can_adjust && /* @__PURE__ */ a(D, { collection: r, itemId: t, data: e })
175
+ e.can_adjust && /* @__PURE__ */ a(G, { collection: t, itemId: r, data: e })
177
176
  ] });
178
177
  }
179
178
  export {
180
- D as AdjustClockPopover,
181
- re as SlaClockLine,
182
- W as overrideSentence,
179
+ G as AdjustClockPopover,
180
+ se as SlaClockLine,
181
+ D as overrideSentence,
183
182
  q as slaStatusKey,
184
- U as useSlaStatus
183
+ W as useSlaStatus
185
184
  };