@nivaro/react 0.3.99 → 0.3.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useFormSchema.js +82 -85
  3. package/dist/hooks/useSessionRecorder.js +206 -175
  4. package/dist/index.d.ts +84 -16
  5. package/dist/index.js +627 -622
  6. package/dist/lib/commands.js +15 -11
  7. package/dist/shared/components/ActivityEntry.js +5 -5
  8. package/dist/shared/components/CollectionBrowserView.js +516 -503
  9. package/dist/shared/components/ItemEditForm.js +3471 -3465
  10. package/dist/shared/components/JobsTray.js +76 -61
  11. package/dist/shared/components/MyWorkView.js +133 -126
  12. package/dist/shared/components/NotificationBell.js +322 -289
  13. package/dist/shared/components/RecordCompare.js +38 -40
  14. package/dist/shared/components/RecordReadView.js +119 -119
  15. package/dist/shared/components/TipLayer.js +56 -41
  16. package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
  17. package/dist/shared/components/integrations/console/SignalCard.js +40 -40
  18. package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
  19. package/dist/shared/components/integrations/console/drill/status.js +23 -18
  20. package/dist/shared/components/item-edit/InlineGridField.js +45 -45
  21. package/dist/shared/components/item-edit/InlineTableField.js +750 -749
  22. package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
  23. package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
  24. package/dist/shared/components/item-edit/RecordInsights.js +86 -86
  25. package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
  26. package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
  27. package/dist/shared/components/item-edit/header-path-preview.js +46 -34
  28. package/dist/shared/components/item-edit/related-missing.js +75 -19
  29. package/dist/shared/components/notifications/DeliveryChips.js +1 -2
  30. package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
  31. package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
  32. package/dist/shared/components/panels/BackgroundMove.js +242 -0
  33. package/dist/shared/components/panels/MoveAdvisory.js +204 -0
  34. package/dist/shared/components/panels/PipelinePanel.js +1459 -1220
  35. package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
  36. package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
  37. package/dist/shared/components/profile/DayTimeline.js +145 -140
  38. package/dist/shared/components/profile/PersonAccess.js +679 -383
  39. package/dist/shared/components/profile/PersonActivity.js +404 -427
  40. package/dist/shared/components/profile/PersonDidPanel.js +248 -134
  41. package/dist/shared/components/profile/PersonProfile.js +33 -32
  42. package/dist/shared/components/profile/journey-view.js +166 -0
  43. package/dist/shared/lib/activity-sentence.js +319 -236
  44. package/dist/shared/lib/commands.js +18 -14
  45. package/dist/shared/lib/error-hints.js +1 -1
  46. package/dist/shared/lib/job-failure-text.js +12 -0
  47. package/dist/shared/lib/jobs-tray.js +60 -41
  48. package/dist/shared/lib/move-failure.js +19 -0
  49. package/dist/shared/lib/obligation-banner.js +22 -21
  50. package/dist/shared/lib/partner-failure.js +83 -0
  51. package/dist/shared/lib/prefetch.js +73 -73
  52. package/dist/shared/lib/replay-checkout.js +18 -13
  53. package/dist/shared/lib/replay-context.js +90 -77
  54. package/dist/shared/lib/replay-idle.js +21 -0
  55. package/dist/shared/lib/replay-socket.js +21 -17
  56. package/dist/shared/lib/rum.js +56 -51
  57. package/dist/shared/lib/safe-error.js +17 -13
  58. package/dist/shared/lib/stale-chunk.js +69 -26
  59. package/dist/shared/lib/system-collections.js +20 -0
  60. package/package.json +1 -1
