@nivaro/react 0.3.116 → 0.3.118

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 (142) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +140 -14
  4. package/dist/index.js +488 -485
  5. package/dist/shared/components/ActivityEntry.js +130 -125
  6. package/dist/shared/components/AgentPresenceChip.js +36 -26
  7. package/dist/shared/components/CellCopyLayer.js +50 -45
  8. package/dist/shared/components/CollectionBrowserView.js +3855 -3785
  9. package/dist/shared/components/FilePreviewLightbox.js +96 -58
  10. package/dist/shared/components/InStep.js +18 -17
  11. package/dist/shared/components/ItemEditForm.js +4220 -4175
  12. package/dist/shared/components/JobsTray.js +8 -8
  13. package/dist/shared/components/LiveNewMatchesPill.js +21 -14
  14. package/dist/shared/components/LiveOffNote.js +3 -2
  15. package/dist/shared/components/LiveRowMark.js +53 -23
  16. package/dist/shared/components/LiveTraceView.js +162 -123
  17. package/dist/shared/components/MyWorkView.js +320 -299
  18. package/dist/shared/components/NotificationBell.js +14 -14
  19. package/dist/shared/components/OverflowRail.js +1 -1
  20. package/dist/shared/components/PageRenderer.js +120 -116
  21. package/dist/shared/components/ProfileView.js +203 -202
  22. package/dist/shared/components/RealtimeStatusBanner.js +31 -29
  23. package/dist/shared/components/RecordDrilldownSheet.js +7 -7
  24. package/dist/shared/components/RecordHoverCard.js +102 -84
  25. package/dist/shared/components/RecordReadView.js +146 -146
  26. package/dist/shared/components/ReportView.js +1086 -1091
  27. package/dist/shared/components/ScreenRefreshButton.js +34 -32
  28. package/dist/shared/components/TipLayer.js +65 -58
  29. package/dist/shared/components/WidgetImageMenu.js +83 -43
  30. package/dist/shared/components/activity/RecordActivityStream.js +175 -173
  31. package/dist/shared/components/bulk/BulkSelectionNotices.js +142 -119
  32. package/dist/shared/components/cbv/column-totals.js +62 -57
  33. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +158 -143
  34. package/dist/shared/components/change-proposals/ProposeChangeButton.js +17 -11
  35. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +201 -173
  36. package/dist/shared/components/charts/category-axis.js +93 -0
  37. package/dist/shared/components/chat/ChatAnalyticsView.js +27 -27
  38. package/dist/shared/components/chat/HuddleAnalyticsTab.js +17 -17
  39. package/dist/shared/components/collections-directory/CollectionsToolbar.js +39 -41
  40. package/dist/shared/components/collections-directory/page-model.js +72 -67
  41. package/dist/shared/components/integrations/RecordIntegrationPreview.js +48 -56
  42. package/dist/shared/components/integrations/SendStatus.js +65 -59
  43. package/dist/shared/components/integrations/console/ReadyToSendView.js +275 -209
  44. package/dist/shared/components/integrations/console/SignalCard.js +237 -230
  45. package/dist/shared/components/item-edit/CatalogPickerField.js +227 -205
  46. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +131 -92
  47. package/dist/shared/components/item-edit/CloneDialog.js +191 -161
  48. package/dist/shared/components/item-edit/DerivedCauseNote.js +44 -30
  49. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +153 -134
  50. package/dist/shared/components/item-edit/FieldComments.js +54 -53
  51. package/dist/shared/components/item-edit/FieldPointer.js +82 -67
  52. package/dist/shared/components/item-edit/FieldRow.js +106 -100
  53. package/dist/shared/components/item-edit/FieldSourceBadge.js +58 -56
  54. package/dist/shared/components/item-edit/FilePickerField.js +452 -387
  55. package/dist/shared/components/item-edit/HeaderSummaryChip.js +78 -56
  56. package/dist/shared/components/item-edit/HeaderTools.js +94 -85
  57. package/dist/shared/components/item-edit/InlineTableField.js +1242 -1218
  58. package/dist/shared/components/item-edit/ListNeighborNav.js +47 -50
  59. package/dist/shared/components/item-edit/LiveTraceSheet.js +15 -10
  60. package/dist/shared/components/item-edit/MembershipSetField.js +285 -254
  61. package/dist/shared/components/item-edit/OutboxReviewTray.js +155 -144
  62. package/dist/shared/components/item-edit/QueueReturnChip.js +15 -36
  63. package/dist/shared/components/item-edit/RecalcValue.js +57 -32
  64. package/dist/shared/components/item-edit/RecordHelpChip.js +21 -22
  65. package/dist/shared/components/item-edit/RecordLiveSync.js +283 -231
  66. package/dist/shared/components/item-edit/RelationCombobox.js +439 -393
  67. package/dist/shared/components/item-edit/RemoteChangeUi.js +292 -224
  68. package/dist/shared/components/item-edit/RemoteUploads.js +26 -20
  69. package/dist/shared/components/item-edit/RemovedLineNote.js +77 -67
  70. package/dist/shared/components/item-edit/RichTextEditorImpl.js +184 -179
  71. package/dist/shared/components/item-edit/ScheduledChangeChip.js +168 -134
  72. package/dist/shared/components/item-edit/SectionPresence.js +18 -10
  73. package/dist/shared/components/item-edit/SplitLinesButton.js +163 -139
  74. package/dist/shared/components/item-edit/UserChip.js +1 -1
  75. package/dist/shared/components/item-edit/file-live.js +69 -54
  76. package/dist/shared/components/item-edit/layout-switch.js +98 -89
  77. package/dist/shared/components/item-edit/partner-needs.js +12 -12
  78. package/dist/shared/components/item-edit/removed-line.js +31 -25
  79. package/dist/shared/components/layout-editor/pickers/field-picker.js +112 -104
  80. package/dist/shared/components/list/ListViewers.js +46 -35
  81. package/dist/shared/components/notifications/NotificationCenterView.js +479 -437
  82. package/dist/shared/components/panels/AccessDeniedPanel.js +176 -101
  83. package/dist/shared/components/panels/AlertBanners.js +82 -72
  84. package/dist/shared/components/panels/BranchLanes.js +22 -22
  85. package/dist/shared/components/panels/CommentImages.js +123 -102
  86. package/dist/shared/components/panels/CommentPanel.js +186 -185
  87. package/dist/shared/components/panels/ExternalRequestsChip.js +111 -119
  88. package/dist/shared/components/panels/OwnerOpenedLine.js +31 -24
  89. package/dist/shared/components/panels/PipelinePanel.js +2037 -1885
  90. package/dist/shared/components/panels/ResubmissionDiff.js +163 -142
  91. package/dist/shared/components/pipeline/BindingStartStateSettings.js +163 -0
  92. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +400 -288
  93. package/dist/shared/components/pipeline/PipelineEditorView.js +320 -299
  94. package/dist/shared/components/profile/AgentNameField.js +107 -81
  95. package/dist/shared/components/profile/AgentsPanel.js +184 -184
  96. package/dist/shared/components/profile/PersonAccess.js +599 -495
  97. package/dist/shared/components/profile/SignInTroubleshooter.js +160 -127
  98. package/dist/shared/components/profile/SignedInDevices.js +17 -17
  99. package/dist/shared/components/profile/primitives.js +1 -1
  100. package/dist/shared/components/queue/OwnerAvatars.js +91 -54
  101. package/dist/shared/components/queue/QueueTeamStrip.js +56 -46
  102. package/dist/shared/components/queue/QueueWorklist.js +1002 -983
  103. package/dist/shared/components/support/AssignRules.js +1733 -0
  104. package/dist/shared/components/support/PersonPick.js +88 -0
  105. package/dist/shared/components/support/RequestList.js +790 -0
  106. package/dist/shared/components/support/ScreenShare.js +158 -152
  107. package/dist/shared/components/support/SupportRequestDialog.js +50 -48
  108. package/dist/shared/components/support/SupportView.js +140 -246
  109. package/dist/shared/components/support/TicketDetailSheet.js +82 -75
  110. package/dist/shared/components/support/TicketSlowScreens.js +9 -9
  111. package/dist/shared/components/support/assign-rules-text.js +171 -0
  112. package/dist/shared/components/support/support-list.js +125 -0
  113. package/dist/shared/components/ui/SimpleSelect.js +28 -20
  114. package/dist/shared/components/ui/checkbox.js +6 -6
  115. package/dist/shared/components/ui/select.js +43 -39
  116. package/dist/shared/components/ui/sheet.js +9 -9
  117. package/dist/shared/components/ui/switch.js +12 -11
  118. package/dist/shared/components/watch-list/WatchDock.js +532 -459
  119. package/dist/shared/components/watch-list/WatchExtras.js +332 -286
  120. package/dist/shared/components/watch-list/WatchRows.js +164 -140
  121. package/dist/shared/lib/activity-sentence.js +103 -91
  122. package/dist/shared/lib/agent-presence.js +27 -21
  123. package/dist/shared/lib/approval-progress.js +2 -2
  124. package/dist/shared/lib/copy-rules.js +31 -24
  125. package/dist/shared/lib/derived-causes.js +113 -78
  126. package/dist/shared/lib/grid-cursors.js +26 -26
  127. package/dist/shared/lib/label-flash.js +27 -0
  128. package/dist/shared/lib/list-return.js +137 -125
  129. package/dist/shared/lib/live-deltas.js +40 -34
  130. package/dist/shared/lib/live-groups.js +56 -52
  131. package/dist/shared/lib/live-preference.js +64 -59
  132. package/dist/shared/lib/live-screen.js +223 -192
  133. package/dist/shared/lib/partner-failure.js +11 -11
  134. package/dist/shared/lib/rollup-recalc.js +68 -64
  135. package/dist/shared/lib/screen-refresh.js +74 -68
  136. package/dist/shared/lib/screen-share.js +108 -104
  137. package/dist/shared/lib/send-status.js +77 -61
  138. package/dist/shared/lib/text-diff-window.js +29 -0
  139. package/dist/shared/lib/use-query-entry.js +17 -0
  140. package/dist/shared/lib/watch-list.js +210 -209
  141. package/dist/shared/lib/widget-image-render.js +72 -49
  142. package/package.json +1 -1
@@ -1,31 +1,33 @@
1
- import { jsx as e, jsxs as o, Fragment as et } from "react/jsx-runtime";
2
- import { saveReportFilterPreset as Et, listReportFilterPresets as ka, deleteReportFilterPreset as Na, readReport as jt, executeCustomQuery as wa, readItems as Sa, readReportFilterOptions as _a, aiReportFilters as Ca, readReportWidgetData as Ct, listReportAlerts as $a, createReportAlert as qa, toggleReportAlert as Aa, deleteReportAlert as Fa, readReportAlertLog as Ma, resolveReportAlert as Ra } from "@nivaro/sdk";
3
- import { useQuery as Se, useQueryClient as lt, useMutation as Ae, isCancelledError as Ta, skipToken as La } from "@tanstack/react-query";
4
- import { X as Te, Check as Ht, Plus as Xt, Camera as Lt, Bell as Zt, RefreshCw as At, ChevronsUpDown as It, Sparkles as Wt, Info as Oa, Table as Ka, Sigma as Da, StickyNote as Pa, Download as za, TrendingUp as ea, TrendingDown as ta, Trash2 as Ea } from "lucide-react";
5
- import { useState as _, useEffect as Ze, useCallback as gt, useRef as Ie, useMemo as tt, Suspense as Rt, createContext as ja, lazy as Pt, memo as Wa, useContext as Ba } from "react";
1
+ import { jsx as e, jsxs as o, Fragment as We } from "react/jsx-runtime";
2
+ import { saveReportFilterPreset as jt, listReportFilterPresets as Na, deleteReportFilterPreset as wa, readReport as zt, executeCustomQuery as Sa, readItems as _a, readReportFilterOptions as Ca, aiReportFilters as $a, readReportWidgetData as Ct, listReportAlerts as qa, createReportAlert as Aa, toggleReportAlert as Ma, deleteReportAlert as Fa, readReportAlertLog as Ra, resolveReportAlert as Ta } from "@nivaro/sdk";
3
+ import { useQuery as _e, useQueryClient as nt, useMutation as Me, isCancelledError as La } from "@tanstack/react-query";
4
+ import { X as Re, Check as Ht, Plus as Xt, Camera as Lt, Bell as Zt, RefreshCw as At, ChevronsUpDown as It, Sparkles as Wt, Info as Oa, Table as Ka, Sigma as Da, StickyNote as Pa, Download as Ea, TrendingUp as ea, TrendingDown as ta, Trash2 as ja } from "lucide-react";
5
+ import { useState as S, useEffect as tt, useCallback as gt, useRef as at, useMemo as lt, Suspense as Rt, createContext as za, lazy as Pt, memo as Wa, useContext as Ba } from "react";
6
6
  import { toast as aa } from "sonner";
7
- import { useNivaroClient as Le, useDrilldown as la, useOverlayState as Qa } from "../context.js";
8
- import { get as bt, post as at, del as Ja, put as Ua } from "../lib/commands.js";
9
- import { changedWidgetIds as Ya, useConfigWatch as Va } from "../lib/config-watch.js";
7
+ import { useNivaroClient as Te, useDrilldown as la, useOverlayState as Qa } from "../context.js";
8
+ import { get as bt, post as rt, del as Ua, put as Ja } from "../lib/commands.js";
9
+ import { changedWidgetIds as Va, useConfigWatch as Ya } from "../lib/config-watch.js";
10
10
  import { useAutoRefreshPref as Ga, useLiveStamp as Ha } from "../lib/live-data-changed.js";
11
11
  import { useLiveWidget as Xa, liveWidgetInterval as Za } from "../lib/live-widgets.js";
12
12
  import { serverErrorText as ra, loadErrorText as Ot } from "../lib/load-error.js";
13
- import { restrictedScopeSelections as Ia, cascadeFilter as el, fetchCascadeRelations as tl } from "../lib/quick-filter-cascade.js";
14
- import { buildReportTree as al } from "../lib/report-tree.js";
15
- import { uniqueByValue as ll } from "../lib/unique-options.js";
16
- import { useMyScopes as na, matchScopeDimension as rl, translateScopeValues as Bt, effectiveScopeSeedIds as nl } from "../lib/use-my-scopes.js";
13
+ import { useQueryEntryState as Ia } from "../lib/use-query-entry.js";
14
+ import { restrictedScopeSelections as el, cascadeFilter as tl, fetchCascadeRelations as al } from "../lib/quick-filter-cascade.js";
15
+ import { buildReportTree as ll } from "../lib/report-tree.js";
16
+ import { uniqueByValue as rl } from "../lib/unique-options.js";
17
+ import { useMyScopes as na, matchScopeDimension as nl, translateScopeValues as Bt, effectiveScopeSeedIds as sl } from "../lib/use-my-scopes.js";
17
18
  import { cn as P, toLocalDateString as sa } from "../lib/utils.js";
18
19
  import { BackgroundRunOffer as oa } from "./BackgroundRunOffer.js";
19
- import { RechartsGate as Ke } from "./charts/RechartsGate.js";
20
- import { LoadErrorNote as ia } from "./LoadErrorNote.js";
21
- import { RecordDrilldownSheet as sl } from "./RecordDrilldownSheet.js";
22
- import { TipLayer as ol } from "./TipLayer.js";
23
- import { Command as il, CommandInput as dl, CommandList as cl, CommandEmpty as ul, CommandItem as ml } from "./ui/command.js";
24
- import { Popover as da, PopoverTrigger as ca, PopoverContent as ua } from "./ui/popover.js";
20
+ import { CategoryAxisBox as ia } from "./charts/category-axis.js";
21
+ import { RechartsGate as Pe } from "./charts/RechartsGate.js";
22
+ import { LoadErrorNote as da } from "./LoadErrorNote.js";
23
+ import { RecordDrilldownSheet as ol } from "./RecordDrilldownSheet.js";
24
+ import { TipLayer as il } from "./TipLayer.js";
25
+ import { Command as dl, CommandInput as cl, CommandList as ul, CommandEmpty as ml, CommandItem as pl } from "./ui/command.js";
26
+ import { Popover as ca, PopoverTrigger as ua, PopoverContent as ma } from "./ui/popover.js";
25
27
  import { SimpleSelect as $t } from "./ui/SimpleSelect.js";
26
- import { Skeleton as De } from "./ui/skeleton.js";
27
- import { WidgetImageMenu as pl } from "./WidgetImageMenu.js";
28
- const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "")}B` : Math.abs(t) >= 1e6 ? `${(t / 1e6).toFixed(1).replace(/\.0$/, "")}M` : Math.abs(t) >= 1e3 ? `${(t / 1e3).toFixed(1).replace(/\.0$/, "")}k` : String(t), hl = [
28
+ import { Skeleton as Ee } from "./ui/skeleton.js";
29
+ import { WidgetImageMenu as hl } from "./WidgetImageMenu.js";
30
+ const $e = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "")}B` : Math.abs(t) >= 1e6 ? `${(t / 1e6).toFixed(1).replace(/\.0$/, "")}M` : Math.abs(t) >= 1e3 ? `${(t / 1e3).toFixed(1).replace(/\.0$/, "")}k` : String(t), fl = [
29
31
  "Jan",
30
32
  "Feb",
31
33
  "Mar",
@@ -38,23 +40,20 @@ const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
38
40
  "Oct",
39
41
  "Nov",
40
42
  "Dec"
41
- ], fl = (t) => {
43
+ ], xl = (t) => {
42
44
  const n = String(t ?? ""), a = /^(\d{4})-(\d{2})(?:-(\d{2}))?/.exec(n);
43
45
  if (a) {
44
- const s = hl[Number(a[2]) - 1] ?? a[2];
46
+ const s = fl[Number(a[2]) - 1] ?? a[2];
45
47
  return a[3] ? `${s} ${Number(a[3])}` : `${s} '${a[1].slice(2)}`;
46
48
  }
47
49
  return n.length > 16 ? `${n.slice(0, 15)}…` : n;
48
- }, Ft = (t) => ({
50
+ }, Mt = (t) => ({
49
51
  interval: t > 12 ? Math.ceil(t / 12) - 1 : 0,
50
- tickFormatter: fl,
52
+ tickFormatter: xl,
51
53
  minTickGap: 4,
52
54
  ...t > 5 && t <= 12 ? { angle: -35, textAnchor: "end", height: 56 } : {}
53
- }), xl = (t) => {
54
- const n = String(t ?? "");
55
- return n.length > 22 ? `${n.slice(0, 21)}…` : n;
56
- }, zt = () => import("./ReportEditMode.js"), bl = Pt(() => zt().then((t) => ({ default: t.AddWidgetBar }))), gl = Pt(() => zt().then((t) => ({ default: t.WidgetConfigSheet }))), vl = Pt(() => zt().then((t) => ({ default: t.WidgetEditBar }))), Xe = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ce = [
57
- Xe,
55
+ }), Et = () => import("./ReportEditMode.js"), bl = Pt(() => Et().then((t) => ({ default: t.AddWidgetBar }))), gl = Pt(() => Et().then((t) => ({ default: t.WidgetConfigSheet }))), vl = Pt(() => Et().then((t) => ({ default: t.WidgetEditBar }))), et = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ue = [
56
+ et,
58
57
  "#4f7cac",
59
58
  // steel blue
60
59
  "#c2703d",
@@ -82,7 +81,7 @@ const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
82
81
  { id: "last_12_months", label: "Last 12 months" },
83
82
  { id: "ytd", label: "Year to date" }
84
83
  ];
