@nivaro/react 0.3.45 → 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 (90) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +290 -23
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/BaseMap.js +149 -103
  6. package/dist/shared/components/CollectionBrowserView.js +813 -826
  7. package/dist/shared/components/ErrorNotice.js +169 -0
  8. package/dist/shared/components/ErrorSurface.js +23 -17
  9. package/dist/shared/components/ListLoadError.js +8 -29
  10. package/dist/shared/components/LoadErrorNote.js +38 -21
  11. package/dist/shared/components/QueryErrorState.js +8 -11
  12. package/dist/shared/components/ReportView.js +1320 -1291
  13. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  14. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  15. package/dist/shared/components/chat/ChatPanel.js +368 -367
  16. package/dist/shared/components/command-center/CommandCenterView.js +313 -69
  17. package/dist/shared/components/command-center/Customize.js +353 -0
  18. package/dist/shared/components/command-center/Header.js +279 -53
  19. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  20. package/dist/shared/components/command-center/PeekPanel.js +144 -3
  21. package/dist/shared/components/command-center/announce.js +13 -0
  22. package/dist/shared/components/command-center/board-prefs.js +99 -0
  23. package/dist/shared/components/command-center/freshness.js +29 -0
  24. package/dist/shared/components/command-center/layout.js +56 -0
  25. package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
  26. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  27. package/dist/shared/components/command-center/panels/BoardSettings.js +224 -0
  28. package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
  29. package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
  30. package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
  31. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  32. package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
  33. package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
  34. package/dist/shared/components/command-center/panels/PeoplePanel.js +258 -40
  35. package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
  36. package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
  37. package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
  38. package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
  39. package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
  40. package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
  41. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  42. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  43. package/dist/shared/components/command-center/panels/registry.js +87 -19
  44. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  45. package/dist/shared/components/command-center/shortcuts.js +37 -0
  46. package/dist/shared/components/command-center/theme.js +39 -21
  47. package/dist/shared/components/command-center/time.js +52 -0
  48. package/dist/shared/components/command-center/url-state.js +54 -0
  49. package/dist/shared/components/command-center/work-links.js +32 -0
  50. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  51. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  52. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  53. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  54. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  55. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  56. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  57. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  58. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  59. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  60. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  61. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  62. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  63. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  64. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  65. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  66. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  67. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  68. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  69. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  70. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  71. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  72. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  73. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  74. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  75. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  76. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  77. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  78. package/dist/shared/components/panels/SlaClock.js +35 -36
  79. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  80. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  81. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  82. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  83. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  84. package/dist/shared/components/support/SupportView.js +94 -87
  85. package/dist/shared/lib/autofill-poll.js +21 -18
  86. package/dist/shared/lib/error-actions.js +85 -0
  87. package/dist/shared/lib/error-message.js +223 -82
  88. package/dist/shared/lib/error-toast.js +71 -13
  89. package/dist/shared/lib/safe-error.js +136 -38
  90. 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,8 +1,8 @@