@@ -1,558 +1,535 @@
1
- import { jsx as e, jsxs as s, Fragment as W } from "react/jsx-runtime";
2
- import { useQuery as T, useInfiniteQuery as B } from "@tanstack/react-query";
3
- import { Flame as Z, X as H, Globe as R, ArrowDownAZ as Y, ArrowUpAZ as G, Activity as J, LogIn as Q, Footprints as z } from "lucide-react";
4
- import { useState as $ } from "react";
5
- import { useNivaroClient as M, useItemNavigation as X, useNavigation as P } from "../../context.js";
6
- import { get as S } from "../../lib/commands.js";
7
- import { cn as v, formatRelative as j, formatDateTime as O } from "../../lib/utils.js";
8
- import { SimpleSelect as V } from "../ui/SimpleSelect.js";
9
- import { SectionCard as A, EmptyLine as C } from "./primitives.js";
10
- function be({ userId: t, title: l = "Rhythm" }) {
11
- const p = M(), { data: a } = T({
12
- queryKey: ["nvr-user-stats", t],
13
- queryFn: () => p.request(S(`/users/${t}/stats`)).then((c) => c.data).catch(() => null),
1
+ import { jsx as a, jsxs as l, Fragment as Z } from "react/jsx-runtime";
2
+ import { useQuery as $ } from "@tanstack/react-query";
3
+ import { Flame as G, LogIn as Q, ChevronLeft as V, ChevronRight as X, Footprints as ee } from "lucide-react";
4
+ import { useState as T, useMemo as R } from "react";
5
+ import { useNivaroClient as B, useNavigation as te, useItemNavigation as ae } from "../../context.js";
6
+ import { get as A } from "../../lib/commands.js";
7
+ import { formatRelative as se, formatDateTime as ne, cn as f } from "../../lib/utils.js";
8
+ import { ErrorNotice as re } from "../ErrorNotice.js";
9
+ import { SkeletonBar as D } from "../Skeletons.js";
10
+ import { SimpleSelect as le } from "../ui/SimpleSelect.js";
11
+ import { localDateKey as ie, localDayOffset as oe, shiftDate as de, isSafeAdminPath as ce } from "./dayTimelineLayout.js";
12
+ import { foldJourneySession as me, fmtDuration as U, fallbackJourneyLabel as ue, words as pe, fmtSpan as he, fmtClock as xe } from "./journey-view.js";
13
+ import { SectionCard as E, EmptyLine as F, usePersonUrl as fe } from "./primitives.js";
14
+ function Re({ userId: e, title: r = "Rhythm" }) {
15
+ const n = B(), { data: t } = $({
16
+ queryKey: ["nvr-user-stats", e],
17
+ queryFn: () => n.request(A(`/users/${e}/stats`)).then((u) => u.data).catch(() => null),
14
18
  staleTime: 5 * 6e4
15
19
  });
16
- if (!a) return null;
17
- const i = Math.max(1, ...a.weeks.map((c) => c.transitions + c.tasks_done + c.created)), u = a.totals.transitions + a.totals.tasks_done + a.totals.created === 0;
18
- return /* @__PURE__ */ e(
19
- A,
20
+ if (!t) return null;
21
+ const c = Math.max(1, ...t.weeks.map((u) => u.transitions + u.tasks_done + u.created)), o = t.totals.transitions + t.totals.tasks_done + t.totals.created === 0;
22
+ return /* @__PURE__ */ a(
23
+ E,
20
24
  {
21
- icon: /* @__PURE__ */ e(Z, { className: "h-4 w-4" }),
22
- title: l,
25
+ icon: /* @__PURE__ */ a(G, { className: "h-4 w-4" }),
26
+ title: r,
23
27
  hint: "Last eight weeks",
24
28
  testId: "stats",
25
- actions: a.streak_days > 0 && /* @__PURE__ */ s("span", { className: "text-[11.5px] font-medium text-amber-600 dark:text-amber-400", children: [
26
- a.streak_days,
29
+ actions: t.streak_days > 0 && /* @__PURE__ */ l("span", { className: "text-[11.5px] font-medium text-amber-600 dark:text-amber-400", children: [
30
+ t.streak_days,
27
31
  "-day streak"
28
32
  ] }),
29
- children: u ? /* @__PURE__ */ e(C, { children: "Nothing recorded in the last eight weeks." }) : /* @__PURE__ */ s(W, { children: [
30
- /* @__PURE__ */ e(ee, { weeks: a.weeks, max: i }),
31
- a.active_days && /* @__PURE__ */ e(ae, { days: a.active_days }),
32
- a.typical_hours_utc && /* @__PURE__ */ e(se, { hours: a.typical_hours_utc }),
33
- /* @__PURE__ */ e("dl", { className: "mt-4 grid grid-cols-3 gap-2 text-center", children: [
34
- ["Approvals", a.totals.transitions],
35
- ["Tasks done", a.totals.tasks_done],
36
- ["Records created", a.totals.created]
37
- ].map(([c, m]) => /* @__PURE__ */ s("div", { className: "rounded-md bg-slate-50 py-2 dark:bg-muted/40", children: [
38
- /* @__PURE__ */ e("dd", { className: "text-[16px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: Number(m).toLocaleString() }),
39
- /* @__PURE__ */ e("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: c })
40
- ] }, String(c))) })
33
+ children: o ? /* @__PURE__ */ a(F, { children: "Nothing recorded in the last eight weeks." }) : /* @__PURE__ */ l(Z, { children: [
34
+ /* @__PURE__ */ a(ye, { weeks: t.weeks, max: c }),
35
+ t.active_days && /* @__PURE__ */ a(be, { days: t.active_days }),
36
+ t.typical_hours_utc && /* @__PURE__ */ a(ve, { hours: t.typical_hours_utc }),
37
+ /* @__PURE__ */ a("dl", { className: "mt-4 grid grid-cols-3 gap-2 text-center", children: [
38
+ ["Approvals", t.totals.transitions],
39
+ ["Tasks done", t.totals.tasks_done],
40
+ ["Records created", t.totals.created]
41
+ ].map(([u, s]) => /* @__PURE__ */ l("div", { className: "rounded-md bg-slate-50 py-2 dark:bg-muted/40", children: [
42
+ /* @__PURE__ */ a("dd", { className: "text-[16px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: Number(s).toLocaleString() }),
43
+ /* @__PURE__ */ a("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: u })
44
+ ] }, String(u))) })
41
45
  ] })
42
46
  }
43
47
  );
44
48
  }
45
- const F = 864e5;
46
- function E(t) {
47
- const l = new Date(Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate())), p = (l.getUTCDay() + 6) % 7;
48
- return l.setUTCDate(l.getUTCDate() - p), l;
49
+ const M = 864e5;
50
+ function P(e) {
51
+ const r = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate())), n = (r.getUTCDay() + 6) % 7;
52
+ return r.setUTCDate(r.getUTCDate() - n), r;
49
53
  }
50
- const q = (t) => t.toLocaleDateString(void 0, { month: "short", day: "numeric", timeZone: "UTC" });
51
- function ee({
52
- weeks: t,
53
- max: l
54
+ const q = (e) => e.toLocaleDateString(void 0, { month: "short", day: "numeric", timeZone: "UTC" });
55
+ function ye({
56
+ weeks: e,
57
+ max: r
54
58
  }) {
55
- const p = E(/* @__PURE__ */ new Date());
56
- return /* @__PURE__ */ s("div", { "data-person-week-bars": !0, children: [
57
- /* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: "Actions per week" }),
58
- /* @__PURE__ */ e("div", { className: "mt-1.5 flex items-end gap-1.5", "data-person-stats-bars": !0, children: t.map((a, i) => {
59
- const u = a.transitions + a.tasks_done + a.created, c = u === 0 ? 2 : Math.max(6, Math.round(u / l * 56)), m = new Date(p.getTime() - (t.length - 1 - i) * 7 * F), d = i === t.length - 1;
60
- return /* @__PURE__ */ s(
59
+ const n = P(/* @__PURE__ */ new Date());
60
+ return /* @__PURE__ */ l("div", { "data-person-week-bars": !0, children: [
61
+ /* @__PURE__ */ a("p", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: "Actions per week" }),
62
+ /* @__PURE__ */ a("div", { className: "mt-1.5 flex items-end gap-1.5", "data-person-stats-bars": !0, children: e.map((t, c) => {
63
+ const o = t.transitions + t.tasks_done + t.created, u = o === 0 ? 2 : Math.max(6, Math.round(o / r * 56)), s = new Date(n.getTime() - (e.length - 1 - c) * 7 * M), d = c === e.length - 1;
64
+ return /* @__PURE__ */ l(
61
65
  "div",
62
66
  {
63
67
  className: "flex flex-1 flex-col items-center justify-end",
64
- title: `Week of ${q(m)} · ${u} actions · ${a.transitions} approvals · ${a.tasks_done} tasks · ${a.created} created`,
68
+ title: `Week of ${q(s)} · ${o} actions · ${t.transitions} approvals · ${t.tasks_done} tasks · ${t.created} created`,
65
69
  children: [
66
- /* @__PURE__ */ e(
70
+ /* @__PURE__ */ a(
67
71
  "span",
68
72
  {
69
- className: v(
73
+ className: f(
70
74
  "mb-0.5 text-[10.5px] tabular-nums",
71
- u === 0 ? "text-transparent" : "text-slate-500 dark:text-slate-400"
75
+ o === 0 ? "text-transparent" : "text-slate-500 dark:text-slate-400"
72
76
  ),
73
- "aria-hidden": u === 0,
74
- children: u
77
+ "aria-hidden": o === 0,
78
+ children: o
75
79
  }
76
80
  ),
77
- /* @__PURE__ */ e(
81
+ /* @__PURE__ */ a(
78
82
  "div",
79
83
  {
80
- className: v(
84
+ className: f(
81
85
  "w-full rounded-sm",
82
- d ? "bg-nvr-cyan" : u === 0 ? "bg-slate-200 dark:bg-slate-700" : "bg-slate-300 dark:bg-slate-600"
86
+ d ? "bg-nvr-cyan" : o === 0 ? "bg-slate-200 dark:bg-slate-700" : "bg-slate-300 dark:bg-slate-600"
83
87
  ),
84
- style: { height: c }
88
+ style: { height: u }
85
89
  }
86
90
  ),
87
- /* @__PURE__ */ e(
91
+ /* @__PURE__ */ a(
88
92
  "span",
89
93
  {
90
- className: v(
94
+ className: f(
91
95
  "mt-1 text-[10px] tabular-nums",
92
96
  d ? "font-semibold text-slate-700 dark:text-slate-200" : "text-slate-400"
93
97
  ),
94
- children: d ? "This wk" : q(m)
98
+ children: d ? "This wk" : q(s)
95
99
  }
96
100
  )
97
101
  ]
98
102
  },
99
- m.toISOString()
103
+ s.toISOString()
100
104
  );
101
105
  }) })
102
106
  ] });
103
107
  }
104
- const te = ["Mon", "", "Wed", "", "Fri", "", "Sun"];
105
- function ae({ days: t }) {
106
- const l = new Set(t), p = E(/* @__PURE__ */ new Date()), a = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), i = Array.from({ length: 8 }, (m, d) => {
107
- const N = new Date(p.getTime() - (7 - d) * 7 * F);
108
+ const ge = ["Mon", "", "Wed", "", "Fri", "", "Sun"];
109
+ function be({ days: e }) {
110
+ const r = new Set(e), n = P(/* @__PURE__ */ new Date()), t = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), c = Array.from({ length: 8 }, (s, d) => {
111
+ const m = new Date(n.getTime() - (7 - d) * 7 * M);
108
112
  return {
109
- monday: N,
110
- cells: Array.from({ length: 7 }, (y, x) => {
111
- const g = new Date(N.getTime() + x * F), b = g.toISOString().slice(0, 10);
112
- return { key: b, on: l.has(b), future: b > a, today: b === a, date: g };
113
+ monday: m,
114
+ cells: Array.from({ length: 7 }, (y, g) => {
115
+ const b = new Date(m.getTime() + g * M), h = b.toISOString().slice(0, 10);
116
+ return { key: h, on: r.has(h), future: h > t, today: h === t, date: b };
113
117
  })
114
118
  };
115
- }), u = i.flat().flatMap((m) => m.cells).filter((m) => m.on).length, c = i.flatMap((m) => m.cells).filter((m) => !m.future).length;
116
- return /* @__PURE__ */ s("div", { className: "mt-4", "data-person-presence-strip": u, children: [
117
- /* @__PURE__ */ s("div", { className: "flex items-baseline justify-between", children: [
118
- /* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: "Days with activity" }),
119
- /* @__PURE__ */ s("p", { className: "text-[11.5px] tabular-nums text-slate-600 dark:text-slate-300", children: [
120
- /* @__PURE__ */ e("span", { className: "font-semibold", children: u }),
119
+ }), o = c.flat().flatMap((s) => s.cells).filter((s) => s.on).length, u = c.flatMap((s) => s.cells).filter((s) => !s.future).length;
120
+ return /* @__PURE__ */ l("div", { className: "mt-4", "data-person-presence-strip": o, children: [
121
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between", children: [
122
+ /* @__PURE__ */ a("p", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: "Days with activity" }),
123
+ /* @__PURE__ */ l("p", { className: "text-[11.5px] tabular-nums text-slate-600 dark:text-slate-300", children: [
124
+ /* @__PURE__ */ a("span", { className: "font-semibold", children: o }),
121
125
  " of the last ",
122
- c,
126
+ u,
123
127
  " days"
124
128
  ] })
125
129
  ] }),
126
- /* @__PURE__ */ s("div", { className: "mt-1.5 flex gap-1.5", children: [
127
- /* @__PURE__ */ e("div", { className: "flex flex-col gap-[3px] pr-1", "aria-hidden": !0, children: te.map((m, d) => /* @__PURE__ */ e(
130
+ /* @__PURE__ */ l("div", { className: "mt-1.5 flex gap-1.5", children: [
131
+ /* @__PURE__ */ a("div", { className: "flex flex-col gap-[3px] pr-1", "aria-hidden": !0, children: ge.map((s, d) => /* @__PURE__ */ a(
128
132
  "span",
129
133
  {
130
134
  className: "h-3 text-[9.5px] leading-3 text-slate-400",
131
- children: m
135
+ children: s
132
136
  },
133
137
  d
134
138
  )) }),
135
- i.map((m) => /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col gap-[3px]", children: m.cells.map((d) => /* @__PURE__ */ e(
139
+ c.map((s) => /* @__PURE__ */ a("div", { className: "flex flex-1 flex-col gap-[3px]", children: s.cells.map((d) => /* @__PURE__ */ a(
136
140
  "span",
137
141
  {
138
142
  title: d.future ? void 0 : `${d.date.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric", timeZone: "UTC" })}${d.on ? " · active" : " · no activity"}`,
139
- className: v(
143
+ className: f(
140
144
  "h-3 rounded-[2px]",
141
145
  d.future ? "bg-transparent" : d.on ? "bg-nvr-cyan" : "bg-slate-200 dark:bg-slate-700",
142
146
  d.today && "ring-1 ring-slate-400 dark:ring-slate-300"
143
147
  )
144
148
  },
145
149
  d.key
146
- )) }, m.monday.toISOString()))
150
+ )) }, s.monday.toISOString()))
147
151
  ] }),
148
- /* @__PURE__ */ s("div", { className: "mt-1.5 flex items-center justify-between text-[10px] text-slate-400", children: [
149
- /* @__PURE__ */ s("span", { className: "flex items-center gap-1", children: [
150
- /* @__PURE__ */ e("span", { className: "inline-block h-2.5 w-2.5 rounded-[2px] bg-nvr-cyan" }),
152
+ /* @__PURE__ */ l("div", { className: "mt-1.5 flex items-center justify-between text-[10px] text-slate-400", children: [
153
+ /* @__PURE__ */ l("span", { className: "flex items-center gap-1", children: [
154
+ /* @__PURE__ */ a("span", { className: "inline-block h-2.5 w-2.5 rounded-[2px] bg-nvr-cyan" }),
151
155
  " did something",
152
- /* @__PURE__ */ e("span", { className: "ml-2 inline-block h-2.5 w-2.5 rounded-[2px] bg-slate-200 dark:bg-slate-700" }),
156
+ /* @__PURE__ */ a("span", { className: "ml-2 inline-block h-2.5 w-2.5 rounded-[2px] bg-slate-200 dark:bg-slate-700" }),
153
157
  " ",
154
158
  "quiet"
155
159
  ] }),
156
- /* @__PURE__ */ s("span", { children: [
157
- q(i[0].monday),
160
+ /* @__PURE__ */ l("span", { children: [
161
+ q(c[0].monday),
158
162
  " → today"
159
163
  ] })
160
164
  ] })
161
165
  ] });
162
166
  }
163
- function se({ hours: t }) {
164
- const l = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, p = (i) => ((i + l) % 24 + 24) % 24, a = (i) => {
165
- const u = Math.round(i * 2) / 2, c = Math.floor(u) % 24, m = u % 1 ? 30 : 0;
166
- return new Date(2e3, 0, 1, c, m).toLocaleTimeString([], { hour: "numeric", minute: m ? "2-digit" : void 0 });
167
+ function ve({ hours: e }) {
168
+ const r = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, n = (c) => ((c + r) % 24 + 24) % 24, t = (c) => {
169
+ const o = Math.round(c * 2) / 2, u = Math.floor(o) % 24, s = o % 1 ? 30 : 0;
170
+ return new Date(2e3, 0, 1, u, s).toLocaleTimeString([], { hour: "numeric", minute: s ? "2-digit" : void 0 });
167
171
  };
168
- return /* @__PURE__ */ s("p", { className: "mt-3 text-[12px] text-slate-600 dark:text-slate-300", "data-person-typical-hours": !0, children: [
172
+ return /* @__PURE__ */ l("p", { className: "mt-3 text-[12px] text-slate-600 dark:text-slate-300", "data-person-typical-hours": !0, children: [
169
173
  "Usually active",
170
174
  " ",
171
- /* @__PURE__ */ s("span", { className: "font-medium text-slate-800 dark:text-slate-100", children: [
172
- a(p(t.start)),
175
+ /* @__PURE__ */ l("span", { className: "font-medium text-slate-800 dark:text-slate-100", children: [
176
+ t(n(e.start)),
173
177
  " – ",
174
- a(p(t.end))
178
+ t(n(e.end))
175
179
  ] }),
176
- /* @__PURE__ */ s("span", { className: "text-slate-400", children: [
180
+ /* @__PURE__ */ l("span", { className: "text-slate-400", children: [
177
181
  " ",
178
182
  "· your time · based on ",
179
- t.samples.toLocaleString(),
183
+ e.samples.toLocaleString(),
180
184
  " actions"
181
185
  ] })
182
186
  ] });
183
187
  }
184
- function ne(t) {
185
- return !t.collection || !t.item || /^(nivaro|directus)_/i.test(t.collection) ? !1 : t.action !== "delete";
188
+ function Je(e) {
189
+ const r = ue(e);
190
+ return r.section && r.kind === "page" ? `${r.section} › ${r.title}` : r.title;
186
191
  }
187
- function le(t) {
188
- return t.link ? t.action === "create" ? "linked" : t.action === "delete" ? "unlinked" : t.action : t.action;
192
+ function ke(e, r, n) {
193
+ return e.request(
194
+ A(`/journeys/days/${r}`, n ? { app: n } : void 0)
195
+ ).then((t) => ({ days: t.data ?? [], apps: t.apps ?? [] })).catch(() => ({ days: [], apps: [] }));
189
196
  }
190
- const U = {
191
- create: {
192
- cls: "bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-400",
193
- dot: "bg-emerald-500"
194
- },
195
- update: {
196
- cls: "bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan",
197
- dot: "bg-nvr-cyan"
198
- },
199
- delete: { cls: "bg-red-50 text-red-600 dark:bg-red-950/40 dark:text-red-400", dot: "bg-red-500" },
200
- login: {
201
- cls: "bg-violet-50 text-violet-700 dark:bg-violet-950/40 dark:text-violet-400",
202
- dot: "bg-violet-500"
203
- }
204
- }, K = {
205
- cls: "bg-slate-100 text-slate-600 dark:bg-muted dark:text-muted-foreground",
206
- dot: "bg-slate-400"
207
- }, re = 50;
208
- function ve({ userId: t }) {
209
- var o, D, h;
210
- const l = M(), { urlFor: p } = X(), a = P(), [i, u] = $(""), [c, m] = $(""), [d, N] = $("desc"), y = !!i || !!c, { data: x } = T({
211
- queryKey: ["nvr-user-activity-summary", t],
212
- queryFn: () => l.request(S(`/user-activity/${t}/summary`)).then((n) => n.data)
213
- }), g = B({
214
- queryKey: ["nvr-user-activity", t, i, c, d],
215
- queryFn: ({ pageParam: n }) => l.request(
216
- S(`/user-activity/${t}`, {
217
- page: n,
218
- limit: re,
219
- ...i && { action: i },
220
- ...c && { collection: c },
221
- sort: d
197
+ function Ne(e) {
198
+ const r = e.filter((n) => n !== "admin");
199
+ return (n) => !n || n === "admin" ? "Admin" : r.length <= 1 ? "Portal" : pe(n);
200
+ }
201
+ function we(e) {
202
+ return e < 600 ? e : Math.floor(e / 60) * 60;
203
+ }
204
+ function W(e, r) {
205
+ if (e === r) return "Today";
206
+ if (e === de(r, -1)) return "Yesterday";
207
+ const [n, t, c] = e.split("-").map(Number);
208
+ return new Date(n, t - 1, c).toLocaleDateString("en-US", {
209
+ weekday: "short",
210
+ month: "short",
211
+ day: "numeric",
212
+ ...Number(r.slice(0, 4)) !== n ? { year: "numeric" } : {}
213
+ });
214
+ }
215
+ function J(e, r, n = !1) {
216
+ const t = W(e, r);
217
+ return t === "Today" || t === "Yesterday" ? t.toLowerCase() : n ? `on ${t}` : t;
218
+ }
219
+ const L = 8, Se = 300;
220
+ function Be({ userId: e }) {
221
+ var O;
222
+ const r = B(), n = ie(/* @__PURE__ */ new Date()), [t, c] = T(n), [o, u] = T(null), { data: s } = $({
223
+ queryKey: ["nvr-journey-days", e, o],
224
+ queryFn: () => ke(r, e, o)
225
+ }), d = (s == null ? void 0 : s.days) ?? [], m = (s == null ? void 0 : s.apps) ?? [], y = oe(t), { data: g, isLoading: b, isError: h, error: w, refetch: S } = $({
226
+ queryKey: ["nvr-journey", e, t, y, o],
227
+ queryFn: () => r.request(
228
+ A(`/journeys/user/${e}`, {
229
+ date: t,
230
+ tz_offset: y,
231
+ ...o ? { app: o } : {}
222
232
  })
233
+ ).then((i) => i.data ?? { sessions: [] }),
234
+ retry: !1
235
+ }), k = m.length > 1 || m.length === 1 && m[0] !== "admin", p = R(
236
+ () => [.../* @__PURE__ */ new Set([n, ...d.map((i) => i.date)])].sort().reverse(),
237
+ [n, d]
238
+ ), N = p.indexOf(t), _ = N > 0 ? p[N - 1] : null, C = N >= 0 && N < p.length - 1 ? p[N + 1] : null, x = R(
239
+ () => ((g == null ? void 0 : g.sessions) ?? []).map((i) => ({ s: i, v: me(i.steps) })).filter((i) => i.v.rows.length > 0).sort((i, v) => i.v.start.localeCompare(v.v.start)),
240
+ [g]
241
+ ), Y = Math.max(60, ...x.flatMap((i) => i.v.rows.map((v) => v.seconds ?? 0))), z = x.reduce((i, v) => i + we(v.v.seconds), 0), I = Ne(m), j = ((O = d.find((i) => i.date !== t)) == null ? void 0 : O.date) ?? null, K = "inline-flex h-7 w-7 items-center justify-center rounded-md text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 disabled:pointer-events-none disabled:opacity-30 dark:text-slate-400 dark:hover:bg-muted dark:hover:text-slate-100", H = /* @__PURE__ */ l("div", { className: "flex items-center gap-0.5", "data-journey-day-picker": !0, children: [
242
+ /* @__PURE__ */ a(
243
+ "button",
244
+ {
245
+ type: "button",
246
+ "aria-label": "Earlier day",
247
+ disabled: !C,
248
+ onClick: () => C && c(C),
249
+ className: K,
250
+ children: /* @__PURE__ */ a(V, { className: "h-3.5 w-3.5" })
251
+ }
223
252
  ),
224
- initialPageParam: 1,
225
- getNextPageParam: (n) => n.page * n.limit < n.total ? n.page + 1 : void 0
226
- }), b = ((o = g.data) == null ? void 0 : o.pages.flatMap((n) => n.data)) ?? [], w = ((h = (D = g.data) == null ? void 0 : D.pages[0]) == null ? void 0 : h.total) ?? (x == null ? void 0 : x.total) ?? 0, _ = [];
227
- for (const n of b) {
228
- const r = new Date(n.timestamp).toLocaleDateString(void 0, {
229
- weekday: "short",
230
- month: "short",
231
- day: "numeric",
232
- year: "numeric"
233
- }), f = _[_.length - 1];
234
- (f == null ? void 0 : f.date) === r ? f.entries.push(n) : _.push({ date: r, entries: [n] });
235
- }
236
- return /* @__PURE__ */ s(
237
- A,
253
+ /* @__PURE__ */ a(
254
+ le,
255
+ {
256
+ value: t,
257
+ onChange: c,
258
+ ariaLabel: "Day",
259
+ options: p.map((i) => ({ value: i, label: W(i, n) })),
260
+ className: "h-7 w-[124px] gap-1 rounded-md border-slate-200 bg-white px-2 text-[12px] font-medium text-slate-700 dark:border-border dark:bg-card dark:text-slate-200 [&>svg]:h-3.5 [&>svg]:w-3.5",
261
+ triggerProps: { "data-journey-day": t }
262
+ }
263
+ ),
264
+ /* @__PURE__ */ a(
265
+ "button",
266
+ {
267
+ type: "button",
268
+ "aria-label": "Later day",
269
+ disabled: !_,
270
+ onClick: () => _ && c(_),
271
+ className: K,
272
+ children: /* @__PURE__ */ a(X, { className: "h-3.5 w-3.5" })
273
+ }
274
+ )
275
+ ] });
276
+ return /* @__PURE__ */ l(
277
+ E,
238
278
  {
239
- icon: /* @__PURE__ */ e(J, { className: "h-4 w-4" }),
240
- title: "Activity",
241
- hint: w ? `${w.toLocaleString()} event${w === 1 ? "" : "s"}` : void 0,
242
- testId: "activity",
243
- actions: /* @__PURE__ */ s(
244
- "button",
245
- {
246
- type: "button",
247
- onClick: () => N((n) => n === "desc" ? "asc" : "desc"),
248
- className: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] text-slate-500 hover:bg-slate-50 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-muted",
249
- children: [
250
- d === "desc" ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(G, { className: "h-3.5 w-3.5" }),
251
- d === "desc" ? "Newest first" : "Oldest first"
252
- ]
253
- }
254
- ),
279
+ icon: /* @__PURE__ */ a(ee, { className: "h-4 w-4" }),
280
+ title: "Pages visited",
281
+ hint: "Session by session, kept 30 days",
282
+ testId: "journey",
283
+ actions: H,
255
284
  children: [
256
- x && x.actions.length > 0 && /* @__PURE__ */ s("div", { className: "mb-3 flex flex-wrap items-center gap-1.5", children: [
257
- x.actions.map((n) => {
258
- const r = U[n.action] ?? K;
259
- return /* @__PURE__ */ s(
260
- "button",
261
- {
262
- type: "button",
263
- "aria-pressed": i === n.action,
264
- onClick: () => u(i === n.action ? "" : n.action),
265
- className: v(
266
- "inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium transition-opacity",
267
- r.cls,
268
- i && i !== n.action && "opacity-40"
269
- ),
270
- children: [
271
- n.action,
272
- /* @__PURE__ */ e("span", { className: "font-mono opacity-70", children: n.count })
273
- ]
274
- },
275
- n.action
276
- );
277
- }),
278
- x.collections.length > 1 && /* @__PURE__ */ e(
279
- V,
285
+ (k || x.length > 0) && /* @__PURE__ */ l("div", { className: "mb-4 flex flex-wrap items-center justify-between gap-x-3 gap-y-2", children: [
286
+ k ? /* @__PURE__ */ l(
287
+ "fieldset",
280
288
  {
281
- ariaLabel: "Collection",
282
- value: c,
283
- onChange: m,
284
- options: [
285
- { value: "", label: "Every collection" },
286
- ...x.collections.map((n) => ({
287
- value: n.collection,
288
- label: `${n.collection_label ?? n.collection} · ${n.count}`
289
- }))
290
- ],
291
- className: "ml-auto h-7 w-[200px] text-[11.5px]"
289
+ className: "inline-flex rounded-md border border-slate-200 p-0.5 dark:border-border",
290
+ "data-journey-apps": !0,
291
+ children: [
292
+ /* @__PURE__ */ a("legend", { className: "sr-only", children: "App" }),
293
+ [null, ...m].map((i) => /* @__PURE__ */ a(
294
+ "button",
295
+ {
296
+ type: "button",
297
+ "aria-pressed": o === i,
298
+ "data-journey-app-filter": i ?? "all",
299
+ onClick: () => u(i),
300
+ className: f(
301
+ "h-6 rounded px-2.5 text-[11.5px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40",
302
+ o === i ? "bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "text-slate-500 hover:text-slate-800 dark:text-slate-400 dark:hover:text-slate-200"
303
+ ),
304
+ children: i ? I(i) : "All apps"
305
+ },
306
+ i ?? "__all"
307
+ ))
308
+ ]
292
309
  }
293
- ),
294
- y && /* @__PURE__ */ s(
295
- "button",
310
+ ) : /* @__PURE__ */ a("span", {}),
311
+ x.length > 0 && /* @__PURE__ */ l(
312
+ "p",
296
313
  {
297
- type: "button",
298
- onClick: () => {
299
- u(""), m("");
300
- },
301
- className: "inline-flex items-center gap-1 text-[11px] text-slate-400 hover:text-slate-600",
314
+ className: "text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400",
315
+ "data-journey-summary": !0,
302
316
  children: [
303
- /* @__PURE__ */ e(H, { className: "h-3 w-3" }),
304
- " Clear"
317
+ x.length,
318
+ " session",
319
+ x.length === 1 ? "" : "s",
320
+ " ·",
321
+ " ",
322
+ U(z) || "under a minute"
305
323
  ]
306
324
  }
307
325
  )
308
326
  ] }),
309
- g.isLoading ? /* @__PURE__ */ e("div", { className: "space-y-3", "aria-busy": !0, children: [0, 1, 2, 3].map((n) => /* @__PURE__ */ s("div", { className: "flex animate-pulse gap-3", children: [
310
- /* @__PURE__ */ e("div", { className: "mt-1 h-2 w-2 rounded-full bg-slate-100 dark:bg-muted" }),
311
- /* @__PURE__ */ s("div", { className: "flex-1 space-y-1.5", children: [
312
- /* @__PURE__ */ e("div", { className: "h-3 w-24 rounded bg-slate-100 dark:bg-muted" }),
313
- /* @__PURE__ */ e("div", { className: "h-3 w-48 rounded bg-slate-100 dark:bg-muted" })
314
- ] })
315
- ] }, n)) }) : b.length === 0 ? /* @__PURE__ */ e(C, { children: y ? "Nothing matches those filters." : "No activity recorded." }) : /* @__PURE__ */ s("div", { children: [
316
- _.map((n) => /* @__PURE__ */ s("div", { children: [
317
- /* @__PURE__ */ s("div", { className: "flex items-center gap-3 py-2", children: [
318
- /* @__PURE__ */ e("div", { className: "h-px flex-1 bg-slate-100 dark:bg-border" }),
319
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-slate-400", children: n.date }),
320
- /* @__PURE__ */ e("div", { className: "h-px flex-1 bg-slate-100 dark:bg-border" })
321
- ] }),
322
- /* @__PURE__ */ e("ol", { className: "relative ml-1 border-l border-slate-100 dark:border-border", children: n.entries.map((r) => {
323
- const f = U[r.action] ?? K, k = ne(r) ? p({ collection: r.collection, itemId: r.item }) : null;
324
- return /* @__PURE__ */ s("li", { className: "relative py-2 pl-4", "data-activity-row": r.id, children: [
325
- /* @__PURE__ */ e(
326
- "span",
327
- {
328
- className: v(
329
- "absolute -left-[4.5px] top-[15px] h-2 w-2 rounded-full",
330
- f.dot
331
- )
332
- }
333
- ),
334
- /* @__PURE__ */ s("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [
335
- /* @__PURE__ */ e(
336
- "span",
337
- {
338
- className: v(
339
- "rounded-full px-1.5 py-0.5 text-[10px] font-medium",
340
- f.cls
341
- ),
342
- children: le(r)
343
- }
344
- ),
345
- r.collection && (k ? /* @__PURE__ */ s(
346
- "a",
347
- {
348
- href: k,
349
- onClick: (L) => {
350
- L.metaKey || L.ctrlKey || (L.preventDefault(), a.navigate(k));
351
- },
352
- className: "min-w-0 truncate text-[12.5px] text-slate-700 hover:underline dark:text-slate-200",
353
- title: `${r.collection} #${r.item}`,
354
- children: [
355
- r.link ? null : /* @__PURE__ */ s("span", { className: "text-slate-400", children: [
356
- r.collection_label ?? r.collection,
357
- " "
358
- ] }),
359
- /* @__PURE__ */ e("span", { className: "font-medium", children: r.record_label ?? `#${r.item}` })
360
- ]
361
- }
362
- ) : /* @__PURE__ */ s("span", { className: "min-w-0 truncate text-[12.5px] text-slate-600 dark:text-slate-300", children: [
363
- r.link && r.record_label ? null : /* @__PURE__ */ s("span", { className: "text-slate-400", children: [
364
- r.collection_label ?? r.collection,
365
- " "
366
- ] }),
367
- r.record_label ? /* @__PURE__ */ e("span", { className: "font-medium", children: r.record_label }) : r.item ? /* @__PURE__ */ s("span", { className: "font-medium", children: [
368
- "#",
369
- r.item
370
- ] }) : null
371
- ] })),
372
- /* @__PURE__ */ e(
373
- "span",
374
- {
375
- className: "ml-auto text-[11px] text-slate-400",
376
- title: O(r.timestamp),
377
- children: j(r.timestamp)
378
- }
379
- )
380
- ] }),
381
- r.comment && /* @__PURE__ */ e("p", { className: "mt-0.5 text-[11.5px] text-slate-500 dark:text-slate-400", children: r.comment }),
382
- r.ip && /* @__PURE__ */ s("span", { className: "mt-0.5 inline-flex items-center gap-1 font-mono text-[10px] text-slate-300 dark:text-slate-600", children: [
383
- /* @__PURE__ */ e(R, { className: "h-2.5 w-2.5" }),
384
- " ",
385
- r.ip
386
- ] })
387
- ] }, r.id);
388
- }) })
389
- ] }, n.date)),
390
- g.hasNextPage && /* @__PURE__ */ e("div", { className: "pt-3 text-center", children: /* @__PURE__ */ e(
327
+ b ? /* @__PURE__ */ a(De, {}) : h ? /* @__PURE__ */ a(re, { error: w, what: "the pages visited", onRetry: () => void S() }) : x.length === 0 ? /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", "data-journey-empty": !0, children: [
328
+ /* @__PURE__ */ l(F, { children: [
329
+ "No pages recorded ",
330
+ t === n ? "today" : J(t, n, !0),
331
+ "."
332
+ ] }),
333
+ j && /* @__PURE__ */ l(
391
334
  "button",
392
335
  {
393
336
  type: "button",
394
- disabled: g.isFetchingNextPage,
395
- onClick: () => void g.fetchNextPage(),
396
- className: "inline-flex h-7 items-center rounded-md border border-slate-200 px-3 text-[11.5px] font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
397
- children: g.isFetchingNextPage ? "Loading…" : "Load more"
337
+ onClick: () => c(j),
338
+ className: "text-[12px] font-medium text-nvr-navy underline decoration-nvr-navy/30 underline-offset-2 hover:decoration-nvr-navy focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-nvr-cyan dark:decoration-nvr-cyan/40 dark:hover:decoration-nvr-cyan",
339
+ children: [
340
+ "Show ",
341
+ J(j, n)
342
+ ]
398
343
  }
399
- ) })
400
- ] })
344
+ )
345
+ ] }) : /* @__PURE__ */ a("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: x.map(({ s: i, v }) => /* @__PURE__ */ a(
346
+ _e,
347
+ {
348
+ app: i.app ?? "admin",
349
+ appName: I(i.app ?? "admin"),
350
+ view: v,
351
+ showApp: k,
352
+ maxDwell: Y
353
+ },
354
+ i.session_id
355
+ )) })
401
356
  ]
402
357
  }
403
358
  );
404
359
  }
405
- function I(t) {
406
- if (t === "/") return "Dashboard";
407
- const l = t.split("/").filter(Boolean);
408
- return l[0] === "collections" && l[1] ? l[2] ? `${l[1]} · record ${l[2]}` : `${l[1]} (browser)` : l.map((p) => p.replace(/-/g, " ")).join(" › ").replace(/\b\w/g, (p) => p.toUpperCase());
409
- }
410
- function ie(t) {
411
- if (t == null) return "";
412
- if (t < 60) return `${t}s`;
413
- const l = Math.floor(t / 60);
414
- return l < 60 ? `${l}m ${t % 60}s` : `${Math.floor(l / 60)}h ${l % 60}m`;
360
+ function De() {
361
+ return /* @__PURE__ */ l("div", { className: "space-y-3", role: "status", "aria-busy": "true", "aria-label": "Loading pages visited", children: [
362
+ /* @__PURE__ */ a(D, { width: 160, className: "h-3.5" }),
363
+ [72, 54, 64, 46].map((e) => /* @__PURE__ */ l("div", { className: "flex items-center gap-3", children: [
364
+ /* @__PURE__ */ a(D, { width: 48 }),
365
+ /* @__PURE__ */ a(D, { width: `${e}%` }),
366
+ /* @__PURE__ */ a(D, { width: 40, className: "ml-auto" })
367
+ ] }, e))
368
+ ] });
415
369
  }
416
- function oe(t, l, p) {
417
- return t.request(
418
- S(`/journeys/days/${l}`, p ? { app: p } : void 0)
419
- ).then((a) => ({ days: a.data ?? [], apps: a.apps ?? [] })).catch(() => ({ days: [], apps: [] }));
370
+ function _e({
371
+ app: e,
372
+ appName: r,
373
+ view: n,
374
+ showApp: t,
375
+ maxDwell: c
376
+ }) {
377
+ const [o, u] = T(!1), s = n.rows.length > L + 2 && !o, d = s ? n.rows.slice(0, L) : n.rows;
378
+ return /* @__PURE__ */ l("section", { className: "py-4 first:pt-0 last:pb-0", "data-journey-session": !0, children: [
379
+ /* @__PURE__ */ l("header", { className: "mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [
380
+ /* @__PURE__ */ a("h4", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: he(n.start, n.end) }),
381
+ /* @__PURE__ */ l("p", { className: "text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400", children: [
382
+ U(n.seconds) || "under a minute",
383
+ " · ",
384
+ n.views,
385
+ " page view",
386
+ n.views === 1 ? "" : "s"
387
+ ] }),
388
+ t && /* @__PURE__ */ a(
389
+ "span",
390
+ {
391
+ className: "ml-auto rounded bg-slate-100 px-1.5 py-px text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
392
+ "data-journey-app": e,
393
+ children: r
394
+ }
395
+ )
396
+ ] }),
397
+ /* @__PURE__ */ a("ol", { className: "-mx-2", children: d.map((m) => /* @__PURE__ */ a(
398
+ Ce,
399
+ {
400
+ row: m,
401
+ maxDwell: c,
402
+ appName: r
403
+ },
404
+ `${m.start}-${m.label.key}`
405
+ )) }),
406
+ (s || n.skipped > 0) && /* @__PURE__ */ l("div", { className: "mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px]", children: [
407
+ s && /* @__PURE__ */ l(
408
+ "button",
409
+ {
410
+ type: "button",
411
+ onClick: () => u(!0),
412
+ className: "font-medium text-nvr-navy hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-nvr-cyan",
413
+ children: [
414
+ "Show ",
415
+ n.rows.length - L,
416
+ " more"
417
+ ]
418
+ }
419
+ ),
420
+ n.skipped > 0 && /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-slate-400", "data-journey-skipped": !0, children: n.skipped === 1 ? "1 page open for less than a second isn’t shown" : `${n.skipped} pages open for less than a second aren’t shown` })
421
+ ] })
422
+ ] });
420
423
  }
421
- function ye({ userId: t }) {
422
- const l = M(), p = P(), a = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), [i, u] = $(a), [c, m] = $(null), { data: d } = T({
423
- queryKey: ["nvr-journey-days", t, c],
424
- queryFn: () => oe(l, t, c)
425
- }), N = (d == null ? void 0 : d.days) ?? [], y = (d == null ? void 0 : d.apps) ?? [], { data: x, isLoading: g } = T({
426
- queryKey: ["nvr-journey", t, i, c],
427
- queryFn: () => l.request(
428
- S(`/journeys/user/${t}`, c ? { date: i, app: c } : { date: i })
429
- ).then((o) => o.data).catch(() => null)
430
- }), b = y.length > 1 || y.length === 1 && y[0] !== "admin", w = (x == null ? void 0 : x.sessions) ?? [], _ = (o) => p.consoleUrl ? p.consoleUrl(o) : o;
431
- return /* @__PURE__ */ s(
432
- A,
424
+ function Ce({
425
+ row: e,
426
+ maxDwell: r,
427
+ appName: n
428
+ }) {
429
+ var k;
430
+ const t = te(), { urlFor: c, open: o } = ae(), u = fe(), s = e.label, d = (p) => t.consoleUrl ? t.consoleUrl(p) : p;
431
+ let m = null, y = null;
432
+ if (s.record) {
433
+ const p = { collection: s.record.collection, itemId: s.record.id };
434
+ m = c(p), y = () => o(p);
435
+ } else s.queue_id ? m = d(`/queues/${encodeURIComponent(s.queue_id)}`) : s.person_id ? m = u(s.person_id) : e.app === "admin" && s.kind !== "record" && ce(e.path) && (m = d(e.path));
436
+ const b = [s.kind === "record" || s.kind === "new-record" || ((k = s.section) == null ? void 0 : k.toLowerCase()) === n.toLowerCase() ? null : s.section, ...e.details, e.visits > 1 ? `${e.visits} visits` : null].filter(
437
+ Boolean
438
+ ), h = (e.seconds ?? 0) >= Se, w = (e.seconds ?? 0) >= 60 ? Math.max(15, Math.round(Math.sqrt((e.seconds ?? 0) / r) * 100)) : 0, S = /* @__PURE__ */ a("span", { className: "line-clamp-2 break-words", children: s.title });
439
+ return /* @__PURE__ */ l(
440
+ "li",
433
441
  {
434
- icon: /* @__PURE__ */ e(z, { className: "h-4 w-4" }),
435
- title: "Pages visited",
436
- hint: "Their path through the admin and the portal, per session — kept 30 days",
437
- testId: "journey",
442
+ className: "grid grid-cols-[52px_minmax(0,1fr)_auto] items-start gap-x-2 rounded-md px-2 py-1.5 hover:bg-slate-50 dark:hover:bg-muted/40",
443
+ "data-journey-row": s.kind,
438
444
  children: [
439
- b && /* @__PURE__ */ e("div", { className: "mb-2 flex flex-wrap items-center gap-1.5", "data-journey-apps": !0, children: [null, ...y].map((o) => /* @__PURE__ */ e(
440
- "button",
445
+ /* @__PURE__ */ a(
446
+ "time",
441
447
  {
442
- type: "button",
443
- "aria-pressed": c === o,
444
- "data-journey-app-filter": o ?? "all",
445
- onClick: () => m(o),
446
- className: v(
447
- "rounded-md border px-2 py-0.5 text-[11px]",
448
- c === o ? "border-nvr-cyan bg-accent text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 dark:border-border dark:text-slate-400"
449
- ),
450
- children: o ?? "All apps"
451
- },
452
- o ?? "__all"
453
- )) }),
454
- N.length > 0 && /* @__PURE__ */ e("div", { className: "mb-3 flex flex-wrap gap-1.5", children: N.slice(0, 14).map((o) => /* @__PURE__ */ e(
455
- "button",
456
- {
457
- type: "button",
458
- "aria-pressed": i === o.date,
459
- onClick: () => u(o.date),
460
- className: v(
461
- "rounded-full border px-2 py-0.5 text-[11px]",
462
- i === o.date ? "border-nvr-cyan bg-accent text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 dark:border-border dark:text-slate-400"
463
- ),
464
- title: `${o.steps} page views`,
465
- children: o.date === a ? "Today" : o.date.slice(5)
466
- },
467
- o.date
468
- )) }),
469
- g ? /* @__PURE__ */ e(C, { children: "Loading…" }) : w.length === 0 ? /* @__PURE__ */ s(C, { children: [
470
- "No pages recorded ",
471
- i === a ? "today" : `on ${i}`,
472
- "."
473
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-4", children: w.map((o, D) => /* @__PURE__ */ s("div", { children: [
474
- /* @__PURE__ */ s("p", { className: "mb-1.5 text-[11px] font-medium text-slate-400", children: [
475
- "Session ",
476
- D + 1,
477
- " · started ",
478
- j(o.started_at),
479
- " · ",
480
- o.steps.length,
481
- " page",
482
- o.steps.length === 1 ? "" : "s",
483
- b && /* @__PURE__ */ e(
484
- "span",
485
- {
486
- className: "ml-1.5 rounded bg-slate-100 px-1.5 py-px text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
487
- "data-journey-app": o.app ?? "admin",
488
- children: o.app ?? "admin"
489
- }
490
- )
491
- ] }),
492
- /* @__PURE__ */ e("ol", { className: "relative ml-2 border-l border-slate-200 dark:border-border", children: o.steps.map((h, n) => {
493
- const f = (h.app ?? "admin") === "admin" && h.path.startsWith("/") && !h.path.startsWith("//") && !h.path.includes(":") ? _(h.path) : null;
494
- return /* @__PURE__ */ s("li", { className: "relative py-1 pl-4", children: [
495
- /* @__PURE__ */ e("span", { className: "absolute -left-[3.5px] top-[13px] h-1.5 w-1.5 rounded-full bg-nvr-cyan" }),
496
- /* @__PURE__ */ s("div", { className: "flex items-baseline gap-2", children: [
497
- f ? /* @__PURE__ */ e(
498
- "a",
499
- {
500
- href: f,
501
- onClick: (k) => {
502
- k.metaKey || k.ctrlKey || (k.preventDefault(), p.navigate(f));
503
- },
504
- className: "truncate text-[12.5px] text-slate-700 hover:text-nvr-navy hover:underline dark:text-slate-300 dark:hover:text-nvr-cyan",
505
- children: I(h.path)
506
- }
507
- ) : /* @__PURE__ */ e("span", { className: "truncate text-[12.5px] text-slate-700 dark:text-slate-300", children: I(h.path) }),
508
- /* @__PURE__ */ s("span", { className: "shrink-0 text-[10.5px] tabular-nums text-slate-400", children: [
509
- new Date(h.entered_at).toLocaleTimeString(void 0, {
510
- hour: "2-digit",
511
- minute: "2-digit"
512
- }),
513
- h.duration_seconds != null && ` · ${ie(h.duration_seconds)}`
514
- ] })
515
- ] })
516
- ] }, `${h.entered_at}-${n}`);
517
- }) })
518
- ] }, o.session_id)) })
448
+ dateTime: e.start,
449
+ className: "pt-px text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400",
450
+ children: xe(e.start)
451
+ }
452
+ ),
453
+ /* @__PURE__ */ l("div", { className: "min-w-0", children: [
454
+ m ? /* @__PURE__ */ a(
455
+ "a",
456
+ {
457
+ href: m,
458
+ onClick: (p) => {
459
+ p.metaKey || p.ctrlKey || p.shiftKey || p.button !== 0 || (p.preventDefault(), y ? y() : m && t.navigate(m));
460
+ },
461
+ className: "block text-[12.5px] font-medium leading-snug text-slate-800 underline-offset-2 hover:text-nvr-navy hover:underline focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-slate-100 dark:hover:text-nvr-cyan",
462
+ children: S
463
+ }
464
+ ) : /* @__PURE__ */ a(
465
+ "span",
466
+ {
467
+ className: f(
468
+ "block text-[12.5px] leading-snug",
469
+ s.record || s.kind === "page" || s.kind === "list" || s.queue_id || s.person_id ? "font-medium text-slate-800 dark:text-slate-100" : "text-slate-600 dark:text-slate-300"
470
+ ),
471
+ children: S
472
+ }
473
+ ),
474
+ b.length > 0 && /* @__PURE__ */ a("p", { className: "mt-0.5 truncate text-[11px] text-slate-500 dark:text-slate-400", children: b.join(" · ") })
475
+ ] }),
476
+ /* @__PURE__ */ l("div", { className: "flex items-center justify-end gap-2 pt-px", children: [
477
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "hidden h-1 w-8 justify-end sm:flex", children: w > 0 && /* @__PURE__ */ a(
478
+ "span",
479
+ {
480
+ className: f(
481
+ "h-1 rounded-full",
482
+ h ? "bg-slate-500 dark:bg-slate-400" : "bg-slate-300 dark:bg-slate-600"
483
+ ),
484
+ style: { width: `${w}%` }
485
+ }
486
+ ) }),
487
+ /* @__PURE__ */ a(
488
+ "span",
489
+ {
490
+ className: f(
491
+ "min-w-[44px] text-right text-[11.5px] tabular-nums",
492
+ h ? "font-semibold text-slate-800 dark:text-slate-100" : "text-slate-500 dark:text-slate-400"
493
+ ),
494
+ children: e.seconds != null ? U(e.seconds) : e.open ? "still open" : ""
495
+ }
496
+ )
497
+ ] })
519
498
  ]
520
499
  }
521
500
  );
522
501
  }
523
- function Ne({ profile: t }) {
524
- var p;
525
- const l = ((p = t.admin) == null ? void 0 : p.logins) ?? [];
526
- return /* @__PURE__ */ e(
527
- A,
502
+ function Pe({ profile: e }) {
503
+ var n;
504
+ const r = ((n = e.admin) == null ? void 0 : n.logins) ?? [];
505
+ return /* @__PURE__ */ a(
506
+ E,
528
507
  {
529
- icon: /* @__PURE__ */ e(Q, { className: "h-4 w-4" }),
508
+ icon: /* @__PURE__ */ a(Q, { className: "h-4 w-4" }),
530
509
  title: "Sign-ins",
531
- hint: t.admin ? `${t.admin.sessions} live session${t.admin.sessions === 1 ? "" : "s"} · ${t.admin.activity_30d.toLocaleString()} actions in 30 days` : void 0,
510
+ hint: e.admin ? `${e.admin.sessions} live session${e.admin.sessions === 1 ? "" : "s"} · ${e.admin.activity_30d.toLocaleString()} actions in 30 days` : void 0,
532
511
  testId: "sign-ins",
533
- children: l.length === 0 ? /* @__PURE__ */ e(C, { children: "No sign-in recorded yet." }) : /* @__PURE__ */ e("ul", { className: "space-y-1.5", children: l.map((a) => /* @__PURE__ */ s(
512
+ children: r.length === 0 ? /* @__PURE__ */ a(F, { children: "No sign-in recorded yet." }) : /* @__PURE__ */ a("ul", { className: "space-y-1.5", children: r.map((t) => /* @__PURE__ */ l(
534
513
  "li",
535
514
  {
536
515
  className: "flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[12px] text-slate-600 dark:text-slate-300",
537
516
  children: [
538
- /* @__PURE__ */ e("span", { title: O(a.at), children: j(a.at) }),
539
- /* @__PURE__ */ e("span", { className: "rounded-full bg-slate-100 px-1.5 py-px text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300", children: a.method }),
540
- a.ip && /* @__PURE__ */ e("span", { className: "font-mono text-[11px] text-slate-400", children: a.ip }),
541
- a.new_ip && /* @__PURE__ */ e("span", { className: "rounded-full bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400", children: "new address" })
517
+ /* @__PURE__ */ a("span", { title: ne(t.at), children: se(t.at) }),
518
+ /* @__PURE__ */ a("span", { className: "rounded-full bg-slate-100 px-1.5 py-px text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300", children: t.method }),
519
+ t.ip && /* @__PURE__ */ a("span", { className: "font-mono text-[11px] text-slate-400", children: t.ip }),
520
+ t.new_ip && /* @__PURE__ */ a("span", { className: "rounded-full bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400", children: "new address" })
542
521
  ]
543
522
  },
544
- a.at
523
+ t.at
545
524
  )) })
546
525
  }
547
526
  );
548
527
  }
549
528
  export {
550
- ve as ActivityFeedCard,
551
- ye as JourneyCard,
552
- Ne as SignInsCard,
553
- be as StatsCard,
554
- ne as activityLinkable,
555
- oe as fetchJourneyDays,
556
- ie as fmtDuration,
557
- I as pageLabel
529
+ Be as JourneyCard,
530
+ Pe as SignInsCard,
531
+ Re as StatsCard,
532
+ ke as fetchJourneyDays,
533
+ U as fmtDuration,
534
+ Je as pageLabel
558
535
  };