85
- function qe(t, n) {
84
+ function Ae(t, n) {
86
85
  if (t == null) return "—";
87
86
  const a = (n == null ? void 0 : n.decimals) != null ? t.toLocaleString(void 0, {
88
87
  minimumFractionDigits: n.decimals,
@@ -108,7 +107,7 @@ function Qt({ pct: t }) {
108
107
  }
109
108
  );
110
109
  }
111
- function ma({
110
+ function pa({
112
111
  reportId: t,
113
112
  field: n,
114
113
  label: a,
@@ -117,82 +116,82 @@ function ma({
117
116
  onChange: u,
118
117
  allowedValues: h
119
118
  }) {
120
- const g = Le(), p = lt(), [D, O] = _(!1), { scopes: y } = na(), Q = s ? Ia(s.collection, y) : [], { data: m = [] } = Se({
119
+ const g = Te(), p = nt(), [K, L] = S(!1), { scopes: y } = na(), Q = s ? el(s.collection, y) : [], { data: m = [] } = _e({
121
120
  queryKey: ["nivaro-report-filter-opts", t, n, s ?? null, Q],
122
121
  queryFn: async () => {
123
122
  if (s) {
124
- const F = s.value_field ?? "id", H = s.label_field ?? F, z = Q.length ? el(
123
+ const q = s.value_field ?? "id", Z = s.label_field ?? q, E = Q.length ? tl(
125
124
  s.collection,
126
- await tl(g, p, s.collection),
125
+ await al(g, p, s.collection),
127
126
  Q
128
- ) : null, ue = await g.request(
129
- Sa(s.collection, {
130
- fields: [.../* @__PURE__ */ new Set(["id", F, H])],
131
- ...z ? { filter: z } : {},
127
+ ) : null, me = await g.request(
128
+ _a(s.collection, {
129
+ fields: [.../* @__PURE__ */ new Set(["id", q, Z])],
130
+ ...E ? { filter: E } : {},
132
131
  sort: s.sort ? [s.sort] : void 0,
133
132
  limit: 200
134
133
  })
135
134
  );
136
- return ll(
137
- (ue.data ?? []).map((J) => ({
138
- value: String(J[F] ?? J.id),
139
- label: String(J[H] ?? J[F] ?? J.id)
135
+ return rl(
136
+ (me.data ?? []).map((J) => ({
137
+ value: String(J[q] ?? J.id),
138
+ label: String(J[Z] ?? J[q] ?? J.id)
140
139
  })),
141
140
  (J) => J.value
142
141
  );
143
142
  }
144
- return g.request(_a(t, n)).then((F) => F.data);
143
+ return g.request(Ca(t, n)).then((q) => q.data);
145
144
  },
146
- enabled: D,
145
+ enabled: K,
147
146
  staleTime: 12e4
148
- }), k = h != null && h.length ? m.filter((F) => h.some((H) => String(H) === F.value)) : m, Z = c.length > 0;
149
- return /* @__PURE__ */ o(da, { open: D, onOpenChange: O, children: [
150
- /* @__PURE__ */ e(ca, { asChild: !0, children: /* @__PURE__ */ o(
147
+ }), N = h != null && h.length ? m.filter((q) => h.some((Z) => String(Z) === q.value)) : m, H = c.length > 0;
148
+ return /* @__PURE__ */ o(ca, { open: K, onOpenChange: L, children: [
149
+ /* @__PURE__ */ e(ua, { asChild: !0, children: /* @__PURE__ */ o(
151
150
  "button",
152
151
  {
153
152
  type: "button",
154
153
  className: P(
155
154
  "flex h-7 items-center gap-1.5 rounded-md border px-2 text-[12px]",
156
- Z ? "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-300 dark:border-border"
155
+ H ? "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-300 dark:border-border"
157
156
  ),
158
157
  children: [
159
158
  a,
160
- Z && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: c.length }),
159
+ H && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: c.length }),
161
160
  /* @__PURE__ */ e(It, { className: "h-3 w-3 opacity-50" })
162
161
  ]
163
162
  }
164
163
  ) }),
165
- /* @__PURE__ */ e(ua, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ o(il, { children: [
166
- /* @__PURE__ */ e(dl, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
167
- /* @__PURE__ */ o(cl, { className: "max-h-52", children: [
168
- /* @__PURE__ */ e(ul, { children: "No values." }),
169
- k.map((F) => {
170
- const H = c.some((z) => String(z) === F.value);
164
+ /* @__PURE__ */ e(ma, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ o(dl, { children: [
165
+ /* @__PURE__ */ e(cl, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
166
+ /* @__PURE__ */ o(ul, { className: "max-h-52", children: [
167
+ /* @__PURE__ */ e(ml, { children: "No values." }),
168
+ N.map((q) => {
169
+ const Z = c.some((E) => String(E) === q.value);
171
170
  return /* @__PURE__ */ o(
172
- ml,
171
+ pl,
173
172
  {
174
- value: F.label,
173
+ value: q.label,
175
174
  onSelect: () => {
176
- const z = H ? c.filter((J) => String(J) !== F.value) : [...c, F.value], ue = (J) => {
175
+ const E = Z ? c.filter((J) => String(J) !== q.value) : [...c, q.value], me = (J) => {
177
176
  var W;
178
- return ((W = m.find((se) => se.value === String(J))) == null ? void 0 : W.label) ?? String(J);
177
+ return ((W = m.find((ie) => ie.value === String(J))) == null ? void 0 : W.label) ?? String(J);
179
178
  };
180
- u(z, z.map(ue));
179
+ u(E, E.map(me));
181
180
  },
182
181
  className: "text-[12.5px]",
183
182
  children: [
184
- /* @__PURE__ */ e(Ht, { className: P("mr-1.5 h-3 w-3", H ? "opacity-100" : "opacity-0") }),
185
- F.label
183
+ /* @__PURE__ */ e(Ht, { className: P("mr-1.5 h-3 w-3", Z ? "opacity-100" : "opacity-0") }),
184
+ q.label
186
185
  ]
187
186
  },
188
- F.value
187
+ q.value
189
188
  );
190
189
  })
191
190
  ] })
192
191
  ] }) })
193
192
  ] });
194
193
  }
195
- function pa(t) {
194
+ function ha(t) {
196
195
  if (!t) return null;
197
196
  const n = /* @__PURE__ */ new Date(), a = (u) => {
198
197
  const h = (g) => String(g).padStart(2, "0");
@@ -235,7 +234,7 @@ function ze(t, n, a) {
235
234
  });
236
235
  return n === "currency" ? `$${c(0, 0)}` : n === "percent" ? `${c(0, 1)}%` : n === "days" ? `${c(0, 1)}d` : n === "integer" ? Math.round(s).toLocaleString() : n === "number" ? c(0, 2) : String(t);
237
236
  }
238
- const Pe = /* @__PURE__ */ new Set([
237
+ const je = /* @__PURE__ */ new Set([
239
238
  "currency",
240
239
  "number",
241
240
  "integer",
@@ -243,7 +242,7 @@ const Pe = /* @__PURE__ */ new Set([
243
242
  "days"
244
243
  ]);
245
244
  function Kt(t, n, a) {
246
- const s = {}, c = pa(n);
245
+ const s = {}, c = ha(n);
247
246
  for (const [u, h] of Object.entries(t.params ?? {})) {
248
247
  if (h === "$date.start") {
249
248
  c && (s[u] = c.start);
@@ -255,15 +254,15 @@ function Kt(t, n, a) {
255
254
  }
256
255
  const g = /^\$filters\.([\w.]+?)(:values)?$/.exec(h);
257
256
  if (g) {
258
- const p = a.find((O) => O.field === g[1]), D = g[2] ? p == null ? void 0 : p.values : p != null && p.labels && p.labels.length > 0 ? p.labels : p == null ? void 0 : p.values;
259
- D && D.length > 0 && (s[u] = D.join(","));
257
+ const p = a.find((L) => L.field === g[1]), K = g[2] ? p == null ? void 0 : p.values : p != null && p.labels && p.labels.length > 0 ? p.labels : p == null ? void 0 : p.values;
258
+ K && K.length > 0 && (s[u] = K.join(","));
260
259
  continue;
261
260
  }
262
261
  s[u] = h;
263
262
  }
264
263
  return s;
265
264
  }
266
- const wl = (t) => `$${Ce(Math.round(t))}`, Sl = [
265
+ const wl = (t) => `$${$e(Math.round(t))}`, Sl = [
267
266
  { gte: 90, color: "#ef4444" },
268
267
  { gte: 70, color: "#f59e0b" },
269
268
  { gte: -1 / 0, color: "#10b981" }
@@ -274,65 +273,65 @@ function _l({
274
273
  onDrill: a
275
274
  }) {
276
275
  const s = n.tree, c = n.series && n.series.length > 0 ? n.series : Object.keys(t[0] ?? {}).filter((m) => {
277
- var k;
278
- return typeof ((k = t[0]) == null ? void 0 : k[m]) == "number";
279
- }).slice(0, 3).map((m) => ({ field: m, label: m })), u = tt(
280
- () => s ? al(
276
+ var N;
277
+ return typeof ((N = t[0]) == null ? void 0 : N[m]) == "number";
278
+ }).slice(0, 3).map((m) => ({ field: m, label: m })), u = lt(
279
+ () => s ? ll(
281
280
  t,
282
281
  s,
283
282
  c.map((m) => m.field)
284
283
  ) : [],
285
284
  // eslint-disable-next-line react-hooks/exhaustive-deps
286
285
  [t, s]
287
- ), [h, g] = _(() => /* @__PURE__ */ new Set()), [p, D] = _(!1);
288
- Ze(() => {
286
+ ), [h, g] = S(() => /* @__PURE__ */ new Set()), [p, K] = S(!1);
287
+ tt(() => {
289
288
  if (p || u.length === 0) return;
290
- const m = /* @__PURE__ */ new Set(), k = (Z) => {
291
- for (const F of Z)
292
- (F.depth > 0 || u.length === 1) && m.add(F.key), k(F.children);
289
+ const m = /* @__PURE__ */ new Set(), N = (H) => {
290
+ for (const q of H)
291
+ (q.depth > 0 || u.length === 1) && m.add(q.key), N(q.children);
293
292
  };
294
- k(u), g(m), D(!0);
293
+ N(u), g(m), K(!0);
295
294
  }, [u, p]);
296
- const O = (s == null ? void 0 : s.thresholds) ?? Sl, y = (m) => {
297
- var k;
298
- return m == null ? void 0 : ((k = O.find((Z) => m >= Z.gte)) == null ? void 0 : k.color) ?? "#10b981";
295
+ const L = (s == null ? void 0 : s.thresholds) ?? Sl, y = (m) => {
296
+ var N;
297
+ return m == null ? void 0 : ((N = L.find((H) => m >= H.gte)) == null ? void 0 : N.color) ?? "#10b981";
299
298
  }, Q = (m) => {
300
- const k = m.children.length === 0, Z = h.has(m.key), F = y(m.pct), H = k && (s == null ? void 0 : s.drill) && m.drillId != null;
299
+ const N = m.children.length === 0, H = h.has(m.key), q = y(m.pct), Z = N && (s == null ? void 0 : s.drill) && m.drillId != null;
301
300
  return /* @__PURE__ */ o("div", { style: { paddingLeft: m.depth === 0 ? 0 : 14 }, children: [
302
301
  /* @__PURE__ */ o(
303
302
  "div",
304
303
  {
305
- role: H || !k ? "button" : void 0,
306
- tabIndex: H || !k ? 0 : void 0,
304
+ role: Z || !N ? "button" : void 0,
305
+ tabIndex: Z || !N ? 0 : void 0,
307
306
  className: P(
308
307
  "group/tn rounded-md px-1.5 py-1",
309
- (H || !k) && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40"
308
+ (Z || !N) && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40"
310
309
  ),
311
310
  onClick: () => {
312
- k ? H && (s != null && s.drill) && a({
311
+ N ? Z && (s != null && s.drill) && a({
313
312
  collection: s.drill.collection,
314
313
  itemId: String(m.drillId),
315
314
  title: m.label
316
- }) : g((z) => {
317
- const ue = new Set(z);
318
- return ue.has(m.key) ? ue.delete(m.key) : ue.add(m.key), ue;
315
+ }) : g((E) => {
316
+ const me = new Set(E);
317
+ return me.has(m.key) ? me.delete(m.key) : me.add(m.key), me;
319
318
  });
320
319
  },
321
- onKeyDown: (z) => {
322
- (z.key === "Enter" || z.key === " ") && z.currentTarget.click();
320
+ onKeyDown: (E) => {
321
+ (E.key === "Enter" || E.key === " ") && E.currentTarget.click();
323
322
  },
324
323
  children: [
325
324
  /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5", children: [
326
- k ? /* @__PURE__ */ e("span", { className: "w-3 shrink-0" }) : /* @__PURE__ */ e(
325
+ N ? /* @__PURE__ */ e("span", { className: "w-3 shrink-0" }) : /* @__PURE__ */ e(
327
326
  It,
328
327
  {
329
328
  className: P(
330
329
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
331
- Z && "rotate-180"
330
+ H && "rotate-180"
332
331
  )
333
332
  }
334
333
  ),
335
- k && m.badge && /* @__PURE__ */ e("span", { className: "shrink-0 rounded bg-slate-100 px-1 py-px text-[9.5px] tabular-nums text-slate-500 dark:bg-muted dark:text-slate-400", children: m.badge }),
334
+ N && m.badge && /* @__PURE__ */ e("span", { className: "shrink-0 rounded bg-slate-100 px-1 py-px text-[9.5px] tabular-nums text-slate-500 dark:bg-muted dark:text-slate-400", children: m.badge }),
336
335
  /* @__PURE__ */ e(
337
336
  "span",
338
337
  {
@@ -340,7 +339,7 @@ function _l({
340
339
  "min-w-0 flex-1 truncate",
341
340
  m.depth === 0 ? "text-[12px] font-semibold text-slate-800 dark:text-slate-100" : m.depth === 1 ? "text-[11.5px] font-medium text-slate-700 dark:text-slate-200" : P(
342
341
  "text-[11px] text-slate-600 dark:text-slate-300",
343
- H && "group-hover/tn:underline"
342
+ Z && "group-hover/tn:underline"
344
343
  )
345
344
  ),
346
345
  children: m.label
@@ -350,7 +349,7 @@ function _l({
350
349
  "span",
351
350
  {
352
351
  className: "shrink-0 text-[10.5px] font-semibold tabular-nums",
353
- style: { color: F },
352
+ style: { color: q },
354
353
  children: [
355
354
  m.pct.toFixed(1),
356
355
  "%"
@@ -369,27 +368,27 @@ function _l({
369
368
  "div",
370
369
  {
371
370
  className: "h-full rounded-full transition-[width] duration-300",
372
- style: { width: `${Math.min(Math.max(m.pct, 0), 100)}%`, background: F }
371
+ style: { width: `${Math.min(Math.max(m.pct, 0), 100)}%`, background: q }
373
372
  }
374
373
  )
375
374
  }
376
375
  ),
377
- /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: c.map((z) => /* @__PURE__ */ o("span", { children: [
378
- z.label ?? z.field,
376
+ /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: c.map((E) => /* @__PURE__ */ o("span", { children: [
377
+ E.label ?? E.field,
379
378
  " ",
380
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: m.sums[z.field] == null ? z.empty_label ?? "—" : n.value_format === "currency" ? wl(m.sums[z.field]) : m.sums[z.field].toLocaleString() })
381
- ] }, z.field)) })
379
+ /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: m.sums[E.field] == null ? E.empty_label ?? "—" : n.value_format === "currency" ? wl(m.sums[E.field]) : m.sums[E.field].toLocaleString() })
380
+ ] }, E.field)) })
382
381
  ]
383
382
  }
384
383
  ),
385
- Z && m.children.map(Q)
384
+ H && m.children.map(Q)
386
385
  ] }, m.key);
387
386
  };
388
387
  return !s || u.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-1", children: u.map(Q) });
389
388
  }
390
389
  function Cl(t) {
391
- const [n, a] = _(() => typeof IntersectionObserver > "u");
392
- return Ze(() => {
390
+ const [n, a] = S(() => typeof IntersectionObserver > "u");
391
+ return tt(() => {
393
392
  if (n) return;
394
393
  const s = t.current;
395
394
  if (!s) {
@@ -410,12 +409,12 @@ function Cl(t) {
410
409
  }, [n, t]), n;
411
410
  }
412
411
  function $l(t) {
413
- const n = Le(), a = Ie(!1);
412
+ const n = Te(), a = at(!1);
414
413
  return async (s) => {
415
414
  if (!(!t || a.current)) {
416
415
  a.current = !0;
417
416
  try {
418
- const u = (await n.request(at("/report-studio/drill-row", { values: s }))).data;
417
+ const u = (await n.request(rt("/report-studio/drill-row", { values: s }))).data;
419
418
  u != null && u.collection && u.item_id && t({ collection: u.collection, itemId: u.item_id });
420
419
  } catch {
421
420
  } finally {
@@ -424,7 +423,7 @@ function $l(t) {
424
423
  }
425
424
  };
426
425
  }
427
- function ha(t, n) {
426
+ function fa(t, n) {
428
427
  let a = n;
429
428
  if (t.group_rows && t.x_field) {
430
429
  const s = /* @__PURE__ */ new Map(), c = new Set(
@@ -443,40 +442,41 @@ function ha(t, n) {
443
442
  if (t.sort) {
444
443
  const s = t.sort.startsWith("-"), c = s ? t.sort.slice(1) : t.sort;
445
444
  a = [...a].sort((u, h) => {
446
- const g = u[c], p = h[c], D = typeof g == "number" && typeof p == "number" ? g - p : String(g ?? "").localeCompare(String(p ?? ""));
447
- return s ? -D : D;
445
+ const g = u[c], p = h[c], K = typeof g == "number" && typeof p == "number" ? g - p : String(g ?? "").localeCompare(String(p ?? ""));
446
+ return s ? -K : K;
448
447
  });
449
448
  }
450
449
  return t.limit && t.limit > 0 && (a = a.slice(0, t.limit)), a;
451
450
  }
452
- function fa(t, n, a, s) {
453
- const c = wa(n, a);
454
- return t.request(s ? { ...c, _signal: s } : c).then((u) => (ba(n, a, u), u.data ?? []));
451
+ function xa(t, n, a, s) {
452
+ const c = Sa(n, a);
453
+ return t.request(s ? { ...c, _signal: s } : c).then((u) => (ga(n, a, u), u.data ?? []));
455
454
  }
456
- const qt = /* @__PURE__ */ new Map(), xa = (t, n) => `${t}\0${JSON.stringify(n)}`;
457
- function ba(t, n, a) {
455
+ const qt = /* @__PURE__ */ new Map(), ba = (t, n) => `${t}\0${JSON.stringify(n)}`;
456
+ function ga(t, n, a) {
458
457
  const s = a;
459
- !s || typeof s != "object" || (qt.size > 200 && qt.clear(), qt.set(xa(t, n), {
458
+ !s || typeof s != "object" || (qt.size > 200 && qt.clear(), qt.set(ba(t, n), {
460
459
  cached_at: s.cached_at ?? null,
461
460
  executed_at: s.executed_at ?? null,
462
461
  freshness_sources: s.freshness_sources ?? null
463
462
  }));
464
463
  }
465
- const ga = ja(void 0);
464
+ const va = za(void 0);
466
465
  function ql({
467
466
  slug: t,
468
467
  params: n,
469
468
  scope: a
470
469
  }) {
471
- const s = Le(), c = lt(), u = Ba(ga), h = ["nivaro-report-query", t, n], { dataUpdatedAt: g } = Se({ queryKey: h, queryFn: La }), [p, D] = _(!1), O = JSON.stringify(h), y = tt(
472
- () => qt.get(xa(t, n)),
473
- [t, O, g]
470
+ var N;
471
+ const s = Te(), c = nt(), u = Ba(va), h = ["nivaro-report-query", t, n], g = ((N = Ia(h)) == null ? void 0 : N.dataUpdatedAt) ?? 0, [p, K] = S(!1), L = JSON.stringify(h), y = lt(
472
+ () => qt.get(ba(t, n)),
473
+ [t, L, g]
474
474
  ), Q = gt(() => {
475
- D(!0), s.request(at(`/custom-queries/${t}/execute`, { params: n, refresh: !0 })).then((k) => {
476
- ba(t, n, k), c.setQueryData(h, k.data ?? []);
475
+ K(!0), s.request(rt(`/custom-queries/${t}/execute`, { params: n, refresh: !0 })).then((H) => {
476
+ ga(t, n, H), c.setQueryData(h, H.data ?? []);
477
477
  }).catch(() => {
478
- }).finally(() => D(!1));
479
- }, [s, c, t, O]);
478
+ }).finally(() => K(!1));
479
+ }, [s, c, t, L]);
480
480
  return Ha({ envelope: y, scope: a, refresh: Q, autoOverride: u }).changed ? /* @__PURE__ */ o(
481
481
  "div",
482
482
  {
@@ -517,20 +517,20 @@ function Al({
517
517
  onDrill: u,
518
518
  deferred: h = !1
519
519
  }) {
520
- var re, ae;
521
- const g = Le(), p = $l(u), [D, O] = _(""), [y, Q] = _(0), [m, k] = _(null), Z = Kt(t, n, a), { data: F, isLoading: H, error: z, isFetching: ue, refetch: J } = Se({
522
- queryKey: ["nivaro-report-query", t.slug, Z],
523
- queryFn: ({ signal: N }) => fa(g, t.slug, Z, N),
520
+ var se, re;
521
+ const g = Te(), p = $l(u), [K, L] = S(""), [y, Q] = S(0), [m, N] = S(null), H = Kt(t, n, a), { data: q, isLoading: Z, error: E, isFetching: me, refetch: J } = _e({
522
+ queryKey: ["nivaro-report-query", t.slug, H],
523
+ queryFn: ({ signal: k }) => xa(g, t.slug, H, k),
524
524
  enabled: !h,
525
525
  staleTime: 6e4,
526
526
  refetchInterval: s,
527
527
  retry: !1
528
528
  });
529
- if (Ze(() => {
530
- c == null || c({ isFetching: ue, refetch: () => void J() });
531
- }, [ue]), h && F === void 0)
529
+ if (tt(() => {
530
+ c == null || c({ isFetching: me, refetch: () => void J() });
531
+ }, [me]), h && q === void 0)
532
532
  return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
533
- if (H)
533
+ if (Z)
534
534
  return /* @__PURE__ */ o("div", { className: "flex flex-col gap-2 px-1", children: [
535
535
  /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
536
536
  /* @__PURE__ */ e(
@@ -540,105 +540,105 @@ function Al({
540
540
  request: {
541
541
  method: "POST",
542
542
  url: `/custom-queries/${t.slug}/execute`,
543
- body: { params: Z }
543
+ body: { params: H }
544
544
  },
545
545
  label: `Query ${t.slug}`,
546
- queryKey: ["nivaro-report-query", t.slug, Z],
547
- select: (N) => (N == null ? void 0 : N.data) ?? []
546
+ queryKey: ["nivaro-report-query", t.slug, H],
547
+ select: (k) => (k == null ? void 0 : k.data) ?? []
548
548
  }
549
549
  )
550
550
  ] });
551
- if (z)
551
+ if (E)
552
552
  return /* @__PURE__ */ e(
553
- ia,
553
+ da,
554
554
  {
555
555
  className: "px-1",
556
- message: ra(z) ?? Ot(z, "this query"),
556
+ message: ra(E) ?? Ot(E, "this query"),
557
557
  onRetry: () => void J()
558
558
  }
559
559
  );
560
- const W = ha(t, F ?? []);
560
+ const W = fa(t, q ?? []);
561
561
  if (W.length === 0) return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
562
- const se = t.columns && t.columns.length > 0 ? t.columns : Object.keys(W[0] ?? {}).map((N) => ({ field: N }));
562
+ const ie = t.columns && t.columns.length > 0 ? t.columns : Object.keys(W[0] ?? {}).map((k) => ({ field: k }));
563
563
  if (t.display === "kpis") {
564
- const N = t.x_field ? W.map((R, Y) => {
565
- var E, oe, me, ge, S;
564
+ const k = t.x_field ? W.map((F, Y) => {
565
+ var j, de, pe, ke, w;
566
566
  return {
567
- label: String(R[t.x_field] ?? ""),
568
- value: R[((oe = (E = t.series) == null ? void 0 : E[0]) == null ? void 0 : oe.field) ?? ((me = se.find((j) => j.field !== t.x_field)) == null ? void 0 : me.field) ?? ""],
569
- color: ((S = (ge = t.series) == null ? void 0 : ge[0]) == null ? void 0 : S.color) ?? ce[Y % ce.length],
567
+ label: String(F[t.x_field] ?? ""),
568
+ value: F[((de = (j = t.series) == null ? void 0 : j[0]) == null ? void 0 : de.field) ?? ((pe = ie.find((I) => I.field !== t.x_field)) == null ? void 0 : pe.field) ?? ""],
569
+ color: ((w = (ke = t.series) == null ? void 0 : ke[0]) == null ? void 0 : w.color) ?? ue[Y % ue.length],
570
570
  format: t.value_format
571
571
  };
572
- }) : se.map((R, Y) => {
573
- var E;
572
+ }) : ie.map((F, Y) => {
573
+ var j;
574
574
  return {
575
- label: R.label ?? R.field,
576
- value: (E = W[0]) == null ? void 0 : E[R.field],
577
- color: ce[Y % ce.length],
578
- format: R.format ?? t.value_format
575
+ label: F.label ?? F.field,
576
+ value: (j = W[0]) == null ? void 0 : j[F.field],
577
+ color: ue[Y % ue.length],
578
+ format: F.format ?? t.value_format
579
579
  };
580
580
  });
581
581
  return /* @__PURE__ */ e(
582
582
  "div",
583
583
  {
584
584
  className: "grid gap-2",
585
- style: { gridTemplateColumns: `repeat(${Math.min(6, Math.max(1, N.length))}, 1fr)` },
586
- children: N.map((R) => /* @__PURE__ */ o(
585
+ style: { gridTemplateColumns: `repeat(${Math.min(6, Math.max(1, k.length))}, 1fr)` },
586
+ children: k.map((F) => /* @__PURE__ */ o(
587
587
  "div",
588
588
  {
589
589
  className: "flex flex-col justify-center rounded-md border border-slate-100 px-3 py-2 dark:border-border/60",
590
- style: { borderTopColor: R.color, borderTopWidth: 2 },
590
+ style: { borderTopColor: F.color, borderTopWidth: 2 },
591
591
  children: [
592
- /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: R.label }),
593
- /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: ze(R.value, R.format ?? "integer") })
592
+ /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: F.label }),
593
+ /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: ze(F.value, F.format ?? "integer") })
594
594
  ]
595
595
  },
596
- R.label
596
+ F.label
597
597
  ))
598
598
  }
599
599
  );
600
600
  }
601
601
  if (t.display === "tree")
602
- return /* @__PURE__ */ e(_l, { rows: W, cfg: t, onDrill: (N) => u == null ? void 0 : u(N) });
602
+ return /* @__PURE__ */ e(_l, { rows: W, cfg: t, onDrill: (k) => u == null ? void 0 : u(k) });
603
603
  if (t.display === "table") {
604
- const N = se.filter((S) => Pe.has(S.format ?? "")), R = D.trim().toLowerCase(), Y = R ? W.filter(
605
- (S) => Object.values(S).some(
606
- (j) => String(j ?? "").toLowerCase().includes(R)
604
+ const k = ie.filter((w) => je.has(w.format ?? "")), F = K.trim().toLowerCase(), Y = F ? W.filter(
605
+ (w) => Object.values(w).some(
606
+ (I) => String(I ?? "").toLowerCase().includes(F)
607
607
  )
608
- ) : W, E = 12, oe = Math.max(1, Math.ceil(Y.length / E)), me = Math.min(y, oe - 1), ge = Y.length > E ? Y.slice(me * E, me * E + E) : Y;
608
+ ) : W, j = 12, de = Math.max(1, Math.ceil(Y.length / j)), pe = Math.min(y, de - 1), ke = Y.length > j ? Y.slice(pe * j, pe * j + j) : Y;
609
609
  return /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
610
- W.length > E && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-2", children: [
610
+ W.length > j && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-2", children: [
611
611
  /* @__PURE__ */ e(
612
612
  "input",
613
613
  {
614
- value: D,
615
- onChange: (S) => {
616
- O(S.target.value), Q(0);
614
+ value: K,
615
+ onChange: (w) => {
616
+ L(w.target.value), Q(0);
617
617
  },
618
618
  placeholder: "Search rows…",
619
619
  className: "h-6 w-40 rounded border border-slate-200 bg-white px-1.5 text-[11px] dark:border-border dark:bg-card dark:text-slate-200"
620
620
  }
621
621
  ),
622
- oe > 1 && /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
622
+ de > 1 && /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
623
623
  /* @__PURE__ */ e(
624
624
  "button",
625
625
  {
626
626
  type: "button",
627
- disabled: me <= 0,
628
- onClick: () => Q(me - 1),
627
+ disabled: pe <= 0,
628
+ onClick: () => Q(pe - 1),
629
629
  className: "rounded px-1 disabled:opacity-30",
630
630
  children: "←"
631
631
  }
632
632
  ),
633
- me + 1,
633
+ pe + 1,
634
634
  "/",
635
- oe,
635
+ de,
636
636
  /* @__PURE__ */ e(
637
637
  "button",
638
638
  {
639
639
  type: "button",
640
- disabled: me >= oe - 1,
641
- onClick: () => Q(me + 1),
640
+ disabled: pe >= de - 1,
641
+ onClick: () => Q(pe + 1),
642
642
  className: "rounded px-1 disabled:opacity-30",
643
643
  children: "→"
644
644
  }
@@ -646,76 +646,76 @@ function Al({
646
646
  ] })
647
647
  ] }),
648
648
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[11.5px]", children: [
649
- /* @__PURE__ */ e("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: se.map((S) => /* @__PURE__ */ e(
649
+ /* @__PURE__ */ e("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: ie.map((w) => /* @__PURE__ */ e(
650
650
  "th",
651
651
  {
652
652
  className: P(
653
653
  "whitespace-nowrap border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
654
- Pe.has(S.format ?? "") && "text-right"
654
+ je.has(w.format ?? "") && "text-right"
655
655
  ),
656
- children: S.label ?? S.field
656
+ children: w.label ?? w.field
657
657
  },
658
- S.field
658
+ w.field
659
659
  )) }) }),
660
- /* @__PURE__ */ e("tbody", { children: ge.map((S, j) => /* @__PURE__ */ e(
660
+ /* @__PURE__ */ e("tbody", { children: ke.map((w, I) => /* @__PURE__ */ e(
661
661
  "tr",
662
662
  {
663
663
  className: u ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60" : void 0,
664
- onClick: () => void p(S),
664
+ onClick: () => void p(w),
665
665
  title: u ? "Open the record behind this row" : void 0,
666
- children: se.map((he) => /* @__PURE__ */ e(
666
+ children: ie.map((ae) => /* @__PURE__ */ e(
667
667
  "td",
668
668
  {
669
669
  className: P(
670
670
  "max-w-[220px] truncate border-b border-slate-50 px-1.5 py-1 text-slate-700 dark:border-border/40 dark:text-slate-300",
671
- Pe.has(he.format ?? "") && "text-right tabular-nums"
671
+ je.has(ae.format ?? "") && "text-right tabular-nums"
672
672
  ),
673
- children: ze(S[he.field], he.format, he.decimals)
673
+ children: ze(w[ae.field], ae.format, ae.decimals)
674
674
  },
675
- he.field
675
+ ae.field
676
676
  ))
677
677
  },
678
- j
678
+ I
679
679
  )) }),
680
- t.totals && N.length > 0 && /* @__PURE__ */ e("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: se.map((S, j) => /* @__PURE__ */ e(
680
+ t.totals && k.length > 0 && /* @__PURE__ */ e("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: ie.map((w, I) => /* @__PURE__ */ e(
681
681
  "td",
682
682
  {
683
683
  className: P(
684
684
  "border-t border-slate-200 px-1.5 py-1 font-semibold text-slate-800 dark:border-border dark:text-slate-200",
685
- Pe.has(S.format ?? "") && "text-right tabular-nums"
685
+ je.has(w.format ?? "") && "text-right tabular-nums"
686
686
  ),
687
- children: j === 0 && !Pe.has(S.format ?? "") ? "Total" : Pe.has(S.format ?? "") ? ze(
688
- W.reduce((he, ve) => he + (Number(ve[S.field]) || 0), 0),
689
- S.format,
690
- S.decimals
687
+ children: I === 0 && !je.has(w.format ?? "") ? "Total" : je.has(w.format ?? "") ? ze(
688
+ W.reduce((ae, we) => ae + (Number(we[w.field]) || 0), 0),
689
+ w.format,
690
+ w.decimals
691
691
  ) : ""
692
692
  },
693
- S.field
693
+ w.field
694
694
  )) }) })
695
695
  ] }) })
696
696
  ] });
697
697
  }
698
- const xe = t.x_field ?? ((re = se[0]) == null ? void 0 : re.field) ?? "", Ne = t.series && t.series.length > 0 ? t.series : se.filter((N) => {
699
- var R;
700
- return N.field !== xe && typeof ((R = W[0]) == null ? void 0 : R[N.field]) == "number";
701
- }).slice(0, 3).map((N) => ({ field: N.field, label: N.label ?? N.field })), we = W.map((N) => {
702
- const R = { [xe]: N[xe] };
703
- for (const Y of Ne) R[Y.field] = Number(N[Y.field]) || 0;
704
- return R;
705
- }), $e = (N) => t.value_format === "currency" ? `$${Ce(N)}` : Ce(N), f = (N) => ze(N, t.value_format ?? "number"), X = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, te = (N) => {
698
+ const be = t.x_field ?? ((se = ie[0]) == null ? void 0 : se.field) ?? "", Ne = t.series && t.series.length > 0 ? t.series : ie.filter((k) => {
699
+ var F;
700
+ return k.field !== be && typeof ((F = W[0]) == null ? void 0 : F[k.field]) == "number";
701
+ }).slice(0, 3).map((k) => ({ field: k.field, label: k.label ?? k.field })), ye = W.map((k) => {
702
+ const F = { [be]: k[be] };
703
+ for (const Y of Ne) F[Y.field] = Number(k[Y.field]) || 0;
704
+ return F;
705
+ }), qe = (k) => t.value_format === "currency" ? `$${$e(k)}` : $e(k), f = (k) => ze(k, t.value_format ?? "number"), X = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, le = (k) => {
706
706
  if (!u) return;
707
- const R = (F ?? []).filter((Y) => String(Y[xe] ?? "") === N);
708
- R.length > 0 && k({ label: N, rows: R });
709
- }, U = m ? /* @__PURE__ */ e(
707
+ const F = (q ?? []).filter((Y) => String(Y[be] ?? "") === k);
708
+ F.length > 0 && N({ label: k, rows: F });
709
+ }, V = m ? /* @__PURE__ */ e(
710
710
  "div",
711
711
  {
712
712
  className: "fixed inset-0 z-[126] flex items-center justify-center bg-black/30 p-6",
713
- onClick: () => k(null),
713
+ onClick: () => N(null),
714
714
  children: /* @__PURE__ */ o(
715
715
  "div",
716
716
  {
717
717
  className: "flex max-h-[70vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-card",
718
- onClick: (N) => N.stopPropagation(),
718
+ onClick: (k) => k.stopPropagation(),
719
719
  children: [
720
720
  /* @__PURE__ */ o("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
721
721
  /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: m.label }),
@@ -727,38 +727,38 @@ function Al({
727
727
  "button",
728
728
  {
729
729
  type: "button",
730
- onClick: () => k(null),
730
+ onClick: () => N(null),
731
731
  className: "rounded p-1 text-slate-400 hover:text-slate-600",
732
- children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
732
+ children: /* @__PURE__ */ e(Re, { className: "h-4 w-4" })
733
733
  }
734
734
  )
735
735
  ] }),
736
736
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto p-2", children: /* @__PURE__ */ o("table", { className: "w-full text-[11px]", children: [
737
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: Object.keys(m.rows[0] ?? {}).slice(0, 7).map((N) => /* @__PURE__ */ e(
737
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: Object.keys(m.rows[0] ?? {}).slice(0, 7).map((k) => /* @__PURE__ */ e(
738
738
  "th",
739
739
  {
740
740
  className: "border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
741
- children: N
741
+ children: k
742
742
  },
743
- N
743
+ k
744
744
  )) }) }),
745
- /* @__PURE__ */ e("tbody", { children: m.rows.slice(0, 100).map((N, R) => /* @__PURE__ */ e(
745
+ /* @__PURE__ */ e("tbody", { children: m.rows.slice(0, 100).map((k, F) => /* @__PURE__ */ e(
746
746
  "tr",
747
747
  {
748
748
  className: "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60",
749
749
  onClick: () => {
750
- k(null), p(N);
750
+ N(null), p(k);
751
751
  },
752
752
  children: Object.keys(m.rows[0] ?? {}).slice(0, 7).map((Y) => /* @__PURE__ */ e(
753
753
  "td",
754
754
  {
755
755
  className: "max-w-[160px] truncate border-b border-slate-50 px-1.5 py-1 text-slate-600 dark:border-border/40 dark:text-slate-300",
756
- children: String(N[Y] ?? "")
756
+ children: String(k[Y] ?? "")
757
757
  },
758
758
  Y
759
759
  ))
760
760
  },
761
- R
761
+ F
762
762
  )) })
763
763
  ] }) })
764
764
  ]
@@ -767,14 +767,14 @@ function Al({
767
767
  }
768
768
  ) : null;
769
769
  if (t.display === "donut") {
770
- const N = ((ae = Ne[0]) == null ? void 0 : ae.field) ?? "", R = we.map((E) => ({ dim: String(E[xe]), value: Number(E[N]) || 0 })), Y = R.reduce((E, oe) => E + oe.value, 0);
770
+ const k = ((re = Ne[0]) == null ? void 0 : re.field) ?? "", F = ye.map((j) => ({ dim: String(j[be]), value: Number(j[k]) || 0 })), Y = F.reduce((j, de) => j + de.value, 0);
771
771
  return /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
772
772
  /* @__PURE__ */ o("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
773
- /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: E, Pie: oe, PieChart: me, ResponsiveContainer: ge, Tooltip: S }) => /* @__PURE__ */ e(ge, { width: "100%", height: "100%", children: /* @__PURE__ */ o(me, { children: [
773
+ /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: j, Pie: de, PieChart: pe, ResponsiveContainer: ke, Tooltip: w }) => /* @__PURE__ */ e(ke, { width: "100%", height: "100%", children: /* @__PURE__ */ o(pe, { children: [
774
774
  /* @__PURE__ */ e(
775
- oe,
775
+ de,
776
776
  {
777
- data: R,
777
+ data: F,
778
778
  dataKey: "value",
779
779
  nameKey: "dim",
780
780
  innerRadius: "58%",
@@ -782,16 +782,16 @@ function Al({
782
782
  paddingAngle: 2,
783
783
  strokeWidth: 0,
784
784
  className: u ? "cursor-pointer" : void 0,
785
- onClick: (j) => {
786
- var ve;
787
- const he = (ve = j == null ? void 0 : j.payload) == null ? void 0 : ve.dim;
788
- he && te(String(he));
785
+ onClick: (I) => {
786
+ var we;
787
+ const ae = (we = I == null ? void 0 : I.payload) == null ? void 0 : we.dim;
788
+ ae && le(String(ae));
789
789
  },
790
- children: R.map((j, he) => /* @__PURE__ */ e(E, { fill: ce[he % ce.length] }, j.dim))
790
+ children: F.map((I, ae) => /* @__PURE__ */ e(j, { fill: ue[ae % ue.length] }, I.dim))
791
791
  }
792
792
  ),
793
793
  /* @__PURE__ */ e(
794
- S,
794
+ w,
795
795
  {
796
796
  contentStyle: {
797
797
  fontSize: 12,
@@ -802,7 +802,7 @@ function Al({
802
802
  },
803
803
  labelStyle: { color: "#f1f5f9" },
804
804
  itemStyle: { color: "#e2e8f0" },
805
- formatter: (j) => f(j)
805
+ formatter: (I) => f(I)
806
806
  }
807
807
  )
808
808
  ] }) }) }),
@@ -811,35 +811,35 @@ function Al({
811
811
  /* @__PURE__ */ e("span", { className: "text-[9.5px] text-slate-400", children: "total" })
812
812
  ] })
813
813
  ] }),
814
- /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: R.slice(0, 12).map((E, oe) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
814
+ /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: F.slice(0, 12).map((j, de) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
815
815
  /* @__PURE__ */ e(
816
816
  "span",
817
817
  {
818
818
  className: "h-2 w-2 shrink-0 rounded-sm",
819
- style: { background: ce[oe % ce.length] }
819
+ style: { background: ue[de % ue.length] }
820
820
  }
821
821
  ),
822
- /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: E.dim }),
823
- /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: f(E.value) })
824
- ] }, E.dim)) }),
825
- U
822
+ /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: j.dim }),
823
+ /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: f(j.value) })
824
+ ] }, j.dim)) }),
825
+ V
826
826
  ] });
827
827
  }
828
828
  if (t.display === "line" || t.display === "area")
829
829
  return /* @__PURE__ */ o("div", { className: "min-h-[110px] min-w-0 flex-1", children: [
830
- /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Area: N, AreaChart: R, Legend: Y, ResponsiveContainer: E, Tooltip: oe, XAxis: me, YAxis: ge }) => /* @__PURE__ */ e(E, { width: "100%", height: "100%", children: /* @__PURE__ */ o(R, { data: we, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
830
+ /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Area: k, AreaChart: F, Legend: Y, ResponsiveContainer: j, Tooltip: de, XAxis: pe, YAxis: ke }) => /* @__PURE__ */ e(j, { width: "100%", height: "100%", children: /* @__PURE__ */ o(F, { data: ye, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
831
831
  /* @__PURE__ */ e(
832
- me,
832
+ pe,
833
833
  {
834
- dataKey: xe,
834
+ dataKey: be,
835
835
  tick: { fontSize: 10 },
836
836
  stroke: "#94a3b8",
837
- ...Ft(we.length)
837
+ ...Mt(ye.length)
838
838
  }
839
839
  ),
840
- /* @__PURE__ */ e(ge, { tick: { fontSize: 10 }, stroke: "#94a3b8", tickFormatter: $e, width: 48 }),
840
+ /* @__PURE__ */ e(ke, { tick: { fontSize: 10 }, stroke: "#94a3b8", tickFormatter: qe, width: 48 }),
841
841
  /* @__PURE__ */ e(
842
- oe,
842
+ de,
843
843
  {
844
844
  contentStyle: {
845
845
  fontSize: 12,
@@ -850,111 +850,115 @@ function Al({
850
850
  },
851
851
  labelStyle: { color: "#f1f5f9" },
852
852
  itemStyle: { color: "#e2e8f0" },
853
- formatter: (S) => f(S)
853
+ formatter: (w) => f(w)
854
854
  }
855
855
  ),
856
- Ne.length > 1 && /* @__PURE__ */ e(Y, { wrapperStyle: { fontSize: 11 } }),
857
- Ne.map((S, j) => /* @__PURE__ */ e(
858
- N,
856
+ Ne.length > 1 && /* @__PURE__ */ e(Y, { wrapperStyle: { fontSize: 11 }, itemSorter: null }),
857
+ Ne.map((w, I) => /* @__PURE__ */ e(
858
+ k,
859
859
  {
860
860
  type: "monotone",
861
- dataKey: S.field,
862
- name: S.label ?? S.field,
863
- stroke: S.color ?? ce[j % ce.length],
861
+ dataKey: w.field,
862
+ name: w.label ?? w.field,
863
+ stroke: w.color ?? ue[I % ue.length],
864
864
  strokeWidth: 2,
865
- strokeDasharray: S.dash ? "4 3" : void 0,
866
- fill: S.color ?? ce[j % ce.length],
867
- fillOpacity: t.display === "area" && !S.dash ? 0.12 : 0
865
+ strokeDasharray: w.dash ? "4 3" : void 0,
866
+ fill: w.color ?? ue[I % ue.length],
867
+ fillOpacity: t.display === "area" && !w.dash ? 0.12 : 0
868
868
  },
869
- S.field
869
+ w.field
870
870
  ))
871
871
  ] }) }) }),
872
- U
872
+ V
873
873
  ] });
874
- const fe = t.display === "stacked_bar";
875
- return /* @__PURE__ */ o("div", { className: "min-h-[110px] min-w-0 flex-1", children: [
876
- /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: N, BarChart: R, Cell: Y, Legend: E, ResponsiveContainer: oe, Tooltip: me, XAxis: ge, YAxis: S }) => /* @__PURE__ */ e(oe, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
877
- R,
878
- {
879
- data: we,
880
- layout: X ? "vertical" : "horizontal",
881
- margin: { top: 6, right: 8, left: X ? 30 : -6, bottom: 0 },
882
- children: [
883
- X ? /* @__PURE__ */ o(et, { children: [
884
- /* @__PURE__ */ e(
885
- ge,
886
- {
887
- type: "number",
888
- tick: { fontSize: 10 },
889
- stroke: "#94a3b8",
890
- tickFormatter: $e
891
- }
892
- ),
893
- /* @__PURE__ */ e(
894
- S,
895
- {
896
- type: "category",
897
- dataKey: xe,
898
- tick: { fontSize: 10 },
899
- stroke: "#94a3b8",
900
- width: 140,
901
- interval: 0,
902
- tickFormatter: Pl
903
- }
904
- )
905
- ] }) : /* @__PURE__ */ o(et, { children: [
906
- /* @__PURE__ */ e(
907
- ge,
908
- {
909
- dataKey: xe,
910
- tick: { fontSize: 10 },
911
- stroke: "#94a3b8",
912
- ...Ft(we.length)
913
- }
914
- ),
915
- /* @__PURE__ */ e(S, { tick: { fontSize: 10 }, stroke: "#94a3b8", tickFormatter: $e, width: 48 })
916
- ] }),
917
- /* @__PURE__ */ e(
918
- me,
919
- {
920
- contentStyle: {
921
- fontSize: 12,
922
- backgroundColor: "#0f172a",
923
- border: "1px solid #334155",
924
- borderRadius: 8,
925
- color: "#f1f5f9"
926
- },
927
- labelStyle: { color: "#f1f5f9" },
928
- itemStyle: { color: "#e2e8f0" },
929
- formatter: (j) => f(j)
930
- }
931
- ),
932
- Ne.length > 1 && /* @__PURE__ */ e(E, { wrapperStyle: { fontSize: 11 } }),
933
- Ne.map((j, he) => /* @__PURE__ */ e(
934
- N,
935
- {
936
- className: u ? "cursor-pointer" : void 0,
937
- onClick: (ve) => {
938
- var Me;
939
- const Fe = (Me = ve == null ? void 0 : ve.payload) == null ? void 0 : Me[xe];
940
- Fe != null && te(String(Fe));
941
- },
942
- dataKey: j.field,
943
- name: j.label ?? j.field,
944
- stackId: fe ? "stack" : void 0,
945
- fill: j.color ?? ce[he % ce.length],
946
- radius: fe ? 0 : X ? [0, 3, 3, 0] : [3, 3, 0, 0],
947
- children: Ne.length === 1 && !j.color && we.map((ve, Fe) => /* @__PURE__ */ e(Y, { fill: ce[Fe % ce.length] }, Fe))
948
- },
949
- j.field
950
- ))
951
- ]
952
- }
953
- ) }) }),
954
- U
955
- ] });
874
+ const xe = t.display === "stacked_bar";
875
+ return /* @__PURE__ */ e(
876
+ ia,
877
+ {
878
+ labels: X ? ye.map((k) => k[be]) : [],
879
+ className: "min-h-[110px] min-w-0 flex-1 text-slate-500 dark:text-slate-400",
880
+ children: (k) => /* @__PURE__ */ o(We, { children: [
881
+ /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: F, BarChart: Y, Cell: j, Legend: de, ResponsiveContainer: pe, Tooltip: ke, XAxis: w, YAxis: I }) => /* @__PURE__ */ e(pe, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
882
+ Y,
883
+ {
884
+ data: ye,
885
+ layout: X ? "vertical" : "horizontal",
886
+ margin: { top: 6, right: 8, left: X ? 0 : -6, bottom: 0 },
887
+ children: [
888
+ X ? /* @__PURE__ */ o(We, { children: [
889
+ /* @__PURE__ */ e(
890
+ w,
891
+ {
892
+ type: "number",
893
+ tick: { fontSize: 10 },
894
+ stroke: "#94a3b8",
895
+ tickFormatter: qe
896
+ }
897
+ ),
898
+ /* @__PURE__ */ e(I, { type: "category", dataKey: be, stroke: "#94a3b8", ...k })
899
+ ] }) : /* @__PURE__ */ o(We, { children: [
900
+ /* @__PURE__ */ e(
901
+ w,
902
+ {
903
+ dataKey: be,
904
+ tick: { fontSize: 10 },
905
+ stroke: "#94a3b8",
906
+ ...Mt(ye.length)
907
+ }
908
+ ),
909
+ /* @__PURE__ */ e(
910
+ I,
911
+ {
912
+ tick: { fontSize: 10 },
913
+ stroke: "#94a3b8",
914
+ tickFormatter: qe,
915
+ width: 48
916
+ }
917
+ )
918
+ ] }),
919
+ /* @__PURE__ */ e(
920
+ ke,
921
+ {
922
+ contentStyle: {
923
+ fontSize: 12,
924
+ backgroundColor: "#0f172a",
925
+ border: "1px solid #334155",
926
+ borderRadius: 8,
927
+ color: "#f1f5f9"
928
+ },
929
+ labelStyle: { color: "#f1f5f9" },
930
+ itemStyle: { color: "#e2e8f0" },
931
+ formatter: (ae) => f(ae)
932
+ }
933
+ ),
934
+ Ne.length > 1 && /* @__PURE__ */ e(de, { wrapperStyle: { fontSize: 11 }, itemSorter: null }),
935
+ Ne.map((ae, we) => /* @__PURE__ */ e(
936
+ F,
937
+ {
938
+ className: u ? "cursor-pointer" : void 0,
939
+ onClick: (Le) => {
940
+ var Oe;
941
+ const Ce = (Oe = Le == null ? void 0 : Le.payload) == null ? void 0 : Oe[be];
942
+ Ce != null && le(String(Ce));
943
+ },
944
+ dataKey: ae.field,
945
+ name: ae.label ?? ae.field,
946
+ stackId: xe ? "stack" : void 0,
947
+ fill: ae.color ?? ue[we % ue.length],
948
+ radius: xe ? 0 : X ? [0, 3, 3, 0] : [3, 3, 0, 0],
949
+ children: Ne.length === 1 && !ae.color && ye.map((Le, Ce) => /* @__PURE__ */ e(j, { fill: ue[Ce % ue.length] }, Ce))
950
+ },
951
+ ae.field
952
+ ))
953
+ ]
954
+ }
955
+ ) }) }),
956
+ V
957
+ ] })
958
+ }
959
+ );
956
960
  }
957
- const Fl = ["gt", "gte", "lt", "lte", "eq"], va = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, Ml = ["sum", "avg", "max", "min"];
961
+ const Ml = ["gt", "gte", "lt", "lte", "eq"], ya = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, Fl = ["sum", "avg", "max", "min"];
958
962
  function Rl(t) {
959
963
  var s, c, u;
960
964
  const n = [
@@ -983,18 +987,18 @@ function Rl(t) {
983
987
  }
984
988
  return n;
985
989
  }
986
- function Jt(t, n) {
990
+ function Ut(t, n) {
987
991
  var h;
988
992
  const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), s = a ? a[2] : t.field, c = ((h = n.find((g) => g.value === t.field || g.value === s)) == null ? void 0 : h.label) ?? s;
989
- return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${c} ${va[t.op] ?? t.op} ${t.value.toLocaleString()}`;
993
+ return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${c} ${ya[t.op] ?? t.op} ${t.value.toLocaleString()}`;
990
994
  }
991
995
  function Tl({ reportId: t, alert: n }) {
992
- const a = Le(), s = lt(), { data: c = [] } = Se({
996
+ const a = Te(), s = nt(), { data: c = [] } = _e({
993
997
  queryKey: ["nivaro-report-alert-log", t, n.id],
994
- queryFn: () => a.request(Ma(t, n.id)).then((h) => h.data),
998
+ queryFn: () => a.request(Ra(t, n.id)).then((h) => h.data),
995
999
  staleTime: 3e4
996
- }), u = Ae({
997
- mutationFn: () => a.request(Ra(t, n.id)),
1000
+ }), u = Me({
1001
+ mutationFn: () => a.request(Ta(t, n.id)),
998
1002
  onSuccess: () => {
999
1003
  s.invalidateQueries({ queryKey: ["nivaro-report-alert-log", t, n.id] }), s.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] });
1000
1004
  }
@@ -1030,59 +1034,59 @@ function Ll({
1030
1034
  widget: n,
1031
1035
  filterBar: a
1032
1036
  }) {
1033
- const s = Le(), c = lt(), [u, h] = _(!1), [g, p] = _(""), [D, O] = _([
1037
+ const s = Te(), c = nt(), [u, h] = S(!1), [g, p] = S(""), [K, L] = S([
1034
1038
  { field: "value", agg: "sum", op: "gt", value: "" }
1035
- ]), [y, Q] = _([]), [m, k] = _(!1), [Z, F] = _(null), H = Rl(n), { data: z = [] } = Se({
1039
+ ]), [y, Q] = S([]), [m, N] = S(!1), [H, q] = S(null), Z = Rl(n), { data: E = [] } = _e({
1036
1040
  queryKey: ["nivaro-report-alerts", t],
1037
- queryFn: () => s.request($a(t)).then((f) => f.data),
1041
+ queryFn: () => s.request(qa(t)).then((f) => f.data),
1038
1042
  enabled: u,
1039
1043
  staleTime: 3e4
1040
- }), ue = z.filter((f) => f.widget === n.id), J = () => void c.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), W = () => D.filter((f) => f.value.trim() !== "" && !Number.isNaN(Number(f.value))).map((f) => {
1041
- const X = H.find((U) => U.value === f.field);
1044
+ }), me = E.filter((f) => f.widget === n.id), J = () => void c.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), W = () => K.filter((f) => f.value.trim() !== "" && !Number.isNaN(Number(f.value))).map((f) => {
1045
+ const X = Z.find((V) => V.value === f.field);
1042
1046
  return { field: X != null && X.aggregatable && f.agg !== "sum" ? `${f.agg}:${f.field}` : f.field, op: f.op, value: Number(f.value) };
1043
- }), se = Ae({
1047
+ }), ie = Me({
1044
1048
  mutationFn: () => {
1045
- const f = W(), X = f.map((te) => Jt(te, H)).join(" & ");
1049
+ const f = W(), X = f.map((le) => Ut(le, Z)).join(" & ");
1046
1050
  return s.request(
1047
- qa(t, {
1051
+ Aa(t, {
1048
1052
  widget: n.id,
1049
1053
  name: g.trim() || X.slice(0, 120),
1050
1054
  conditions: f,
1051
- filters: y.filter((te) => te.values.length > 0),
1055
+ filters: y.filter((le) => le.values.length > 0),
1052
1056
  delivery_email: m,
1053
1057
  delivery_inapp: !0
1054
1058
  })
1055
1059
  );
1056
1060
  },
1057
1061
  onSuccess: () => {
1058
- p(""), O([{ field: "value", agg: "sum", op: "gt", value: "" }]), Q([]), J();
1062
+ p(""), L([{ field: "value", agg: "sum", op: "gt", value: "" }]), Q([]), J();
1059
1063
  }
1060
- }), xe = Ae({
1061
- mutationFn: (f) => s.request(Aa(t, f.id, !f.is_active)),
1064
+ }), be = Me({
1065
+ mutationFn: (f) => s.request(Ma(t, f.id, !f.is_active)),
1062
1066
  onSuccess: J
1063
- }), Ne = Ae({
1067
+ }), Ne = Me({
1064
1068
  mutationFn: (f) => s.request(Fa(t, f.id)),
1065
1069
  onSuccess: J
1066
- }), we = W().length > 0, $e = ue.some((f) => f.firing);
1067
- return /* @__PURE__ */ o(da, { open: u, onOpenChange: h, children: [
1068
- /* @__PURE__ */ e(ca, { asChild: !0, children: /* @__PURE__ */ e(
1070
+ }), ye = W().length > 0, qe = me.some((f) => f.firing);
1071
+ return /* @__PURE__ */ o(ca, { open: u, onOpenChange: h, children: [
1072
+ /* @__PURE__ */ e(ua, { asChild: !0, children: /* @__PURE__ */ e(
1069
1073
  "button",
1070
1074
  {
1071
1075
  type: "button",
1072
1076
  title: "Alerts on this widget",
1073
1077
  className: P(
1074
1078
  "rounded p-0.5",
1075
- $e ? "text-amber-500" : "text-slate-300 hover:text-amber-500 dark:text-slate-600"
1079
+ qe ? "text-amber-500" : "text-slate-300 hover:text-amber-500 dark:text-slate-600"
1076
1080
  ),
1077
1081
  children: /* @__PURE__ */ e(Zt, { className: "h-3 w-3" })
1078
1082
  }
1079
1083
  ) }),
1080
- /* @__PURE__ */ o(ua, { className: "w-[380px] p-3", align: "end", children: [
1084
+ /* @__PURE__ */ o(ma, { className: "w-[380px] p-3", align: "end", children: [
1081
1085
  /* @__PURE__ */ o("p", { className: "mb-2 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: [
1082
1086
  "Alerts · ",
1083
1087
  n.title
1084
1088
  ] }),
1085
- ue.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 space-y-1.5", children: ue.map((f) => /* @__PURE__ */ o(
1089
+ me.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 space-y-1.5", children: me.map((f) => /* @__PURE__ */ o(
1086
1090
  "div",
1087
1091
  {
1088
1092
  className: "rounded-md border border-slate-100 px-2 py-1.5 dark:border-border/60",
@@ -1103,7 +1107,7 @@ function Ll({
1103
1107
  {
1104
1108
  type: "button",
1105
1109
  className: "text-[10.5px] text-slate-400 hover:text-slate-600",
1106
- onClick: () => F(Z === f.id ? null : f.id),
1110
+ onClick: () => q(H === f.id ? null : f.id),
1107
1111
  children: "History"
1108
1112
  }
1109
1113
  ),
@@ -1112,7 +1116,7 @@ function Ll({
1112
1116
  {
1113
1117
  type: "button",
1114
1118
  className: "text-[10.5px] text-slate-400 hover:text-slate-600",
1115
- onClick: () => xe.mutate(f),
1119
+ onClick: () => be.mutate(f),
1116
1120
  children: f.is_active ? "Pause" : "Resume"
1117
1121
  }
1118
1122
  ),
@@ -1122,19 +1126,19 @@ function Ll({
1122
1126
  type: "button",
1123
1127
  className: "text-slate-300 hover:text-red-500",
1124
1128
  onClick: () => Ne.mutate(f),
1125
- children: /* @__PURE__ */ e(Ea, { className: "h-3 w-3" })
1129
+ children: /* @__PURE__ */ e(ja, { className: "h-3 w-3" })
1126
1130
  }
1127
1131
  )
1128
1132
  ] }),
1129
1133
  /* @__PURE__ */ o("p", { className: "mt-0.5 truncate pl-3 text-[10.5px] text-slate-400", children: [
1130
- (f.conditions ?? []).map((X) => Jt(X, H)).join(" & "),
1134
+ (f.conditions ?? []).map((X) => Ut(X, Z)).join(" & "),
1131
1135
  f.filters && f.filters.length > 0 && ` · scoped: ${f.filters.map((X) => (X.labels ?? X.values).join("/")).join(", ")}`,
1132
1136
  " · ",
1133
1137
  f.delivery_email ? "In-app + Email" : "In-app",
1134
1138
  " · Last fired: ",
1135
1139
  f.last_fired ? new Date(f.last_fired).toLocaleString() : "Never"
1136
1140
  ] }),
1137
- Z === f.id && /* @__PURE__ */ e(Tl, { reportId: t, alert: f })
1141
+ H === f.id && /* @__PURE__ */ e(Tl, { reportId: t, alert: f })
1138
1142
  ]
1139
1143
  },
1140
1144
  f.id
@@ -1149,27 +1153,27 @@ function Ll({
1149
1153
  className: "h-7 w-full rounded-md border border-slate-200 bg-white px-2 text-[11.5px] dark:border-border dark:bg-card"
1150
1154
  }
1151
1155
  ),
1152
- D.map((f, X) => {
1153
- const te = H.find((U) => U.value === f.field);
1156
+ K.map((f, X) => {
1157
+ const le = Z.find((V) => V.value === f.field);
1154
1158
  return /* @__PURE__ */ o("div", { className: "flex items-center gap-1", children: [
1155
1159
  /* @__PURE__ */ e(
1156
1160
  $t,
1157
1161
  {
1158
1162
  value: f.field,
1159
- onChange: (U) => O((fe) => fe.map((re, ae) => ae === X ? { ...re, field: U } : re)),
1160
- options: H.map((U) => ({ value: U.value, label: U.label })),
1163
+ onChange: (V) => L((xe) => xe.map((se, re) => re === X ? { ...se, field: V } : se)),
1164
+ options: Z.map((V) => ({ value: V.value, label: V.label })),
1161
1165
  ariaLabel: "Alert metric field",
1162
1166
  className: "h-7 min-w-0 flex-1 rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1163
1167
  }
1164
1168
  ),
1165
- (te == null ? void 0 : te.aggregatable) && /* @__PURE__ */ e(
1169
+ (le == null ? void 0 : le.aggregatable) && /* @__PURE__ */ e(
1166
1170
  $t,
1167
1171
  {
1168
1172
  value: f.agg,
1169
- onChange: (U) => O(
1170
- (fe) => fe.map((re, ae) => ae === X ? { ...re, agg: U } : re)
1173
+ onChange: (V) => L(
1174
+ (xe) => xe.map((se, re) => re === X ? { ...se, agg: V } : se)
1171
1175
  ),
1172
- options: Ml.map((U) => ({ value: U, label: U })),
1176
+ options: Fl.map((V) => ({ value: V, label: V })),
1173
1177
  ariaLabel: "Aggregate",
1174
1178
  className: "h-7 w-[62px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1175
1179
  }
@@ -1178,10 +1182,10 @@ function Ll({
1178
1182
  $t,
1179
1183
  {
1180
1184
  value: f.op,
1181
- onChange: (U) => O(
1182
- (fe) => fe.map((re, ae) => ae === X ? { ...re, op: U } : re)
1185
+ onChange: (V) => L(
1186
+ (xe) => xe.map((se, re) => re === X ? { ...se, op: V } : se)
1183
1187
  ),
1184
- options: Fl.map((U) => ({ value: U, label: va[U] })),
1188
+ options: Ml.map((V) => ({ value: V, label: ya[V] })),
1185
1189
  ariaLabel: "Operator",
1186
1190
  className: "h-7 w-[52px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1187
1191
  }
@@ -1190,21 +1194,21 @@ function Ll({
1190
1194
  "input",
1191
1195
  {
1192
1196
  value: f.value,
1193
- onChange: (U) => O(
1194
- (fe) => fe.map((re, ae) => ae === X ? { ...re, value: U.target.value } : re)
1197
+ onChange: (V) => L(
1198
+ (xe) => xe.map((se, re) => re === X ? { ...se, value: V.target.value } : se)
1195
1199
  ),
1196
1200
  placeholder: "0",
1197
1201
  inputMode: "decimal",
1198
1202
  className: "h-7 w-[64px] rounded-md border border-slate-200 bg-white px-2 text-right text-[11.5px] tabular-nums dark:border-border dark:bg-card"
1199
1203
  }
1200
1204
  ),
1201
- D.length > 1 && /* @__PURE__ */ e(
1205
+ K.length > 1 && /* @__PURE__ */ e(
1202
1206
  "button",
1203
1207
  {
1204
1208
  type: "button",
1205
1209
  className: "text-slate-300 hover:text-red-500",
1206
- onClick: () => O((U) => U.filter((fe, re) => re !== X)),
1207
- children: /* @__PURE__ */ e(Te, { className: "h-3 w-3" })
1210
+ onClick: () => L((V) => V.filter((xe, se) => se !== X)),
1211
+ children: /* @__PURE__ */ e(Re, { className: "h-3 w-3" })
1208
1212
  }
1209
1213
  )
1210
1214
  ] }, X);
@@ -1214,7 +1218,7 @@ function Ll({
1214
1218
  {
1215
1219
  type: "button",
1216
1220
  className: "text-[10.5px] text-slate-400 hover:text-nvr-navy dark:hover:text-nvr-cyan",
1217
- onClick: () => O((f) => [...f, { field: "value", agg: "sum", op: "gt", value: "" }]),
1221
+ onClick: () => L((f) => [...f, { field: "value", agg: "sum", op: "gt", value: "" }]),
1218
1222
  children: "+ condition (all must match)"
1219
1223
  }
1220
1224
  ),
@@ -1223,16 +1227,16 @@ function Ll({
1223
1227
  /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1", children: a.map((f) => {
1224
1228
  var X;
1225
1229
  return /* @__PURE__ */ e(
1226
- ma,
1230
+ pa,
1227
1231
  {
1228
1232
  reportId: t,
1229
1233
  field: f.field,
1230
1234
  label: f.label,
1231
1235
  optionSource: f.options,
1232
- selected: ((X = y.find((te) => te.field === f.field)) == null ? void 0 : X.values) ?? [],
1233
- onChange: (te, U) => Q((fe) => [
1234
- ...fe.filter((re) => re.field !== f.field),
1235
- ...te.length > 0 ? [{ field: f.field, values: te, labels: U }] : []
1236
+ selected: ((X = y.find((le) => le.field === f.field)) == null ? void 0 : X.values) ?? [],
1237
+ onChange: (le, V) => Q((xe) => [
1238
+ ...xe.filter((se) => se.field !== f.field),
1239
+ ...le.length > 0 ? [{ field: f.field, values: le, labels: V }] : []
1236
1240
  ])
1237
1241
  },
1238
1242
  f.field
@@ -1246,7 +1250,7 @@ function Ll({
1246
1250
  {
1247
1251
  type: "checkbox",
1248
1252
  checked: m,
1249
- onChange: (f) => k(f.target.checked),
1253
+ onChange: (f) => N(f.target.checked),
1250
1254
  className: "h-3 w-3 accent-nvr-cyan"
1251
1255
  }
1252
1256
  ),
@@ -1256,8 +1260,8 @@ function Ll({
1256
1260
  "button",
1257
1261
  {
1258
1262
  type: "button",
1259
- disabled: !we || se.isPending,
1260
- onClick: () => se.mutate(),
1263
+ disabled: !ye || ie.isPending,
1264
+ onClick: () => ie.mutate(),
1261
1265
  className: "inline-flex h-7 items-center gap-1 rounded-md bg-nvr-cyan px-2 text-[11.5px] font-semibold text-white disabled:opacity-50",
1262
1266
  children: [
1263
1267
  /* @__PURE__ */ e(Xt, { className: "h-3 w-3" }),
@@ -1284,17 +1288,17 @@ const Ol = {
1284
1288
  nnull: "_nnull"
1285
1289
  };
1286
1290
  function Tt(t, n, a, s) {
1287
- var D, O;
1291
+ var K, L;
1288
1292
  const c = t.config ?? {}, u = [];
1289
1293
  for (const y of c.filters ?? []) {
1290
1294
  const Q = Ol[y.op];
1291
1295
  if (!Q) continue;
1292
1296
  let m = y.value;
1293
- y.op === "in" && typeof m == "string" && (m = m.split(",").map((k) => k.trim())), u.push({ path: [y.field], op: Q, value: m });
1297
+ y.op === "in" && typeof m == "string" && (m = m.split(",").map((N) => N.trim())), u.push({ path: [y.field], op: Q, value: m });
1294
1298
  }
1295
1299
  for (const y of n)
1296
- (D = y.values) != null && D.length && u.push({ path: [y.field], op: "_in", value: y.values });
1297
- const h = c.date_field || ((O = c.dimension) != null && O.bucket ? c.dimension.field : null), g = pa(a);
1300
+ (K = y.values) != null && K.length && u.push({ path: [y.field], op: "_in", value: y.values });
1301
+ const h = c.date_field || ((L = c.dimension) != null && L.bucket ? c.dimension.field : null), g = ha(a);
1298
1302
  g && h && (u.push({ path: [h], op: "_gte", value: g.start }), u.push({ path: [h], op: "_lte", value: `${g.end}T23:59:59` }));
1299
1303
  const p = c.dimension;
1300
1304
  if (s !== void 0 && (p != null && p.field))
@@ -1303,17 +1307,17 @@ function Tt(t, n, a, s) {
1303
1307
  if (/^\d{4}-\d{2}-\d{2}$/.test(y))
1304
1308
  u.push({ path: [p.field], op: "_gte", value: y }), u.push({ path: [p.field], op: "_lte", value: `${y}T23:59:59` });
1305
1309
  else if (/^\d{4}-\d{2}$/.test(y)) {
1306
- const [Q, m] = y.split("-").map(Number), k = new Date(Q, m, 0).getDate();
1310
+ const [Q, m] = y.split("-").map(Number), N = new Date(Q, m, 0).getDate();
1307
1311
  u.push({ path: [p.field], op: "_gte", value: `${y}-01` }), u.push({
1308
1312
  path: [p.field],
1309
1313
  op: "_lte",
1310
- value: `${y}-${String(k).padStart(2, "0")}T23:59:59`
1314
+ value: `${y}-${String(N).padStart(2, "0")}T23:59:59`
1311
1315
  });
1312
1316
  }
1313
1317
  } else s === null ? u.push({ path: [p.field], op: "_null", value: !0 }) : u.push({ path: [p.field], op: "_eq", value: s });
1314
1318
  return u;
1315
1319
  }
1316
- function Ut(t) {
1320
+ function Jt(t) {
1317
1321
  const n = t.config ?? {}, a = [], s = n.query;
1318
1322
  if (t.type === "query" && (s != null && s.slug))
1319
1323
  a.push(`Custom query: ${s.slug}`);
@@ -1334,10 +1338,10 @@ function Kl(t) {
1334
1338
  var n, a;
1335
1339
  return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((s, c) => s + (Number(c.value) || 0), 0) : (n = t.tiles) != null && n.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1336
1340
  }
1337
- function Yt(t, n, a) {
1338
- var O, y, Q;
1341
+ function Vt(t, n, a) {
1342
+ var L, y, Q;
1339
1343
  const s = a ? [...a] : [];
1340
- if (s.length === 0 && ((O = n == null ? void 0 : n.rows) != null && O.length) && s.push(...n.rows), s.length === 0 && ((y = n == null ? void 0 : n.series) != null && y.length))
1344
+ if (s.length === 0 && ((L = n == null ? void 0 : n.rows) != null && L.length) && s.push(...n.rows), s.length === 0 && ((y = n == null ? void 0 : n.series) != null && y.length))
1341
1345
  for (const m of n.series)
1342
1346
  s.push({
1343
1347
  dim: m.dim,
@@ -1354,15 +1358,15 @@ function Yt(t, n, a) {
1354
1358
  return;
1355
1359
  }
1356
1360
  const c = [...new Set(s.flatMap((m) => Object.keys(m)))], u = (m) => {
1357
- const k = String(m ?? "");
1358
- return /[",\n]/.test(k) ? `"${k.replace(/"/g, '""')}"` : k;
1359
- }, h = [c.join(","), ...s.map((m) => c.map((k) => u(m[k])).join(","))].join(
1361
+ const N = String(m ?? "");
1362
+ return /[",\n]/.test(N) ? `"${N.replace(/"/g, '""')}"` : N;
1363
+ }, h = [c.join(","), ...s.map((m) => c.map((N) => u(m[N])).join(","))].join(
1360
1364
  `
1361
1365
  `
1362
1366
  ), g = new Blob([h], { type: "text/csv;charset=utf-8" }), p = document.createElement("a");
1363
1367
  p.href = URL.createObjectURL(g), p.download = `${(t.title || "widget").replace(/[^\w-]+/g, "_")}.csv`, p.click();
1364
- const D = p.href;
1365
- setTimeout(() => URL.revokeObjectURL(D), 1e4);
1368
+ const K = p.href;
1369
+ setTimeout(() => URL.revokeObjectURL(K), 1e4);
1366
1370
  }
1367
1371
  function Dl({
1368
1372
  collection: t,
@@ -1372,14 +1376,14 @@ function Dl({
1372
1376
  onOpen: c,
1373
1377
  crossFilter: u
1374
1378
  }) {
1375
- const h = Le(), { data: g, isLoading: p } = Se({
1379
+ const h = Te(), { data: g, isLoading: p } = _e({
1376
1380
  queryKey: ["nvr-report-drill", t, JSON.stringify(n)],
1377
1381
  queryFn: () => h.request(
1378
1382
  bt(`/items/${t}`, { limit: 50, conditions: JSON.stringify(n) })
1379
1383
  ),
1380
1384
  staleTime: 3e4,
1381
1385
  retry: !1
1382
- }), D = (g == null ? void 0 : g.data) ?? [], O = (y) => {
1386
+ }), K = (g == null ? void 0 : g.data) ?? [], L = (y) => {
1383
1387
  for (const m of [
1384
1388
  "title",
1385
1389
  "name",
@@ -1389,11 +1393,11 @@ function Dl({
1389
1393
  "project_id",
1390
1394
  "description"
1391
1395
  ]) {
1392
- const k = y[m];
1393
- if (typeof k == "string" && k.trim()) return k.slice(0, 90);
1396
+ const N = y[m];
1397
+ if (typeof N == "string" && N.trim()) return N.slice(0, 90);
1394
1398
  }
1395
1399
  const Q = Object.entries(y).find(
1396
- ([m, k]) => m !== "id" && typeof k == "string" && k.trim()
1400
+ ([m, N]) => m !== "id" && typeof N == "string" && N.trim()
1397
1401
  );
1398
1402
  return Q ? String(Q[1]).slice(0, 90) : `#${y.id}`;
1399
1403
  };
@@ -1410,7 +1414,7 @@ function Dl({
1410
1414
  children: [
1411
1415
  /* @__PURE__ */ o("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
1412
1416
  /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: a }),
1413
- /* @__PURE__ */ e("span", { className: "text-[11.5px] tabular-nums text-slate-400", children: g ? `${D.length}${(g.total ?? 0) > D.length ? ` of ${g.total.toLocaleString()}` : ""} records` : "" }),
1417
+ /* @__PURE__ */ e("span", { className: "text-[11.5px] tabular-nums text-slate-400", children: g ? `${K.length}${(g.total ?? 0) > K.length ? ` of ${g.total.toLocaleString()}` : ""} records` : "" }),
1414
1418
  u && /* @__PURE__ */ e(
1415
1419
  "button",
1416
1420
  {
@@ -1427,20 +1431,20 @@ function Dl({
1427
1431
  type: "button",
1428
1432
  onClick: s,
1429
1433
  className: "rounded p-1 text-slate-400 hover:text-slate-600",
1430
- children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
1434
+ children: /* @__PURE__ */ e(Re, { className: "h-4 w-4" })
1431
1435
  }
1432
1436
  )
1433
1437
  ] }),
1434
1438
  /* @__PURE__ */ o("div", { className: "min-h-0 flex-1 overflow-y-auto p-1.5", children: [
1435
1439
  p && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "Loading…" }),
1436
- !p && D.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "No records match." }),
1437
- D.map((y) => /* @__PURE__ */ e(
1440
+ !p && K.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "No records match." }),
1441
+ K.map((y) => /* @__PURE__ */ e(
1438
1442
  "button",
1439
1443
  {
1440
1444
  type: "button",
1441
1445
  onClick: () => c({ collection: t, itemId: String(y.id) }),
1442
1446
  className: "block w-full truncate rounded-md px-2.5 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-slate-50 dark:text-slate-200 dark:hover:bg-muted",
1443
- children: O(y)
1447
+ children: L(y)
1444
1448
  },
1445
1449
  String(y.id)
1446
1450
  ))
@@ -1451,7 +1455,7 @@ function Dl({
1451
1455
  }
1452
1456
  );
1453
1457
  }
1454
- const Vt = {
1458
+ const Yt = {
1455
1459
  red: {
1456
1460
  cell: "bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300",
1457
1461
  row: "bg-red-50/70 dark:bg-red-500/10"
@@ -1482,56 +1486,56 @@ const Dt = Wa(function({
1482
1486
  filterBar: h = [],
1483
1487
  onDrill: g,
1484
1488
  snapshot: p,
1485
- asOf: D,
1486
- annotations: O,
1489
+ asOf: K,
1490
+ annotations: L,
1487
1491
  onAddAnnotation: y,
1488
1492
  onDeleteAnnotation: Q,
1489
1493
  onCrossFilter: m,
1490
- reportUrl: k,
1491
- currentFilters: Z
1494
+ reportUrl: N,
1495
+ currentFilters: H
1492
1496
  }) {
1493
- var yt, Je, kt, Ue, Nt, wt, dt, St, Ye, ct, Ve, ut, mt, pt, ne, _t, Ge, He, ht, ft;
1494
- const F = Le(), [H, z] = _(""), [ue, J] = _(0), [W, se] = _(null), [xe, Ne] = _(!1), [we, $e] = _(""), [f, X] = _(""), [te, U] = _(!1), [fe, re] = _(!1), [ae, N] = _([]), R = Ie(null), Y = Ie(null), E = Cl(R), [oe, me] = _(!1), [ge, S] = _(null), [j, he] = _(!1), [ve, Fe] = _(null), Me = ["bar", "line", "donut", "pareto", "area"].includes(a.type) || a.type === "kpi" && !!((yt = a.config) != null && yt.compare || (Je = a.config) != null && Je.sparkline), rt = lt(), [be, Ee] = _(!1), _e = async () => {
1495
- Ee(!0);
1497
+ var yt, Ye, kt, Ge, Nt, wt, ct, St, He, ut, Xe, mt, pt, ht, oe, _t, Ze, Ie, ft, xt;
1498
+ const q = Te(), [Z, E] = S(""), [me, J] = S(0), [W, ie] = S(null), [be, Ne] = S(!1), [ye, qe] = S(""), [f, X] = S(""), [le, V] = S(!1), [xe, se] = S(!1), [re, k] = S([]), F = at(null), Y = at(null), j = Cl(F), [de, pe] = S(!1), [ke, w] = S(null), [I, ae] = S(!1), [we, Le] = S(null), Ce = ["bar", "line", "donut", "pareto", "area"].includes(a.type) || a.type === "kpi" && !!((yt = a.config) != null && yt.compare || (Ye = a.config) != null && Ye.sparkline), Oe = nt(), [ge, Be] = S(!1), Se = async () => {
1499
+ Be(!0);
1496
1500
  try {
1497
- const l = await F.request(
1501
+ const l = await q.request(
1498
1502
  Ct(n, a.id, {
1499
1503
  date_range: s,
1500
1504
  entity_filters: c,
1501
1505
  fresh: 1
1502
1506
  })
1503
1507
  );
1504
- rt.setQueryData(
1508
+ Oe.setQueryData(
1505
1509
  ["nivaro-report-widget", n, a.id, s, c],
1506
1510
  l.data
1507
1511
  );
1508
1512
  } catch {
1509
1513
  }
1510
- Ee(!1);
1511
- }, Re = tt(
1514
+ Be(!1);
1515
+ }, Fe = lt(
1512
1516
  () => ({ date_range: s ?? null, entity_filters: c }),
1513
1517
  [s, c]
1514
- ), nt = Xa({
1518
+ ), st = Xa({
1515
1519
  kind: "report",
1516
1520
  widget: a.id,
1517
1521
  report: n,
1518
- params: Re,
1519
- enabled: E && a.type !== "divider" && a.type !== "query",
1520
- onData: (l) => rt.setQueryData(
1522
+ params: Fe,
1523
+ enabled: j && a.type !== "divider" && a.type !== "query",
1524
+ onData: (l) => Oe.setQueryData(
1521
1525
  ["nivaro-report-widget", n, a.id, s, c],
1522
1526
  l
1523
1527
  ),
1524
- onStale: () => void ot()
1528
+ onStale: () => void it()
1525
1529
  }), {
1526
- data: je,
1527
- isLoading: st,
1528
- error: We,
1529
- refetch: ot,
1530
- isFetching: Mt,
1531
- dataUpdatedAt: Oe
1532
- } = Se({
1530
+ data: Qe,
1531
+ isLoading: ot,
1532
+ error: Ue,
1533
+ refetch: it,
1534
+ isFetching: Ft,
1535
+ dataUpdatedAt: Ke
1536
+ } = _e({
1533
1537
  queryKey: ["nivaro-report-widget", n, a.id, s, c],
1534
- queryFn: () => F.request(
1538
+ queryFn: () => q.request(
1535
1539
  Ct(n, a.id, {
1536
1540
  date_range: s,
1537
1541
  entity_filters: c
@@ -1540,60 +1544,60 @@ const Dt = Wa(function({
1540
1544
  // Query widgets resolve client-side in QueryWidgetBody — but when a
1541
1545
  // snapshot comparison is active, the server-resolved value (the same
1542
1546
  // number the snapshot stored) is fetched so the delta badge can render.
1543
- enabled: E && a.type !== "divider" && (a.type !== "query" || !!p),
1547
+ enabled: j && a.type !== "divider" && (a.type !== "query" || !!p),
1544
1548
  staleTime: 6e4,
1545
1549
  // Per-widget auto-refresh (#168) overrides the report-level interval.
1546
1550
  refetchInterval: Za(
1547
- nt,
1551
+ st,
1548
1552
  Number((kt = a.config) == null ? void 0 : kt.refresh_secs) >= 10 ? Number(a.config.refresh_secs) * 1e3 : u
1549
1553
  ),
1550
1554
  retry: !1
1551
- }), Be = (((Ue = a.config) == null ? void 0 : Ue.drill_levels) ?? []).filter(
1555
+ }), Je = (((Ge = a.config) == null ? void 0 : Ge.drill_levels) ?? []).filter(
1552
1556
  (l) => typeof l == "string" && l
1553
- ), { data: vt } = Se({
1554
- queryKey: ["nvr-report-drill", n, a.id, ae, s, c],
1555
- queryFn: () => F.request(
1557
+ ), { data: vt } = _e({
1558
+ queryKey: ["nvr-report-drill", n, a.id, re, s, c],
1559
+ queryFn: () => q.request(
1556
1560
  Ct(n, a.id, {
1557
1561
  date_range: s,
1558
1562
  entity_filters: [
1559
1563
  ...c,
1560
- ...ae.map((l) => ({ field: l.field, values: [l.value] }))
1564
+ ...re.map((l) => ({ field: l.field, values: [l.value] }))
1561
1565
  ],
1562
- dimension_override: Be[ae.length - 1]
1566
+ dimension_override: Je[re.length - 1]
1563
1567
  })
1564
1568
  ).then((l) => l.data),
1565
- enabled: ae.length > 0 && Be.length > 0,
1569
+ enabled: re.length > 0 && Je.length > 0,
1566
1570
  staleTime: 6e4,
1567
1571
  retry: !1
1568
- }), T = ae.length > 0 && vt ? vt : je, ie = (Nt = a.config) == null ? void 0 : Nt.format, it = {
1572
+ }), R = re.length > 0 && vt ? vt : Qe, ce = (Nt = a.config) == null ? void 0 : Nt.format, dt = {
1569
1573
  gridColumn: `${Math.max(1, (a.x ?? 0) + 1)} / span ${Math.min(12, Math.max(2, a.w || 4))}`,
1570
1574
  gridRow: `span ${Math.max(1, a.h || 3)}`
1571
1575
  };
1572
1576
  if (a.type === "divider")
1573
- return /* @__PURE__ */ e("div", { style: it, className: "self-end border-b border-slate-200 pb-1 dark:border-border", children: /* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: a.title }) });
1574
- const Qe = a.type === "query" ? (wt = a.config) == null ? void 0 : wt.query : null, ye = Qe ? {
1575
- ...Qe,
1576
- slug: Qe.slug || Qe.query_slug || ""
1577
+ return /* @__PURE__ */ e("div", { style: dt, className: "self-end border-b border-slate-200 pb-1 dark:border-border", children: /* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: a.title }) });
1578
+ const Ve = a.type === "query" ? (wt = a.config) == null ? void 0 : wt.query : null, ve = Ve ? {
1579
+ ...Ve,
1580
+ slug: Ve.slug || Ve.query_slug || ""
1577
1581
  } : null;
1578
- let V = null;
1579
- if (ye != null && ye.slug)
1580
- V = /* @__PURE__ */ e(
1582
+ let G = null;
1583
+ if (ve != null && ve.slug)
1584
+ G = /* @__PURE__ */ e(
1581
1585
  Al,
1582
1586
  {
1583
- cfg: ye,
1587
+ cfg: ve,
1584
1588
  dateRange: s,
1585
1589
  entityFilters: c,
1586
1590
  refetchInterval: u,
1587
1591
  onDrill: g,
1588
- deferred: !E
1592
+ deferred: !j
1589
1593
  }
1590
1594
  );
1591
1595
  else if (a.type === "query")
1592
- V = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No query configured." });
1593
- else if (!E && T === void 0)
1594
- V = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
1595
- else if (st)
1596
- V = /* @__PURE__ */ o("div", { className: "flex flex-col gap-2 px-1", children: [
1596
+ G = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No query configured." });
1597
+ else if (!j && R === void 0)
1598
+ G = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
1599
+ else if (ot)
1600
+ G = /* @__PURE__ */ o("div", { className: "flex flex-col gap-2 px-1", children: [
1597
1601
  /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
1598
1602
  /* @__PURE__ */ e(
1599
1603
  oa,
@@ -1610,39 +1614,39 @@ const Dt = Wa(function({
1610
1614
  }
1611
1615
  )
1612
1616
  ] });
1613
- else if (We)
1614
- V = /* @__PURE__ */ e(
1615
- ia,
1617
+ else if (Ue)
1618
+ G = /* @__PURE__ */ e(
1619
+ da,
1616
1620
  {
1617
1621
  className: "px-1",
1618
- message: ra(We) ?? Ot(We, "this widget"),
1619
- onRetry: () => void ot()
1622
+ message: ra(Ue) ?? Ot(Ue, "this widget"),
1623
+ onRetry: () => void it()
1620
1624
  }
1621
1625
  );
1622
- else if (T)
1626
+ else if (R)
1623
1627
  if (a.type === "queue") {
1624
- const l = T.series ?? [], i = Math.max(...l.map((L) => L.value), 1), b = Math.min(...l.map((L) => L.value), 0), C = Math.max(i - b, 1), $ = l.map(
1625
- (L, le) => `${le / Math.max(1, l.length - 1) * 100},${28 - (L.value - b) / C * 26}`
1628
+ const l = R.series ?? [], i = Math.max(...l.map((T) => T.value), 1), b = Math.min(...l.map((T) => T.value), 0), _ = Math.max(i - b, 1), $ = l.map(
1629
+ (T, ne) => `${ne / Math.max(1, l.length - 1) * 100},${28 - (T.value - b) / _ * 26}`
1626
1630
  ).join(" ");
1627
- V = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1628
- /* @__PURE__ */ e("p", { className: "text-[28px] font-semibold leading-none tracking-tight tabular-nums text-slate-900 dark:text-foreground", children: T.value == null ? "—" : Number(T.value).toLocaleString() }),
1631
+ G = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1632
+ /* @__PURE__ */ e("p", { className: "text-[28px] font-semibold leading-none tracking-tight tabular-nums text-slate-900 dark:text-foreground", children: R.value == null ? "—" : Number(R.value).toLocaleString() }),
1629
1633
  l.length >= 3 && /* @__PURE__ */ e("svg", { viewBox: "0 0 100 30", preserveAspectRatio: "none", className: "mt-1.5 h-7 w-full", children: /* @__PURE__ */ e(
1630
1634
  "polyline",
1631
1635
  {
1632
1636
  points: $,
1633
1637
  fill: "none",
1634
- stroke: Xe,
1638
+ stroke: et,
1635
1639
  strokeWidth: "2",
1636
1640
  vectorEffect: "non-scaling-stroke"
1637
1641
  }
1638
1642
  ) }),
1639
1643
  /* @__PURE__ */ o("p", { className: "mt-0.5 text-[10.5px] text-slate-400", children: [
1640
- ((dt = a.config) == null ? void 0 : dt.metric) ?? "total",
1644
+ ((ct = a.config) == null ? void 0 : ct.metric) ?? "total",
1641
1645
  " · daily snapshots"
1642
1646
  ] })
1643
1647
  ] });
1644
1648
  } else if (a.type === "kpi" || a.type === "calc") {
1645
- if (V = /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2", children: [
1649
+ if (G = /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2", children: [
1646
1650
  /* @__PURE__ */ e(
1647
1651
  "p",
1648
1652
  {
@@ -1653,32 +1657,32 @@ const Dt = Wa(function({
1653
1657
  (() => {
1654
1658
  var b;
1655
1659
  const l = (b = a.config) == null ? void 0 : b.thresholds;
1656
- if (!(l != null && l.length) || T.value == null) return null;
1657
- const i = [...l].filter((C) => Number.isFinite(C.gte)).sort((C, $) => $.gte - C.gte).find((C) => T.value >= C.gte);
1660
+ if (!(l != null && l.length) || R.value == null) return null;
1661
+ const i = [...l].filter((_) => Number.isFinite(_.gte)).sort((_, $) => $.gte - _.gte).find((_) => R.value >= _.gte);
1658
1662
  return (i == null ? void 0 : i.color) === "red" ? "!text-red-600 dark:!text-red-400" : (i == null ? void 0 : i.color) === "amber" ? "!text-amber-600 dark:!text-amber-400" : (i == null ? void 0 : i.color) === "green" ? "!text-emerald-600 dark:!text-emerald-400" : null;
1659
1663
  })()
1660
1664
  ),
1661
1665
  title: a.collection ? "See the records behind this number" : void 0,
1662
1666
  onClick: () => {
1663
- a.collection && se({
1667
+ a.collection && ie({
1664
1668
  conditions: Tt(a, c, s),
1665
1669
  title: a.title || a.collection
1666
1670
  });
1667
1671
  },
1668
- children: qe(T.value, ie)
1672
+ children: Ae(R.value, ce)
1669
1673
  }
1670
1674
  ),
1671
- /* @__PURE__ */ e(Qt, { pct: T.change_pct })
1672
- ] }), T.spark && T.spark.length >= 3) {
1673
- const l = T.spark, i = Math.max(...l.map((L) => L.value), 1), b = Math.min(...l.map((L) => L.value), 0), C = Math.max(i - b, 1), $ = l.map((L, le) => `${le / (l.length - 1) * 100},${28 - (L.value - b) / C * 26}`).join(" ");
1674
- V = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1675
- V,
1675
+ /* @__PURE__ */ e(Qt, { pct: R.change_pct })
1676
+ ] }), R.spark && R.spark.length >= 3) {
1677
+ const l = R.spark, i = Math.max(...l.map((T) => T.value), 1), b = Math.min(...l.map((T) => T.value), 0), _ = Math.max(i - b, 1), $ = l.map((T, ne) => `${ne / (l.length - 1) * 100},${28 - (T.value - b) / _ * 26}`).join(" ");
1678
+ G = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1679
+ G,
1676
1680
  /* @__PURE__ */ e("svg", { viewBox: "0 0 100 30", preserveAspectRatio: "none", className: "mt-1.5 h-7 w-full", children: /* @__PURE__ */ e(
1677
1681
  "polyline",
1678
1682
  {
1679
1683
  points: $,
1680
1684
  fill: "none",
1681
- stroke: Xe,
1685
+ stroke: et,
1682
1686
  strokeWidth: "2",
1683
1687
  vectorEffect: "non-scaling-stroke"
1684
1688
  }
@@ -1686,8 +1690,8 @@ const Dt = Wa(function({
1686
1690
  ] });
1687
1691
  }
1688
1692
  } else if (a.type === "kpi_group") {
1689
- const l = T.tiles ?? [];
1690
- V = /* @__PURE__ */ e(
1693
+ const l = R.tiles ?? [];
1694
+ G = /* @__PURE__ */ e(
1691
1695
  "div",
1692
1696
  {
1693
1697
  className: "grid gap-2",
@@ -1697,13 +1701,13 @@ const Dt = Wa(function({
1697
1701
  {
1698
1702
  className: "flex flex-col justify-center rounded-md border border-slate-100 px-3 py-2 dark:border-border/60",
1699
1703
  style: {
1700
- borderTopColor: i.color ?? ce[b % ce.length],
1704
+ borderTopColor: i.color ?? ue[b % ue.length],
1701
1705
  borderTopWidth: 2
1702
1706
  },
1703
1707
  children: [
1704
1708
  /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: i.label }),
1705
1709
  /* @__PURE__ */ o("div", { className: "flex items-baseline gap-1.5", children: [
1706
- /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: qe(i.value, i.format) }),
1710
+ /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: Ae(i.value, i.format) }),
1707
1711
  /* @__PURE__ */ e(Qt, { pct: i.change_pct })
1708
1712
  ] })
1709
1713
  ]
@@ -1713,46 +1717,46 @@ const Dt = Wa(function({
1713
1717
  }
1714
1718
  );
1715
1719
  } else if (a.type === "narrative")
1716
- V = /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: (T.narrative ?? "").split(/(\*\*[^*]+\*\*)/g).map(
1720
+ G = /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: (R.narrative ?? "").split(/(\*\*[^*]+\*\*)/g).map(
1717
1721
  (l, i) => l.startsWith("**") && l.endsWith("**") ? /* @__PURE__ */ e("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: l.slice(2, -2) }, i) : /* @__PURE__ */ e("span", { children: l }, i)
1718
1722
  ) });
1719
1723
  else if (a.type === "heatmap") {
1720
- const l = T.cells ?? [], i = [...new Set(l.map((L) => L.dim))], b = [...new Set(l.map((L) => L.dim2))], C = Math.max(1, ...l.map((L) => L.value)), $ = (L, le) => l.find((I) => I.dim === L && I.dim2 === le);
1721
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[10.5px]", children: [
1724
+ const l = R.cells ?? [], i = [...new Set(l.map((T) => T.dim))], b = [...new Set(l.map((T) => T.dim2))], _ = Math.max(1, ...l.map((T) => T.value)), $ = (T, ne) => l.find((ee) => ee.dim === T && ee.dim2 === ne);
1725
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[10.5px]", children: [
1722
1726
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ o("tr", { children: [
1723
1727
  /* @__PURE__ */ e("th", {}),
1724
- b.map((L) => /* @__PURE__ */ e(
1728
+ b.map((T) => /* @__PURE__ */ e(
1725
1729
  "th",
1726
1730
  {
1727
1731
  className: "max-w-[80px] truncate px-1 pb-1 text-left font-medium text-slate-400",
1728
- children: L
1732
+ children: T
1729
1733
  },
1730
- L
1734
+ T
1731
1735
  ))
1732
1736
  ] }) }),
1733
- /* @__PURE__ */ e("tbody", { children: i.map((L) => /* @__PURE__ */ o("tr", { children: [
1734
- /* @__PURE__ */ e("td", { className: "max-w-[110px] truncate pr-1.5 text-slate-500 dark:text-slate-400", children: L }),
1735
- b.map((le) => {
1736
- const I = $(L, le), M = I ? I.value / C : 0;
1737
+ /* @__PURE__ */ e("tbody", { children: i.map((T) => /* @__PURE__ */ o("tr", { children: [
1738
+ /* @__PURE__ */ e("td", { className: "max-w-[110px] truncate pr-1.5 text-slate-500 dark:text-slate-400", children: T }),
1739
+ b.map((ne) => {
1740
+ const ee = $(T, ne), A = ee ? ee.value / _ : 0;
1737
1741
  return /* @__PURE__ */ e("td", { className: "p-0.5", children: /* @__PURE__ */ e(
1738
1742
  "div",
1739
1743
  {
1740
- "data-tip": I ? `${L} × ${le}: ${I.value.toLocaleString()}` : void 0,
1744
+ "data-tip": ee ? `${T} × ${ne}: ${ee.value.toLocaleString()}` : void 0,
1741
1745
  className: "flex h-6 items-center justify-center rounded text-[9.5px] tabular-nums",
1742
1746
  style: {
1743
- backgroundColor: I ? `rgba(0, 165, 204, ${0.08 + M * 0.85})` : "transparent",
1744
- color: M > 0.55 ? "#fff" : void 0,
1745
- border: I ? void 0 : "1px dashed rgba(148,163,184,0.25)"
1747
+ backgroundColor: ee ? `rgba(0, 165, 204, ${0.08 + A * 0.85})` : "transparent",
1748
+ color: A > 0.55 ? "#fff" : void 0,
1749
+ border: ee ? void 0 : "1px dashed rgba(148,163,184,0.25)"
1746
1750
  },
1747
- children: I ? Ce(Math.round(I.value)) : ""
1751
+ children: ee ? $e(Math.round(ee.value)) : ""
1748
1752
  }
1749
- ) }, le);
1753
+ ) }, ne);
1750
1754
  })
1751
- ] }, L)) })
1755
+ ] }, T)) })
1752
1756
  ] }) });
1753
1757
  } else if (a.type === "ai_insight") {
1754
- const l = T.narrative ?? "";
1755
- V = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1758
+ const l = R.narrative ?? "";
1759
+ G = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1756
1760
  /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-1.5", children: [
1757
1761
  /* @__PURE__ */ e(Wt, { className: "h-3.5 w-3.5 text-[#00a5cc]" }),
1758
1762
  /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wide text-slate-400", children: "AI-generated" }),
@@ -1761,18 +1765,18 @@ const Dt = Wa(function({
1761
1765
  {
1762
1766
  type: "button",
1763
1767
  title: "Regenerate this summary",
1764
- disabled: be,
1765
- onClick: () => void _e(),
1768
+ disabled: ge,
1769
+ onClick: () => void Se(),
1766
1770
  className: "ml-auto rounded p-0.5 text-slate-300 hover:text-[#00a5cc] disabled:opacity-50",
1767
- children: /* @__PURE__ */ e(At, { className: P("h-3 w-3", be && "animate-spin") })
1771
+ children: /* @__PURE__ */ e(At, { className: P("h-3 w-3", ge && "animate-spin") })
1768
1772
  }
1769
1773
  )
1770
1774
  ] }),
1771
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: be ? "Regenerating…" : l })
1775
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: ge ? "Regenerating…" : l })
1772
1776
  ] });
1773
1777
  } else if (a.type === "pivot") {
1774
- const l = T.pivot;
1775
- V = !l || l.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1778
+ const l = R.pivot;
1779
+ G = !l || l.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1776
1780
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full border-collapse text-[10.5px]", children: [
1777
1781
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ o("tr", { children: [
1778
1782
  /* @__PURE__ */ e("th", { className: "sticky left-0 top-0 z-[2] bg-white dark:bg-card" }),
@@ -1790,17 +1794,17 @@ const Dt = Wa(function({
1790
1794
  /* @__PURE__ */ e("td", { className: "sticky left-0 z-[1] max-w-[150px] truncate bg-white pr-1.5 text-slate-500 dark:bg-card dark:text-slate-400", children: i }),
1791
1795
  l.cols.map((b) => {
1792
1796
  var $;
1793
- const C = ($ = l.cells[i]) == null ? void 0 : $[b];
1797
+ const _ = ($ = l.cells[i]) == null ? void 0 : $[b];
1794
1798
  return /* @__PURE__ */ e(
1795
1799
  "td",
1796
1800
  {
1797
1801
  className: "px-1.5 py-0.5 text-right tabular-nums text-slate-700 dark:text-slate-300",
1798
- children: C == null ? "" : qe(C, ie)
1802
+ children: _ == null ? "" : Ae(_, ce)
1799
1803
  },
1800
1804
  b
1801
1805
  );
1802
1806
  }),
1803
- /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200", children: qe(l.row_totals[i] ?? 0, ie) })
1807
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200", children: Ae(l.row_totals[i] ?? 0, ce) })
1804
1808
  ] }, i)) }),
1805
1809
  /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ o("tr", { className: "border-t border-slate-200 dark:border-border", children: [
1806
1810
  /* @__PURE__ */ e("td", { className: "sticky left-0 z-[1] bg-white pr-1.5 font-semibold text-slate-600 dark:bg-card dark:text-slate-300", children: "Total" }),
@@ -1808,11 +1812,11 @@ const Dt = Wa(function({
1808
1812
  "td",
1809
1813
  {
1810
1814
  className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200",
1811
- children: qe(l.col_totals[i] ?? 0, ie)
1815
+ children: Ae(l.col_totals[i] ?? 0, ce)
1812
1816
  },
1813
1817
  i
1814
1818
  )),
1815
- /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-900 dark:text-foreground", children: qe(l.grand_total, ie) })
1819
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-900 dark:text-foreground", children: Ae(l.grand_total, ce) })
1816
1820
  ] }) })
1817
1821
  ] }) }),
1818
1822
  (l.truncated_rows > 0 || l.truncated_cols > 0) && /* @__PURE__ */ o("p", { className: "mt-1 shrink-0 px-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
@@ -1831,8 +1835,8 @@ const Dt = Wa(function({
1831
1835
  ] })
1832
1836
  ] });
1833
1837
  } else if (a.type === "waterfall") {
1834
- const l = T.waterfall;
1835
- V = l ? (() => {
1838
+ const l = R.waterfall;
1839
+ G = l ? (() => {
1836
1840
  const i = [];
1837
1841
  i.push({ label: "Previous", from: 0, to: l.start, kind: "total" });
1838
1842
  let b = l.start;
@@ -1844,21 +1848,21 @@ const Dt = Wa(function({
1844
1848
  kind: $.delta >= 0 ? "up" : "down"
1845
1849
  }), b += $.delta;
1846
1850
  i.push({ label: "Current", from: 0, to: l.end, kind: "total" });
1847
- const C = Math.max(1, ...i.map(($) => Math.max($.from, $.to)));
1848
- return /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 items-end gap-1 overflow-x-auto px-1 pb-4", children: i.map(($, L) => {
1849
- const le = Math.max($.from, $.to) / C * 100, I = Math.abs($.to - $.from) / C * 100;
1851
+ const _ = Math.max(1, ...i.map(($) => Math.max($.from, $.to)));
1852
+ return /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 items-end gap-1 overflow-x-auto px-1 pb-4", children: i.map(($, T) => {
1853
+ const ne = Math.max($.from, $.to) / _ * 100, ee = Math.abs($.to - $.from) / _ * 100;
1850
1854
  return /* @__PURE__ */ o(
1851
1855
  "div",
1852
1856
  {
1853
1857
  className: "relative flex h-full min-w-[46px] flex-1 flex-col justify-end",
1854
1858
  children: [
1855
- /* @__PURE__ */ e("div", { style: { height: `${Math.max(le, 0.5)}%` }, className: "relative w-full", children: /* @__PURE__ */ e(
1859
+ /* @__PURE__ */ e("div", { style: { height: `${Math.max(ne, 0.5)}%` }, className: "relative w-full", children: /* @__PURE__ */ e(
1856
1860
  "div",
1857
1861
  {
1858
1862
  "data-tip": `${$.label}: ${($.to - $.from).toLocaleString()}`,
1859
1863
  className: "absolute inset-x-0 top-0 rounded-sm",
1860
1864
  style: {
1861
- height: `${Math.max(I / Math.max(le, 1e-3) * 100, 2)}%`,
1865
+ height: `${Math.max(ee / Math.max(ne, 1e-3) * 100, 2)}%`,
1862
1866
  backgroundColor: $.kind === "total" ? "#172940" : $.kind === "up" ? "#10b981" : "#ef4444"
1863
1867
  }
1864
1868
  }
@@ -1866,26 +1870,26 @@ const Dt = Wa(function({
1866
1870
  /* @__PURE__ */ e("p", { className: "absolute -bottom-4 left-0 right-0 truncate text-center text-[9px] text-slate-400", children: $.label })
1867
1871
  ]
1868
1872
  },
1869
- L
1873
+ T
1870
1874
  );
1871
1875
  }) });
1872
1876
  })() : /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
1873
1877
  } else if (a.type === "stats") {
1874
- const l = T.rows ?? [];
1875
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "grid min-h-0 flex-1 grid-cols-2 content-start gap-x-4 gap-y-1.5 overflow-auto px-1", children: l.map((i) => /* @__PURE__ */ o(
1878
+ const l = R.rows ?? [];
1879
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "grid min-h-0 flex-1 grid-cols-2 content-start gap-x-4 gap-y-1.5 overflow-auto px-1", children: l.map((i) => /* @__PURE__ */ o(
1876
1880
  "div",
1877
1881
  {
1878
1882
  className: "flex items-baseline justify-between border-b border-slate-100 pb-1 dark:border-border/50",
1879
1883
  children: [
1880
1884
  /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500", children: i.stat }),
1881
- /* @__PURE__ */ e("span", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: i.value == null ? "—" : qe(i.value, ie) })
1885
+ /* @__PURE__ */ e("span", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: i.value == null ? "—" : Ae(i.value, ce) })
1882
1886
  ]
1883
1887
  },
1884
1888
  i.stat
1885
1889
  )) });
1886
1890
  } else if (a.type === "hot_records") {
1887
- const l = T.rows ?? [], i = Math.max(1, ...l.map((b) => b.views));
1888
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No views recorded in the window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-1 overflow-auto px-1", children: l.map((b) => /* @__PURE__ */ o(
1891
+ const l = R.rows ?? [], i = Math.max(1, ...l.map((b) => b.views));
1892
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No views recorded in the window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-1 overflow-auto px-1", children: l.map((b) => /* @__PURE__ */ o(
1889
1893
  "button",
1890
1894
  {
1891
1895
  type: "button",
@@ -1906,32 +1910,32 @@ const Dt = Wa(function({
1906
1910
  b.id
1907
1911
  )) });
1908
1912
  } else if (a.type === "scatter") {
1909
- const l = T.rows ?? [];
1910
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : (() => {
1911
- const i = l.length, b = l.reduce((ee, r) => ee + r.x, 0), C = l.reduce((ee, r) => ee + r.y, 0), $ = l.reduce((ee, r) => ee + r.x * r.x, 0), L = l.reduce((ee, r) => ee + r.x * r.y, 0), le = i * $ - b * b, I = le !== 0 ? (i * L - b * C) / le : 0, M = i > 0 ? (C - I * b) / i : 0, G = l.map((ee) => ee.x), B = Math.min(...G), K = Math.max(...G), pe = [
1912
- { x: B, y: M + I * B },
1913
- { x: K, y: M + I * K }
1913
+ const l = R.rows ?? [];
1914
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : (() => {
1915
+ const i = l.length, b = l.reduce((te, r) => te + r.x, 0), _ = l.reduce((te, r) => te + r.y, 0), $ = l.reduce((te, r) => te + r.x * r.x, 0), T = l.reduce((te, r) => te + r.x * r.y, 0), ne = i * $ - b * b, ee = ne !== 0 ? (i * T - b * _) / ne : 0, A = i > 0 ? (_ - ee * b) / i : 0, U = l.map((te) => te.x), z = Math.min(...U), O = Math.max(...U), he = [
1916
+ { x: z, y: A + ee * z },
1917
+ { x: O, y: A + ee * O }
1914
1918
  ];
1915
- return /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({
1916
- ComposedChart: ee,
1919
+ return /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({
1920
+ ComposedChart: te,
1917
1921
  Line: r,
1918
1922
  ResponsiveContainer: d,
1919
1923
  Scatter: x,
1920
1924
  Tooltip: v,
1921
- XAxis: q,
1922
- YAxis: w
1923
- }) => /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ o(ee, { data: l, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
1925
+ XAxis: C,
1926
+ YAxis: M
1927
+ }) => /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ o(te, { data: l, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
1924
1928
  /* @__PURE__ */ e(
1925
- q,
1929
+ C,
1926
1930
  {
1927
1931
  dataKey: "x",
1928
1932
  type: "number",
1929
1933
  tick: { fontSize: 10 },
1930
- tickFormatter: Ce,
1934
+ tickFormatter: $e,
1931
1935
  domain: ["dataMin", "dataMax"]
1932
1936
  }
1933
1937
  ),
1934
- /* @__PURE__ */ e(w, { tick: { fontSize: 10 }, tickFormatter: Ce }),
1938
+ /* @__PURE__ */ e(M, { tick: { fontSize: 10 }, tickFormatter: $e }),
1935
1939
  /* @__PURE__ */ e(
1936
1940
  v,
1937
1941
  {
@@ -1948,7 +1952,7 @@ const Dt = Wa(function({
1948
1952
  /* @__PURE__ */ e(
1949
1953
  r,
1950
1954
  {
1951
- data: pe,
1955
+ data: he,
1952
1956
  dataKey: "y",
1953
1957
  stroke: "#f59e0b",
1954
1958
  strokeWidth: 2,
@@ -1959,10 +1963,10 @@ const Dt = Wa(function({
1959
1963
  ] }) }) }) });
1960
1964
  })();
1961
1965
  } else if (a.type === "pareto") {
1962
- const l = T.series ?? [];
1963
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: i, ComposedChart: b, Line: C, ResponsiveContainer: $, Tooltip: L, XAxis: le, YAxis: I }) => /* @__PURE__ */ e($, { width: "100%", height: "100%", children: /* @__PURE__ */ o(b, { data: l, margin: { top: 6, right: 4, left: -10, bottom: 0 }, children: [
1966
+ const l = R.series ?? [];
1967
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: i, ComposedChart: b, Line: _, ResponsiveContainer: $, Tooltip: T, XAxis: ne, YAxis: ee }) => /* @__PURE__ */ e($, { width: "100%", height: "100%", children: /* @__PURE__ */ o(b, { data: l, margin: { top: 6, right: 4, left: -10, bottom: 0 }, children: [
1964
1968
  /* @__PURE__ */ e(
1965
- le,
1969
+ ne,
1966
1970
  {
1967
1971
  dataKey: "dim",
1968
1972
  tick: { fontSize: 10 },
@@ -1972,19 +1976,19 @@ const Dt = Wa(function({
1972
1976
  height: 42
1973
1977
  }
1974
1978
  ),
1975
- /* @__PURE__ */ e(I, { yAxisId: "v", tick: { fontSize: 10 }, tickFormatter: Ce }),
1979
+ /* @__PURE__ */ e(ee, { yAxisId: "v", tick: { fontSize: 10 }, tickFormatter: $e }),
1976
1980
  /* @__PURE__ */ e(
1977
- I,
1981
+ ee,
1978
1982
  {
1979
1983
  yAxisId: "pct",
1980
1984
  orientation: "right",
1981
1985
  domain: [0, 100],
1982
1986
  tick: { fontSize: 10 },
1983
- tickFormatter: (M) => `${M}%`
1987
+ tickFormatter: (A) => `${A}%`
1984
1988
  }
1985
1989
  ),
1986
1990
  /* @__PURE__ */ e(
1987
- L,
1991
+ T,
1988
1992
  {
1989
1993
  contentStyle: {
1990
1994
  fontSize: 12,
@@ -2006,7 +2010,7 @@ const Dt = Wa(function({
2006
2010
  }
2007
2011
  ),
2008
2012
  /* @__PURE__ */ e(
2009
- C,
2013
+ _,
2010
2014
  {
2011
2015
  yAxisId: "pct",
2012
2016
  dataKey: "cum_pct",
@@ -2018,13 +2022,13 @@ const Dt = Wa(function({
2018
2022
  )
2019
2023
  ] }) }) }) });
2020
2024
  } else if (a.type === "metric")
2021
- V = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
2022
- /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-slate-900 dark:text-slate-50", children: T.value == null ? "—" : qe(T.value, ie) }),
2025
+ G = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
2026
+ /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-slate-900 dark:text-slate-50", children: R.value == null ? "—" : Ae(R.value, ce) }),
2023
2027
  /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: String(((St = a.config) == null ? void 0 : St.metric_key) ?? "") })
2024
2028
  ] });
2025
2029
  else if (a.type === "movers") {
2026
- const l = T.rows ?? [];
2027
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No movement in this window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto", children: l.map((i) => /* @__PURE__ */ o("div", { className: "flex items-center gap-2 text-[11.5px]", children: [
2030
+ const l = R.rows ?? [];
2031
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No movement in this window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto", children: l.map((i) => /* @__PURE__ */ o("div", { className: "flex items-center gap-2 text-[11.5px]", children: [
2028
2032
  /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: i.dim }),
2029
2033
  /* @__PURE__ */ o("span", { className: "tabular-nums text-slate-400", children: [
2030
2034
  i.previous.toLocaleString(),
@@ -2051,61 +2055,61 @@ const Dt = Wa(function({
2051
2055
  )
2052
2056
  ] }, i.dim)) });
2053
2057
  } else if (a.type === "table") {
2054
- const l = T.rows ?? [], i = (Ye = a.config) != null && Ye.columns && a.config.columns.length > 0 ? a.config.columns.map((d) => typeof d == "string" ? { field: d } : d) : l[0] ? Object.keys(l[0]).filter((d) => d !== "id").map((d) => ({ field: d })) : [], b = i.map((d) => d.field), C = (d) => i.find((x) => x.field === d), $ = ((ct = a.config) == null ? void 0 : ct.format_rules) ?? [], L = (d) => {
2058
+ const l = R.rows ?? [], i = (He = a.config) != null && He.columns && a.config.columns.length > 0 ? a.config.columns.map((d) => typeof d == "string" ? { field: d } : d) : l[0] ? Object.keys(l[0]).filter((d) => d !== "id").map((d) => ({ field: d })) : [], b = i.map((d) => d.field), _ = (d) => i.find((x) => x.field === d), $ = ((ut = a.config) == null ? void 0 : ut.format_rules) ?? [], T = (d) => {
2055
2059
  var x;
2056
2060
  for (const v of $)
2057
2061
  if ((v.scope ?? "cell") === "row" && Gt(v, d[v.field]))
2058
- return ((x = Vt[v.color]) == null ? void 0 : x.row) ?? null;
2062
+ return ((x = Yt[v.color]) == null ? void 0 : x.row) ?? null;
2059
2063
  return null;
2060
- }, le = (d, x) => {
2064
+ }, ne = (d, x) => {
2061
2065
  var v;
2062
- for (const q of $)
2063
- if ((q.scope ?? "cell") === "cell" && q.field === x && Gt(q, d[x]))
2064
- return ((v = Vt[q.color]) == null ? void 0 : v.cell) ?? null;
2066
+ for (const C of $)
2067
+ if ((C.scope ?? "cell") === "cell" && C.field === x && Gt(C, d[x]))
2068
+ return ((v = Yt[C.color]) == null ? void 0 : v.cell) ?? null;
2065
2069
  return null;
2066
- }, I = H.trim().toLowerCase(), M = a.config, G = M != null && M.suppress_zero ? l.filter(
2070
+ }, ee = Z.trim().toLowerCase(), A = a.config, U = A != null && A.suppress_zero ? l.filter(
2067
2071
  (d) => b.some((x) => {
2068
2072
  const v = Number(d[x]);
2069
2073
  return Number.isFinite(v) && v !== 0;
2070
2074
  })
2071
- ) : l, B = I ? G.filter(
2075
+ ) : l, z = ee ? U.filter(
2072
2076
  (d) => Object.values(d).some(
2073
- (x) => String(x ?? "").toLowerCase().includes(I)
2077
+ (x) => String(x ?? "").toLowerCase().includes(ee)
2074
2078
  )
2075
- ) : G, K = 12, pe = Math.max(1, Math.ceil(B.length / K)), ee = Math.min(ue, pe - 1), r = B.length > K ? B.slice(ee * K, ee * K + K) : B;
2076
- V = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No rows." }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
2077
- l.length > K && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-2", children: [
2079
+ ) : U, O = 12, he = Math.max(1, Math.ceil(z.length / O)), te = Math.min(me, he - 1), r = z.length > O ? z.slice(te * O, te * O + O) : z;
2080
+ G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No rows." }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
2081
+ l.length > O && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-2", children: [
2078
2082
  /* @__PURE__ */ e(
2079
2083
  "input",
2080
2084
  {
2081
- value: H,
2085
+ value: Z,
2082
2086
  onChange: (d) => {
2083
- z(d.target.value), J(0);
2087
+ E(d.target.value), J(0);
2084
2088
  },
2085
2089
  placeholder: "Search rows…",
2086
2090
  className: "h-6 w-40 rounded border border-slate-200 bg-white px-1.5 text-[11px] dark:border-border dark:bg-card dark:text-slate-200"
2087
2091
  }
2088
2092
  ),
2089
- pe > 1 && /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2093
+ he > 1 && /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2090
2094
  /* @__PURE__ */ e(
2091
2095
  "button",
2092
2096
  {
2093
2097
  type: "button",
2094
- disabled: ee <= 0,
2095
- onClick: () => J(ee - 1),
2098
+ disabled: te <= 0,
2099
+ onClick: () => J(te - 1),
2096
2100
  className: "rounded px-1 disabled:opacity-30",
2097
2101
  children: "←"
2098
2102
  }
2099
2103
  ),
2100
- ee + 1,
2104
+ te + 1,
2101
2105
  "/",
2102
- pe,
2106
+ he,
2103
2107
  /* @__PURE__ */ e(
2104
2108
  "button",
2105
2109
  {
2106
2110
  type: "button",
2107
- disabled: ee >= pe - 1,
2108
- onClick: () => J(ee + 1),
2111
+ disabled: te >= he - 1,
2112
+ onClick: () => J(te + 1),
2109
2113
  className: "rounded px-1 disabled:opacity-30",
2110
2114
  children: "→"
2111
2115
  }
@@ -2119,7 +2123,7 @@ const Dt = Wa(function({
2119
2123
  "th",
2120
2124
  {
2121
2125
  className: "border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
2122
- children: ((x = C(d)) == null ? void 0 : x.label) ?? d
2126
+ children: ((x = _(d)) == null ? void 0 : x.label) ?? d
2123
2127
  },
2124
2128
  d
2125
2129
  );
@@ -2128,23 +2132,23 @@ const Dt = Wa(function({
2128
2132
  "tr",
2129
2133
  {
2130
2134
  className: P(
2131
- L(d),
2135
+ T(d),
2132
2136
  a.collection && d.id != null && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60"
2133
2137
  ),
2134
2138
  onClick: () => {
2135
2139
  a.collection && d.id != null && (g == null || g({ collection: a.collection, itemId: String(d.id) }));
2136
2140
  },
2137
2141
  children: b.map((x) => {
2138
- var v, q, w, A;
2142
+ var v, C, M, B;
2139
2143
  return /* @__PURE__ */ e(
2140
2144
  "td",
2141
2145
  {
2142
2146
  className: P(
2143
2147
  "max-w-[180px] truncate border-b border-slate-50 px-1.5 py-1 text-slate-700 dark:border-border/40 dark:text-slate-300",
2144
- (typeof d[x] == "number" || Pe.has(((v = C(x)) == null ? void 0 : v.format) ?? "")) && "text-right tabular-nums",
2145
- le(d, x)
2148
+ (typeof d[x] == "number" || je.has(((v = _(x)) == null ? void 0 : v.format) ?? "")) && "text-right tabular-nums",
2149
+ ne(d, x)
2146
2150
  ),
2147
- children: (q = C(x)) != null && q.format ? ze(d[x], (w = C(x)) == null ? void 0 : w.format, (A = C(x)) == null ? void 0 : A.decimals) : String(d[x] ?? "")
2151
+ children: (C = _(x)) != null && C.format ? ze(d[x], (M = _(x)) == null ? void 0 : M.format, (B = _(x)) == null ? void 0 : B.decimals) : String(d[x] ?? "")
2148
2152
  },
2149
2153
  x
2150
2154
  );
@@ -2152,17 +2156,17 @@ const Dt = Wa(function({
2152
2156
  },
2153
2157
  String(d.id)
2154
2158
  )) }),
2155
- (M == null ? void 0 : M.grand_total) && B.length > 1 && /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ e("tr", { className: "border-t border-slate-200 font-semibold dark:border-border", children: b.map((d, x) => {
2156
- var A, de, ke;
2157
- const v = B.map((xt) => Number(xt[d])).filter((xt) => Number.isFinite(xt)), q = v.length > B.length / 2, w = v.reduce((xt, ya) => xt + ya, 0);
2159
+ (A == null ? void 0 : A.grand_total) && z.length > 1 && /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ e("tr", { className: "border-t border-slate-200 font-semibold dark:border-border", children: b.map((d, x) => {
2160
+ var B, D, fe;
2161
+ const v = z.map((De) => Number(De[d])).filter((De) => Number.isFinite(De)), C = v.length > z.length / 2, M = v.reduce((De, ka) => De + ka, 0);
2158
2162
  return /* @__PURE__ */ e(
2159
2163
  "td",
2160
2164
  {
2161
2165
  className: P(
2162
2166
  "px-1.5 py-1 text-slate-800 dark:text-slate-100",
2163
- q && "text-right tabular-nums"
2167
+ C && "text-right tabular-nums"
2164
2168
  ),
2165
- children: x === 0 && !q ? "Total" : q ? (A = C(d)) != null && A.format ? ze(w, (de = C(d)) == null ? void 0 : de.format, (ke = C(d)) == null ? void 0 : ke.decimals) : w.toLocaleString() : ""
2169
+ children: x === 0 && !C ? "Total" : C ? (B = _(d)) != null && B.format ? ze(M, (D = _(d)) == null ? void 0 : D.format, (fe = _(d)) == null ? void 0 : fe.decimals) : M.toLocaleString() : ""
2166
2170
  },
2167
2171
  d
2168
2172
  );
@@ -2170,38 +2174,38 @@ const Dt = Wa(function({
2170
2174
  ] }) })
2171
2175
  ] });
2172
2176
  } else {
2173
- let l = T.series ?? [];
2174
- const i = !!((ut = (Ve = a.config) == null ? void 0 : Ve.dimension) != null && ut.bucket), b = Number((mt = a.config) == null ? void 0 : mt.rolling_avg) || 0;
2175
- if (b >= 2 && i && !te && l.length >= b && (l = l.map((M, G) => {
2176
- if (G < b - 1) return M;
2177
- const B = l.slice(G - b + 1, G + 1);
2178
- return { ...M, ma: B.reduce((K, pe) => K + pe.value, 0) / b };
2179
- })), te && i) {
2180
- let M = 0, G = 0, B = 0;
2181
- l = l.map((K) => (M += K.value, G += K.prev ?? 0, B += K.value2 ?? 0, {
2182
- ...K,
2183
- value: M,
2184
- ...K.prev != null ? { prev: G } : {},
2185
- ...K.value2 != null ? { value2: B } : {}
2177
+ let l = R.series ?? [];
2178
+ const i = !!((mt = (Xe = a.config) == null ? void 0 : Xe.dimension) != null && mt.bucket), b = Number((pt = a.config) == null ? void 0 : pt.rolling_avg) || 0;
2179
+ if (b >= 2 && i && !le && l.length >= b && (l = l.map((A, U) => {
2180
+ if (U < b - 1) return A;
2181
+ const z = l.slice(U - b + 1, U + 1);
2182
+ return { ...A, ma: z.reduce((O, he) => O + he.value, 0) / b };
2183
+ })), le && i) {
2184
+ let A = 0, U = 0, z = 0;
2185
+ l = l.map((O) => (A += O.value, U += O.prev ?? 0, z += O.value2 ?? 0, {
2186
+ ...O,
2187
+ value: A,
2188
+ ...O.prev != null ? { prev: U } : {},
2189
+ ...O.value2 != null ? { value2: z } : {}
2186
2190
  }));
2187
2191
  }
2188
- const C = l.some((M) => M.value2 != null), $ = ((ne = (pt = a.config) == null ? void 0 : pt.metric2) == null ? void 0 : ne.label) ?? "secondary", L = l.some((M) => M.band != null), le = (() => {
2189
- if (!i || te || l.length < 8) return /* @__PURE__ */ new Set();
2190
- const M = l.map((K) => K.value), G = M.reduce((K, pe) => K + pe, 0) / M.length, B = Math.sqrt(M.reduce((K, pe) => K + (pe - G) ** 2, 0) / M.length);
2191
- return B === 0 ? /* @__PURE__ */ new Set() : new Set(
2192
- l.filter((K) => Math.abs(K.value - G) > 2 * B).map((K) => K.dim)
2192
+ const _ = l.some((A) => A.value2 != null), $ = ((oe = (ht = a.config) == null ? void 0 : ht.metric2) == null ? void 0 : oe.label) ?? "secondary", T = l.some((A) => A.band != null), ne = (() => {
2193
+ if (!i || le || l.length < 8) return /* @__PURE__ */ new Set();
2194
+ const A = l.map((O) => O.value), U = A.reduce((O, he) => O + he, 0) / A.length, z = Math.sqrt(A.reduce((O, he) => O + (he - U) ** 2, 0) / A.length);
2195
+ return z === 0 ? /* @__PURE__ */ new Set() : new Set(
2196
+ l.filter((O) => Math.abs(O.value - U) > 2 * z).map((O) => O.dim)
2193
2197
  );
2194
- })(), I = (O ?? []).filter(
2195
- (M) => M.anchor_date && l.some((G) => G.dim === M.anchor_date)
2198
+ })(), ee = (L ?? []).filter(
2199
+ (A) => A.anchor_date && l.some((U) => U.dim === A.anchor_date)
2196
2200
  );
2197
- if (l.length === 0) V = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
2201
+ if (l.length === 0) G = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
2198
2202
  else if (a.type === "donut") {
2199
- const M = l.reduce((G, B) => G + B.value, 0);
2200
- V = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
2203
+ const A = l.reduce((U, z) => U + z.value, 0);
2204
+ G = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
2201
2205
  /* @__PURE__ */ o("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
2202
- /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: G, Pie: B, PieChart: K, ResponsiveContainer: pe, Tooltip: ee }) => /* @__PURE__ */ e(pe, { width: "100%", height: "100%", children: /* @__PURE__ */ o(K, { children: [
2206
+ /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: U, Pie: z, PieChart: O, ResponsiveContainer: he, Tooltip: te }) => /* @__PURE__ */ e(he, { width: "100%", height: "100%", children: /* @__PURE__ */ o(O, { children: [
2203
2207
  /* @__PURE__ */ e(
2204
- B,
2208
+ z,
2205
2209
  {
2206
2210
  data: l,
2207
2211
  dataKey: "value",
@@ -2212,22 +2216,22 @@ const Dt = Wa(function({
2212
2216
  strokeWidth: 0,
2213
2217
  className: a.collection ? "cursor-pointer" : void 0,
2214
2218
  onClick: (r) => {
2215
- var v, q, w, A;
2219
+ var v, C, M, B;
2216
2220
  if (!a.collection) return;
2217
2221
  const d = r == null ? void 0 : r.payload;
2218
2222
  if (d != null && d.other) return;
2219
- if (Be.length > ae.length) {
2220
- const de = ae.length === 0 ? (q = (v = a.config) == null ? void 0 : v.dimension) == null ? void 0 : q.field : Be[ae.length - 1];
2221
- if (de) {
2222
- N((ke) => [
2223
- ...ke,
2224
- { field: de, value: String((d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim) ?? "") }
2223
+ if (Je.length > re.length) {
2224
+ const D = re.length === 0 ? (C = (v = a.config) == null ? void 0 : v.dimension) == null ? void 0 : C.field : Je[re.length - 1];
2225
+ if (D) {
2226
+ k((fe) => [
2227
+ ...fe,
2228
+ { field: D, value: String((d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim) ?? "") }
2225
2229
  ]);
2226
2230
  return;
2227
2231
  }
2228
2232
  }
2229
- const x = (A = (w = a.config) == null ? void 0 : w.dimension) == null ? void 0 : A.field;
2230
- se({
2233
+ const x = (B = (M = a.config) == null ? void 0 : M.dimension) == null ? void 0 : B.field;
2234
+ ie({
2231
2235
  conditions: Tt(
2232
2236
  a,
2233
2237
  c,
@@ -2241,16 +2245,16 @@ const Dt = Wa(function({
2241
2245
  });
2242
2246
  },
2243
2247
  children: l.map((r, d) => /* @__PURE__ */ e(
2244
- G,
2248
+ U,
2245
2249
  {
2246
- fill: r.other ? "#94a3b8" : ce[d % ce.length]
2250
+ fill: r.other ? "#94a3b8" : ue[d % ue.length]
2247
2251
  },
2248
2252
  r.dim
2249
2253
  ))
2250
2254
  }
2251
2255
  ),
2252
2256
  /* @__PURE__ */ e(
2253
- ee,
2257
+ te,
2254
2258
  {
2255
2259
  contentStyle: {
2256
2260
  fontSize: 12,
@@ -2265,39 +2269,39 @@ const Dt = Wa(function({
2265
2269
  )
2266
2270
  ] }) }) }),
2267
2271
  /* @__PURE__ */ o("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center", children: [
2268
- /* @__PURE__ */ e("span", { className: "text-[17px] font-semibold leading-none text-slate-900 dark:text-foreground", children: M.toLocaleString() }),
2272
+ /* @__PURE__ */ e("span", { className: "text-[17px] font-semibold leading-none text-slate-900 dark:text-foreground", children: A.toLocaleString() }),
2269
2273
  /* @__PURE__ */ e("span", { className: "text-[9.5px] text-slate-400", children: "total" })
2270
2274
  ] })
2271
2275
  ] }),
2272
- /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: l.slice(0, 10).map((G, B) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
2276
+ /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: l.slice(0, 10).map((U, z) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
2273
2277
  /* @__PURE__ */ e(
2274
2278
  "span",
2275
2279
  {
2276
2280
  className: "h-2 w-2 shrink-0 rounded-sm",
2277
- style: { background: ce[B % ce.length] }
2281
+ style: { background: ue[z % ue.length] }
2278
2282
  }
2279
2283
  ),
2280
- /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: G.dim }),
2281
- /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: G.value.toLocaleString() })
2282
- ] }, G.dim)) })
2284
+ /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: U.dim }),
2285
+ /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: U.value.toLocaleString() })
2286
+ ] }, U.dim)) })
2283
2287
  ] });
2284
2288
  } else if (a.type === "line")
2285
- V = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2286
- Area: M,
2287
- ComposedChart: G,
2288
- Line: B,
2289
- ReferenceLine: K,
2290
- ResponsiveContainer: pe,
2291
- Tooltip: ee,
2289
+ G = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2290
+ Area: A,
2291
+ ComposedChart: U,
2292
+ Line: z,
2293
+ ReferenceLine: O,
2294
+ ResponsiveContainer: he,
2295
+ Tooltip: te,
2292
2296
  XAxis: r,
2293
2297
  YAxis: d
2294
2298
  }) => {
2295
2299
  var x;
2296
- return /* @__PURE__ */ e(pe, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
2297
- G,
2300
+ return /* @__PURE__ */ e(he, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
2301
+ U,
2298
2302
  {
2299
2303
  data: l,
2300
- margin: { top: 6, right: C ? 4 : 8, left: -10, bottom: 0 },
2304
+ margin: { top: 6, right: _ ? 4 : 8, left: -10, bottom: 0 },
2301
2305
  children: [
2302
2306
  /* @__PURE__ */ e(
2303
2307
  r,
@@ -2305,7 +2309,7 @@ const Dt = Wa(function({
2305
2309
  dataKey: "dim",
2306
2310
  tick: { fontSize: 10 },
2307
2311
  stroke: "#94a3b8",
2308
- ...Ft(l.length)
2312
+ ...Mt(l.length)
2309
2313
  }
2310
2314
  ),
2311
2315
  /* @__PURE__ */ e(
@@ -2313,23 +2317,23 @@ const Dt = Wa(function({
2313
2317
  {
2314
2318
  tick: { fontSize: 10 },
2315
2319
  stroke: "#94a3b8",
2316
- tickFormatter: Ce,
2320
+ tickFormatter: $e,
2317
2321
  width: 44
2318
2322
  }
2319
2323
  ),
2320
- C && /* @__PURE__ */ e(
2324
+ _ && /* @__PURE__ */ e(
2321
2325
  d,
2322
2326
  {
2323
2327
  yAxisId: "right",
2324
2328
  orientation: "right",
2325
2329
  tick: { fontSize: 10 },
2326
2330
  stroke: "#94a3b8",
2327
- tickFormatter: Ce,
2331
+ tickFormatter: $e,
2328
2332
  width: 44
2329
2333
  }
2330
2334
  ),
2331
- I.map((v) => /* @__PURE__ */ e(
2332
- K,
2335
+ ee.map((v) => /* @__PURE__ */ e(
2336
+ O,
2333
2337
  {
2334
2338
  x: v.anchor_date,
2335
2339
  stroke: "#f59e0b",
@@ -2339,7 +2343,7 @@ const Dt = Wa(function({
2339
2343
  v.id
2340
2344
  )),
2341
2345
  /* @__PURE__ */ e(
2342
- ee,
2346
+ te,
2343
2347
  {
2344
2348
  contentStyle: {
2345
2349
  fontSize: 12,
@@ -2352,8 +2356,8 @@ const Dt = Wa(function({
2352
2356
  itemStyle: { color: "#e2e8f0" }
2353
2357
  }
2354
2358
  ),
2355
- L && /* @__PURE__ */ e(
2356
- M,
2359
+ T && /* @__PURE__ */ e(
2360
+ A,
2357
2361
  {
2358
2362
  type: "monotone",
2359
2363
  dataKey: "band",
@@ -2365,7 +2369,7 @@ const Dt = Wa(function({
2365
2369
  }
2366
2370
  ),
2367
2371
  ((x = a.config) == null ? void 0 : x.compare) && /* @__PURE__ */ e(
2368
- B,
2372
+ z,
2369
2373
  {
2370
2374
  type: "monotone",
2371
2375
  dataKey: "prev",
@@ -2377,15 +2381,15 @@ const Dt = Wa(function({
2377
2381
  }
2378
2382
  ),
2379
2383
  /* @__PURE__ */ e(
2380
- B,
2384
+ z,
2381
2385
  {
2382
2386
  type: "monotone",
2383
2387
  dataKey: "value",
2384
- stroke: Xe,
2388
+ stroke: et,
2385
2389
  strokeWidth: 2,
2386
2390
  dot: (v) => {
2387
- var q, w, A;
2388
- return le.has(((q = v.payload) == null ? void 0 : q.dim) ?? "") ? /* @__PURE__ */ e(
2391
+ var C, M, B;
2392
+ return ne.has(((C = v.payload) == null ? void 0 : C.dim) ?? "") ? /* @__PURE__ */ e(
2389
2393
  "circle",
2390
2394
  {
2391
2395
  cx: v.cx,
@@ -2395,13 +2399,13 @@ const Dt = Wa(function({
2395
2399
  stroke: "#fff",
2396
2400
  strokeWidth: 1
2397
2401
  },
2398
- (w = v.payload) == null ? void 0 : w.dim
2399
- ) : /* @__PURE__ */ e("g", {}, (A = v.payload) == null ? void 0 : A.dim);
2402
+ (M = v.payload) == null ? void 0 : M.dim
2403
+ ) : /* @__PURE__ */ e("g", {}, (B = v.payload) == null ? void 0 : B.dim);
2400
2404
  }
2401
2405
  }
2402
2406
  ),
2403
- C && /* @__PURE__ */ e(
2404
- B,
2407
+ _ && /* @__PURE__ */ e(
2408
+ z,
2405
2409
  {
2406
2410
  yAxisId: "right",
2407
2411
  type: "monotone",
@@ -2413,7 +2417,7 @@ const Dt = Wa(function({
2413
2417
  }
2414
2418
  ),
2415
2419
  b >= 2 && /* @__PURE__ */ e(
2416
- B,
2420
+ z,
2417
2421
  {
2418
2422
  type: "monotone",
2419
2423
  dataKey: "ma",
@@ -2430,145 +2434,141 @@ const Dt = Wa(function({
2430
2434
  ) });
2431
2435
  } }) });
2432
2436
  else {
2433
- const M = ((_t = a.config) == null ? void 0 : _t.orientation) === "horizontal";
2434
- V = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Ke, { fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2435
- Bar: G,
2436
- Cell: B,
2437
- ComposedChart: K,
2438
- Line: pe,
2439
- ReferenceLine: ee,
2440
- ResponsiveContainer: r,
2441
- Tooltip: d,
2442
- XAxis: x,
2443
- YAxis: v
2444
- }) => {
2445
- var q;
2446
- return /* @__PURE__ */ e(r, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
2447
- K,
2448
- {
2449
- data: l,
2450
- layout: M ? "vertical" : "horizontal",
2451
- margin: { top: 6, right: 8, left: M ? 10 : -10, bottom: 0 },
2452
- children: [
2453
- M ? /* @__PURE__ */ o(et, { children: [
2454
- /* @__PURE__ */ e(x, { type: "number", tick: { fontSize: 10 }, stroke: "#94a3b8" }),
2455
- /* @__PURE__ */ e(
2456
- v,
2457
- {
2458
- type: "category",
2459
- dataKey: "dim",
2460
- tick: { fontSize: 10 },
2461
- stroke: "#94a3b8",
2462
- tickFormatter: xl,
2463
- interval: 0,
2464
- width: 140
2465
- }
2466
- )
2467
- ] }) : /* @__PURE__ */ o(et, { children: [
2468
- /* @__PURE__ */ e(
2469
- x,
2470
- {
2471
- dataKey: "dim",
2472
- tick: { fontSize: 10 },
2473
- stroke: "#94a3b8",
2474
- ...Ft(l.length)
2475
- }
2476
- ),
2477
- /* @__PURE__ */ e(
2478
- v,
2479
- {
2480
- tick: { fontSize: 10 },
2481
- stroke: "#94a3b8",
2482
- tickFormatter: Ce,
2483
- width: 44
2484
- }
2485
- ),
2486
- C && /* @__PURE__ */ e(
2487
- v,
2488
- {
2489
- yAxisId: "right",
2490
- orientation: "right",
2491
- tick: { fontSize: 10 },
2492
- stroke: "#94a3b8",
2493
- tickFormatter: Ce,
2494
- width: 44
2495
- }
2496
- )
2497
- ] }),
2498
- !M && I.map((w) => /* @__PURE__ */ e(
2499
- ee,
2500
- {
2501
- x: w.anchor_date,
2502
- stroke: "#f59e0b",
2503
- strokeDasharray: "4 3",
2504
- label: { value: "✎", position: "top", fontSize: 11, fill: "#f59e0b" }
2505
- },
2506
- w.id
2507
- )),
2508
- /* @__PURE__ */ e(
2509
- d,
2510
- {
2511
- contentStyle: {
2512
- fontSize: 12,
2513
- backgroundColor: "#0f172a",
2514
- border: "1px solid #334155",
2515
- borderRadius: 8,
2516
- color: "#f1f5f9"
2517
- },
2518
- labelStyle: { color: "#f1f5f9" },
2519
- itemStyle: { color: "#e2e8f0" }
2520
- }
2521
- ),
2522
- ((q = a.config) == null ? void 0 : q.compare) && /* @__PURE__ */ e(G, { dataKey: "prev", fill: "#cbd5e1", radius: [3, 3, 0, 0], name: "previous" }),
2523
- /* @__PURE__ */ e(
2524
- G,
2525
- {
2526
- dataKey: "value",
2527
- fill: Xe,
2528
- radius: [3, 3, 0, 0],
2529
- className: a.collection ? "cursor-pointer" : void 0,
2530
- onClick: (w) => {
2531
- var ke;
2532
- if (!a.collection) return;
2533
- const A = w == null ? void 0 : w.payload;
2534
- if (A != null && A.other) return;
2535
- const de = (ke = a.config) == null ? void 0 : ke.dimension;
2536
- se({
2537
- conditions: Tt(
2538
- a,
2539
- c,
2540
- s,
2541
- (A == null ? void 0 : A.raw) ?? (A == null ? void 0 : A.dim)
2542
- ),
2543
- title: `${a.title || a.collection} — ${(A == null ? void 0 : A.dim) ?? ""}`,
2544
- dimField: de != null && de.bucket || de == null ? void 0 : de.field,
2545
- dimRaw: (A == null ? void 0 : A.raw) ?? (A == null ? void 0 : A.dim),
2546
- dimLabel: A == null ? void 0 : A.dim
2547
- });
2548
- },
2549
- children: l.map((w) => /* @__PURE__ */ e(B, { fill: w.other ? "#94a3b8" : Xe }, w.dim))
2550
- }
2551
- ),
2552
- C && /* @__PURE__ */ e(
2553
- pe,
2554
- {
2555
- yAxisId: M ? void 0 : "right",
2556
- type: "monotone",
2557
- dataKey: "value2",
2558
- stroke: "#8b5cf6",
2559
- strokeWidth: 1.5,
2560
- dot: !1,
2561
- name: $
2562
- }
2563
- )
2564
- ]
2565
- }
2566
- ) });
2567
- } }) });
2437
+ const A = ((_t = a.config) == null ? void 0 : _t.orientation) === "horizontal";
2438
+ G = /* @__PURE__ */ e(
2439
+ ia,
2440
+ {
2441
+ labels: A ? l.map((U) => U.dim) : [],
2442
+ className: "min-h-[110px] flex-1 text-slate-500 dark:text-slate-400",
2443
+ children: (U) => /* @__PURE__ */ e(Pe, { fallback: /* @__PURE__ */ e(Ee, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2444
+ Bar: z,
2445
+ Cell: O,
2446
+ ComposedChart: he,
2447
+ Line: te,
2448
+ ReferenceLine: r,
2449
+ ResponsiveContainer: d,
2450
+ Tooltip: x,
2451
+ XAxis: v,
2452
+ YAxis: C
2453
+ }) => {
2454
+ var M;
2455
+ return /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
2456
+ he,
2457
+ {
2458
+ data: l,
2459
+ layout: A ? "vertical" : "horizontal",
2460
+ margin: { top: 6, right: 8, left: A ? 0 : -10, bottom: 0 },
2461
+ children: [
2462
+ A ? /* @__PURE__ */ o(We, { children: [
2463
+ /* @__PURE__ */ e(v, { type: "number", tick: { fontSize: 10 }, stroke: "#94a3b8" }),
2464
+ /* @__PURE__ */ e(C, { type: "category", dataKey: "dim", stroke: "#94a3b8", ...U })
2465
+ ] }) : /* @__PURE__ */ o(We, { children: [
2466
+ /* @__PURE__ */ e(
2467
+ v,
2468
+ {
2469
+ dataKey: "dim",
2470
+ tick: { fontSize: 10 },
2471
+ stroke: "#94a3b8",
2472
+ ...Mt(l.length)
2473
+ }
2474
+ ),
2475
+ /* @__PURE__ */ e(
2476
+ C,
2477
+ {
2478
+ tick: { fontSize: 10 },
2479
+ stroke: "#94a3b8",
2480
+ tickFormatter: $e,
2481
+ width: 44
2482
+ }
2483
+ ),
2484
+ _ && /* @__PURE__ */ e(
2485
+ C,
2486
+ {
2487
+ yAxisId: "right",
2488
+ orientation: "right",
2489
+ tick: { fontSize: 10 },
2490
+ stroke: "#94a3b8",
2491
+ tickFormatter: $e,
2492
+ width: 44
2493
+ }
2494
+ )
2495
+ ] }),
2496
+ !A && ee.map((B) => /* @__PURE__ */ e(
2497
+ r,
2498
+ {
2499
+ x: B.anchor_date,
2500
+ stroke: "#f59e0b",
2501
+ strokeDasharray: "4 3",
2502
+ label: { value: "✎", position: "top", fontSize: 11, fill: "#f59e0b" }
2503
+ },
2504
+ B.id
2505
+ )),
2506
+ /* @__PURE__ */ e(
2507
+ x,
2508
+ {
2509
+ contentStyle: {
2510
+ fontSize: 12,
2511
+ backgroundColor: "#0f172a",
2512
+ border: "1px solid #334155",
2513
+ borderRadius: 8,
2514
+ color: "#f1f5f9"
2515
+ },
2516
+ labelStyle: { color: "#f1f5f9" },
2517
+ itemStyle: { color: "#e2e8f0" }
2518
+ }
2519
+ ),
2520
+ ((M = a.config) == null ? void 0 : M.compare) && /* @__PURE__ */ e(z, { dataKey: "prev", fill: "#cbd5e1", radius: [3, 3, 0, 0], name: "previous" }),
2521
+ /* @__PURE__ */ e(
2522
+ z,
2523
+ {
2524
+ dataKey: "value",
2525
+ fill: et,
2526
+ radius: [3, 3, 0, 0],
2527
+ className: a.collection ? "cursor-pointer" : void 0,
2528
+ onClick: (B) => {
2529
+ var De;
2530
+ if (!a.collection) return;
2531
+ const D = B == null ? void 0 : B.payload;
2532
+ if (D != null && D.other) return;
2533
+ const fe = (De = a.config) == null ? void 0 : De.dimension;
2534
+ ie({
2535
+ conditions: Tt(
2536
+ a,
2537
+ c,
2538
+ s,
2539
+ (D == null ? void 0 : D.raw) ?? (D == null ? void 0 : D.dim)
2540
+ ),
2541
+ title: `${a.title || a.collection} — ${(D == null ? void 0 : D.dim) ?? ""}`,
2542
+ dimField: fe != null && fe.bucket || fe == null ? void 0 : fe.field,
2543
+ dimRaw: (D == null ? void 0 : D.raw) ?? (D == null ? void 0 : D.dim),
2544
+ dimLabel: D == null ? void 0 : D.dim
2545
+ });
2546
+ },
2547
+ children: l.map((B) => /* @__PURE__ */ e(O, { fill: B.other ? "#94a3b8" : et }, B.dim))
2548
+ }
2549
+ ),
2550
+ _ && /* @__PURE__ */ e(
2551
+ te,
2552
+ {
2553
+ yAxisId: A ? void 0 : "right",
2554
+ type: "monotone",
2555
+ dataKey: "value2",
2556
+ stroke: "#8b5cf6",
2557
+ strokeWidth: 1.5,
2558
+ dot: !1,
2559
+ name: $
2560
+ }
2561
+ )
2562
+ ]
2563
+ }
2564
+ ) });
2565
+ } })
2566
+ }
2567
+ );
2568
2568
  }
2569
2569
  }
2570
- return D && p && (V = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
2571
- /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-amber-700 dark:text-amber-400", children: p.value == null ? "—" : qe(p.value, ie) }),
2570
+ return K && p && (G = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
2571
+ /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-amber-700 dark:text-amber-400", children: p.value == null ? "—" : Ae(p.value, ce) }),
2572
2572
  /* @__PURE__ */ o("p", { className: "text-[10.5px] text-slate-400", children: [
2573
2573
  "As of ",
2574
2574
  p.name,
@@ -2579,21 +2579,21 @@ const Dt = Wa(function({
2579
2579
  {
2580
2580
  ref: Y,
2581
2581
  className: "flex min-h-0 flex-col overflow-hidden rounded-lg border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
2582
- style: it,
2582
+ style: dt,
2583
2583
  children: [
2584
2584
  /* @__PURE__ */ o("div", { className: "mb-1.5 flex items-center gap-1.5", "data-widget-image-ignore": "", children: [
2585
2585
  (() => {
2586
2586
  var i;
2587
2587
  const l = (i = a.config) == null ? void 0 : i.link_report;
2588
- return l != null && l.report_id && k ? /* @__PURE__ */ o(
2588
+ return l != null && l.report_id && N ? /* @__PURE__ */ o(
2589
2589
  "a",
2590
2590
  {
2591
- href: k(l.report_id),
2591
+ href: N(l.report_id),
2592
2592
  onClick: () => {
2593
2593
  try {
2594
2594
  sessionStorage.setItem(
2595
2595
  `nvr-report-xf:${l.report_id}`,
2596
- JSON.stringify(Z ?? [])
2596
+ JSON.stringify(H ?? [])
2597
2597
  );
2598
2598
  } catch {
2599
2599
  }
@@ -2610,21 +2610,21 @@ const Dt = Wa(function({
2610
2610
  /* @__PURE__ */ e(
2611
2611
  "span",
2612
2612
  {
2613
- "data-tip": Ut(a),
2613
+ "data-tip": Jt(a),
2614
2614
  className: "shrink-0 cursor-help text-slate-300 hover:text-slate-500",
2615
2615
  children: /* @__PURE__ */ e(Oa, { className: "h-3 w-3" })
2616
2616
  }
2617
2617
  ),
2618
2618
  /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-0.5", children: [
2619
2619
  /* @__PURE__ */ e(
2620
- pl,
2620
+ hl,
2621
2621
  {
2622
2622
  getTarget: () => Y.current,
2623
2623
  label: () => {
2624
2624
  var l;
2625
2625
  return {
2626
2626
  title: a.title || a.collection || "Report widget",
2627
- asOf: Oe || Date.now(),
2627
+ asOf: Ke || Date.now(),
2628
2628
  dateRange: s,
2629
2629
  entityFilters: c,
2630
2630
  widgetRules: (l = a.config) == null ? void 0 : l.filters
@@ -2637,12 +2637,12 @@ const Dt = Wa(function({
2637
2637
  "button",
2638
2638
  {
2639
2639
  type: "button",
2640
- title: fe ? "Back to the chart" : "View as table (#383)",
2640
+ title: xe ? "Back to the chart" : "View as table (#383)",
2641
2641
  className: P(
2642
2642
  "rounded p-0.5",
2643
- fe ? "text-[#00a5cc]" : "text-slate-300 hover:text-[#00a5cc]"
2643
+ xe ? "text-[#00a5cc]" : "text-slate-300 hover:text-[#00a5cc]"
2644
2644
  ),
2645
- onClick: () => re((l) => !l),
2645
+ onClick: () => se((l) => !l),
2646
2646
  children: /* @__PURE__ */ e(Ka, { className: "h-3 w-3" })
2647
2647
  }
2648
2648
  ),
@@ -2650,31 +2650,31 @@ const Dt = Wa(function({
2650
2650
  "button",
2651
2651
  {
2652
2652
  type: "button",
2653
- title: Me ? "Explain the trend" : "Explain this number",
2654
- "data-explain-trend": Me ? "1" : void 0,
2653
+ title: Ce ? "Explain the trend" : "Explain this number",
2654
+ "data-explain-trend": Ce ? "1" : void 0,
2655
2655
  className: "rounded p-0.5 text-slate-300 hover:text-[#00a5cc]",
2656
2656
  onClick: () => {
2657
- if (oe) {
2658
- me(!1);
2657
+ if (de) {
2658
+ pe(!1);
2659
2659
  return;
2660
2660
  }
2661
- if (me(!0), ge || j) return;
2662
- if (he(!0), Me) {
2663
- F.request(
2664
- at(`/report-studio/${n}/widgets/${a.id}/explain-trend`, {
2661
+ if (pe(!0), ke || I) return;
2662
+ if (ae(!0), Ce) {
2663
+ q.request(
2664
+ rt(`/report-studio/${n}/widgets/${a.id}/explain-trend`, {
2665
2665
  date_range: s,
2666
2666
  entity_filters: c
2667
2667
  })
2668
2668
  ).then((i) => {
2669
- S(i.data.explanation || "No explanation available."), Fe(i.data.movers ?? null);
2669
+ w(i.data.explanation || "No explanation available."), Le(i.data.movers ?? null);
2670
2670
  }).catch(
2671
- (i) => S(
2671
+ (i) => w(
2672
2672
  (i == null ? void 0 : i.status) === 503 ? "AI is not configured on this instance." : (i == null ? void 0 : i.status) === 400 ? i.message ?? "Not enough data to describe a trend." : "AI is not configured or unavailable."
2673
2673
  )
2674
- ).finally(() => he(!1));
2674
+ ).finally(() => ae(!1));
2675
2675
  return;
2676
2676
  }
2677
- (T ? Promise.resolve(T) : F.request(
2677
+ (R ? Promise.resolve(R) : q.request(
2678
2678
  Ct(n, a.id, {
2679
2679
  date_range: s,
2680
2680
  entity_filters: c
@@ -2683,7 +2683,7 @@ const Dt = Wa(function({
2683
2683
  })).then((i) => {
2684
2684
  const b = {
2685
2685
  widget: a.title,
2686
- how_computed: Ut(a),
2686
+ how_computed: Jt(a),
2687
2687
  value: (i == null ? void 0 : i.value) ?? null,
2688
2688
  previous_value: (i == null ? void 0 : i.prev_value) ?? null,
2689
2689
  change_pct: (i == null ? void 0 : i.change_pct) ?? null,
@@ -2691,35 +2691,35 @@ const Dt = Wa(function({
2691
2691
  series: ((i == null ? void 0 : i.series) ?? []).slice(0, 15),
2692
2692
  rows: ((i == null ? void 0 : i.rows) ?? []).slice(0, 10),
2693
2693
  tiles: (i == null ? void 0 : i.tiles) ?? null
2694
- }, C = (i == null ? void 0 : i.prev_value) != null || ((i == null ? void 0 : i.series) ?? []).some(($) => $.prev != null);
2695
- return F.request(
2696
- at("/ai/brief", {
2694
+ }, _ = (i == null ? void 0 : i.prev_value) != null || ((i == null ? void 0 : i.series) ?? []).some(($) => $.prev != null);
2695
+ return q.request(
2696
+ rt("/ai/brief", {
2697
2697
  context: JSON.stringify(b),
2698
2698
  // `template` picks the server's prompt; `instructions` (the same
2699
2699
  // text) keeps an older API answering the same way.
2700
- template: C ? "report-compare" : "report-explain",
2701
- instructions: C ? "Compare the current period against the previous one in 2-4 plain sentences: overall direction, the biggest movers up and down, and anything anomalous. No preamble." : "In 2-3 plain sentences, explain what this report metric shows and what stands out (biggest contributor, direction of change). No preamble."
2700
+ template: _ ? "report-compare" : "report-explain",
2701
+ instructions: _ ? "Compare the current period against the previous one in 2-4 plain sentences: overall direction, the biggest movers up and down, and anything anomalous. No preamble." : "In 2-3 plain sentences, explain what this report metric shows and what stands out (biggest contributor, direction of change). No preamble."
2702
2702
  })
2703
2703
  );
2704
2704
  }).then((i) => {
2705
- var C, $;
2706
- const b = ((C = i.data) == null ? void 0 : C.brief) ?? (($ = i.data) == null ? void 0 : $.text) ?? null;
2707
- S(b || "No explanation available.");
2708
- }).catch(() => S("AI is not configured or unavailable.")).finally(() => he(!1));
2705
+ var _, $;
2706
+ const b = ((_ = i.data) == null ? void 0 : _.brief) ?? (($ = i.data) == null ? void 0 : $.text) ?? null;
2707
+ w(b || "No explanation available.");
2708
+ }).catch(() => w("AI is not configured or unavailable.")).finally(() => ae(!1));
2709
2709
  },
2710
2710
  children: /* @__PURE__ */ e(Wt, { className: "h-3 w-3" })
2711
2711
  }
2712
2712
  ),
2713
- ((He = (Ge = a.config) == null ? void 0 : Ge.dimension) == null ? void 0 : He.bucket) && /* @__PURE__ */ e(
2713
+ ((Ie = (Ze = a.config) == null ? void 0 : Ze.dimension) == null ? void 0 : Ie.bucket) && /* @__PURE__ */ e(
2714
2714
  "button",
2715
2715
  {
2716
2716
  type: "button",
2717
- title: te ? "Show per-period values" : "Show running total",
2717
+ title: le ? "Show per-period values" : "Show running total",
2718
2718
  className: P(
2719
2719
  "rounded p-0.5",
2720
- te ? "text-[#00a5cc]" : "text-slate-300 hover:text-slate-500"
2720
+ le ? "text-[#00a5cc]" : "text-slate-300 hover:text-slate-500"
2721
2721
  ),
2722
- onClick: () => U((l) => !l),
2722
+ onClick: () => V((l) => !l),
2723
2723
  children: /* @__PURE__ */ e(Da, { className: "h-3 w-3" })
2724
2724
  }
2725
2725
  ),
@@ -2730,7 +2730,7 @@ const Dt = Wa(function({
2730
2730
  title: "Notes on this widget",
2731
2731
  className: P(
2732
2732
  "relative rounded p-0.5",
2733
- ((O == null ? void 0 : O.length) ?? 0) > 0 ? "text-amber-500" : "text-slate-300 hover:text-slate-500"
2733
+ ((L == null ? void 0 : L.length) ?? 0) > 0 ? "text-amber-500" : "text-slate-300 hover:text-slate-500"
2734
2734
  ),
2735
2735
  onClick: () => Ne((l) => !l),
2736
2736
  children: /* @__PURE__ */ e(Pa, { className: "h-3 w-3" })
@@ -2743,20 +2743,20 @@ const Dt = Wa(function({
2743
2743
  title: "Download as CSV",
2744
2744
  className: "rounded p-0.5 text-slate-300 hover:text-slate-500",
2745
2745
  onClick: () => {
2746
- if (!(ye != null && ye.slug)) {
2747
- Yt(a, T);
2746
+ if (!(ve != null && ve.slug)) {
2747
+ Vt(a, R);
2748
2748
  return;
2749
2749
  }
2750
- const l = ye, i = Kt(l, s, c);
2751
- rt.fetchQuery({
2750
+ const l = ve, i = Kt(l, s, c);
2751
+ Oe.fetchQuery({
2752
2752
  queryKey: ["nivaro-report-query", l.slug, i],
2753
- queryFn: () => fa(F, l.slug, i),
2753
+ queryFn: () => xa(q, l.slug, i),
2754
2754
  staleTime: 6e4
2755
- }).then((b) => Yt(a, void 0, ha(l, b))).catch((b) => {
2756
- Ta(b) || aa.error(Ot(b, "this widget"));
2755
+ }).then((b) => Vt(a, void 0, fa(l, b))).catch((b) => {
2756
+ La(b) || aa.error(Ot(b, "this widget"));
2757
2757
  });
2758
2758
  },
2759
- children: /* @__PURE__ */ e(za, { className: "h-3 w-3" })
2759
+ children: /* @__PURE__ */ e(Ea, { className: "h-3 w-3" })
2760
2760
  }
2761
2761
  ),
2762
2762
  /* @__PURE__ */ e(Ll, { reportId: n, widget: a, filterBar: h }),
@@ -2766,14 +2766,14 @@ const Dt = Wa(function({
2766
2766
  type: "button",
2767
2767
  title: "Refresh",
2768
2768
  className: "rounded p-0.5 text-slate-300 hover:text-slate-500",
2769
- onClick: () => ot(),
2770
- children: /* @__PURE__ */ e(At, { className: P("h-3 w-3", Mt && "animate-spin") })
2769
+ onClick: () => it(),
2770
+ children: /* @__PURE__ */ e(At, { className: P("h-3 w-3", Ft && "animate-spin") })
2771
2771
  }
2772
2772
  )
2773
2773
  ] })
2774
2774
  ] }),
2775
- xe && /* @__PURE__ */ o("div", { className: "mb-1.5 space-y-1 rounded-md border border-amber-200 bg-amber-50/60 p-2 dark:border-amber-500/30 dark:bg-amber-500/10", children: [
2776
- (O ?? []).map((l) => /* @__PURE__ */ o(
2775
+ be && /* @__PURE__ */ o("div", { className: "mb-1.5 space-y-1 rounded-md border border-amber-200 bg-amber-50/60 p-2 dark:border-amber-500/30 dark:bg-amber-500/10", children: [
2776
+ (L ?? []).map((l) => /* @__PURE__ */ o(
2777
2777
  "div",
2778
2778
  {
2779
2779
  className: "group/note flex items-start gap-1.5 text-[11px] text-slate-600 dark:text-slate-300",
@@ -2793,20 +2793,20 @@ const Dt = Wa(function({
2793
2793
  type: "button",
2794
2794
  onClick: () => Q(l.id),
2795
2795
  className: "shrink-0 rounded p-0.5 text-slate-300 opacity-0 hover:text-red-500 group-hover/note:opacity-100",
2796
- children: /* @__PURE__ */ e(Te, { className: "h-2.5 w-2.5" })
2796
+ children: /* @__PURE__ */ e(Re, { className: "h-2.5 w-2.5" })
2797
2797
  }
2798
2798
  )
2799
2799
  ]
2800
2800
  },
2801
2801
  l.id
2802
2802
  )),
2803
- (O ?? []).length === 0 && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: "No notes yet — record why a number moved." }),
2803
+ (L ?? []).length === 0 && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: "No notes yet — record why a number moved." }),
2804
2804
  y && /* @__PURE__ */ o("div", { className: "flex items-center gap-1 pt-0.5", children: [
2805
2805
  /* @__PURE__ */ e(
2806
2806
  "input",
2807
2807
  {
2808
- value: we,
2809
- onChange: (l) => $e(l.target.value),
2808
+ value: ye,
2809
+ onChange: (l) => qe(l.target.value),
2810
2810
  placeholder: "Add a note…",
2811
2811
  className: "h-6 min-w-0 flex-1 rounded border border-amber-200 bg-white px-1.5 text-[11px] dark:border-amber-500/30 dark:bg-card dark:text-slate-200"
2812
2812
  }
@@ -2825,9 +2825,9 @@ const Dt = Wa(function({
2825
2825
  "button",
2826
2826
  {
2827
2827
  type: "button",
2828
- disabled: !we.trim(),
2828
+ disabled: !ye.trim(),
2829
2829
  onClick: () => {
2830
- y(a.id, we.trim(), f.trim() || null), $e(""), X("");
2830
+ y(a.id, ye.trim(), f.trim() || null), qe(""), X("");
2831
2831
  },
2832
2832
  className: "h-6 rounded bg-amber-500 px-2 text-[11px] font-medium text-white hover:brightness-105 disabled:opacity-40",
2833
2833
  children: "Add"
@@ -2836,7 +2836,7 @@ const Dt = Wa(function({
2836
2836
  ] })
2837
2837
  ] }),
2838
2838
  p && (() => {
2839
- const l = Kl(T), i = p.value;
2839
+ const l = Kl(R), i = p.value;
2840
2840
  if (l == null || i == null) return null;
2841
2841
  const b = i === 0 ? null : (l - i) / Math.abs(i) * 100;
2842
2842
  return /* @__PURE__ */ o("p", { className: "mb-1 flex items-center gap-1 text-[10.5px] text-slate-400", children: [
@@ -2860,14 +2860,14 @@ const Dt = Wa(function({
2860
2860
  )
2861
2861
  ] });
2862
2862
  })(),
2863
- oe && /* @__PURE__ */ o(
2863
+ de && /* @__PURE__ */ o(
2864
2864
  "div",
2865
2865
  {
2866
2866
  className: "mb-1.5 rounded-md border border-nvr-cyan/25 bg-nvr-cyan/5 px-2.5 py-1.5 text-[11.5px] leading-snug text-slate-600 dark:text-slate-300",
2867
- "data-explain-panel": Me ? "trend" : "number",
2867
+ "data-explain-panel": Ce ? "trend" : "number",
2868
2868
  children: [
2869
- j ? "Thinking…" : ge,
2870
- !j && ve && ve.length > 0 && /* @__PURE__ */ e("div", { className: "mt-1.5 flex flex-wrap gap-1", "data-explain-movers": !0, children: ve.slice(0, 4).map((l) => /* @__PURE__ */ o(
2869
+ I ? "Thinking…" : ke,
2870
+ !I && we && we.length > 0 && /* @__PURE__ */ e("div", { className: "mt-1.5 flex flex-wrap gap-1", "data-explain-movers": !0, children: we.slice(0, 4).map((l) => /* @__PURE__ */ o(
2871
2871
  "span",
2872
2872
  {
2873
2873
  className: P(
@@ -2893,64 +2893,64 @@ const Dt = Wa(function({
2893
2893
  ]
2894
2894
  }
2895
2895
  ),
2896
- ae.length > 0 && /* @__PURE__ */ o("div", { className: "mb-1 flex flex-wrap items-center gap-1 text-[10.5px] text-slate-500", children: [
2896
+ re.length > 0 && /* @__PURE__ */ o("div", { className: "mb-1 flex flex-wrap items-center gap-1 text-[10.5px] text-slate-500", children: [
2897
2897
  /* @__PURE__ */ e(
2898
2898
  "button",
2899
2899
  {
2900
2900
  type: "button",
2901
- onClick: () => N([]),
2901
+ onClick: () => k([]),
2902
2902
  className: "rounded px-1 hover:bg-muted",
2903
2903
  children: "⌂ All"
2904
2904
  }
2905
2905
  ),
2906
- ae.map((l, i) => /* @__PURE__ */ o("span", { className: "flex items-center gap-1", children: [
2906
+ re.map((l, i) => /* @__PURE__ */ o("span", { className: "flex items-center gap-1", children: [
2907
2907
  /* @__PURE__ */ e("span", { className: "text-slate-300", children: "›" }),
2908
2908
  /* @__PURE__ */ e(
2909
2909
  "button",
2910
2910
  {
2911
2911
  type: "button",
2912
- onClick: () => N(ae.slice(0, i + 1)),
2912
+ onClick: () => k(re.slice(0, i + 1)),
2913
2913
  className: "rounded bg-nvr-cyan/[0.08] px-1.5 py-0.5 font-medium text-[#007a99] dark:text-nvr-cyan",
2914
2914
  children: l.value
2915
2915
  }
2916
2916
  )
2917
2917
  ] }, `${l.field}-${i}`))
2918
2918
  ] }),
2919
- /* @__PURE__ */ e("div", { ref: R, className: "flex min-h-0 flex-1 flex-col", children: fe && ((ht = T == null ? void 0 : T.series) != null && ht.length) ? /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[11.5px]", children: [
2919
+ /* @__PURE__ */ e("div", { ref: F, className: "flex min-h-0 flex-1 flex-col", children: xe && ((ft = R == null ? void 0 : R.series) != null && ft.length) ? /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[11.5px]", children: [
2920
2920
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ o("tr", { className: "text-left text-[10px] uppercase tracking-wide text-slate-400", children: [
2921
2921
  /* @__PURE__ */ e("th", { className: "px-1.5 pb-1", children: "Dimension" }),
2922
2922
  /* @__PURE__ */ e("th", { className: "px-1.5 pb-1 text-right", children: "Value" })
2923
2923
  ] }) }),
2924
- /* @__PURE__ */ e("tbody", { children: (T.series ?? []).map((l) => /* @__PURE__ */ o("tr", { className: "border-b border-slate-50 dark:border-border/40", children: [
2924
+ /* @__PURE__ */ e("tbody", { children: (R.series ?? []).map((l) => /* @__PURE__ */ o("tr", { className: "border-b border-slate-50 dark:border-border/40", children: [
2925
2925
  /* @__PURE__ */ e("td", { className: "max-w-[220px] truncate px-1.5 py-1 text-slate-700 dark:text-slate-300", children: l.dim }),
2926
- /* @__PURE__ */ e("td", { className: "px-1.5 py-1 text-right tabular-nums text-slate-800 dark:text-slate-100", children: qe(l.value, ie) })
2926
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-1 text-right tabular-nums text-slate-800 dark:text-slate-100", children: Ae(l.value, ce) })
2927
2927
  ] }, l.dim)) })
2928
- ] }) }) : V }),
2929
- (ye == null ? void 0 : ye.slug) && E && /* @__PURE__ */ e(
2928
+ ] }) }) : G }),
2929
+ (ve == null ? void 0 : ve.slug) && j && /* @__PURE__ */ e(
2930
2930
  ql,
2931
2931
  {
2932
- slug: ye.slug,
2933
- params: Kt(ye, s, c),
2932
+ slug: ve.slug,
2933
+ params: Kt(ve, s, c),
2934
2934
  scope: `report:${n}`
2935
2935
  }
2936
2936
  ),
2937
- ((ft = a.config) == null ? void 0 : ft.footnote) && /* @__PURE__ */ e("p", { className: "mt-1 border-t border-slate-100 pt-1 text-[10.5px] leading-snug text-slate-400 dark:border-border/50", children: a.config.footnote }),
2937
+ ((xt = a.config) == null ? void 0 : xt.footnote) && /* @__PURE__ */ e("p", { className: "mt-1 border-t border-slate-100 pt-1 text-[10.5px] leading-snug text-slate-400 dark:border-border/50", children: a.config.footnote }),
2938
2938
  W && /* @__PURE__ */ e(
2939
2939
  Dl,
2940
2940
  {
2941
2941
  collection: a.collection ?? "",
2942
2942
  conditions: W.conditions,
2943
2943
  title: W.title,
2944
- onClose: () => se(null),
2944
+ onClose: () => ie(null),
2945
2945
  onOpen: (l) => {
2946
- se(null), g == null || g(l);
2946
+ ie(null), g == null || g(l);
2947
2947
  },
2948
2948
  crossFilter: m && W.dimField && W.dimRaw != null ? () => {
2949
2949
  m(
2950
2950
  W.dimField,
2951
2951
  W.dimRaw,
2952
2952
  W.dimLabel ?? String(W.dimRaw)
2953
- ), se(null);
2953
+ ), ie(null);
2954
2954
  } : void 0
2955
2955
  }
2956
2956
  )
@@ -2958,7 +2958,7 @@ const Dt = Wa(function({
2958
2958
  }
2959
2959
  );
2960
2960
  });
2961
- function pr({
2961
+ function hr({
2962
2962
  reportId: t,
2963
2963
  widget: n,
2964
2964
  dateRange: a = null,
@@ -2967,7 +2967,7 @@ function pr({
2967
2967
  const c = la(), u = gt(
2968
2968
  (g) => c == null ? void 0 : c.open(g),
2969
2969
  [c]
2970
- ), h = tt(() => ({ ...n, x: 0 }), [n]);
2970
+ ), h = lt(() => ({ ...n, x: 0 }), [n]);
2971
2971
  return /* @__PURE__ */ e(
2972
2972
  Dt,
2973
2973
  {
@@ -2980,14 +2980,10 @@ function pr({
2980
2980
  );
2981
2981
  }
2982
2982
  function Pl(t) {
2983
- const n = t == null ? "" : String(t);
2984
- return n.length > 24 ? `${n.slice(0, 23)}…` : n;
2985
- }
2986
- function zl(t) {
2987
2983
  const n = t;
2988
2984
  return !(n != null && n.admin) || !n.access_scope_label ? null : `(your access scope: ${n.access_scope_label})`;
2989
2985
  }
2990
- function hr({
2986
+ function fr({
2991
2987
  reportId: t,
2992
2988
  showFilterBar: n = !0,
2993
2989
  dateRange: a,
@@ -2997,11 +2993,11 @@ function hr({
2997
2993
  emptyState: h,
2998
2994
  reportUrl: g
2999
2995
  }) {
3000
- var pe, ee;
3001
- const p = Le(), D = la(), O = Qa("drill.report"), y = O.value, Q = gt(
3002
- (r) => D ? D.open(r) : O.push([r]),
3003
- [D, O.push]
3004
- ), [m, k] = _(void 0), [Z, F] = _(s), [H, z] = _(void 0), [ue, J] = _(s), { scopes: W, ready: se } = na(), [xe, Ne] = _(!1), [we, $e] = _({}), f = lt(), { data: X = [] } = Se({
2996
+ var he, te;
2997
+ const p = Te(), K = la(), L = Qa("drill.report"), y = L.value, Q = gt(
2998
+ (r) => K ? K.open(r) : L.push([r]),
2999
+ [K, L.push]
3000
+ ), [m, N] = S(void 0), [H, q] = S(s), [Z, E] = S(void 0), [me, J] = S(s), { scopes: W, ready: ie } = na(), [be, Ne] = S(!1), [ye, qe] = S({}), f = nt(), { data: X = [] } = _e({
3005
3001
  queryKey: ["nivaro-report-presets", t],
3006
3002
  queryFn: async () => {
3007
3003
  try {
@@ -3009,7 +3005,7 @@ function hr({
3009
3005
  if (Array.isArray(r) && r.length > 0) {
3010
3006
  for (const d of r)
3011
3007
  d != null && d.name && await p.request(
3012
- Et(t, {
3008
+ jt(t, {
3013
3009
  name: String(d.name),
3014
3010
  date_range: d.date_range ?? null,
3015
3011
  entity_filters: d.entity_filters ?? []
@@ -3020,29 +3016,29 @@ function hr({
3020
3016
  }
3021
3017
  } catch {
3022
3018
  }
3023
- return p.request(ka(t)).then((r) => r.data);
3019
+ return p.request(Na(t)).then((r) => r.data);
3024
3020
  },
3025
3021
  staleTime: 6e4
3026
- }), te = () => void f.invalidateQueries({ queryKey: ["nivaro-report-presets", t] }), U = Ae({
3022
+ }), le = () => void f.invalidateQueries({ queryKey: ["nivaro-report-presets", t] }), V = Me({
3027
3023
  mutationFn: (r) => p.request(
3028
- Et(t, {
3024
+ jt(t, {
3029
3025
  name: r,
3030
- date_range: ht.current ?? null,
3031
- entity_filters: ft.current
3026
+ date_range: ft.current ?? null,
3027
+ entity_filters: xt.current
3032
3028
  })
3033
3029
  ),
3034
- onSuccess: te
3035
- }), fe = Ae({
3036
- mutationFn: (r) => p.request(Na(t, r)),
3037
- onSuccess: te
3038
- }), [re, ae] = _(""), [N, R] = _(!1), [Y, E] = _(null), [oe, me] = _(!1), { data: ge = [] } = Se({
3030
+ onSuccess: le
3031
+ }), xe = Me({
3032
+ mutationFn: (r) => p.request(wa(t, r)),
3033
+ onSuccess: le
3034
+ }), [se, re] = S(""), [k, F] = S(!1), [Y, j] = S(null), [de, pe] = S(!1), { data: ke = [] } = _e({
3039
3035
  queryKey: ["nvr-report-snaps", t],
3040
3036
  queryFn: () => p.request(
3041
3037
  bt(`/report-studio/${t}/snapshots`)
3042
3038
  ).then((r) => r.data ?? []),
3043
3039
  staleTime: 6e4,
3044
3040
  retry: !1
3045
- }), { data: S } = Se({
3041
+ }), { data: w } = _e({
3046
3042
  queryKey: ["nvr-report-snap", t, Y],
3047
3043
  queryFn: () => p.request(
3048
3044
  bt(`/report-studio/${t}/snapshots/${Y}`)
@@ -3050,99 +3046,99 @@ function hr({
3050
3046
  enabled: Y != null,
3051
3047
  staleTime: 5 * 6e4,
3052
3048
  retry: !1
3053
- }), j = Ae({
3054
- mutationFn: () => p.request(at(`/report-studio/${t}/snapshots`, {})),
3049
+ }), I = Me({
3050
+ mutationFn: () => p.request(rt(`/report-studio/${t}/snapshots`, {})),
3055
3051
  onSuccess: () => void f.invalidateQueries({ queryKey: ["nvr-report-snaps", t] })
3056
- }), { data: he = [] } = Se({
3052
+ }), { data: ae = [] } = _e({
3057
3053
  queryKey: ["nvr-report-notes", t],
3058
3054
  queryFn: () => p.request(bt(`/report-studio/${t}/annotations`)).then((r) => r.data ?? []),
3059
3055
  staleTime: 6e4,
3060
3056
  retry: !1
3061
- }), ve = () => void f.invalidateQueries({ queryKey: ["nvr-report-notes", t] }), Fe = Ae({
3062
- mutationFn: (r) => p.request(at(`/report-studio/${t}/annotations`, r)),
3063
- onSuccess: ve
3064
- }), Me = Ae({
3065
- mutationFn: (r) => p.request(Ja(`/report-studio/${t}/annotations/${r}`)),
3066
- onSuccess: ve
3067
- }), rt = gt((r, d, x) => {
3057
+ }), we = () => void f.invalidateQueries({ queryKey: ["nvr-report-notes", t] }), Le = Me({
3058
+ mutationFn: (r) => p.request(rt(`/report-studio/${t}/annotations`, r)),
3059
+ onSuccess: we
3060
+ }), Ce = Me({
3061
+ mutationFn: (r) => p.request(Ua(`/report-studio/${t}/annotations/${r}`)),
3062
+ onSuccess: we
3063
+ }), Oe = gt((r, d, x) => {
3068
3064
  const v = {
3069
3065
  field: r,
3070
3066
  values: [d],
3071
3067
  labels: [x]
3072
3068
  };
3073
- F((q) => [...q.filter((w) => w.field !== r), v]), J((q) => [...q.filter((w) => w.field !== r), v]);
3074
- }, []), [be, Ee] = _(!1), [_e, Re] = _(null), [nt, je] = _(null), st = Ae({
3069
+ q((C) => [...C.filter((M) => M.field !== r), v]), J((C) => [...C.filter((M) => M.field !== r), v]);
3070
+ }, []), [ge, Be] = S(!1), [Se, Fe] = S(null), [st, Qe] = S(null), ot = Me({
3075
3071
  mutationFn: (r) => p.request(
3076
- Ua(`/report-studio/${t}/widgets`, {
3072
+ Ja(`/report-studio/${t}/widgets`, {
3077
3073
  widgets: r.map((d, x) => ({ ...d, sort: x }))
3078
3074
  })
3079
3075
  ),
3080
3076
  onSuccess: () => {
3081
- Ee(!1), Re(null), je(null), f.invalidateQueries({ queryKey: ["nivaro-report", t] }), f.invalidateQueries({ queryKey: ["nivaro-report-widget"] });
3077
+ Be(!1), Fe(null), Qe(null), f.invalidateQueries({ queryKey: ["nivaro-report", t] }), f.invalidateQueries({ queryKey: ["nivaro-report-widget"] });
3082
3078
  }
3083
- }), We = (r) => [...r].sort((d, x) => (d.y ?? 0) - (x.y ?? 0) || (d.x ?? 0) - (x.x ?? 0)), [ot, Mt] = _(() => /* @__PURE__ */ new Date()), [Oe, Be] = Ga(`report:${t}`), vt = () => {
3084
- f.invalidateQueries({ queryKey: ["nivaro-report-widget", t] }), f.invalidateQueries({ queryKey: ["nivaro-report-query"] }), Mt(/* @__PURE__ */ new Date());
3085
- }, { data: T = [] } = Se({
3079
+ }), Ue = (r) => [...r].sort((d, x) => (d.y ?? 0) - (x.y ?? 0) || (d.x ?? 0) - (x.x ?? 0)), [it, Ft] = S(() => /* @__PURE__ */ new Date()), [Ke, Je] = Ga(`report:${t}`), vt = () => {
3080
+ f.invalidateQueries({ queryKey: ["nivaro-report-widget", t] }), f.invalidateQueries({ queryKey: ["nivaro-report-query"] }), Ft(/* @__PURE__ */ new Date());
3081
+ }, { data: R = [] } = _e({
3086
3082
  queryKey: ["nvr-report-firing", t],
3087
3083
  queryFn: () => p.request(bt(`/report-studio/${t}/firing`)).then((r) => r.data ?? []).catch(() => []),
3088
3084
  staleTime: 6e4,
3089
3085
  refetchInterval: 5 * 6e4,
3090
3086
  retry: !1
3091
- }), [ie, it] = _(null), [Qe, ye] = _(!1), [V, yt] = _(""), [Je, kt] = _(""), [Ue, Nt] = _("");
3092
- Ze(() => {
3087
+ }), [ce, dt] = S(null), [Ve, ve] = S(!1), [G, yt] = S(""), [Ye, kt] = S(""), [Ge, Nt] = S("");
3088
+ tt(() => {
3093
3089
  try {
3094
3090
  const r = sessionStorage.getItem(`nvr-report-xf:${t}`);
3095
3091
  if (r) {
3096
3092
  sessionStorage.removeItem(`nvr-report-xf:${t}`);
3097
3093
  const d = JSON.parse(r);
3098
- Array.isArray(d) && d.length > 0 && (F(d), J(d));
3094
+ Array.isArray(d) && d.length > 0 && (q(d), J(d));
3099
3095
  }
3100
3096
  } catch {
3101
3097
  }
3102
3098
  }, [t]);
3103
3099
  const wt = () => {
3104
- Re(We((ne == null ? void 0 : ne.widgets) ?? [])), Ee(!0), window.__nvrReportId = t;
3105
- }, dt = (r) => Re((d) => (d ?? []).map((x) => x.id === r.id ? r : x)), St = (r, d) => Re((x) => {
3106
- const v = [...x ?? []], q = v.findIndex((ke) => ke.id === r), w = q + d;
3107
- if (q < 0 || w < 0 || w >= v.length) return v;
3108
- const A = v[q], de = v[w];
3109
- return v[q] = { ...de, x: A.x, y: A.y }, v[w] = { ...A, x: de.x, y: de.y }, v;
3110
- }), [Ye, ct] = _(""), [Ve, ut] = _(!1), [mt, pt] = _(null), { data: ne, isLoading: _t } = Se({
3100
+ Fe(Ue((oe == null ? void 0 : oe.widgets) ?? [])), Be(!0), window.__nvrReportId = t;
3101
+ }, ct = (r) => Fe((d) => (d ?? []).map((x) => x.id === r.id ? r : x)), St = (r, d) => Fe((x) => {
3102
+ const v = [...x ?? []], C = v.findIndex((fe) => fe.id === r), M = C + d;
3103
+ if (C < 0 || M < 0 || M >= v.length) return v;
3104
+ const B = v[C], D = v[M];
3105
+ return v[C] = { ...D, x: B.x, y: B.y }, v[M] = { ...B, x: D.x, y: D.y }, v;
3106
+ }), [He, ut] = S(""), [Xe, mt] = S(!1), [pt, ht] = S(null), { data: oe, isLoading: _t } = _e({
3111
3107
  queryKey: ["nivaro-report", t],
3112
- queryFn: () => p.request(jt(t)).then((r) => r.data),
3108
+ queryFn: () => p.request(zt(t)).then((r) => r.data),
3113
3109
  staleTime: 3e4
3114
- }), Ge = Ie(!1), He = gt(async () => {
3110
+ }), Ze = at(!1), Ie = gt(async () => {
3115
3111
  var x;
3116
3112
  const r = (x = f.getQueryData(["nivaro-report", t])) == null ? void 0 : x.widgets, d = await f.fetchQuery({
3117
3113
  queryKey: ["nivaro-report", t],
3118
- queryFn: () => p.request(jt(t)).then((v) => v.data),
3114
+ queryFn: () => p.request(zt(t)).then((v) => v.data),
3119
3115
  staleTime: 0
3120
3116
  }).catch(() => null);
3121
3117
  if (d)
3122
- for (const v of Ya(
3118
+ for (const v of Va(
3123
3119
  r,
3124
3120
  d.widgets
3125
3121
  ))
3126
3122
  f.invalidateQueries({ queryKey: ["nivaro-report-widget", t, v] });
3127
3123
  }, [f, p, t]);
3128
- Va("report", t, {
3124
+ Ya("report", t, {
3129
3125
  onChange: () => {
3130
- be ? Ge.current = !0 : He();
3126
+ ge ? Ze.current = !0 : Ie();
3131
3127
  }
3132
- }), Ze(() => {
3133
- !be && Ge.current && (Ge.current = !1, He());
3134
- }, [be, He]);
3135
- const ht = Ie(null), ft = Ie([]), l = ((pe = ne == null ? void 0 : ne.global_filters) == null ? void 0 : pe.date_range) ?? null, i = tt(() => m !== void 0 ? m : a !== void 0 ? a : l, [m, a, l]);
3136
- ht.current = i ?? null, ft.current = Z;
3137
- const b = tt(
3128
+ }), tt(() => {
3129
+ !ge && Ze.current && (Ze.current = !1, Ie());
3130
+ }, [ge, Ie]);
3131
+ const ft = at(null), xt = at([]), l = ((he = oe == null ? void 0 : oe.global_filters) == null ? void 0 : he.date_range) ?? null, i = lt(() => m !== void 0 ? m : a !== void 0 ? a : l, [m, a, l]);
3132
+ ft.current = i ?? null, xt.current = H;
3133
+ const b = lt(
3138
3134
  () => {
3139
3135
  var r;
3140
- return ((r = ne == null ? void 0 : ne.global_filters) == null ? void 0 : r.filter_bar) ?? [];
3136
+ return ((r = oe == null ? void 0 : oe.global_filters) == null ? void 0 : r.filter_bar) ?? [];
3141
3137
  },
3142
- [(ee = ne == null ? void 0 : ne.global_filters) == null ? void 0 : ee.filter_bar]
3138
+ [(te = oe == null ? void 0 : oe.global_filters) == null ? void 0 : te.filter_bar]
3143
3139
  );
3144
- Ze(() => {
3145
- if (!xe && !(!se || !ne)) {
3140
+ tt(() => {
3141
+ if (!be && !(!ie || !oe)) {
3146
3142
  if (!W || b.length === 0) {
3147
3143
  Ne(!0);
3148
3144
  return;
@@ -3151,92 +3147,92 @@ function hr({
3151
3147
  var x;
3152
3148
  const r = [], d = {};
3153
3149
  for (const v of b) {
3154
- const q = rl(W, {
3150
+ const C = nl(W, {
3155
3151
  key: v.field,
3156
3152
  collection: (x = v.options) == null ? void 0 : x.collection
3157
3153
  });
3158
- if (!q) continue;
3159
- const w = v.options ? v.options.value_field ?? "id" : "id", A = W.restricted[q.name] ?? [];
3160
- if (A.length > 0) {
3161
- const ke = await Bt(p, q, A, w).catch(
3154
+ if (!C) continue;
3155
+ const M = v.options ? v.options.value_field ?? "id" : "id", B = W.restricted[C.name] ?? [];
3156
+ if (B.length > 0) {
3157
+ const fe = await Bt(p, C, B, M).catch(
3162
3158
  () => []
3163
3159
  );
3164
- ke.length > 0 && (d[v.field] = ke);
3160
+ fe.length > 0 && (d[v.field] = fe);
3165
3161
  }
3166
- const de = nl(W, q.name);
3167
- if (de.length > 0) {
3168
- const ke = await Bt(p, q, de, w).catch(
3162
+ const D = sl(W, C.name);
3163
+ if (D.length > 0) {
3164
+ const fe = await Bt(p, C, D, M).catch(
3169
3165
  () => []
3170
3166
  );
3171
- ke.length > 0 && r.push({ field: v.field, values: ke, labels: ke.map(String) });
3167
+ fe.length > 0 && r.push({ field: v.field, values: fe, labels: fe.map(String) });
3172
3168
  }
3173
3169
  }
3174
- if (Object.keys(d).length > 0 && $e(d), r.length > 0) {
3175
- const v = (q) => {
3176
- const w = [...q];
3177
- for (const A of r) w.some((de) => de.field === A.field) || w.push(A);
3178
- return w;
3170
+ if (Object.keys(d).length > 0 && qe(d), r.length > 0) {
3171
+ const v = (C) => {
3172
+ const M = [...C];
3173
+ for (const B of r) M.some((D) => D.field === B.field) || M.push(B);
3174
+ return M;
3179
3175
  };
3180
- J(v), F(v);
3176
+ J(v), q(v);
3181
3177
  }
3182
3178
  Ne(!0);
3183
3179
  })();
3184
3180
  }
3185
- }, [xe, se, ne, W, b]);
3186
- const C = (ne == null ? void 0 : ne.widgets) ?? [], $ = H !== void 0 ? H : i, L = Z.filter((r) => r.values.length > 0).length + (i ? 1 : 0), le = JSON.stringify(ue) !== JSON.stringify(Z) || H !== void 0, I = () => {
3187
- F(ue), H !== void 0 && (k(H), z(void 0));
3188
- }, M = () => {
3189
- J([]), F([]), k(null), z(void 0);
3190
- }, G = (r) => {
3191
- J(r.entity_filters), F(r.entity_filters), k(r.date_range), z(void 0);
3192
- }, B = async () => {
3181
+ }, [be, ie, oe, W, b]);
3182
+ const _ = (oe == null ? void 0 : oe.widgets) ?? [], $ = Z !== void 0 ? Z : i, T = H.filter((r) => r.values.length > 0).length + (i ? 1 : 0), ne = JSON.stringify(me) !== JSON.stringify(H) || Z !== void 0, ee = () => {
3183
+ q(me), Z !== void 0 && (N(Z), E(void 0));
3184
+ }, A = () => {
3185
+ J([]), q([]), N(null), E(void 0);
3186
+ }, U = (r) => {
3187
+ J(r.entity_filters), q(r.entity_filters), N(r.date_range), E(void 0);
3188
+ }, z = async () => {
3193
3189
  var d, x;
3194
- const r = Ye.trim();
3195
- if (!(!r || Ve)) {
3196
- ut(!0), pt(null);
3190
+ const r = He.trim();
3191
+ if (!(!r || Xe)) {
3192
+ mt(!0), ht(null);
3197
3193
  try {
3198
3194
  const v = await p.request(
3199
- Ca(
3195
+ $a(
3200
3196
  t,
3201
3197
  r,
3202
- b.map((w) => ({ field: w.field, label: w.label }))
3198
+ b.map((M) => ({ field: M.field, label: M.label }))
3203
3199
  )
3204
- ), q = (v.data.entity_filters ?? []).filter((w) => {
3205
- var A;
3206
- return b.some((de) => de.field === w.field) && ((A = w.values) == null ? void 0 : A.length) > 0;
3207
- }).map((w) => ({ field: w.field, values: w.values, labels: w.values.map(String) }));
3208
- J(q), F(q), k(v.data.date_range ?? null), z(void 0), ct("");
3200
+ ), C = (v.data.entity_filters ?? []).filter((M) => {
3201
+ var B;
3202
+ return b.some((D) => D.field === M.field) && ((B = M.values) == null ? void 0 : B.length) > 0;
3203
+ }).map((M) => ({ field: M.field, values: M.values, labels: M.values.map(String) }));
3204
+ J(C), q(C), N(v.data.date_range ?? null), E(void 0), ut("");
3209
3205
  } catch (v) {
3210
- pt(
3206
+ ht(
3211
3207
  ((x = (d = v.response) == null ? void 0 : d.data) == null ? void 0 : x.error) ?? "Could not parse that"
3212
3208
  );
3213
3209
  } finally {
3214
- ut(!1);
3210
+ mt(!1);
3215
3211
  }
3216
3212
  }
3217
3213
  };
3218
- if (_t || !xe)
3214
+ if (_t || !be)
3219
3215
  return /* @__PURE__ */ e("div", { className: P("p-6 text-[13px] text-slate-400", u), children: "Loading report…" });
3220
- if (!ne)
3216
+ if (!oe)
3221
3217
  return /* @__PURE__ */ e("div", { className: P("p-6 text-[13px] text-slate-400", u), children: "Report not found." });
3222
- const K = zl(W);
3223
- return /* @__PURE__ */ e(ga.Provider, { value: Oe, children: /* @__PURE__ */ o("div", { className: P("flex flex-col gap-3", u), children: [
3224
- K && (!n || C.length === 0 && b.length === 0) && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-amber-700 dark:text-amber-300", children: K }),
3225
- n && (C.length > 0 || b.length > 0) && /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
3218
+ const O = Pl(W);
3219
+ return /* @__PURE__ */ e(va.Provider, { value: Ke, children: /* @__PURE__ */ o("div", { className: P("flex flex-col gap-3", u), children: [
3220
+ O && (!n || _.length === 0 && b.length === 0) && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-amber-700 dark:text-amber-300", children: O }),
3221
+ n && (_.length > 0 || b.length > 0) && /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
3226
3222
  /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3227
3223
  /* @__PURE__ */ o("span", { className: "flex items-center gap-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-slate-300", children: [
3228
3224
  "Filters",
3229
- K && /* @__PURE__ */ e("span", { className: "font-normal text-amber-700 dark:text-amber-300", children: K }),
3230
- L > 0 && /* @__PURE__ */ o("span", { className: "rounded-full bg-emerald-50 px-1.5 py-px text-[10px] font-semibold text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400", children: [
3225
+ O && /* @__PURE__ */ e("span", { className: "font-normal text-amber-700 dark:text-amber-300", children: O }),
3226
+ T > 0 && /* @__PURE__ */ o("span", { className: "rounded-full bg-emerald-50 px-1.5 py-px text-[10px] font-semibold text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400", children: [
3231
3227
  "Active · ",
3232
- L
3228
+ T
3233
3229
  ] })
3234
3230
  ] }),
3235
3231
  /* @__PURE__ */ e(
3236
3232
  $t,
3237
3233
  {
3238
3234
  value: ($ == null ? void 0 : $.preset) ?? "",
3239
- onChange: (r) => z(r ? { preset: r } : null),
3235
+ onChange: (r) => E(r ? { preset: r } : null),
3240
3236
  options: yl.map((r) => ({ value: r.id, label: r.label })),
3241
3237
  ariaLabel: "Date range",
3242
3238
  className: "h-7 w-auto rounded-md px-1.5 py-0 text-[12px] text-slate-600 dark:border-border dark:bg-card dark:text-slate-300"
@@ -3245,16 +3241,16 @@ function hr({
3245
3241
  b.map((r) => {
3246
3242
  var d;
3247
3243
  return /* @__PURE__ */ e(
3248
- ma,
3244
+ pa,
3249
3245
  {
3250
3246
  reportId: t,
3251
3247
  field: r.field,
3252
3248
  label: r.label,
3253
3249
  optionSource: r.options,
3254
- allowedValues: we[r.field],
3255
- selected: ((d = ue.find((x) => x.field === r.field)) == null ? void 0 : d.values) ?? [],
3256
- onChange: (x, v) => J((q) => [
3257
- ...q.filter((w) => w.field !== r.field),
3250
+ allowedValues: ye[r.field],
3251
+ selected: ((d = me.find((x) => x.field === r.field)) == null ? void 0 : d.values) ?? [],
3252
+ onChange: (x, v) => J((C) => [
3253
+ ...C.filter((M) => M.field !== r.field),
3258
3254
  ...x.length > 0 ? [{ field: r.field, values: x, labels: v }] : []
3259
3255
  ])
3260
3256
  },
@@ -3265,11 +3261,11 @@ function hr({
3265
3261
  "button",
3266
3262
  {
3267
3263
  type: "button",
3268
- disabled: !le,
3269
- onClick: I,
3264
+ disabled: !ne,
3265
+ onClick: ee,
3270
3266
  className: P(
3271
3267
  "inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11.5px] font-semibold",
3272
- le ? "bg-nvr-cyan text-white" : "bg-slate-100 text-slate-400 dark:bg-muted dark:text-slate-500"
3268
+ ne ? "bg-nvr-cyan text-white" : "bg-slate-100 text-slate-400 dark:bg-muted dark:text-slate-500"
3273
3269
  ),
3274
3270
  children: [
3275
3271
  /* @__PURE__ */ e(Ht, { className: "h-3 w-3" }),
@@ -3277,14 +3273,14 @@ function hr({
3277
3273
  ]
3278
3274
  }
3279
3275
  ),
3280
- (L > 0 || le) && /* @__PURE__ */ o(
3276
+ (T > 0 || ne) && /* @__PURE__ */ o(
3281
3277
  "button",
3282
3278
  {
3283
3279
  type: "button",
3284
3280
  className: "flex items-center gap-1 text-[11.5px] text-slate-400 hover:text-red-500",
3285
- onClick: M,
3281
+ onClick: A,
3286
3282
  children: [
3287
- /* @__PURE__ */ e(Te, { className: "h-3 w-3" }),
3283
+ /* @__PURE__ */ e(Re, { className: "h-3 w-3" }),
3288
3284
  " Clear"
3289
3285
  ]
3290
3286
  }
@@ -3296,30 +3292,30 @@ function hr({
3296
3292
  {
3297
3293
  className: "group/preset inline-flex h-6 items-center gap-1 rounded-full border border-slate-200 pl-2 pr-1 text-[11px] text-slate-500 hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:hover:text-nvr-cyan",
3298
3294
  children: [
3299
- /* @__PURE__ */ e("button", { type: "button", onClick: () => G(r), children: r.name }),
3295
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => U(r), children: r.name }),
3300
3296
  /* @__PURE__ */ e(
3301
3297
  "button",
3302
3298
  {
3303
3299
  type: "button",
3304
3300
  title: "Delete preset",
3305
3301
  className: "rounded-full p-0.5 text-slate-300 opacity-0 hover:text-red-500 group-hover/preset:opacity-100",
3306
- onClick: () => fe.mutate(r.id),
3307
- children: /* @__PURE__ */ e(Te, { className: "h-2.5 w-2.5" })
3302
+ onClick: () => xe.mutate(r.id),
3303
+ children: /* @__PURE__ */ e(Re, { className: "h-2.5 w-2.5" })
3308
3304
  }
3309
3305
  )
3310
3306
  ]
3311
3307
  },
3312
3308
  r.name
3313
3309
  )),
3314
- N ? /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1", children: /* @__PURE__ */ e(
3310
+ k ? /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1", children: /* @__PURE__ */ e(
3315
3311
  "input",
3316
3312
  {
3317
- value: re,
3318
- onChange: (r) => ae(r.target.value),
3313
+ value: se,
3314
+ onChange: (r) => re(r.target.value),
3319
3315
  placeholder: "Preset name",
3320
3316
  autoFocus: !0,
3321
3317
  onKeyDown: (r) => {
3322
- r.key === "Enter" && re.trim() && (U.mutate(re.trim()), ae(""), R(!1)), r.key === "Escape" && R(!1);
3318
+ r.key === "Enter" && se.trim() && (V.mutate(se.trim()), re(""), F(!1)), r.key === "Escape" && F(!1);
3323
3319
  },
3324
3320
  className: "h-6 w-[130px] rounded-md border border-slate-200 bg-white px-2 text-[11px] dark:border-border dark:bg-card"
3325
3321
  }
@@ -3328,7 +3324,7 @@ function hr({
3328
3324
  {
3329
3325
  type: "button",
3330
3326
  className: "inline-flex h-6 items-center gap-1 rounded-full border border-dashed border-slate-200 px-2 text-[11px] text-slate-400 hover:border-slate-300 hover:text-slate-600 dark:border-border",
3331
- onClick: () => R(!0),
3327
+ onClick: () => F(!0),
3332
3328
  children: [
3333
3329
  /* @__PURE__ */ e(Xt, { className: "h-2.5 w-2.5" }),
3334
3330
  " Save preset"
@@ -3341,22 +3337,22 @@ function hr({
3341
3337
  {
3342
3338
  type: "button",
3343
3339
  title: "Save the current numbers as a snapshot to compare against later",
3344
- disabled: j.isPending,
3345
- onClick: () => j.mutate(),
3340
+ disabled: I.isPending,
3341
+ onClick: () => I.mutate(),
3346
3342
  className: "inline-flex h-6 items-center gap-1 rounded-full border border-dashed border-slate-200 px-2 text-[11px] text-slate-400 hover:border-slate-300 hover:text-slate-600 disabled:opacity-40 dark:border-border",
3347
3343
  children: [
3348
3344
  /* @__PURE__ */ e(Lt, { className: "h-2.5 w-2.5" }),
3349
3345
  " ",
3350
- j.isPending ? "Saving…" : "Snapshot"
3346
+ I.isPending ? "Saving…" : "Snapshot"
3351
3347
  ]
3352
3348
  }
3353
3349
  ),
3354
- ge.map((r) => /* @__PURE__ */ o(
3350
+ ke.map((r) => /* @__PURE__ */ o(
3355
3351
  "button",
3356
3352
  {
3357
3353
  type: "button",
3358
3354
  title: `Compare against ${r.name} (${sa(r.taken_at)})`,
3359
- onClick: () => E((d) => d === r.id ? null : r.id),
3355
+ onClick: () => j((d) => d === r.id ? null : r.id),
3360
3356
  className: P(
3361
3357
  "inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px]",
3362
3358
  Y === r.id ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
@@ -3365,7 +3361,7 @@ function hr({
3365
3361
  /* @__PURE__ */ e(Lt, { className: "h-2.5 w-2.5" }),
3366
3362
  " ",
3367
3363
  r.name,
3368
- Y === r.id && /* @__PURE__ */ e(Te, { className: "h-2.5 w-2.5" })
3364
+ Y === r.id && /* @__PURE__ */ e(Re, { className: "h-2.5 w-2.5" })
3369
3365
  ]
3370
3366
  },
3371
3367
  r.id
@@ -3375,10 +3371,10 @@ function hr({
3375
3371
  {
3376
3372
  type: "button",
3377
3373
  title: "Time machine (#404): show the snapshot values AS the numbers, not as delta badges",
3378
- onClick: () => me((r) => !r),
3374
+ onClick: () => pe((r) => !r),
3379
3375
  className: P(
3380
3376
  "inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px]",
3381
- oe ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-400/10 dark:text-amber-400" : "border-dashed border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
3377
+ de ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-400/10 dark:text-amber-400" : "border-dashed border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
3382
3378
  ),
3383
3379
  children: "As of"
3384
3380
  }
@@ -3389,10 +3385,10 @@ function hr({
3389
3385
  /* @__PURE__ */ e(
3390
3386
  "input",
3391
3387
  {
3392
- value: Ye,
3393
- onChange: (r) => ct(r.target.value),
3388
+ value: He,
3389
+ onChange: (r) => ut(r.target.value),
3394
3390
  onKeyDown: (r) => {
3395
- r.key === "Enter" && B();
3391
+ r.key === "Enter" && z();
3396
3392
  },
3397
3393
  placeholder: 'Describe filters… e.g. "Zone 1 CRAN this year"',
3398
3394
  className: "h-full min-w-0 flex-1 bg-transparent text-[11.5px] outline-none placeholder:text-slate-300 dark:text-slate-200"
@@ -3402,24 +3398,24 @@ function hr({
3402
3398
  "button",
3403
3399
  {
3404
3400
  type: "button",
3405
- disabled: Ve || !Ye.trim(),
3406
- onClick: () => void B(),
3401
+ disabled: Xe || !He.trim(),
3402
+ onClick: () => void z(),
3407
3403
  className: "text-[11px] font-semibold text-nvr-navy disabled:opacity-40 dark:text-nvr-cyan",
3408
- children: Ve ? "…" : "Set"
3404
+ children: Xe ? "…" : "Set"
3409
3405
  }
3410
3406
  )
3411
3407
  ] }),
3412
- mt && /* @__PURE__ */ e("span", { className: "text-[10.5px] text-red-400", children: mt })
3408
+ pt && /* @__PURE__ */ e("span", { className: "text-[10.5px] text-red-400", children: pt })
3413
3409
  ] })
3414
3410
  ] }),
3415
- T.length > 0 && /* @__PURE__ */ o("div", { className: "mb-2 flex items-center gap-2 rounded-lg border border-red-300 bg-red-50 px-3 py-2 dark:border-red-500/40 dark:bg-red-500/10", children: [
3411
+ R.length > 0 && /* @__PURE__ */ o("div", { className: "mb-2 flex items-center gap-2 rounded-lg border border-red-300 bg-red-50 px-3 py-2 dark:border-red-500/40 dark:bg-red-500/10", children: [
3416
3412
  /* @__PURE__ */ e(Zt, { className: "h-3.5 w-3.5 shrink-0 text-red-500" }),
3417
- /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[12px] text-red-700 dark:text-red-300", children: T.length === 1 ? `Alert firing: ${T[0].name}` : `${T.length} alerts firing: ${T.map((r) => r.name).join(" · ")}` })
3413
+ /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[12px] text-red-700 dark:text-red-300", children: R.length === 1 ? `Alert firing: ${R[0].name}` : `${R.length} alerts firing: ${R.map((r) => r.name).join(" · ")}` })
3418
3414
  ] }),
3419
3415
  /* @__PURE__ */ o("div", { className: "mb-2 flex flex-wrap items-center gap-2", children: [
3420
3416
  /* @__PURE__ */ o("span", { className: "text-[10.5px] text-slate-400", children: [
3421
3417
  "Data as of ",
3422
- ot.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
3418
+ it.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
3423
3419
  ] }),
3424
3420
  /* @__PURE__ */ o(
3425
3421
  "button",
@@ -3433,21 +3429,21 @@ function hr({
3433
3429
  ]
3434
3430
  }
3435
3431
  ),
3436
- C.some((r) => r.type === "query") && /* @__PURE__ */ o(
3432
+ _.some((r) => r.type === "query") && /* @__PURE__ */ o(
3437
3433
  "button",
3438
3434
  {
3439
3435
  type: "button",
3440
- onClick: () => Be(!Oe),
3441
- "aria-pressed": Oe,
3436
+ onClick: () => Je(!Ke),
3437
+ "aria-pressed": Ke,
3442
3438
  "data-report-auto-refresh": !0,
3443
- "data-tip": Oe ? "Query widgets re-run on their own when the data they read changes. Click to stop." : "Re-run query widgets on their own when the data they read changes",
3439
+ "data-tip": Ke ? "Query widgets re-run on their own when the data they read changes. Click to stop." : "Re-run query widgets on their own when the data they read changes",
3444
3440
  className: P(
3445
3441
  "inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[11px]",
3446
- Oe ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400"
3442
+ Ke ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400"
3447
3443
  ),
3448
3444
  children: [
3449
3445
  "Auto-refresh",
3450
- Oe ? " on" : ""
3446
+ Ke ? " on" : ""
3451
3447
  ]
3452
3448
  }
3453
3449
  ),
@@ -3456,30 +3452,30 @@ function hr({
3456
3452
  "button",
3457
3453
  {
3458
3454
  type: "button",
3459
- onClick: () => ye((r) => !r),
3455
+ onClick: () => ve((r) => !r),
3460
3456
  className: P(
3461
3457
  "inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[11px]",
3462
- ie ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400"
3458
+ ce ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400"
3463
3459
  ),
3464
3460
  children: [
3465
- ie ? `Comparing ${ie.a} vs ${ie.b}` : "Compare A/B",
3466
- ie && /* @__PURE__ */ e(
3467
- Te,
3461
+ ce ? `Comparing ${ce.a} vs ${ce.b}` : "Compare A/B",
3462
+ ce && /* @__PURE__ */ e(
3463
+ Re,
3468
3464
  {
3469
3465
  className: "h-2.5 w-2.5",
3470
3466
  onClick: (r) => {
3471
- r.stopPropagation(), it(null);
3467
+ r.stopPropagation(), dt(null);
3472
3468
  }
3473
3469
  }
3474
3470
  )
3475
3471
  ]
3476
3472
  }
3477
3473
  ),
3478
- Qe && /* @__PURE__ */ o("span", { className: "absolute left-0 top-full z-50 mt-1 flex w-72 flex-col gap-1.5 rounded-xl border border-slate-200 bg-white p-2.5 shadow-lg dark:border-border dark:bg-card", children: [
3474
+ Ve && /* @__PURE__ */ o("span", { className: "absolute left-0 top-full z-50 mt-1 flex w-72 flex-col gap-1.5 rounded-xl border border-slate-200 bg-white p-2.5 shadow-lg dark:border-border dark:bg-card", children: [
3479
3475
  /* @__PURE__ */ e(
3480
3476
  "input",
3481
3477
  {
3482
- value: V,
3478
+ value: G,
3483
3479
  onChange: (r) => yt(r.target.value),
3484
3480
  placeholder: "Filter field (e.g. division)",
3485
3481
  className: "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card dark:text-slate-200"
@@ -3489,7 +3485,7 @@ function hr({
3489
3485
  /* @__PURE__ */ e(
3490
3486
  "input",
3491
3487
  {
3492
- value: Je,
3488
+ value: Ye,
3493
3489
  onChange: (r) => kt(r.target.value),
3494
3490
  placeholder: "Value A",
3495
3491
  className: "h-7 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card dark:text-slate-200"
@@ -3498,7 +3494,7 @@ function hr({
3498
3494
  /* @__PURE__ */ e(
3499
3495
  "input",
3500
3496
  {
3501
- value: Ue,
3497
+ value: Ge,
3502
3498
  onChange: (r) => Nt(r.target.value),
3503
3499
  placeholder: "Value B",
3504
3500
  className: "h-7 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card dark:text-slate-200"
@@ -3509,9 +3505,9 @@ function hr({
3509
3505
  "button",
3510
3506
  {
3511
3507
  type: "button",
3512
- disabled: !V.trim() || !Je.trim() || !Ue.trim(),
3508
+ disabled: !G.trim() || !Ye.trim() || !Ge.trim(),
3513
3509
  onClick: () => {
3514
- it({ field: V.trim(), a: Je.trim(), b: Ue.trim() }), ye(!1);
3510
+ dt({ field: G.trim(), a: Ye.trim(), b: Ge.trim() }), ve(!1);
3515
3511
  },
3516
3512
  className: "h-7 rounded-md bg-nvr-cyan text-[11.5px] font-semibold text-white hover:brightness-110 disabled:opacity-40",
3517
3513
  children: "Compare"
@@ -3520,7 +3516,7 @@ function hr({
3520
3516
  ] })
3521
3517
  ] })
3522
3518
  ] }),
3523
- Z.filter((r) => !b.some((d) => d.field === r.field)).length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5 px-1 pb-2", children: Z.filter((r) => !b.some((d) => d.field === r.field)).map((r) => /* @__PURE__ */ o(
3519
+ H.filter((r) => !b.some((d) => d.field === r.field)).length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5 px-1 pb-2", children: H.filter((r) => !b.some((d) => d.field === r.field)).map((r) => /* @__PURE__ */ o(
3524
3520
  "span",
3525
3521
  {
3526
3522
  className: "inline-flex items-center gap-1.5 rounded-full border border-nvr-cyan/40 bg-nvr-cyan/[0.08] py-0.5 pl-2.5 pr-1 text-[11.5px] text-[#007a99] dark:text-nvr-cyan",
@@ -3534,25 +3530,25 @@ function hr({
3534
3530
  type: "button",
3535
3531
  "aria-label": "Remove filter",
3536
3532
  onClick: () => {
3537
- F((d) => d.filter((x) => x.field !== r.field)), J((d) => d.filter((x) => x.field !== r.field));
3533
+ q((d) => d.filter((x) => x.field !== r.field)), J((d) => d.filter((x) => x.field !== r.field));
3538
3534
  },
3539
3535
  className: "rounded-full p-0.5 hover:bg-nvr-cyan/[0.16]",
3540
- children: /* @__PURE__ */ e(Te, { className: "h-2.5 w-2.5" })
3536
+ children: /* @__PURE__ */ e(Re, { className: "h-2.5 w-2.5" })
3541
3537
  }
3542
3538
  )
3543
3539
  ]
3544
3540
  },
3545
3541
  r.field
3546
3542
  )) }),
3547
- (ne == null ? void 0 : ne.editable) && /* @__PURE__ */ e("div", { className: "mb-2 flex items-center gap-1.5", children: be ? /* @__PURE__ */ o(et, { children: [
3543
+ (oe == null ? void 0 : oe.editable) && /* @__PURE__ */ e("div", { className: "mb-2 flex items-center gap-1.5", children: ge ? /* @__PURE__ */ o(We, { children: [
3548
3544
  /* @__PURE__ */ e(
3549
3545
  "button",
3550
3546
  {
3551
3547
  type: "button",
3552
- disabled: st.isPending,
3553
- onClick: () => _e && st.mutate(_e),
3548
+ disabled: ot.isPending,
3549
+ onClick: () => Se && ot.mutate(Se),
3554
3550
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-semibold text-white hover:brightness-110 disabled:opacity-40",
3555
- children: st.isPending ? "Saving…" : "Save layout"
3551
+ children: ot.isPending ? "Saving…" : "Save layout"
3556
3552
  }
3557
3553
  ),
3558
3554
  /* @__PURE__ */ e(
@@ -3560,7 +3556,7 @@ function hr({
3560
3556
  {
3561
3557
  type: "button",
3562
3558
  onClick: () => {
3563
- Ee(!1), Re(null), je(null);
3559
+ Be(!1), Fe(null), Qe(null);
3564
3560
  },
3565
3561
  className: "rounded-md border border-slate-200 px-3 py-1 text-[12px] text-slate-500 dark:border-border",
3566
3562
  children: "Cancel"
@@ -3576,34 +3572,34 @@ function hr({
3576
3572
  children: "Edit report"
3577
3573
  }
3578
3574
  ) }),
3579
- be && _e && /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(Rt, { fallback: null, children: /* @__PURE__ */ e(
3575
+ ge && Se && /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(Rt, { fallback: null, children: /* @__PURE__ */ e(
3580
3576
  bl,
3581
3577
  {
3582
- maxY: Math.max(0, ..._e.map((r) => (r.y ?? 0) + (r.h ?? 1))),
3583
- onAdd: (r) => Re((d) => [...d ?? [], r])
3578
+ maxY: Math.max(0, ...Se.map((r) => (r.y ?? 0) + (r.h ?? 1))),
3579
+ onAdd: (r) => Fe((d) => [...d ?? [], r])
3584
3580
  }
3585
3581
  ) }) }),
3586
- C.length === 0 && !be ? /* @__PURE__ */ e("div", { className: "p-6 text-[13px] text-slate-400", children: h ?? "This report has no widgets yet." }) : /* @__PURE__ */ e(
3582
+ _.length === 0 && !ge ? /* @__PURE__ */ e("div", { className: "p-6 text-[13px] text-slate-400", children: h ?? "This report has no widgets yet." }) : /* @__PURE__ */ e(
3587
3583
  "div",
3588
3584
  {
3589
3585
  className: "grid gap-3",
3590
3586
  style: {
3591
3587
  gridTemplateColumns: "repeat(12, minmax(0, 1fr))",
3592
- gridAutoRows: be ? void 0 : "72px"
3588
+ gridAutoRows: ge ? void 0 : "72px"
3593
3589
  },
3594
- children: We(be && _e ? _e : C).map((r) => {
3590
+ children: Ue(ge && Se ? Se : _).map((r) => {
3595
3591
  var d;
3596
3592
  return /* @__PURE__ */ e(
3597
3593
  "div",
3598
3594
  {
3599
3595
  style: {
3600
- gridColumn: ie ? "1 / -1" : `${Math.max(1, (r.x ?? 0) + 1)} / span ${Math.min(12, Math.max(2, r.w || 4))}`,
3596
+ gridColumn: ce ? "1 / -1" : `${Math.max(1, (r.x ?? 0) + 1)} / span ${Math.min(12, Math.max(2, r.w || 4))}`,
3601
3597
  gridRow: void 0
3602
3598
  },
3603
- className: be || ie ? "" : "contents",
3604
- children: ie && !be && r.type !== "divider" ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [ie.a, ie.b].map((x, v) => /* @__PURE__ */ o("div", { className: "flex min-h-[160px] flex-col", children: [
3599
+ className: ge || ce ? "" : "contents",
3600
+ children: ce && !ge && r.type !== "divider" ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [ce.a, ce.b].map((x, v) => /* @__PURE__ */ o("div", { className: "flex min-h-[160px] flex-col", children: [
3605
3601
  /* @__PURE__ */ o("p", { className: "mb-1 text-[10.5px] font-semibold uppercase tracking-wide text-[#007a99] dark:text-nvr-cyan", children: [
3606
- ie.field.replace(/_/g, " "),
3602
+ ce.field.replace(/_/g, " "),
3607
3603
  ": ",
3608
3604
  x
3609
3605
  ] }),
@@ -3614,22 +3610,22 @@ function hr({
3614
3610
  widget: r,
3615
3611
  dateRange: i,
3616
3612
  entityFilters: [
3617
- ...Z.filter((q) => q.field !== ie.field),
3618
- { field: ie.field, values: [x], labels: [x] }
3613
+ ...H.filter((C) => C.field !== ce.field),
3614
+ { field: ce.field, values: [x], labels: [x] }
3619
3615
  ],
3620
3616
  refetchInterval: c,
3621
3617
  filterBar: b,
3622
3618
  onDrill: Q
3623
3619
  }
3624
3620
  )
3625
- ] }, v)) }) : /* @__PURE__ */ o(et, { children: [
3626
- be && /* @__PURE__ */ e(Rt, { fallback: null, children: /* @__PURE__ */ e(
3621
+ ] }, v)) }) : /* @__PURE__ */ o(We, { children: [
3622
+ ge && /* @__PURE__ */ e(Rt, { fallback: null, children: /* @__PURE__ */ e(
3627
3623
  vl,
3628
3624
  {
3629
3625
  widget: r,
3630
- onConfigure: () => je(r.id),
3631
- onDelete: () => Re((x) => (x ?? []).filter((v) => v.id !== r.id)),
3632
- onResize: (x, v) => dt({
3626
+ onConfigure: () => Qe(r.id),
3627
+ onDelete: () => Fe((x) => (x ?? []).filter((v) => v.id !== r.id)),
3628
+ onResize: (x, v) => ct({
3633
3629
  ...r,
3634
3630
  w: Math.min(12, Math.max(2, (r.w || 4) + x)),
3635
3631
  h: Math.min(8, Math.max(1, (r.h || 2) + v))
@@ -3643,18 +3639,18 @@ function hr({
3643
3639
  reportId: t,
3644
3640
  widget: r,
3645
3641
  dateRange: i,
3646
- entityFilters: Z,
3642
+ entityFilters: H,
3647
3643
  refetchInterval: c,
3648
3644
  filterBar: b,
3649
3645
  onDrill: Q,
3650
- snapshot: S && S.data[r.id] !== void 0 ? { name: S.name, value: ((d = S.data[r.id]) == null ? void 0 : d.value) ?? null } : null,
3651
- asOf: oe,
3652
- annotations: he.filter((x) => x.widget === r.id),
3653
- onAddAnnotation: (x, v, q) => Fe.mutate({ widget: x, note: v, anchor_date: q }),
3654
- onDeleteAnnotation: (x) => Me.mutate(x),
3655
- onCrossFilter: rt,
3646
+ snapshot: w && w.data[r.id] !== void 0 ? { name: w.name, value: ((d = w.data[r.id]) == null ? void 0 : d.value) ?? null } : null,
3647
+ asOf: de,
3648
+ annotations: ae.filter((x) => x.widget === r.id),
3649
+ onAddAnnotation: (x, v, C) => Le.mutate({ widget: x, note: v, anchor_date: C }),
3650
+ onDeleteAnnotation: (x) => Ce.mutate(x),
3651
+ onCrossFilter: Oe,
3656
3652
  reportUrl: g,
3657
- currentFilters: Z
3653
+ currentFilters: H
3658
3654
  }
3659
3655
  )
3660
3656
  ] })
@@ -3664,40 +3660,39 @@ function hr({
3664
3660
  })
3665
3661
  }
3666
3662
  ),
3667
- be && nt && (_e == null ? void 0 : _e.some((r) => r.id === nt)) && /* @__PURE__ */ e(Rt, { fallback: null, children: /* @__PURE__ */ e(
3663
+ ge && st && (Se == null ? void 0 : Se.some((r) => r.id === st)) && /* @__PURE__ */ e(Rt, { fallback: null, children: /* @__PURE__ */ e(
3668
3664
  gl,
3669
3665
  {
3670
- widget: _e.find((r) => r.id === nt),
3671
- allWidgets: _e,
3672
- onChange: dt,
3673
- onClose: () => je(null)
3666
+ widget: Se.find((r) => r.id === st),
3667
+ allWidgets: Se,
3668
+ onChange: ct,
3669
+ onClose: () => Qe(null)
3674
3670
  }
3675
3671
  ) }),
3676
- /* @__PURE__ */ e(ol, {}),
3677
- !D && (y != null && y.length) ? /* @__PURE__ */ e(
3678
- sl,
3672
+ /* @__PURE__ */ e(il, {}),
3673
+ !K && (y != null && y.length) ? /* @__PURE__ */ e(
3674
+ ol,
3679
3675
  {
3680
3676
  collection: y[0].collection,
3681
3677
  itemId: y[0].itemId,
3682
3678
  title: y[0].title,
3683
3679
  width: "72%",
3684
3680
  stack: y,
3685
- onPush: (r) => O.push([...y, r]),
3686
- onPop: () => O.back(),
3687
- onClose: () => O.back(y.length)
3681
+ onPush: (r) => L.push([...y, r]),
3682
+ onPop: () => L.back(),
3683
+ onClose: () => L.back(y.length)
3688
3684
  }
3689
3685
  ) : null
3690
3686
  ] }) });
3691
3687
  }
3692
3688
  export {
3693
3689
  Ll as AlertBell,
3694
- ce as CHART_COLORS,
3690
+ ue as CHART_COLORS,
3695
3691
  kl as NO_WORKFLOW_NUMBER,
3696
3692
  Al as QueryWidgetBody,
3697
- hr as ReportView,
3698
- pr as ReportWidgetCard,
3699
- zl as adminAccessScopeNote,
3693
+ fr as ReportView,
3694
+ hr as ReportWidgetCard,
3695
+ Pl as adminAccessScopeNote,
3700
3696
  ze as fmtCell,
3701
- ha as shapeQueryRows,
3702
- Pl as shortCategoryLabel
3697
+ fa as shapeQueryRows
3703
3698
  };