1
- import { jsxs as n, jsx as a } from "react/jsx-runtime";
2
- import { useQuery as b } from "@tanstack/react-query";
3
- import { useNivaroClient as g, useNavigation as k } from "../../context.js";
4
- import { get as q } from "../../lib/commands.js";
5
- const N = {
1
+ import { jsxs as l, jsx as n } from "react/jsx-runtime";
2
+ import { useQuery as M } from "@tanstack/react-query";
3
+ import { useNivaroClient as _, useNavigation as L } from "../../context.js";
4
+ import { get as A } from "../../lib/commands.js";
5
+ const C = {
6
6
  items: "Collections",
7
7
  widgets: "Widgets",
8
8
  pages: "Pages",
@@ -14,44 +14,44 @@ const N = {
14
14
  system: "System",
15
15
  other: "Other"
16
16
  };
17
- function v(e, d = 4, p = 3) {
18
- const c = /* @__PURE__ */ new Map();
17
+ function F(e, o = 4, s = 3) {
18
+ const m = /* @__PURE__ */ new Map();
19
19
  for (const t of e.entities) {
20
- let r = c.get(t.lane);
21
- r || (r = { req: 0, series: new Array(t.series.length).fill(0) }, c.set(t.lane, r)), r.req += t.req, t.series.forEach((i, m) => {
22
- r.series[m] = (r.series[m] ?? 0) + i;
20
+ let i = m.get(t.lane);
21
+ i || (i = { req: 0, series: new Array(t.series.length).fill(0) }, m.set(t.lane, i)), i.req += t.req, t.series.forEach((p, a) => {
22
+ i.series[a] = (i.series[a] ?? 0) + p;
23
23
  });
24
24
  }
25
- const l = e.totals.req;
25
+ const d = e.totals.req;
26
26
  return {
27
- rpm: e.window_s ? l * 60 / e.window_s : 0,
28
- req: l,
27
+ rpm: e.window_s ? d * 60 / e.window_s : 0,
28
+ req: d,
29
29
  errors: e.totals.error,
30
- errPct: l ? 100 * e.totals.error / l : 0,
30
+ errPct: d ? 100 * e.totals.error / d : 0,
31
31
  p95: e.totals.p95,
32
- lanes: [...c].filter(([, t]) => t.req > 0).sort((t, r) => r[1].req - t[1].req).slice(0, d).map(([t, r]) => ({
32
+ lanes: [...m].filter(([, t]) => t.req > 0).sort((t, i) => i[1].req - t[1].req).slice(0, o).map(([t, i]) => ({
33
33
  lane: t,
34
- label: N[t] ?? t,
35
- req: r.req,
36
- series: r.series
34
+ label: C[t] ?? t,
35
+ req: i.req,
36
+ series: i.series
37
37
  })),
38
- top: e.entities.filter((t) => t.req > 0 && !t.key.endsWith("/__other__")).sort((t, r) => r.req - t.req).slice(0, p).map((t) => ({ key: t.key, label: t.label, req: t.req }))
38
+ top: e.entities.filter((t) => t.req > 0 && !t.key.endsWith("/__other__")).sort((t, i) => i.req - t.req).slice(0, s).map((t) => ({ key: t.key, label: t.label, req: t.req }))
39
39
  };
40
40
  }
41
- function w({ data: e, className: d }) {
42
- const l = Math.max(1, ...e), t = e.map(
43
- (r, i) => `${(i / Math.max(1, e.length - 1) * 96).toFixed(1)},${(20 - r / l * 18 - 1).toFixed(1)}`
41
+ function k({ data: e, className: o }) {
42
+ const d = Math.max(1, ...e), t = e.map(
43
+ (i, p) => `${(p / Math.max(1, e.length - 1) * 96).toFixed(1)},${(20 - i / d * 18 - 1).toFixed(1)}`
44
44
  ).join(" ");
45
- return /* @__PURE__ */ a(
45
+ return /* @__PURE__ */ n(
46
46
  "svg",
47
47
  {
48
48
  viewBox: "0 0 96 20",
49
49
  width: 96,
50
50
  height: 20,
51
- className: d,
51
+ className: o,
52
52
  "aria-hidden": "true",
53
53
  preserveAspectRatio: "none",
54
- children: /* @__PURE__ */ a(
54
+ children: /* @__PURE__ */ n(
55
55
  "polyline",
56
56
  {
57
57
  points: t,
@@ -64,7 +64,16 @@ function w({ data: e, className: d }) {
64
64
  }
65
65
  );
66
66
  }
67
- const h = (e) => Math.round(e).toLocaleString(), $ = (e) => e < 10 ? e.toFixed(1) : h(e), y = (e) => e ? e >= 1e3 ? `${(e / 1e3).toFixed(1)} s` : `${Math.round(e)} ms` : "—", _ = {
67
+ function N(e, o, s, m) {
68
+ const d = s * 1e3 / Math.max(1, o), t = m - s * 1e3 + (e + 0.5) * d;
69
+ return Math.floor(t / 6e4) * 6e4;
70
+ }
71
+ function q(e) {
72
+ let o = 0;
73
+ for (let s = 0; s < e.length; s++) e[s] >= e[o] && (o = s);
74
+ return o;
75
+ }
76
+ const f = (e) => Math.round(e).toLocaleString(), T = (e) => e < 10 ? e.toFixed(1) : f(e), j = (e) => e ? e >= 1e3 ? `${(e / 1e3).toFixed(1)} s` : `${Math.round(e)} ms` : "—", S = {
68
77
  // always dark (Command Center)
69
78
  dark: {
70
79
  card: "rounded-lg border border-white/10 bg-[#101828] text-[#e2e8f0]",
@@ -84,83 +93,115 @@ const h = (e) => Math.round(e).toLocaleString(), $ = (e) => e < 10 ? e.toFixed(1
84
93
  link: "text-[#0e7490] hover:underline dark:text-[#67e8f9] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0891b2]"
85
94
  }
86
95
  };
87
- function A({
96
+ function P({
88
97
  window: e = 300,
89
- tone: d = "auto",
90
- href: p,
91
- refreshMs: c = 15e3,
92
- className: l
98
+ tone: o = "auto",
99
+ href: s,
100
+ refreshMs: m = 15e3,
101
+ className: d,
102
+ onPickTime: t
93
103
  }) {
94
- const t = g(), { navigate: r } = k(), i = _[d], m = b({
104
+ const i = _(), { navigate: p } = L(), a = S[o], h = M({
95
105
  queryKey: ["traffic-mini-map", e],
96
- queryFn: () => t.request(q("/traffic-map/snapshot", { window: e })).then((s) => s.data).catch(() => null),
106
+ queryFn: () => i.request(A("/traffic-map/snapshot", { window: e })).then((r) => r.data).catch(() => null),
97
107
  // not an administrator, or no map here: render nothing
98
- refetchInterval: c,
99
- staleTime: c / 2
108
+ refetchInterval: m,
109
+ staleTime: m / 2
100
110
  });
101
- if (!m.data) return null;
102
- const o = v(m.data), f = p ?? "/traffic-map", u = /^https?:\/\//.test(f), x = e === 60 ? "last minute" : `last ${e / 60} min`;
103
- return /* @__PURE__ */ n(
111
+ if (!h.data) return null;
112
+ const c = F(h.data), w = h.data.window_s, u = s ?? "/traffic-map", x = /^https?:\/\//.test(u), $ = e === 60 ? "last minute" : `last ${e / 60} min`;
113
+ return /* @__PURE__ */ l(
104
114
  "section",
105
115
  {
106
- className: `${i.card} ${l ?? ""}`,
116
+ className: `${a.card} ${d ?? ""}`,
107
117
  "aria-label": "Traffic",
108
118
  "data-traffic-mini-map": "",
109
119
  children: [
110
- /* @__PURE__ */ n("div", { className: `flex items-center justify-between gap-2 px-3 py-2 ${i.head}`, children: [
111
- /* @__PURE__ */ n("h3", { className: "text-[12.5px] font-semibold", children: [
120
+ /* @__PURE__ */ l("div", { className: `flex items-center justify-between gap-2 px-3 py-2 ${a.head}`, children: [
121
+ /* @__PURE__ */ l("h3", { className: "text-[12.5px] font-semibold", children: [
112
122
  "Traffic ",
113
- /* @__PURE__ */ n("span", { className: `font-normal ${i.muted}`, children: [
123
+ /* @__PURE__ */ l("span", { className: `font-normal ${a.muted}`, children: [
114
124
  "· ",
115
- x
125
+ $
116
126
  ] })
117
127
  ] }),
118
- f ? /* @__PURE__ */ a(
128
+ u ? /* @__PURE__ */ n(
119
129
  "a",
120
130
  {
121
- href: f,
122
- target: u ? "_blank" : void 0,
123
- rel: u ? "noreferrer" : void 0,
124
- className: `rounded text-[12px] font-medium ${i.link}`,
125
- onClick: (s) => {
126
- u || s.metaKey || s.ctrlKey || (s.preventDefault(), r(f));
131
+ href: u,
132
+ target: x ? "_blank" : void 0,
133
+ rel: x ? "noreferrer" : void 0,
134
+ className: `rounded text-[12px] font-medium ${a.link}`,
135
+ onClick: (r) => {
136
+ x || r.metaKey || r.ctrlKey || (r.preventDefault(), p(u));
127
137
  },
128
138
  "data-traffic-mini-open": "",
129
139
  children: "Open map"
130
140
  }
131
141
  ) : null
132
142
  ] }),
133
- /* @__PURE__ */ n("div", { className: "grid grid-cols-3 gap-2 px-3 pt-2.5 text-[12px] tabular-nums", children: [
134
- /* @__PURE__ */ n("div", { children: [
135
- /* @__PURE__ */ a("p", { className: "text-[18px] font-semibold leading-tight", "data-traffic-mini-rpm": "", children: $(o.rpm) }),
136
- /* @__PURE__ */ a("p", { className: i.muted, children: "requests/min" })
143
+ /* @__PURE__ */ l("div", { className: "grid grid-cols-3 gap-2 px-3 pt-2.5 text-[12px] tabular-nums", children: [
144
+ /* @__PURE__ */ l("div", { children: [
145
+ /* @__PURE__ */ n("p", { className: "text-[18px] font-semibold leading-tight", "data-traffic-mini-rpm": "", children: T(c.rpm) }),
146
+ /* @__PURE__ */ n("p", { className: a.muted, children: "requests/min" })
137
147
  ] }),
138
- /* @__PURE__ */ n("div", { children: [
139
- /* @__PURE__ */ a("p", { className: `text-[18px] font-semibold leading-tight ${o.errors ? i.error : ""}`, children: h(o.errors) }),
140
- /* @__PURE__ */ n("p", { className: i.muted, children: [
148
+ /* @__PURE__ */ l("div", { children: [
149
+ /* @__PURE__ */ n("p", { className: `text-[18px] font-semibold leading-tight ${c.errors ? a.error : ""}`, children: f(c.errors) }),
150
+ /* @__PURE__ */ l("p", { className: a.muted, children: [
141
151
  "errors",
142
- o.req ? ` · ${o.errPct.toFixed(1)}%` : ""
152
+ c.req ? ` · ${c.errPct.toFixed(1)}%` : ""
143
153
  ] })
144
154
  ] }),
145
- /* @__PURE__ */ n("div", { children: [
146
- /* @__PURE__ */ a("p", { className: "text-[18px] font-semibold leading-tight", children: y(o.p95) }),
147
- /* @__PURE__ */ a("p", { className: i.muted, children: "p95" })
155
+ /* @__PURE__ */ l("div", { children: [
156
+ /* @__PURE__ */ n("p", { className: "text-[18px] font-semibold leading-tight", children: j(c.p95) }),
157
+ /* @__PURE__ */ n("p", { className: a.muted, children: "p95" })
148
158
  ] })
149
159
  ] }),
150
- o.lanes.length === 0 ? /* @__PURE__ */ a("p", { className: `px-3 py-2.5 text-[12px] ${i.muted}`, children: "No API traffic in the window." }) : /* @__PURE__ */ a("ul", { className: "space-y-1 px-3 pb-1 pt-2.5 text-[12px]", children: o.lanes.map((s) => /* @__PURE__ */ n("li", { className: "flex items-center gap-2", "data-traffic-mini-lane": s.lane, children: [
151
- /* @__PURE__ */ a("span", { className: "w-[84px] shrink-0 truncate", children: s.label }),
152
- /* @__PURE__ */ a(w, { data: s.series, className: `min-w-0 flex-1 ${i.spark}` }),
153
- /* @__PURE__ */ a("span", { className: `w-[52px] shrink-0 text-right tabular-nums ${i.muted}`, children: h(s.req) })
154
- ] }, s.lane)) }),
155
- o.top.length > 0 && /* @__PURE__ */ n("p", { className: `truncate px-3 pb-2.5 pt-1 text-[11.5px] ${i.muted}`, children: [
160
+ c.lanes.length === 0 ? /* @__PURE__ */ n("p", { className: `px-3 py-2.5 text-[12px] ${a.muted}`, children: "No API traffic in the window." }) : /* @__PURE__ */ n("ul", { className: "space-y-1 px-3 pb-1 pt-2.5 text-[12px]", children: c.lanes.map((r) => /* @__PURE__ */ l("li", { className: "flex items-center gap-2", "data-traffic-mini-lane": r.lane, children: [
161
+ /* @__PURE__ */ n("span", { className: "w-[84px] shrink-0 truncate", children: r.label }),
162
+ t ? /* @__PURE__ */ n(
163
+ "button",
164
+ {
165
+ type: "button",
166
+ className: `min-w-0 flex-1 rounded ${a.link}`,
167
+ "aria-label": `Rewind to the busiest minute for ${r.label} (${new Date(
168
+ N(
169
+ q(r.series),
170
+ r.series.length,
171
+ w,
172
+ h.dataUpdatedAt || Date.now()
173
+ )
174
+ ).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })})`,
175
+ "data-tip": "Click a point to rewind the board to that minute",
176
+ "data-traffic-mini-pick": r.lane,
177
+ onClick: (b) => {
178
+ const v = h.dataUpdatedAt || Date.now(), g = b.currentTarget.getBoundingClientRect(), y = b.detail === 0 || g.width === 0 ? q(r.series) : Math.max(
179
+ 0,
180
+ Math.min(
181
+ r.series.length - 1,
182
+ Math.round(
183
+ (b.clientX - g.left) / g.width * (r.series.length - 1)
184
+ )
185
+ )
186
+ );
187
+ t(N(y, r.series.length, w, v));
188
+ },
189
+ children: /* @__PURE__ */ n(k, { data: r.series, className: `w-full ${a.spark}` })
190
+ }
191
+ ) : /* @__PURE__ */ n(k, { data: r.series, className: `min-w-0 flex-1 ${a.spark}` }),
192
+ /* @__PURE__ */ n("span", { className: `w-[52px] shrink-0 text-right tabular-nums ${a.muted}`, children: f(r.req) })
193
+ ] }, r.lane)) }),
194
+ c.top.length > 0 && /* @__PURE__ */ l("p", { className: `truncate px-3 pb-2.5 pt-1 text-[11.5px] ${a.muted}`, children: [
156
195
  "Busiest: ",
157
- o.top.map((s) => `${s.label} (${h(s.req)})`).join(", ")
196
+ c.top.map((r) => `${r.label} (${f(r.req)})`).join(", ")
158
197
  ] })
159
198
  ]
160
199
  }
161
200
  );
162
201
  }
163
202
  export {
164
- A as TrafficMiniMap,
165
- v as miniMapSummary
203
+ P as TrafficMiniMap,
204
+ F as miniMapSummary,
205
+ N as sparkPointTime,
206
+ q as spikeIndex
166
207
  };