@nivaro/react 0.2.54 → 0.2.56

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 (151) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +367 -2
  4. package/dist/index.js +645 -616
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/stale-chunk.js +60 -0
  150. package/dist/shared/lib/worker-socket.js +200 -0
  151. package/package.json +1 -1
@@ -1,42 +1,43 @@
1
- import { jsx as e, jsxs as n, Fragment as Ie } from "react/jsx-runtime";
2
- import { executeCustomQuery as ra, saveReportFilterPreset as Dt, listReportFilterPresets as na, deleteReportFilterPreset as sa, readReport as ia, readItems as oa, readReportFilterOptions as da, aiReportFilters as ca, readReportWidgetData as Nt, listReportAlerts as ma, createReportAlert as ua, toggleReportAlert as pa, deleteReportAlert as ha, readReportAlertLog as fa, resolveReportAlert as xa } from "@nivaro/sdk";
1
+ import { jsxs as n, jsx as e, Fragment as Ie } from "react/jsx-runtime";
2
+ import { executeCustomQuery as na, saveReportFilterPreset as Dt, listReportFilterPresets as sa, deleteReportFilterPreset as ia, readReport as oa, readItems as da, readReportFilterOptions as ca, aiReportFilters as ma, readReportWidgetData as Nt, listReportAlerts as ua, createReportAlert as pa, toggleReportAlert as ha, deleteReportAlert as fa, readReportAlertLog as xa, resolveReportAlert as ba } from "@nivaro/sdk";
3
3
  import { useQuery as Ne, useQueryClient as qt, useMutation as Fe } from "@tanstack/react-query";
4
- import { X as Re, Check as Qt, Plus as Ut, Camera as St, Bell as Yt, RefreshCw as At, ChevronsUpDown as Jt, Sparkles as Kt, Info as ba, Table as ga, Sigma as va, StickyNote as ya, Download as ka, TrendingUp as Vt, TrendingDown as Gt, Trash2 as Na } from "lucide-react";
5
- import { useState as M, useEffect as _t, useCallback as Rt, useRef as Ct, useMemo as ut, Suspense as Mt, lazy as Lt, memo as wa } from "react";
6
- import { useNivaroClient as Ke, useDrilldown as Ht, useOverlayState as Sa } from "../context.js";
7
- import { get as mt, post as pt, del as _a, put as Ca } from "../lib/commands.js";
8
- import { useLiveWidget as $a, liveWidgetInterval as qa } from "../lib/live-widgets.js";
9
- import { buildReportTree as Ma } from "../lib/report-tree.js";
10
- import { useMyScopes as Fa, matchScopeDimension as Aa, translateScopeValues as Pt, effectiveScopeSeedIds as Ra } from "../lib/use-my-scopes.js";
4
+ import { X as Re, Check as Qt, Plus as Ut, Camera as St, Bell as Yt, RefreshCw as At, ChevronsUpDown as Jt, Sparkles as Kt, Info as ga, Table as va, Sigma as ya, StickyNote as ka, Download as Na, TrendingUp as Vt, TrendingDown as Gt, Trash2 as wa } from "lucide-react";
5
+ import { useState as M, useEffect as _t, useCallback as Rt, useRef as Ct, useMemo as ut, Suspense as Mt, lazy as Lt, memo as Sa } from "react";
6
+ import { useNivaroClient as Ke, useDrilldown as Ht, useOverlayState as _a } from "../context.js";
7
+ import { get as mt, post as pt, del as Ca, put as $a } from "../lib/commands.js";
8
+ import { useLiveWidget as qa, liveWidgetInterval as Ma } from "../lib/live-widgets.js";
9
+ import { buildReportTree as Fa } from "../lib/report-tree.js";
10
+ import { useMyScopes as Aa, matchScopeDimension as Ra, translateScopeValues as Pt, effectiveScopeSeedIds as Ta } from "../lib/use-my-scopes.js";
11
11
  import { cn as W } from "../lib/utils.js";
12
+ import { BackgroundRunOffer as Xt } from "./BackgroundRunOffer.js";
12
13
  import { RechartsGate as Oe } from "./charts/RechartsGate.js";
13
- import { RecordDrilldownSheet as Ta } from "./RecordDrilldownSheet.js";
14
- import { TipLayer as La } from "./TipLayer.js";
15
- import { Command as Oa, CommandInput as Da, CommandList as Ka, CommandEmpty as Pa, CommandItem as za } from "./ui/command.js";
16
- import { Popover as Xt, PopoverTrigger as Zt, PopoverContent as It } from "./ui/popover.js";
14
+ import { RecordDrilldownSheet as La } from "./RecordDrilldownSheet.js";
15
+ import { TipLayer as Oa } from "./TipLayer.js";
16
+ import { Command as Da, CommandInput as Ka, CommandList as Pa, CommandEmpty as za, CommandItem as ja } from "./ui/command.js";
17
+ import { Popover as Zt, PopoverTrigger as It, PopoverContent as ea } from "./ui/popover.js";
17
18
  import { Skeleton as De } from "./ui/skeleton.js";
18
19
  import { SimpleSelect as wt } from "./ui/SimpleSelect.js";
19
- async function ja(t, i) {
20
+ async function Ea(t, s) {
20
21
  const a = t == null ? void 0 : t.querySelector("svg");
21
22
  if (!(!a || typeof ClipboardItem > "u"))
22
23
  try {
23
- const o = a.getBoundingClientRect(), m = a.cloneNode(!0);
24
- m.setAttribute("width", String(o.width)), m.setAttribute("height", String(o.height));
25
- const u = new XMLSerializer().serializeToString(m), b = URL.createObjectURL(new Blob([u], { type: "image/svg+xml;charset=utf-8" })), x = new Image();
26
- await new Promise((_, c) => {
27
- x.onload = () => _(), x.onerror = () => c(new Error("svg load failed")), x.src = b;
24
+ const o = a.getBoundingClientRect(), c = a.cloneNode(!0);
25
+ c.setAttribute("width", String(o.width)), c.setAttribute("height", String(o.height));
26
+ const u = new XMLSerializer().serializeToString(c), b = URL.createObjectURL(new Blob([u], { type: "image/svg+xml;charset=utf-8" })), x = new Image();
27
+ await new Promise((C, m) => {
28
+ x.onload = () => C(), x.onerror = () => m(new Error("svg load failed")), x.src = b;
28
29
  });
29
30
  const p = 2, K = document.createElement("canvas");
30
31
  K.width = Math.max(1, Math.round(o.width * p)), K.height = Math.max(1, Math.round(o.height * p) + 28 * p);
31
32
  const F = K.getContext("2d");
32
33
  if (!F) return;
33
- F.fillStyle = "#ffffff", F.fillRect(0, 0, K.width, K.height), F.fillStyle = "#172940", F.font = `${12 * p}px system-ui, sans-serif`, F.fillText(i || "Chart", 8 * p, 18 * p), F.drawImage(x, 0, 28 * p, o.width * p, o.height * p), URL.revokeObjectURL(b);
34
- const N = await new Promise((_) => K.toBlob(_, "image/png"));
34
+ F.fillStyle = "#ffffff", F.fillRect(0, 0, K.width, K.height), F.fillStyle = "#172940", F.font = `${12 * p}px system-ui, sans-serif`, F.fillText(s || "Chart", 8 * p, 18 * p), F.drawImage(x, 0, 28 * p, o.width * p, o.height * p), URL.revokeObjectURL(b);
35
+ const N = await new Promise((C) => K.toBlob(C, "image/png"));
35
36
  N && await navigator.clipboard.write([new ClipboardItem({ "image/png": N })]);
36
37
  } catch {
37
38
  }
38
39
  }
39
- const qe = (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), Ea = [
40
+ const qe = (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), Wa = [
40
41
  "Jan",
41
42
  "Feb",
42
43
  "Mar",
@@ -49,18 +50,18 @@ const qe = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
49
50
  "Oct",
50
51
  "Nov",
51
52
  "Dec"
52
- ], Wa = (t) => {
53
- const i = String(t ?? ""), a = /^(\d{4})-(\d{2})(?:-(\d{2}))?/.exec(i);
53
+ ], Ba = (t) => {
54
+ const s = String(t ?? ""), a = /^(\d{4})-(\d{2})(?:-(\d{2}))?/.exec(s);
54
55
  if (a) {
55
- const o = Ea[Number(a[2]) - 1] ?? a[2];
56
+ const o = Wa[Number(a[2]) - 1] ?? a[2];
56
57
  return a[3] ? `${o} ${Number(a[3])}` : `${o} '${a[1].slice(2)}`;
57
58
  }
58
- return i.length > 16 ? `${i.slice(0, 15)}…` : i;
59
+ return s.length > 16 ? `${s.slice(0, 15)}…` : s;
59
60
  }, $t = (t) => ({
60
61
  interval: t > 12 ? Math.ceil(t / 12) - 1 : 0,
61
- tickFormatter: Wa,
62
+ tickFormatter: Ba,
62
63
  minTickGap: 4
63
- }), Ot = () => import("./ReportEditMode.js"), Ba = Lt(() => Ot().then((t) => ({ default: t.AddWidgetBar }))), Qa = Lt(() => Ot().then((t) => ({ default: t.WidgetConfigSheet }))), Ua = Lt(() => Ot().then((t) => ({ default: t.WidgetEditBar }))), Ze = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ue = [Ze, "#172940", "#10b981", "#f59e0b", "#8b5cf6", "#ef4444", "#64748b"], Ya = [
64
+ }), Ot = () => import("./ReportEditMode.js"), Qa = Lt(() => Ot().then((t) => ({ default: t.AddWidgetBar }))), Ua = Lt(() => Ot().then((t) => ({ default: t.WidgetConfigSheet }))), Ya = Lt(() => Ot().then((t) => ({ default: t.WidgetEditBar }))), Ze = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ue = [Ze, "#172940", "#10b981", "#f59e0b", "#8b5cf6", "#ef4444", "#64748b"], Ja = [
64
65
  { id: "", label: "All time" },
65
66
  { id: "this_month", label: "This month" },
66
67
  { id: "last_30_days", label: "Last 30 days" },
@@ -69,90 +70,90 @@ const qe = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
69
70
  { id: "last_12_months", label: "Last 12 months" },
70
71
  { id: "ytd", label: "Year to date" }
71
72
  ];
72
- function Me(t, i) {
73
+ function Me(t, s) {
73
74
  if (t == null) return "—";
74
- const a = (i == null ? void 0 : i.decimals) != null ? t.toLocaleString(void 0, {
75
- minimumFractionDigits: i.decimals,
76
- maximumFractionDigits: i.decimals
75
+ const a = (s == null ? void 0 : s.decimals) != null ? t.toLocaleString(void 0, {
76
+ minimumFractionDigits: s.decimals,
77
+ maximumFractionDigits: s.decimals
77
78
  }) : t.toLocaleString();
78
- return `${(i == null ? void 0 : i.prefix) ?? ""}${a}${(i == null ? void 0 : i.suffix) ?? ""}`;
79
+ return `${(s == null ? void 0 : s.prefix) ?? ""}${a}${(s == null ? void 0 : s.suffix) ?? ""}`;
79
80
  }
80
81
  function zt({ pct: t }) {
81
82
  if (t == null) return null;
82
- const i = t >= 0;
83
+ const s = t >= 0;
83
84
  return /* @__PURE__ */ n(
84
85
  "span",
85
86
  {
86
87
  className: W(
87
88
  "inline-flex items-center gap-0.5 rounded px-1 py-px text-[10.5px] font-medium",
88
- i ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
89
+ s ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
89
90
  ),
90
91
  children: [
91
- i ? /* @__PURE__ */ e(Vt, { className: "h-2.5 w-2.5" }) : /* @__PURE__ */ e(Gt, { className: "h-2.5 w-2.5" }),
92
+ s ? /* @__PURE__ */ e(Vt, { className: "h-2.5 w-2.5" }) : /* @__PURE__ */ e(Gt, { className: "h-2.5 w-2.5" }),
92
93
  Math.abs(t),
93
94
  "%"
94
95
  ]
95
96
  }
96
97
  );
97
98
  }
98
- function ea({
99
+ function ta({
99
100
  reportId: t,
100
- field: i,
101
+ field: s,
101
102
  label: a,
102
103
  optionSource: o,
103
- selected: m,
104
+ selected: c,
104
105
  onChange: u,
105
106
  allowedValues: b
106
107
  }) {
107
108
  const x = Ke(), [p, K] = M(!1), { data: F = [] } = Ne({
108
- queryKey: ["nivaro-report-filter-opts", t, i, o ?? null],
109
+ queryKey: ["nivaro-report-filter-opts", t, s, o ?? null],
109
110
  queryFn: async () => {
110
111
  if (o) {
111
- const c = o.value_field ?? "id", $ = o.label_field ?? c;
112
+ const m = o.value_field ?? "id", S = o.label_field ?? m;
112
113
  return ((await x.request(
113
- oa(o.collection, {
114
- fields: [.../* @__PURE__ */ new Set(["id", c, $])],
114
+ da(o.collection, {
115
+ fields: [.../* @__PURE__ */ new Set(["id", m, S])],
115
116
  sort: o.sort ? [o.sort] : void 0,
116
117
  limit: 200
117
118
  })
118
119
  )).data ?? []).map((E) => ({
119
- value: String(E[c] ?? E.id),
120
- label: String(E[$] ?? E[c] ?? E.id)
120
+ value: String(E[m] ?? E.id),
121
+ label: String(E[S] ?? E[m] ?? E.id)
121
122
  }));
122
123
  }
123
- return x.request(da(t, i)).then((c) => c.data);
124
+ return x.request(ca(t, s)).then((m) => m.data);
124
125
  },
125
126
  enabled: p,
126
127
  staleTime: 12e4
127
- }), N = b != null && b.length ? F.filter((c) => b.some(($) => String($) === c.value)) : F, _ = m.length > 0;
128
- return /* @__PURE__ */ n(Xt, { open: p, onOpenChange: K, children: [
129
- /* @__PURE__ */ e(Zt, { asChild: !0, children: /* @__PURE__ */ n(
128
+ }), N = b != null && b.length ? F.filter((m) => b.some((S) => String(S) === m.value)) : F, C = c.length > 0;
129
+ return /* @__PURE__ */ n(Zt, { open: p, onOpenChange: K, children: [
130
+ /* @__PURE__ */ e(It, { asChild: !0, children: /* @__PURE__ */ n(
130
131
  "button",
131
132
  {
132
133
  type: "button",
133
134
  className: W(
134
135
  "flex h-7 items-center gap-1.5 rounded-md border px-2 text-[12px]",
135
- _ ? "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"
136
+ C ? "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"
136
137
  ),
137
138
  children: [
138
139
  a,
139
- _ && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: m.length }),
140
+ C && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: c.length }),
140
141
  /* @__PURE__ */ e(Jt, { className: "h-3 w-3 opacity-50" })
141
142
  ]
142
143
  }
143
144
  ) }),
144
- /* @__PURE__ */ e(It, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ n(Oa, { children: [
145
- /* @__PURE__ */ e(Da, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
146
- /* @__PURE__ */ n(Ka, { className: "max-h-52", children: [
147
- /* @__PURE__ */ e(Pa, { children: "No values." }),
148
- N.map((c) => {
149
- const $ = m.some((X) => String(X) === c.value);
145
+ /* @__PURE__ */ e(ea, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ n(Da, { children: [
146
+ /* @__PURE__ */ e(Ka, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
147
+ /* @__PURE__ */ n(Pa, { className: "max-h-52", children: [
148
+ /* @__PURE__ */ e(za, { children: "No values." }),
149
+ N.map((m) => {
150
+ const S = c.some((X) => String(X) === m.value);
150
151
  return /* @__PURE__ */ n(
151
- za,
152
+ ja,
152
153
  {
153
- value: c.label,
154
+ value: m.label,
154
155
  onSelect: () => {
155
- const X = $ ? m.filter((I) => String(I) !== c.value) : [...m, c.value], E = (I) => {
156
+ const X = S ? c.filter((I) => String(I) !== m.value) : [...c, m.value], E = (I) => {
156
157
  var ee;
157
158
  return ((ee = F.find((he) => he.value === String(I))) == null ? void 0 : ee.label) ?? String(I);
158
159
  };
@@ -160,57 +161,57 @@ function ea({
160
161
  },
161
162
  className: "text-[12.5px]",
162
163
  children: [
163
- /* @__PURE__ */ e(Qt, { className: W("mr-1.5 h-3 w-3", $ ? "opacity-100" : "opacity-0") }),
164
- c.label
164
+ /* @__PURE__ */ e(Qt, { className: W("mr-1.5 h-3 w-3", S ? "opacity-100" : "opacity-0") }),
165
+ m.label
165
166
  ]
166
167
  },
167
- c.value
168
+ m.value
168
169
  );
169
170
  })
170
171
  ] })
171
172
  ] }) })
172
173
  ] });
173
174
  }
174
- function ta(t) {
175
+ function aa(t) {
175
176
  if (!t) return null;
176
- const i = /* @__PURE__ */ new Date(), a = (u) => {
177
+ const s = /* @__PURE__ */ new Date(), a = (u) => {
177
178
  const b = (x) => String(x).padStart(2, "0");
178
179
  return `${u.getFullYear()}-${b(u.getMonth() + 1)}-${b(u.getDate())}`;
179
- }, o = (u, b) => new Date(u, b, 1), m = (u) => new Date(u.getFullYear(), u.getMonth() + 1, 0);
180
+ }, o = (u, b) => new Date(u, b, 1), c = (u) => new Date(u.getFullYear(), u.getMonth() + 1, 0);
180
181
  switch (t.preset) {
181
182
  case "this_month":
182
- return { start: a(o(i.getFullYear(), i.getMonth())), end: a(m(i)) };
183
+ return { start: a(o(s.getFullYear(), s.getMonth())), end: a(c(s)) };
183
184
  case "last_30_days":
184
- return { start: a(new Date(i.getTime() - 30 * 864e5)), end: a(i) };
185
+ return { start: a(new Date(s.getTime() - 30 * 864e5)), end: a(s) };
185
186
  case "last_3_months":
186
- return { start: a(o(i.getFullYear(), i.getMonth() - 3)), end: a(m(i)) };
187
+ return { start: a(o(s.getFullYear(), s.getMonth() - 3)), end: a(c(s)) };
187
188
  case "last_6_months":
188
- return { start: a(o(i.getFullYear(), i.getMonth() - 6)), end: a(m(i)) };
189
+ return { start: a(o(s.getFullYear(), s.getMonth() - 6)), end: a(c(s)) };
189
190
  case "last_12_months":
190
- return { start: a(o(i.getFullYear(), i.getMonth() - 12)), end: a(m(i)) };
191
+ return { start: a(o(s.getFullYear(), s.getMonth() - 12)), end: a(c(s)) };
191
192
  case "ytd":
192
- return { start: `${i.getFullYear()}-01-01`, end: a(i) };
193
+ return { start: `${s.getFullYear()}-01-01`, end: a(s) };
193
194
  case "custom":
194
195
  return t.start && t.end ? { start: t.start, end: t.end } : null;
195
196
  default:
196
197
  return null;
197
198
  }
198
199
  }
199
- function Be(t, i, a) {
200
+ function Be(t, s, a) {
200
201
  if (t == null || t === "") return "—";
201
- if (i === "date" || i === "datetime") {
202
+ if (s === "date" || s === "datetime") {
202
203
  const u = new Date(String(t));
203
204
  if (Number.isNaN(u.getTime())) return String(t);
204
205
  const b = u.toLocaleDateString();
205
- return i === "date" ? b : `${b} ${u.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
206
+ return s === "date" ? b : `${b} ${u.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
206
207
  }
207
208
  const o = Number(t);
208
209
  if (Number.isNaN(o)) return String(t);
209
- const m = (u, b) => o.toLocaleString(void 0, {
210
+ const c = (u, b) => o.toLocaleString(void 0, {
210
211
  minimumFractionDigits: a ?? u,
211
212
  maximumFractionDigits: a ?? b
212
213
  });
213
- return i === "currency" ? `$${m(0, 0)}` : i === "percent" ? `${m(0, 1)}%` : i === "days" ? `${m(0, 1)}d` : i === "integer" ? Math.round(o).toLocaleString() : i === "number" ? m(0, 2) : String(t);
214
+ return s === "currency" ? `$${c(0, 0)}` : s === "percent" ? `${c(0, 1)}%` : s === "days" ? `${c(0, 1)}d` : s === "integer" ? Math.round(o).toLocaleString() : s === "number" ? c(0, 2) : String(t);
214
215
  }
215
216
  const We = /* @__PURE__ */ new Set([
216
217
  "currency",
@@ -219,15 +220,15 @@ const We = /* @__PURE__ */ new Set([
219
220
  "percent",
220
221
  "days"
221
222
  ]);
222
- function Ja(t, i, a) {
223
- const o = {}, m = ta(i);
223
+ function Va(t, s, a) {
224
+ const o = {}, c = aa(s);
224
225
  for (const [u, b] of Object.entries(t.params ?? {})) {
225
226
  if (b === "$date.start") {
226
- m && (o[u] = m.start);
227
+ c && (o[u] = c.start);
227
228
  continue;
228
229
  }
229
230
  if (b === "$date.end") {
230
- m && (o[u] = m.end);
231
+ c && (o[u] = c.end);
231
232
  continue;
232
233
  }
233
234
  const x = /^\$filters\.([\w.]+?)(:values)?$/.exec(b);
@@ -240,59 +241,59 @@ function Ja(t, i, a) {
240
241
  }
241
242
  return o;
242
243
  }
243
- const Va = (t) => `$${qe(Math.round(t))}`, Ga = [
244
+ const Ga = (t) => `$${qe(Math.round(t))}`, Ha = [
244
245
  { gte: 90, color: "#ef4444" },
245
246
  { gte: 70, color: "#f59e0b" },
246
247
  { gte: -1 / 0, color: "#10b981" }
247
248
  ];
248
- function Ha({
249
+ function Xa({
249
250
  rows: t,
250
- cfg: i,
251
+ cfg: s,
251
252
  onDrill: a
252
253
  }) {
253
- const o = i.tree, m = i.series && i.series.length > 0 ? i.series : Object.keys(t[0] ?? {}).filter((c) => {
254
- var $;
255
- return typeof (($ = t[0]) == null ? void 0 : $[c]) == "number";
256
- }).slice(0, 3).map((c) => ({ field: c, label: c })), u = ut(
257
- () => o ? Ma(
254
+ const o = s.tree, c = s.series && s.series.length > 0 ? s.series : Object.keys(t[0] ?? {}).filter((m) => {
255
+ var S;
256
+ return typeof ((S = t[0]) == null ? void 0 : S[m]) == "number";
257
+ }).slice(0, 3).map((m) => ({ field: m, label: m })), u = ut(
258
+ () => o ? Fa(
258
259
  t,
259
260
  o,
260
- m.map((c) => c.field)
261
+ c.map((m) => m.field)
261
262
  ) : [],
262
263
  // eslint-disable-next-line react-hooks/exhaustive-deps
263
264
  [t, o]
264
265
  ), [b, x] = M(() => /* @__PURE__ */ new Set()), [p, K] = M(!1);
265
266
  _t(() => {
266
267
  if (p || u.length === 0) return;
267
- const c = /* @__PURE__ */ new Set(), $ = (X) => {
268
+ const m = /* @__PURE__ */ new Set(), S = (X) => {
268
269
  for (const E of X)
269
- (E.depth > 0 || u.length === 1) && c.add(E.key), $(E.children);
270
+ (E.depth > 0 || u.length === 1) && m.add(E.key), S(E.children);
270
271
  };
271
- $(u), x(c), K(!0);
272
+ S(u), x(m), K(!0);
272
273
  }, [u, p]);
273
- const F = (o == null ? void 0 : o.thresholds) ?? Ga, N = (c) => {
274
- var $;
275
- return c == null ? void 0 : (($ = F.find((X) => c >= X.gte)) == null ? void 0 : $.color) ?? "#10b981";
276
- }, _ = (c) => {
277
- const $ = c.children.length === 0, X = b.has(c.key), E = N(c.pct), I = $ && (o == null ? void 0 : o.drill) && c.drillId != null;
278
- return /* @__PURE__ */ n("div", { style: { paddingLeft: c.depth === 0 ? 0 : 14 }, children: [
274
+ const F = (o == null ? void 0 : o.thresholds) ?? Ha, N = (m) => {
275
+ var S;
276
+ return m == null ? void 0 : ((S = F.find((X) => m >= X.gte)) == null ? void 0 : S.color) ?? "#10b981";
277
+ }, C = (m) => {
278
+ const S = m.children.length === 0, X = b.has(m.key), E = N(m.pct), I = S && (o == null ? void 0 : o.drill) && m.drillId != null;
279
+ return /* @__PURE__ */ n("div", { style: { paddingLeft: m.depth === 0 ? 0 : 14 }, children: [
279
280
  /* @__PURE__ */ n(
280
281
  "div",
281
282
  {
282
- role: I || !$ ? "button" : void 0,
283
- tabIndex: I || !$ ? 0 : void 0,
283
+ role: I || !S ? "button" : void 0,
284
+ tabIndex: I || !S ? 0 : void 0,
284
285
  className: W(
285
286
  "group/tn rounded-md px-1.5 py-1",
286
- (I || !$) && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40"
287
+ (I || !S) && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40"
287
288
  ),
288
289
  onClick: () => {
289
- $ ? I && (o != null && o.drill) && a({
290
+ S ? I && (o != null && o.drill) && a({
290
291
  collection: o.drill.collection,
291
- itemId: String(c.drillId),
292
- title: c.label
292
+ itemId: String(m.drillId),
293
+ title: m.label
293
294
  }) : x((ee) => {
294
295
  const he = new Set(ee);
295
- return he.has(c.key) ? he.delete(c.key) : he.add(c.key), he;
296
+ return he.has(m.key) ? he.delete(m.key) : he.add(m.key), he;
296
297
  });
297
298
  },
298
299
  onKeyDown: (ee) => {
@@ -300,7 +301,7 @@ function Ha({
300
301
  },
301
302
  children: [
302
303
  /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5", children: [
303
- $ ? /* @__PURE__ */ e("span", { className: "w-3 shrink-0" }) : /* @__PURE__ */ e(
304
+ S ? /* @__PURE__ */ e("span", { className: "w-3 shrink-0" }) : /* @__PURE__ */ e(
304
305
  Jt,
305
306
  {
306
307
  className: W(
@@ -309,68 +310,68 @@ function Ha({
309
310
  )
310
311
  }
311
312
  ),
312
- $ && c.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: c.badge }),
313
+ S && 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 }),
313
314
  /* @__PURE__ */ e(
314
315
  "span",
315
316
  {
316
317
  className: W(
317
318
  "min-w-0 flex-1 truncate",
318
- c.depth === 0 ? "text-[12px] font-semibold text-slate-800 dark:text-slate-100" : c.depth === 1 ? "text-[11.5px] font-medium text-slate-700 dark:text-slate-200" : W(
319
+ 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" : W(
319
320
  "text-[11px] text-slate-600 dark:text-slate-300",
320
321
  I && "group-hover/tn:underline"
321
322
  )
322
323
  ),
323
- children: c.label
324
+ children: m.label
324
325
  }
325
326
  ),
326
- (o == null ? void 0 : o.pct) && (c.pct == null ? /* @__PURE__ */ e("span", { className: "shrink-0 text-[10.5px] font-semibold tabular-nums text-slate-400", children: "—" }) : /* @__PURE__ */ n(
327
+ (o == null ? void 0 : o.pct) && (m.pct == null ? /* @__PURE__ */ e("span", { className: "shrink-0 text-[10.5px] font-semibold tabular-nums text-slate-400", children: "—" }) : /* @__PURE__ */ n(
327
328
  "span",
328
329
  {
329
330
  className: "shrink-0 text-[10.5px] font-semibold tabular-nums",
330
331
  style: { color: E },
331
332
  children: [
332
- c.pct.toFixed(1),
333
+ m.pct.toFixed(1),
333
334
  "%"
334
335
  ]
335
336
  }
336
337
  ))
337
338
  ] }),
338
- (o == null ? void 0 : o.pct) && c.pct != null && /* @__PURE__ */ e(
339
+ (o == null ? void 0 : o.pct) && m.pct != null && /* @__PURE__ */ e(
339
340
  "div",
340
341
  {
341
342
  className: W(
342
343
  "ml-[18px] mt-0.5 overflow-hidden rounded-full bg-slate-100 dark:bg-muted",
343
- c.depth === 0 ? "h-[5px]" : c.depth === 1 ? "h-[3px]" : "h-[2px]"
344
+ m.depth === 0 ? "h-[5px]" : m.depth === 1 ? "h-[3px]" : "h-[2px]"
344
345
  ),
345
346
  children: /* @__PURE__ */ e(
346
347
  "div",
347
348
  {
348
349
  className: "h-full rounded-full transition-[width] duration-300",
349
- style: { width: `${Math.min(Math.max(c.pct, 0), 100)}%`, background: E }
350
+ style: { width: `${Math.min(Math.max(m.pct, 0), 100)}%`, background: E }
350
351
  }
351
352
  )
352
353
  }
353
354
  ),
354
- /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: m.map((ee) => /* @__PURE__ */ n("span", { children: [
355
+ /* @__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((ee) => /* @__PURE__ */ n("span", { children: [
355
356
  (ee.label ?? ee.field).slice(0, 14),
356
357
  " ",
357
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: c.sums[ee.field] == null ? "—" : i.value_format === "currency" ? Va(c.sums[ee.field]) : c.sums[ee.field].toLocaleString() })
358
+ /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: m.sums[ee.field] == null ? "—" : s.value_format === "currency" ? Ga(m.sums[ee.field]) : m.sums[ee.field].toLocaleString() })
358
359
  ] }, ee.field)) })
359
360
  ]
360
361
  }
361
362
  ),
362
- X && c.children.map(_)
363
- ] }, c.key);
363
+ X && m.children.map(C)
364
+ ] }, m.key);
364
365
  };
365
- return !o || 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(_) });
366
+ return !o || 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(C) });
366
367
  }
367
- function Xa(t) {
368
- const i = Ke(), a = Ct(!1);
368
+ function Za(t) {
369
+ const s = Ke(), a = Ct(!1);
369
370
  return async (o) => {
370
371
  if (!(!t || a.current)) {
371
372
  a.current = !0;
372
373
  try {
373
- const u = (await i.request(pt("/report-studio/drill-row", { values: o }))).data;
374
+ const u = (await s.request(pt("/report-studio/drill-row", { values: o }))).data;
374
375
  u != null && u.collection && u.item_id && t({ collection: u.collection, itemId: u.item_id });
375
376
  } catch {
376
377
  } finally {
@@ -379,55 +380,72 @@ function Xa(t) {
379
380
  }
380
381
  };
381
382
  }
382
- function Za({
383
+ function Ia({
383
384
  cfg: t,
384
- dateRange: i,
385
+ dateRange: s,
385
386
  entityFilters: a,
386
387
  refetchInterval: o,
387
- onStatus: m,
388
+ onStatus: c,
388
389
  onDrill: u
389
390
  }) {
390
391
  var pe, ne, re, Te;
391
- const b = Ke(), x = Xa(u), [p, K] = M(""), [F, N] = M(0), [_, c] = M(null), $ = Ja(t, i, a), { data: X, isLoading: E, error: I, isFetching: ee, refetch: he } = Ne({
392
- queryKey: ["nivaro-report-query", t.slug, $],
393
- queryFn: () => b.request(ra(t.slug, $)).then((k) => k.data ?? []),
392
+ const b = Ke(), x = Za(u), [p, K] = M(""), [F, N] = M(0), [C, m] = M(null), S = Va(t, s, a), { data: X, isLoading: E, error: I, isFetching: ee, refetch: he } = Ne({
393
+ queryKey: ["nivaro-report-query", t.slug, S],
394
+ queryFn: () => b.request(na(t.slug, S)).then((v) => v.data ?? []),
394
395
  staleTime: 6e4,
395
396
  refetchInterval: o,
396
397
  retry: !1
397
398
  });
398
399
  if (_t(() => {
399
- m == null || m({ isFetching: ee, refetch: () => void he() });
400
- }, [ee]), E) return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
400
+ c == null || c({ isFetching: ee, refetch: () => void he() });
401
+ }, [ee]), E)
402
+ return /* @__PURE__ */ n("div", { className: "flex flex-col gap-2 px-1", children: [
403
+ /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
404
+ /* @__PURE__ */ e(
405
+ Xt,
406
+ {
407
+ pending: !0,
408
+ request: {
409
+ method: "POST",
410
+ url: `/custom-queries/${t.slug}/execute`,
411
+ body: { params: S }
412
+ },
413
+ label: `Query ${t.slug}`,
414
+ queryKey: ["nivaro-report-query", t.slug, S],
415
+ select: (v) => (v == null ? void 0 : v.data) ?? []
416
+ }
417
+ )
418
+ ] });
401
419
  if (I) {
402
- const k = ((ne = (pe = I.response) == null ? void 0 : pe.data) == null ? void 0 : ne.error) ?? "Query failed";
403
- return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-red-400", children: k });
420
+ const v = ((ne = (pe = I.response) == null ? void 0 : pe.data) == null ? void 0 : ne.error) ?? "Query failed";
421
+ return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-red-400", children: v });
404
422
  }
405
423
  let z = X ?? [];
406
424
  if (t.group_rows && t.x_field) {
407
- const k = /* @__PURE__ */ new Map(), w = new Set(
425
+ const v = /* @__PURE__ */ new Map(), w = new Set(
408
426
  (t.series ?? []).map((P) => P.field).length > 0 ? (t.series ?? []).map((P) => P.field) : Object.keys(z[0] ?? {}).filter((P) => {
409
427
  var O;
410
428
  return typeof ((O = z[0]) == null ? void 0 : O[P]) == "number";
411
429
  })
412
430
  );
413
431
  for (const P of z) {
414
- const O = String(P[t.x_field] ?? "Unknown"), U = k.get(O) ?? { [t.x_field]: O };
432
+ const O = String(P[t.x_field] ?? "Unknown"), U = v.get(O) ?? { [t.x_field]: O };
415
433
  for (const G of w) U[G] = (Number(U[G]) || 0) + (Number(P[G]) || 0);
416
- k.set(O, U);
434
+ v.set(O, U);
417
435
  }
418
- z = [...k.values()];
436
+ z = [...v.values()];
419
437
  }
420
438
  if (t.sort) {
421
- const k = t.sort.startsWith("-"), w = k ? t.sort.slice(1) : t.sort;
439
+ const v = t.sort.startsWith("-"), w = v ? t.sort.slice(1) : t.sort;
422
440
  z = [...z].sort((P, O) => {
423
441
  const U = P[w], G = O[w], ie = typeof U == "number" && typeof G == "number" ? U - G : String(U ?? "").localeCompare(String(G ?? ""));
424
- return k ? -ie : ie;
442
+ return v ? -ie : ie;
425
443
  });
426
444
  }
427
445
  if (t.limit && t.limit > 0 && (z = z.slice(0, t.limit)), z.length === 0) return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
428
- const ae = t.columns && t.columns.length > 0 ? t.columns : Object.keys(z[0] ?? {}).map((k) => ({ field: k }));
446
+ const ae = t.columns && t.columns.length > 0 ? t.columns : Object.keys(z[0] ?? {}).map((v) => ({ field: v }));
429
447
  if (t.display === "kpis") {
430
- const k = t.x_field ? z.map((w, P) => {
448
+ const v = t.x_field ? z.map((w, P) => {
431
449
  var O, U, G, ie, q;
432
450
  return {
433
451
  label: String(w[t.x_field] ?? ""),
@@ -448,8 +466,8 @@ function Za({
448
466
  "div",
449
467
  {
450
468
  className: "grid gap-2",
451
- style: { gridTemplateColumns: `repeat(${Math.min(6, Math.max(1, k.length))}, 1fr)` },
452
- children: k.map((w) => /* @__PURE__ */ n(
469
+ style: { gridTemplateColumns: `repeat(${Math.min(6, Math.max(1, v.length))}, 1fr)` },
470
+ children: v.map((w) => /* @__PURE__ */ n(
453
471
  "div",
454
472
  {
455
473
  className: "flex flex-col justify-center rounded-md border border-slate-100 px-3 py-2 dark:border-border/60",
@@ -465,9 +483,9 @@ function Za({
465
483
  );
466
484
  }
467
485
  if (t.display === "tree")
468
- return /* @__PURE__ */ e(Ha, { rows: z, cfg: t, onDrill: (k) => u == null ? void 0 : u(k) });
486
+ return /* @__PURE__ */ e(Xa, { rows: z, cfg: t, onDrill: (v) => u == null ? void 0 : u(v) });
469
487
  if (t.display === "table") {
470
- const k = ae.filter((q) => We.has(q.format ?? "")), w = p.trim().toLowerCase(), P = w ? z.filter(
488
+ const v = ae.filter((q) => We.has(q.format ?? "")), w = p.trim().toLowerCase(), P = w ? z.filter(
471
489
  (q) => Object.values(q).some(
472
490
  (J) => String(J ?? "").toLowerCase().includes(w)
473
491
  )
@@ -543,7 +561,7 @@ function Za({
543
561
  },
544
562
  J
545
563
  )) }),
546
- t.totals && k.length > 0 && /* @__PURE__ */ e("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: ae.map((q, J) => /* @__PURE__ */ e(
564
+ t.totals && v.length > 0 && /* @__PURE__ */ e("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: ae.map((q, J) => /* @__PURE__ */ e(
547
565
  "td",
548
566
  {
549
567
  className: W(
@@ -561,65 +579,65 @@ function Za({
561
579
  ] }) })
562
580
  ] });
563
581
  }
564
- const ce = t.x_field ?? ((re = ae[0]) == null ? void 0 : re.field) ?? "", xe = t.series && t.series.length > 0 ? t.series : ae.filter((k) => {
582
+ const ce = t.x_field ?? ((re = ae[0]) == null ? void 0 : re.field) ?? "", xe = t.series && t.series.length > 0 ? t.series : ae.filter((v) => {
565
583
  var w;
566
- return k.field !== ce && typeof ((w = z[0]) == null ? void 0 : w[k.field]) == "number";
567
- }).slice(0, 3).map((k) => ({ field: k.field, label: k.label ?? k.field })), ye = z.map((k) => {
568
- const w = { [ce]: k[ce] };
569
- for (const P of xe) w[P.field] = Number(k[P.field]) || 0;
584
+ return v.field !== ce && typeof ((w = z[0]) == null ? void 0 : w[v.field]) == "number";
585
+ }).slice(0, 3).map((v) => ({ field: v.field, label: v.label ?? v.field })), ye = z.map((v) => {
586
+ const w = { [ce]: v[ce] };
587
+ for (const P of xe) w[P.field] = Number(v[P.field]) || 0;
570
588
  return w;
571
- }), _e = (k) => t.value_format === "currency" ? `$${qe(k)}` : qe(k), Ce = (k) => Be(k, t.value_format ?? "number"), f = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, te = (k) => {
589
+ }), _e = (v) => t.value_format === "currency" ? `$${qe(v)}` : qe(v), Ce = (v) => Be(v, t.value_format ?? "number"), f = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, te = (v) => {
572
590
  if (!u) return;
573
- const w = (X ?? []).filter((P) => String(P[ce] ?? "") === k);
574
- w.length > 0 && c({ label: k, rows: w });
575
- }, le = _ ? /* @__PURE__ */ e(
591
+ const w = (X ?? []).filter((P) => String(P[ce] ?? "") === v);
592
+ w.length > 0 && m({ label: v, rows: w });
593
+ }, le = C ? /* @__PURE__ */ e(
576
594
  "div",
577
595
  {
578
596
  className: "fixed inset-0 z-[126] flex items-center justify-center bg-black/30 p-6",
579
- onClick: () => c(null),
597
+ onClick: () => m(null),
580
598
  children: /* @__PURE__ */ n(
581
599
  "div",
582
600
  {
583
601
  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",
584
- onClick: (k) => k.stopPropagation(),
602
+ onClick: (v) => v.stopPropagation(),
585
603
  children: [
586
604
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
587
- /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: _.label }),
605
+ /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: C.label }),
588
606
  /* @__PURE__ */ n("span", { className: "text-[11.5px] text-slate-400", children: [
589
- _.rows.length,
607
+ C.rows.length,
590
608
  " rows — click one to open its record"
591
609
  ] }),
592
610
  /* @__PURE__ */ e(
593
611
  "button",
594
612
  {
595
613
  type: "button",
596
- onClick: () => c(null),
614
+ onClick: () => m(null),
597
615
  className: "rounded p-1 text-slate-400 hover:text-slate-600",
598
616
  children: /* @__PURE__ */ e(Re, { className: "h-4 w-4" })
599
617
  }
600
618
  )
601
619
  ] }),
602
620
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto p-2", children: /* @__PURE__ */ n("table", { className: "w-full text-[11px]", children: [
603
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: Object.keys(_.rows[0] ?? {}).slice(0, 7).map((k) => /* @__PURE__ */ e(
621
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: Object.keys(C.rows[0] ?? {}).slice(0, 7).map((v) => /* @__PURE__ */ e(
604
622
  "th",
605
623
  {
606
624
  className: "border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
607
- children: k
625
+ children: v
608
626
  },
609
- k
627
+ v
610
628
  )) }) }),
611
- /* @__PURE__ */ e("tbody", { children: _.rows.slice(0, 100).map((k, w) => /* @__PURE__ */ e(
629
+ /* @__PURE__ */ e("tbody", { children: C.rows.slice(0, 100).map((v, w) => /* @__PURE__ */ e(
612
630
  "tr",
613
631
  {
614
632
  className: "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60",
615
633
  onClick: () => {
616
- c(null), x(k);
634
+ m(null), x(v);
617
635
  },
618
- children: Object.keys(_.rows[0] ?? {}).slice(0, 7).map((P) => /* @__PURE__ */ e(
636
+ children: Object.keys(C.rows[0] ?? {}).slice(0, 7).map((P) => /* @__PURE__ */ e(
619
637
  "td",
620
638
  {
621
639
  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",
622
- children: String(k[P] ?? "")
640
+ children: String(v[P] ?? "")
623
641
  },
624
642
  P
625
643
  ))
@@ -633,7 +651,7 @@ function Za({
633
651
  }
634
652
  ) : null;
635
653
  if (t.display === "donut") {
636
- const k = ((Te = xe[0]) == null ? void 0 : Te.field) ?? "", w = ye.map((O) => ({ dim: String(O[ce]), value: Number(O[k]) || 0 })), P = w.reduce((O, U) => O + U.value, 0);
654
+ const v = ((Te = xe[0]) == null ? void 0 : Te.field) ?? "", w = ye.map((O) => ({ dim: String(O[ce]), value: Number(O[v]) || 0 })), P = w.reduce((O, U) => O + U.value, 0);
637
655
  return /* @__PURE__ */ n("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
638
656
  /* @__PURE__ */ n("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
639
657
  /* @__PURE__ */ e(
@@ -703,7 +721,7 @@ function Za({
703
721
  Oe,
704
722
  {
705
723
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
706
- children: ({ Area: k, AreaChart: w, Legend: P, ResponsiveContainer: O, Tooltip: U, XAxis: G, YAxis: ie }) => /* @__PURE__ */ e(O, { width: "100%", height: "100%", children: /* @__PURE__ */ n(w, { data: ye, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
724
+ children: ({ Area: v, AreaChart: w, Legend: P, ResponsiveContainer: O, Tooltip: U, XAxis: G, YAxis: ie }) => /* @__PURE__ */ e(O, { width: "100%", height: "100%", children: /* @__PURE__ */ n(w, { data: ye, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
707
725
  /* @__PURE__ */ e(
708
726
  G,
709
727
  {
@@ -731,7 +749,7 @@ function Za({
731
749
  ),
732
750
  xe.length > 1 && /* @__PURE__ */ e(P, { wrapperStyle: { fontSize: 11 } }),
733
751
  xe.map((q, J) => /* @__PURE__ */ e(
734
- k,
752
+ v,
735
753
  {
736
754
  type: "monotone",
737
755
  dataKey: q.field,
@@ -755,7 +773,7 @@ function Za({
755
773
  Oe,
756
774
  {
757
775
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
758
- children: ({ Bar: k, BarChart: w, Cell: P, Legend: O, ResponsiveContainer: U, Tooltip: G, XAxis: ie, YAxis: q }) => /* @__PURE__ */ e(U, { width: "100%", height: "100%", children: /* @__PURE__ */ n(
776
+ children: ({ Bar: v, BarChart: w, Cell: P, Legend: O, ResponsiveContainer: U, Tooltip: G, XAxis: ie, YAxis: q }) => /* @__PURE__ */ e(U, { width: "100%", height: "100%", children: /* @__PURE__ */ n(
759
777
  w,
760
778
  {
761
779
  data: ye,
@@ -803,7 +821,7 @@ function Za({
803
821
  ),
804
822
  xe.length > 1 && /* @__PURE__ */ e(O, { wrapperStyle: { fontSize: 11 } }),
805
823
  xe.map((J, me) => /* @__PURE__ */ e(
806
- k,
824
+ v,
807
825
  {
808
826
  className: u ? "cursor-pointer" : void 0,
809
827
  onClick: (ge) => {
@@ -828,10 +846,10 @@ function Za({
828
846
  le
829
847
  ] });
830
848
  }
831
- const Ia = ["gt", "gte", "lt", "lte", "eq"], aa = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, el = ["sum", "avg", "max", "min"];
832
- function tl(t) {
833
- var o, m, u;
834
- const i = [
849
+ const el = ["gt", "gte", "lt", "lte", "eq"], la = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, tl = ["sum", "avg", "max", "min"];
850
+ function al(t) {
851
+ var o, c, u;
852
+ const s = [
835
853
  { value: "value", label: "Value (widget metric)" },
836
854
  { value: "row_count", label: "Row count" }
837
855
  ], a = (o = t.config) == null ? void 0 : o.query;
@@ -841,39 +859,39 @@ function tl(t) {
841
859
  label: x.label ?? x.field,
842
860
  aggregatable: !0
843
861
  }));
844
- return [...i, ...b];
862
+ return [...s, ...b];
845
863
  }
846
864
  if (t.type === "kpi_group")
847
865
  return [
848
- ...i,
849
- ...(((m = t.config) == null ? void 0 : m.metrics) ?? []).map((b) => ({
866
+ ...s,
867
+ ...(((c = t.config) == null ? void 0 : c.metrics) ?? []).map((b) => ({
850
868
  value: `tile:${b.label}`,
851
869
  label: `Tile: ${b.label}`
852
870
  }))
853
871
  ];
854
872
  if (t.type === "table") {
855
873
  const b = (((u = t.config) == null ? void 0 : u.columns) ?? []).map((x) => typeof x == "string" ? { field: x } : x).map((x) => ({ value: x.field, label: x.label ?? x.field, aggregatable: !0 }));
856
- return [...i, ...b];
874
+ return [...s, ...b];
857
875
  }
858
- return i;
876
+ return s;
859
877
  }
860
- function jt(t, i) {
878
+ function jt(t, s) {
861
879
  var b;
862
- const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), o = a ? a[2] : t.field, m = ((b = i.find((x) => x.value === t.field || x.value === o)) == null ? void 0 : b.label) ?? o;
863
- return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${m} ${aa[t.op] ?? t.op} ${t.value.toLocaleString()}`;
880
+ const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), o = a ? a[2] : t.field, c = ((b = s.find((x) => x.value === t.field || x.value === o)) == null ? void 0 : b.label) ?? o;
881
+ return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${c} ${la[t.op] ?? t.op} ${t.value.toLocaleString()}`;
864
882
  }
865
- function al({ reportId: t, alert: i }) {
866
- const a = Ke(), o = qt(), { data: m = [] } = Ne({
867
- queryKey: ["nivaro-report-alert-log", t, i.id],
868
- queryFn: () => a.request(fa(t, i.id)).then((b) => b.data),
883
+ function ll({ reportId: t, alert: s }) {
884
+ const a = Ke(), o = qt(), { data: c = [] } = Ne({
885
+ queryKey: ["nivaro-report-alert-log", t, s.id],
886
+ queryFn: () => a.request(xa(t, s.id)).then((b) => b.data),
869
887
  staleTime: 3e4
870
888
  }), u = Fe({
871
- mutationFn: () => a.request(xa(t, i.id)),
889
+ mutationFn: () => a.request(ba(t, s.id)),
872
890
  onSuccess: () => {
873
- o.invalidateQueries({ queryKey: ["nivaro-report-alert-log", t, i.id] }), o.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] });
891
+ o.invalidateQueries({ queryKey: ["nivaro-report-alert-log", t, s.id] }), o.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] });
874
892
  }
875
893
  });
876
- return m.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 py-1 text-[10.5px] text-slate-400", children: "Never fired." }) : /* @__PURE__ */ e("div", { className: "max-h-36 space-y-1 overflow-y-auto py-1", children: m.slice(0, 20).map((b) => /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
894
+ return c.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 py-1 text-[10.5px] text-slate-400", children: "Never fired." }) : /* @__PURE__ */ e("div", { className: "max-h-36 space-y-1 overflow-y-auto py-1", children: c.slice(0, 20).map((b) => /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
877
895
  /* @__PURE__ */ e(
878
896
  "span",
879
897
  {
@@ -899,47 +917,47 @@ function al({ reportId: t, alert: i }) {
899
917
  )
900
918
  ] }, b.id)) });
901
919
  }
902
- function ll({
920
+ function rl({
903
921
  reportId: t,
904
- widget: i,
922
+ widget: s,
905
923
  filterBar: a
906
924
  }) {
907
- const o = Ke(), m = qt(), [u, b] = M(!1), [x, p] = M(""), [K, F] = M([
925
+ const o = Ke(), c = qt(), [u, b] = M(!1), [x, p] = M(""), [K, F] = M([
908
926
  { field: "value", agg: "sum", op: "gt", value: "" }
909
- ]), [N, _] = M([]), [c, $] = M(!1), [X, E] = M(null), I = tl(i), { data: ee = [] } = Ne({
927
+ ]), [N, C] = M([]), [m, S] = M(!1), [X, E] = M(null), I = al(s), { data: ee = [] } = Ne({
910
928
  queryKey: ["nivaro-report-alerts", t],
911
- queryFn: () => o.request(ma(t)).then((f) => f.data),
929
+ queryFn: () => o.request(ua(t)).then((f) => f.data),
912
930
  enabled: u,
913
931
  staleTime: 3e4
914
- }), he = ee.filter((f) => f.widget === i.id), z = () => void m.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), ae = () => K.filter((f) => f.value.trim() !== "" && !Number.isNaN(Number(f.value))).map((f) => {
932
+ }), he = ee.filter((f) => f.widget === s.id), z = () => void c.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), ae = () => K.filter((f) => f.value.trim() !== "" && !Number.isNaN(Number(f.value))).map((f) => {
915
933
  const te = I.find((Y) => Y.value === f.field);
916
934
  return { field: te != null && te.aggregatable && f.agg !== "sum" ? `${f.agg}:${f.field}` : f.field, op: f.op, value: Number(f.value) };
917
935
  }), ce = Fe({
918
936
  mutationFn: () => {
919
937
  const f = ae(), te = f.map((le) => jt(le, I)).join(" & ");
920
938
  return o.request(
921
- ua(t, {
922
- widget: i.id,
939
+ pa(t, {
940
+ widget: s.id,
923
941
  name: x.trim() || te.slice(0, 120),
924
942
  conditions: f,
925
943
  filters: N.filter((le) => le.values.length > 0),
926
- delivery_email: c,
944
+ delivery_email: m,
927
945
  delivery_inapp: !0
928
946
  })
929
947
  );
930
948
  },
931
949
  onSuccess: () => {
932
- p(""), F([{ field: "value", agg: "sum", op: "gt", value: "" }]), _([]), z();
950
+ p(""), F([{ field: "value", agg: "sum", op: "gt", value: "" }]), C([]), z();
933
951
  }
934
952
  }), xe = Fe({
935
- mutationFn: (f) => o.request(pa(t, f.id, !f.is_active)),
953
+ mutationFn: (f) => o.request(ha(t, f.id, !f.is_active)),
936
954
  onSuccess: z
937
955
  }), ye = Fe({
938
- mutationFn: (f) => o.request(ha(t, f.id)),
956
+ mutationFn: (f) => o.request(fa(t, f.id)),
939
957
  onSuccess: z
940
958
  }), _e = ae().length > 0, Ce = he.some((f) => f.firing);
941
- return /* @__PURE__ */ n(Xt, { open: u, onOpenChange: b, children: [
942
- /* @__PURE__ */ e(Zt, { asChild: !0, children: /* @__PURE__ */ e(
959
+ return /* @__PURE__ */ n(Zt, { open: u, onOpenChange: b, children: [
960
+ /* @__PURE__ */ e(It, { asChild: !0, children: /* @__PURE__ */ e(
943
961
  "button",
944
962
  {
945
963
  type: "button",
@@ -951,10 +969,10 @@ function ll({
951
969
  children: /* @__PURE__ */ e(Yt, { className: "h-3 w-3" })
952
970
  }
953
971
  ) }),
954
- /* @__PURE__ */ n(It, { className: "w-[380px] p-3", align: "end", children: [
972
+ /* @__PURE__ */ n(ea, { className: "w-[380px] p-3", align: "end", children: [
955
973
  /* @__PURE__ */ n("p", { className: "mb-2 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: [
956
974
  "Alerts · ",
957
- i.title
975
+ s.title
958
976
  ] }),
959
977
  he.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 space-y-1.5", children: he.map((f) => /* @__PURE__ */ n(
960
978
  "div",
@@ -996,7 +1014,7 @@ function ll({
996
1014
  type: "button",
997
1015
  className: "text-slate-300 hover:text-red-500",
998
1016
  onClick: () => ye.mutate(f),
999
- children: /* @__PURE__ */ e(Na, { className: "h-3 w-3" })
1017
+ children: /* @__PURE__ */ e(wa, { className: "h-3 w-3" })
1000
1018
  }
1001
1019
  )
1002
1020
  ] }),
@@ -1008,7 +1026,7 @@ function ll({
1008
1026
  " · Last fired: ",
1009
1027
  f.last_fired ? new Date(f.last_fired).toLocaleString() : "Never"
1010
1028
  ] }),
1011
- X === f.id && /* @__PURE__ */ e(al, { reportId: t, alert: f })
1029
+ X === f.id && /* @__PURE__ */ e(ll, { reportId: t, alert: f })
1012
1030
  ]
1013
1031
  },
1014
1032
  f.id
@@ -1043,7 +1061,7 @@ function ll({
1043
1061
  onChange: (Y) => F(
1044
1062
  (pe) => pe.map((ne, re) => re === te ? { ...ne, agg: Y } : ne)
1045
1063
  ),
1046
- options: el.map((Y) => ({ value: Y, label: Y })),
1064
+ options: tl.map((Y) => ({ value: Y, label: Y })),
1047
1065
  ariaLabel: "Aggregate",
1048
1066
  className: "h-7 w-[62px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1049
1067
  }
@@ -1055,7 +1073,7 @@ function ll({
1055
1073
  onChange: (Y) => F(
1056
1074
  (pe) => pe.map((ne, re) => re === te ? { ...ne, op: Y } : ne)
1057
1075
  ),
1058
- options: Ia.map((Y) => ({ value: Y, label: aa[Y] })),
1076
+ options: el.map((Y) => ({ value: Y, label: la[Y] })),
1059
1077
  ariaLabel: "Operator",
1060
1078
  className: "h-7 w-[52px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1061
1079
  }
@@ -1097,14 +1115,14 @@ function ll({
1097
1115
  /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1", children: a.map((f) => {
1098
1116
  var te;
1099
1117
  return /* @__PURE__ */ e(
1100
- ea,
1118
+ ta,
1101
1119
  {
1102
1120
  reportId: t,
1103
1121
  field: f.field,
1104
1122
  label: f.label,
1105
1123
  optionSource: f.options,
1106
1124
  selected: ((te = N.find((le) => le.field === f.field)) == null ? void 0 : te.values) ?? [],
1107
- onChange: (le, Y) => _((pe) => [
1125
+ onChange: (le, Y) => C((pe) => [
1108
1126
  ...pe.filter((ne) => ne.field !== f.field),
1109
1127
  ...le.length > 0 ? [{ field: f.field, values: le, labels: Y }] : []
1110
1128
  ])
@@ -1119,8 +1137,8 @@ function ll({
1119
1137
  "input",
1120
1138
  {
1121
1139
  type: "checkbox",
1122
- checked: c,
1123
- onChange: (f) => $(f.target.checked),
1140
+ checked: m,
1141
+ onChange: (f) => S(f.target.checked),
1124
1142
  className: "h-3 w-3 accent-nvr-cyan"
1125
1143
  }
1126
1144
  ),
@@ -1145,7 +1163,7 @@ function ll({
1145
1163
  ] })
1146
1164
  ] });
1147
1165
  }
1148
- const rl = {
1166
+ const nl = {
1149
1167
  eq: "_eq",
1150
1168
  neq: "_neq",
1151
1169
  gt: "_gt",
@@ -1157,97 +1175,97 @@ const rl = {
1157
1175
  null: "_null",
1158
1176
  nnull: "_nnull"
1159
1177
  };
1160
- function Ft(t, i, a, o) {
1178
+ function Ft(t, s, a, o) {
1161
1179
  var K, F;
1162
- const m = t.config ?? {}, u = [];
1163
- for (const N of m.filters ?? []) {
1164
- const _ = rl[N.op];
1165
- if (!_) continue;
1166
- let c = N.value;
1167
- N.op === "in" && typeof c == "string" && (c = c.split(",").map(($) => $.trim())), u.push({ path: [N.field], op: _, value: c });
1180
+ const c = t.config ?? {}, u = [];
1181
+ for (const N of c.filters ?? []) {
1182
+ const C = nl[N.op];
1183
+ if (!C) continue;
1184
+ let m = N.value;
1185
+ N.op === "in" && typeof m == "string" && (m = m.split(",").map((S) => S.trim())), u.push({ path: [N.field], op: C, value: m });
1168
1186
  }
1169
- for (const N of i)
1187
+ for (const N of s)
1170
1188
  (K = N.values) != null && K.length && u.push({ path: [N.field], op: "_in", value: N.values });
1171
- const b = m.date_field || ((F = m.dimension) != null && F.bucket ? m.dimension.field : null), x = ta(a);
1189
+ const b = c.date_field || ((F = c.dimension) != null && F.bucket ? c.dimension.field : null), x = aa(a);
1172
1190
  x && b && (u.push({ path: [b], op: "_gte", value: x.start }), u.push({ path: [b], op: "_lte", value: `${x.end}T23:59:59` }));
1173
- const p = m.dimension;
1191
+ const p = c.dimension;
1174
1192
  if (o !== void 0 && (p != null && p.field))
1175
1193
  if (p.bucket) {
1176
1194
  const N = String(o);
1177
1195
  if (/^\d{4}-\d{2}-\d{2}$/.test(N))
1178
1196
  u.push({ path: [p.field], op: "_gte", value: N }), u.push({ path: [p.field], op: "_lte", value: `${N}T23:59:59` });
1179
1197
  else if (/^\d{4}-\d{2}$/.test(N)) {
1180
- const [_, c] = N.split("-").map(Number), $ = new Date(_, c, 0).getDate();
1198
+ const [C, m] = N.split("-").map(Number), S = new Date(C, m, 0).getDate();
1181
1199
  u.push({ path: [p.field], op: "_gte", value: `${N}-01` }), u.push({
1182
1200
  path: [p.field],
1183
1201
  op: "_lte",
1184
- value: `${N}-${String($).padStart(2, "0")}T23:59:59`
1202
+ value: `${N}-${String(S).padStart(2, "0")}T23:59:59`
1185
1203
  });
1186
1204
  }
1187
1205
  } else o === null ? u.push({ path: [p.field], op: "_null", value: !0 }) : u.push({ path: [p.field], op: "_eq", value: o });
1188
1206
  return u;
1189
1207
  }
1190
1208
  function Et(t) {
1191
- const i = t.config ?? {}, a = [], o = i.query;
1209
+ const s = t.config ?? {}, a = [], o = s.query;
1192
1210
  if (t.type === "query" && (o != null && o.slug))
1193
1211
  a.push(`Custom query: ${o.slug}`);
1194
1212
  else if (t.collection) {
1195
- const m = i.metric, u = (m == null ? void 0 : m.aggregate) ?? "count";
1213
+ const c = s.metric, u = (c == null ? void 0 : c.aggregate) ?? "count";
1196
1214
  a.push(
1197
- `${u === "count" ? "Count of" : `${u.toUpperCase()} of ${(m == null ? void 0 : m.field) ?? "?"} on`} ${t.collection.replace(/_/g, " ")}`
1215
+ `${u === "count" ? "Count of" : `${u.toUpperCase()} of ${(c == null ? void 0 : c.field) ?? "?"} on`} ${t.collection.replace(/_/g, " ")}`
1198
1216
  );
1199
- const b = i.dimension;
1217
+ const b = s.dimension;
1200
1218
  b != null && b.field && a.push(`by ${b.field}${b.bucket ? ` (${b.bucket})` : ""}`);
1201
- const x = i.filters ?? [];
1219
+ const x = s.filters ?? [];
1202
1220
  for (const p of x) a.push(`${p.field} ${p.op} ${String(p.value ?? "")}`);
1203
- i.date_field && a.push(`dated by ${i.date_field}`), i.compare && a.push(`compared to ${String(i.compare).replace(/_/g, " ")}`);
1221
+ s.date_field && a.push(`dated by ${s.date_field}`), s.compare && a.push(`compared to ${String(s.compare).replace(/_/g, " ")}`);
1204
1222
  }
1205
1223
  return a.length > 0 ? a.join(" · ") : "No configuration details";
1206
1224
  }
1207
- function nl(t) {
1208
- var i, a;
1209
- return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((o, m) => o + (Number(m.value) || 0), 0) : (i = t.tiles) != null && i.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1225
+ function sl(t) {
1226
+ var s, a;
1227
+ return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((o, c) => o + (Number(c.value) || 0), 0) : (s = t.tiles) != null && s.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1210
1228
  }
1211
- function sl(t, i, a) {
1229
+ function il(t, s, a) {
1212
1230
  var K, F, N;
1213
1231
  const o = [];
1214
- if (o.length === 0 && ((K = i == null ? void 0 : i.rows) != null && K.length) && o.push(...i.rows), o.length === 0 && ((F = i == null ? void 0 : i.series) != null && F.length))
1215
- for (const _ of i.series)
1232
+ if (o.length === 0 && ((K = s == null ? void 0 : s.rows) != null && K.length) && o.push(...s.rows), o.length === 0 && ((F = s == null ? void 0 : s.series) != null && F.length))
1233
+ for (const C of s.series)
1216
1234
  o.push({
1217
- dim: _.dim,
1218
- value: _.value,
1219
- ..._.prev != null ? { previous: _.prev } : {},
1220
- ..._.value2 != null ? { value2: _.value2 } : {}
1235
+ dim: C.dim,
1236
+ value: C.value,
1237
+ ...C.prev != null ? { previous: C.prev } : {},
1238
+ ...C.value2 != null ? { value2: C.value2 } : {}
1221
1239
  });
1222
- if (o.length === 0 && ((N = i == null ? void 0 : i.tiles) != null && N.length))
1223
- for (const _ of i.tiles) o.push({ label: _.label, value: _.value });
1224
- if (o.length === 0 && (i == null ? void 0 : i.value) != null && o.push({ value: i.value }), o.length === 0) return;
1225
- const m = [...new Set(o.flatMap((_) => Object.keys(_)))], u = (_) => {
1226
- const c = String(_ ?? "");
1227
- return /[",\n]/.test(c) ? `"${c.replace(/"/g, '""')}"` : c;
1228
- }, b = [m.join(","), ...o.map((_) => m.map((c) => u(_[c])).join(","))].join(
1240
+ if (o.length === 0 && ((N = s == null ? void 0 : s.tiles) != null && N.length))
1241
+ for (const C of s.tiles) o.push({ label: C.label, value: C.value });
1242
+ if (o.length === 0 && (s == null ? void 0 : s.value) != null && o.push({ value: s.value }), o.length === 0) return;
1243
+ const c = [...new Set(o.flatMap((C) => Object.keys(C)))], u = (C) => {
1244
+ const m = String(C ?? "");
1245
+ return /[",\n]/.test(m) ? `"${m.replace(/"/g, '""')}"` : m;
1246
+ }, b = [c.join(","), ...o.map((C) => c.map((m) => u(C[m])).join(","))].join(
1229
1247
  `
1230
1248
  `
1231
1249
  ), x = new Blob([b], { type: "text/csv;charset=utf-8" }), p = document.createElement("a");
1232
1250
  p.href = URL.createObjectURL(x), p.download = `${(t.title || "widget").replace(/[^\w-]+/g, "_")}.csv`, p.click(), URL.revokeObjectURL(p.href);
1233
1251
  }
1234
- function il({
1252
+ function ol({
1235
1253
  collection: t,
1236
- conditions: i,
1254
+ conditions: s,
1237
1255
  title: a,
1238
1256
  onClose: o,
1239
- onOpen: m,
1257
+ onOpen: c,
1240
1258
  crossFilter: u
1241
1259
  }) {
1242
1260
  const b = Ke(), { data: x, isLoading: p } = Ne({
1243
- queryKey: ["nvr-report-drill", t, JSON.stringify(i)],
1261
+ queryKey: ["nvr-report-drill", t, JSON.stringify(s)],
1244
1262
  queryFn: () => b.request(
1245
- mt(`/items/${t}`, { limit: 50, conditions: JSON.stringify(i) })
1263
+ mt(`/items/${t}`, { limit: 50, conditions: JSON.stringify(s) })
1246
1264
  ),
1247
1265
  staleTime: 3e4,
1248
1266
  retry: !1
1249
1267
  }), K = (x == null ? void 0 : x.data) ?? [], F = (N) => {
1250
- for (const c of [
1268
+ for (const m of [
1251
1269
  "title",
1252
1270
  "name",
1253
1271
  "label",
@@ -1256,13 +1274,13 @@ function il({
1256
1274
  "project_id",
1257
1275
  "description"
1258
1276
  ]) {
1259
- const $ = N[c];
1260
- if (typeof $ == "string" && $.trim()) return $.slice(0, 90);
1277
+ const S = N[m];
1278
+ if (typeof S == "string" && S.trim()) return S.slice(0, 90);
1261
1279
  }
1262
- const _ = Object.entries(N).find(
1263
- ([c, $]) => c !== "id" && typeof $ == "string" && $.trim()
1280
+ const C = Object.entries(N).find(
1281
+ ([m, S]) => m !== "id" && typeof S == "string" && S.trim()
1264
1282
  );
1265
- return _ ? String(_[1]).slice(0, 90) : `#${N.id}`;
1283
+ return C ? String(C[1]).slice(0, 90) : `#${N.id}`;
1266
1284
  };
1267
1285
  return /* @__PURE__ */ e(
1268
1286
  "div",
@@ -1305,7 +1323,7 @@ function il({
1305
1323
  "button",
1306
1324
  {
1307
1325
  type: "button",
1308
- onClick: () => m({ collection: t, itemId: String(N.id) }),
1326
+ onClick: () => c({ collection: t, itemId: String(N.id) }),
1309
1327
  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",
1310
1328
  children: F(N)
1311
1329
  },
@@ -1336,15 +1354,15 @@ const Wt = {
1336
1354
  row: "bg-sky-50/70 dark:bg-sky-500/10"
1337
1355
  }
1338
1356
  };
1339
- function Bt(t, i) {
1340
- const a = Number(i);
1357
+ function Bt(t, s) {
1358
+ const a = Number(s);
1341
1359
  return Number.isFinite(a) ? t.op === "gt" ? a > t.value : t.op === "gte" ? a >= t.value : t.op === "lt" ? a < t.value : t.op === "lte" ? a <= t.value : a === t.value : !1;
1342
1360
  }
1343
- const Tt = wa(function({
1344
- reportId: i,
1361
+ const Tt = Sa(function({
1362
+ reportId: s,
1345
1363
  widget: a,
1346
1364
  dateRange: o,
1347
- entityFilters: m,
1365
+ entityFilters: c,
1348
1366
  refetchInterval: u,
1349
1367
  filterBar: b = [],
1350
1368
  onDrill: x,
@@ -1352,40 +1370,40 @@ const Tt = wa(function({
1352
1370
  asOf: K,
1353
1371
  annotations: F,
1354
1372
  onAddAnnotation: N,
1355
- onDeleteAnnotation: _,
1356
- onCrossFilter: c,
1357
- reportUrl: $,
1373
+ onDeleteAnnotation: C,
1374
+ onCrossFilter: m,
1375
+ reportUrl: S,
1358
1376
  currentFilters: X
1359
1377
  }) {
1360
1378
  var Je, xt, Ve, bt, Ge, gt, vt, at, yt, He, lt, Xe, rt, nt, st, se, kt, it, ot, dt, Le, ve;
1361
- const E = Ke(), [I, ee] = M(""), [he, z] = M(0), [ae, ce] = M(null), [xe, ye] = M(!1), [_e, Ce] = M(""), [f, te] = M(""), [le, Y] = M(!1), [pe, ne] = M(!1), [re, Te] = M([]), k = Ct(null), [w, P] = M(!1), [O, U] = M(null), [G, ie] = M(!1), [q, J] = M(null), me = ["bar", "line", "donut", "pareto", "area"].includes(a.type) || a.type === "kpi" && !!((Je = a.config) != null && Je.compare || (xt = a.config) != null && xt.sparkline), ge = qt(), [$e, Pe] = M(!1), we = async () => {
1379
+ const E = Ke(), [I, ee] = M(""), [he, z] = M(0), [ae, ce] = M(null), [xe, ye] = M(!1), [_e, Ce] = M(""), [f, te] = M(""), [le, Y] = M(!1), [pe, ne] = M(!1), [re, Te] = M([]), v = Ct(null), [w, P] = M(!1), [O, U] = M(null), [G, ie] = M(!1), [q, J] = M(null), me = ["bar", "line", "donut", "pareto", "area"].includes(a.type) || a.type === "kpi" && !!((Je = a.config) != null && Je.compare || (xt = a.config) != null && xt.sparkline), ge = qt(), [$e, Pe] = M(!1), we = async () => {
1362
1380
  Pe(!0);
1363
1381
  try {
1364
1382
  const l = await E.request(
1365
- Nt(i, a.id, {
1383
+ Nt(s, a.id, {
1366
1384
  date_range: o,
1367
- entity_filters: m,
1385
+ entity_filters: c,
1368
1386
  fresh: 1
1369
1387
  })
1370
1388
  );
1371
1389
  ge.setQueryData(
1372
- ["nivaro-report-widget", i, a.id, o, m],
1390
+ ["nivaro-report-widget", s, a.id, o, c],
1373
1391
  l.data
1374
1392
  );
1375
1393
  } catch {
1376
1394
  }
1377
1395
  Pe(!1);
1378
1396
  }, et = ut(
1379
- () => ({ date_range: o ?? null, entity_filters: m }),
1380
- [o, m]
1381
- ), ke = $a({
1397
+ () => ({ date_range: o ?? null, entity_filters: c }),
1398
+ [o, c]
1399
+ ), ke = qa({
1382
1400
  kind: "report",
1383
1401
  widget: a.id,
1384
- report: i,
1402
+ report: s,
1385
1403
  params: et,
1386
1404
  enabled: a.type !== "divider" && a.type !== "query",
1387
1405
  onData: (l) => ge.setQueryData(
1388
- ["nivaro-report-widget", i, a.id, o, m],
1406
+ ["nivaro-report-widget", s, a.id, o, c],
1389
1407
  l
1390
1408
  ),
1391
1409
  onStale: () => void Qe()
@@ -1396,11 +1414,11 @@ const Tt = wa(function({
1396
1414
  refetch: Qe,
1397
1415
  isFetching: ht
1398
1416
  } = Ne({
1399
- queryKey: ["nivaro-report-widget", i, a.id, o, m],
1417
+ queryKey: ["nivaro-report-widget", s, a.id, o, c],
1400
1418
  queryFn: () => E.request(
1401
- Nt(i, a.id, {
1419
+ Nt(s, a.id, {
1402
1420
  date_range: o,
1403
- entity_filters: m
1421
+ entity_filters: c
1404
1422
  })
1405
1423
  ).then((l) => l.data),
1406
1424
  // Query widgets resolve client-side in QueryWidgetBody — but when a
@@ -1409,7 +1427,7 @@ const Tt = wa(function({
1409
1427
  enabled: a.type !== "divider" && (a.type !== "query" || !!p),
1410
1428
  staleTime: 6e4,
1411
1429
  // Per-widget auto-refresh (#168) overrides the report-level interval.
1412
- refetchInterval: qa(
1430
+ refetchInterval: Ma(
1413
1431
  ke,
1414
1432
  Number((Ve = a.config) == null ? void 0 : Ve.refresh_secs) >= 10 ? Number(a.config.refresh_secs) * 1e3 : u
1415
1433
  ),
@@ -1417,12 +1435,12 @@ const Tt = wa(function({
1417
1435
  }), Ue = (((bt = a.config) == null ? void 0 : bt.drill_levels) ?? []).filter(
1418
1436
  (l) => typeof l == "string" && l
1419
1437
  ), { data: ft } = Ne({
1420
- queryKey: ["nvr-report-drill", i, a.id, re, o, m],
1438
+ queryKey: ["nvr-report-drill", s, a.id, re, o, c],
1421
1439
  queryFn: () => E.request(
1422
- Nt(i, a.id, {
1440
+ Nt(s, a.id, {
1423
1441
  date_range: o,
1424
1442
  entity_filters: [
1425
- ...m,
1443
+ ...c,
1426
1444
  ...re.map((l) => ({ field: l.field, values: [l.value] }))
1427
1445
  ],
1428
1446
  dimension_override: Ue[re.length - 1]
@@ -1444,24 +1462,41 @@ const Tt = wa(function({
1444
1462
  let H = null;
1445
1463
  if (Ye != null && Ye.slug)
1446
1464
  H = /* @__PURE__ */ e(
1447
- Za,
1465
+ Ia,
1448
1466
  {
1449
1467
  cfg: Ye,
1450
1468
  dateRange: o,
1451
- entityFilters: m,
1469
+ entityFilters: c,
1452
1470
  refetchInterval: u,
1453
1471
  onDrill: x
1454
1472
  }
1455
1473
  );
1456
1474
  else if (a.type === "query")
1457
1475
  H = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No query configured." });
1458
- else if (tt) H = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
1476
+ else if (tt)
1477
+ H = /* @__PURE__ */ n("div", { className: "flex flex-col gap-2 px-1", children: [
1478
+ /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
1479
+ /* @__PURE__ */ e(
1480
+ Xt,
1481
+ {
1482
+ pending: !0,
1483
+ request: {
1484
+ method: "POST",
1485
+ url: `/report-studio/${s}/widgets/${a.id}/data`,
1486
+ body: { date_range: o, entity_filters: c }
1487
+ },
1488
+ label: a.title || "Report widget",
1489
+ queryKey: ["nivaro-report-widget", s, a.id, o, c],
1490
+ select: (l) => l == null ? void 0 : l.data
1491
+ }
1492
+ )
1493
+ ] });
1459
1494
  else if (ze) {
1460
1495
  const l = ((at = (vt = ze.response) == null ? void 0 : vt.data) == null ? void 0 : at.error) ?? "Failed to load";
1461
1496
  H = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-red-400", children: l });
1462
1497
  } else if (j)
1463
1498
  if (a.type === "queue") {
1464
- const l = j.series ?? [], s = Math.max(...l.map((D) => D.value), 1), g = Math.min(...l.map((D) => D.value), 0), A = Math.max(s - g, 1), L = l.map(
1499
+ const l = j.series ?? [], i = Math.max(...l.map((D) => D.value), 1), g = Math.min(...l.map((D) => D.value), 0), A = Math.max(i - g, 1), L = l.map(
1465
1500
  (D, oe) => `${oe / Math.max(1, l.length - 1) * 100},${28 - (D.value - g) / A * 26}`
1466
1501
  ).join(" ");
1467
1502
  H = /* @__PURE__ */ n("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
@@ -1494,14 +1529,14 @@ const Tt = wa(function({
1494
1529
  var g;
1495
1530
  const l = (g = a.config) == null ? void 0 : g.thresholds;
1496
1531
  if (!(l != null && l.length) || j.value == null) return null;
1497
- const s = [...l].filter((A) => Number.isFinite(A.gte)).sort((A, L) => L.gte - A.gte).find((A) => j.value >= A.gte);
1498
- return (s == null ? void 0 : s.color) === "red" ? "!text-red-600 dark:!text-red-400" : (s == null ? void 0 : s.color) === "amber" ? "!text-amber-600 dark:!text-amber-400" : (s == null ? void 0 : s.color) === "green" ? "!text-emerald-600 dark:!text-emerald-400" : null;
1532
+ const i = [...l].filter((A) => Number.isFinite(A.gte)).sort((A, L) => L.gte - A.gte).find((A) => j.value >= A.gte);
1533
+ 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;
1499
1534
  })()
1500
1535
  ),
1501
1536
  title: a.collection ? "See the records behind this number" : void 0,
1502
1537
  onClick: () => {
1503
1538
  a.collection && ce({
1504
- conditions: Ft(a, m, o),
1539
+ conditions: Ft(a, c, o),
1505
1540
  title: a.title || a.collection
1506
1541
  });
1507
1542
  },
@@ -1510,7 +1545,7 @@ const Tt = wa(function({
1510
1545
  ),
1511
1546
  /* @__PURE__ */ e(zt, { pct: j.change_pct })
1512
1547
  ] }), j.spark && j.spark.length >= 3) {
1513
- const l = j.spark, s = Math.max(...l.map((D) => D.value), 1), g = Math.min(...l.map((D) => D.value), 0), A = Math.max(s - g, 1), L = l.map((D, oe) => `${oe / (l.length - 1) * 100},${28 - (D.value - g) / A * 26}`).join(" ");
1548
+ const l = j.spark, i = Math.max(...l.map((D) => D.value), 1), g = Math.min(...l.map((D) => D.value), 0), A = Math.max(i - g, 1), L = l.map((D, oe) => `${oe / (l.length - 1) * 100},${28 - (D.value - g) / A * 26}`).join(" ");
1514
1549
  H = /* @__PURE__ */ n("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1515
1550
  H,
1516
1551
  /* @__PURE__ */ e("svg", { viewBox: "0 0 100 30", preserveAspectRatio: "none", className: "mt-1.5 h-7 w-full", children: /* @__PURE__ */ e(
@@ -1532,32 +1567,32 @@ const Tt = wa(function({
1532
1567
  {
1533
1568
  className: "grid gap-2",
1534
1569
  style: { gridTemplateColumns: `repeat(${Math.max(1, l.length)}, 1fr)` },
1535
- children: l.map((s, g) => /* @__PURE__ */ n(
1570
+ children: l.map((i, g) => /* @__PURE__ */ n(
1536
1571
  "div",
1537
1572
  {
1538
1573
  className: "flex flex-col justify-center rounded-md border border-slate-100 px-3 py-2 dark:border-border/60",
1539
1574
  style: {
1540
- borderTopColor: s.color ?? ue[g % ue.length],
1575
+ borderTopColor: i.color ?? ue[g % ue.length],
1541
1576
  borderTopWidth: 2
1542
1577
  },
1543
1578
  children: [
1544
- /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: s.label }),
1579
+ /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: i.label }),
1545
1580
  /* @__PURE__ */ n("div", { className: "flex items-baseline gap-1.5", children: [
1546
- /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: Me(s.value, s.format) }),
1547
- /* @__PURE__ */ e(zt, { pct: s.change_pct })
1581
+ /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: Me(i.value, i.format) }),
1582
+ /* @__PURE__ */ e(zt, { pct: i.change_pct })
1548
1583
  ] })
1549
1584
  ]
1550
1585
  },
1551
- s.label
1586
+ i.label
1552
1587
  ))
1553
1588
  }
1554
1589
  );
1555
1590
  } else if (a.type === "narrative")
1556
1591
  H = /* @__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: (j.narrative ?? "").split(/(\*\*[^*]+\*\*)/g).map(
1557
- (l, s) => l.startsWith("**") && l.endsWith("**") ? /* @__PURE__ */ e("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: l.slice(2, -2) }, s) : /* @__PURE__ */ e("span", { children: l }, s)
1592
+ (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)
1558
1593
  ) });
1559
1594
  else if (a.type === "heatmap") {
1560
- const l = j.cells ?? [], s = [...new Set(l.map((D) => D.dim))], g = [...new Set(l.map((D) => D.dim2))], A = Math.max(1, ...l.map((D) => D.value)), L = (D, oe) => l.find((Z) => Z.dim === D && Z.dim2 === oe);
1595
+ const l = j.cells ?? [], i = [...new Set(l.map((D) => D.dim))], g = [...new Set(l.map((D) => D.dim2))], A = Math.max(1, ...l.map((D) => D.value)), L = (D, oe) => l.find((Z) => Z.dim === D && Z.dim2 === oe);
1561
1596
  H = 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__ */ n("table", { className: "w-full text-[10.5px]", children: [
1562
1597
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
1563
1598
  /* @__PURE__ */ e("th", {}),
@@ -1570,7 +1605,7 @@ const Tt = wa(function({
1570
1605
  D
1571
1606
  ))
1572
1607
  ] }) }),
1573
- /* @__PURE__ */ e("tbody", { children: s.map((D) => /* @__PURE__ */ n("tr", { children: [
1608
+ /* @__PURE__ */ e("tbody", { children: i.map((D) => /* @__PURE__ */ n("tr", { children: [
1574
1609
  /* @__PURE__ */ e("td", { className: "max-w-[110px] truncate pr-1.5 text-slate-500 dark:text-slate-400", children: D }),
1575
1610
  g.map((oe) => {
1576
1611
  const Z = L(D, oe), R = Z ? Z.value / A : 0;
@@ -1616,21 +1651,21 @@ const Tt = wa(function({
1616
1651
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ n("table", { className: "w-full border-collapse text-[10.5px]", children: [
1617
1652
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
1618
1653
  /* @__PURE__ */ e("th", { className: "sticky left-0 top-0 z-[2] bg-white dark:bg-card" }),
1619
- l.cols.map((s) => /* @__PURE__ */ e(
1654
+ l.cols.map((i) => /* @__PURE__ */ e(
1620
1655
  "th",
1621
1656
  {
1622
1657
  className: "sticky top-0 z-[1] whitespace-nowrap bg-white px-1.5 pb-1 text-right font-medium text-slate-400 dark:bg-card",
1623
- children: s
1658
+ children: i
1624
1659
  },
1625
- s
1660
+ i
1626
1661
  )),
1627
1662
  /* @__PURE__ */ e("th", { className: "sticky top-0 z-[1] bg-white px-1.5 pb-1 text-right font-semibold text-slate-500 dark:bg-card dark:text-slate-300", children: "Total" })
1628
1663
  ] }) }),
1629
- /* @__PURE__ */ e("tbody", { children: l.rows.map((s) => /* @__PURE__ */ n("tr", { className: "hover:bg-muted", children: [
1630
- /* @__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: s }),
1664
+ /* @__PURE__ */ e("tbody", { children: l.rows.map((i) => /* @__PURE__ */ n("tr", { className: "hover:bg-muted", children: [
1665
+ /* @__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 }),
1631
1666
  l.cols.map((g) => {
1632
1667
  var L;
1633
- const A = (L = l.cells[s]) == null ? void 0 : L[g];
1668
+ const A = (L = l.cells[i]) == null ? void 0 : L[g];
1634
1669
  return /* @__PURE__ */ e(
1635
1670
  "td",
1636
1671
  {
@@ -1640,17 +1675,17 @@ const Tt = wa(function({
1640
1675
  g
1641
1676
  );
1642
1677
  }),
1643
- /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200", children: Me(l.row_totals[s] ?? 0, be) })
1644
- ] }, s)) }),
1678
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200", children: Me(l.row_totals[i] ?? 0, be) })
1679
+ ] }, i)) }),
1645
1680
  /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ n("tr", { className: "border-t border-slate-200 dark:border-border", children: [
1646
1681
  /* @__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" }),
1647
- l.cols.map((s) => /* @__PURE__ */ e(
1682
+ l.cols.map((i) => /* @__PURE__ */ e(
1648
1683
  "td",
1649
1684
  {
1650
1685
  className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200",
1651
- children: Me(l.col_totals[s] ?? 0, be)
1686
+ children: Me(l.col_totals[i] ?? 0, be)
1652
1687
  },
1653
- s
1688
+ i
1654
1689
  )),
1655
1690
  /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-900 dark:text-foreground", children: Me(l.grand_total, be) })
1656
1691
  ] }) })
@@ -1673,19 +1708,19 @@ const Tt = wa(function({
1673
1708
  } else if (a.type === "waterfall") {
1674
1709
  const l = j.waterfall;
1675
1710
  H = l ? (() => {
1676
- const s = [];
1677
- s.push({ label: "Previous", from: 0, to: l.start, kind: "total" });
1711
+ const i = [];
1712
+ i.push({ label: "Previous", from: 0, to: l.start, kind: "total" });
1678
1713
  let g = l.start;
1679
1714
  for (const L of l.steps)
1680
- s.push({
1715
+ i.push({
1681
1716
  label: L.dim,
1682
1717
  from: g,
1683
1718
  to: g + L.delta,
1684
1719
  kind: L.delta >= 0 ? "up" : "down"
1685
1720
  }), g += L.delta;
1686
- s.push({ label: "Current", from: 0, to: l.end, kind: "total" });
1687
- const A = Math.max(1, ...s.map((L) => Math.max(L.from, L.to)));
1688
- return /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 items-end gap-1 overflow-x-auto px-1 pb-4", children: s.map((L, D) => {
1721
+ i.push({ label: "Current", from: 0, to: l.end, kind: "total" });
1722
+ const A = Math.max(1, ...i.map((L) => Math.max(L.from, L.to)));
1723
+ 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, D) => {
1689
1724
  const oe = Math.max(L.from, L.to) / A * 100, Z = Math.abs(L.to - L.from) / A * 100;
1690
1725
  return /* @__PURE__ */ n(
1691
1726
  "div",
@@ -1712,19 +1747,19 @@ const Tt = wa(function({
1712
1747
  })() : /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
1713
1748
  } else if (a.type === "stats") {
1714
1749
  const l = j.rows ?? [];
1715
- H = 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((s) => /* @__PURE__ */ n(
1750
+ H = 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__ */ n(
1716
1751
  "div",
1717
1752
  {
1718
1753
  className: "flex items-baseline justify-between border-b border-slate-100 pb-1 dark:border-border/50",
1719
1754
  children: [
1720
- /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500", children: s.stat }),
1721
- /* @__PURE__ */ e("span", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: s.value == null ? "—" : Me(s.value, be) })
1755
+ /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500", children: i.stat }),
1756
+ /* @__PURE__ */ e("span", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: i.value == null ? "—" : Me(i.value, be) })
1722
1757
  ]
1723
1758
  },
1724
- s.stat
1759
+ i.stat
1725
1760
  )) });
1726
1761
  } else if (a.type === "hot_records") {
1727
- const l = j.rows ?? [], s = Math.max(1, ...l.map((g) => g.views));
1762
+ const l = j.rows ?? [], i = Math.max(1, ...l.map((g) => g.views));
1728
1763
  H = 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((g) => /* @__PURE__ */ n(
1729
1764
  "button",
1730
1765
  {
@@ -1737,7 +1772,7 @@ const Tt = wa(function({
1737
1772
  "span",
1738
1773
  {
1739
1774
  className: "absolute inset-y-0 left-0 rounded-full bg-[#00a5cc]",
1740
- style: { width: `${g.views / s * 100}%` }
1775
+ style: { width: `${g.views / i * 100}%` }
1741
1776
  }
1742
1777
  ) }),
1743
1778
  /* @__PURE__ */ e("span", { className: "w-8 text-right text-[11px] tabular-nums text-slate-400", children: g.views })
@@ -1748,7 +1783,7 @@ const Tt = wa(function({
1748
1783
  } else if (a.type === "scatter") {
1749
1784
  const l = j.rows ?? [];
1750
1785
  H = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : (() => {
1751
- const s = l.length, g = l.reduce((v, S) => v + S.x, 0), A = l.reduce((v, S) => v + S.y, 0), L = l.reduce((v, S) => v + S.x * S.x, 0), D = l.reduce((v, S) => v + S.x * S.y, 0), oe = s * L - g * g, Z = oe !== 0 ? (s * D - g * A) / oe : 0, R = s > 0 ? (A - Z * g) / s : 0, B = l.map((v) => v.x), r = Math.min(...B), h = Math.max(...B), y = [
1786
+ const i = l.length, g = l.reduce((y, _) => y + _.x, 0), A = l.reduce((y, _) => y + _.y, 0), L = l.reduce((y, _) => y + _.x * _.x, 0), D = l.reduce((y, _) => y + _.x * _.y, 0), oe = i * L - g * g, Z = oe !== 0 ? (i * D - g * A) / oe : 0, R = i > 0 ? (A - Z * g) / i : 0, B = l.map((y) => y.x), r = Math.min(...B), h = Math.max(...B), k = [
1752
1787
  { x: r, y: R + Z * r },
1753
1788
  { x: h, y: R + Z * h }
1754
1789
  ];
@@ -1756,7 +1791,7 @@ const Tt = wa(function({
1756
1791
  Oe,
1757
1792
  {
1758
1793
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
1759
- children: ({ ComposedChart: v, Line: S, ResponsiveContainer: d, Scatter: C, Tooltip: T, XAxis: V, YAxis: de }) => /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ n(v, { data: l, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
1794
+ children: ({ ComposedChart: y, Line: _, ResponsiveContainer: d, Scatter: $, Tooltip: T, XAxis: V, YAxis: de }) => /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ n(y, { data: l, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
1760
1795
  /* @__PURE__ */ e(
1761
1796
  V,
1762
1797
  {
@@ -1780,11 +1815,11 @@ const Tt = wa(function({
1780
1815
  }
1781
1816
  }
1782
1817
  ),
1783
- /* @__PURE__ */ e(C, { data: l, dataKey: "y", fill: "#00a5cc", opacity: 0.7 }),
1818
+ /* @__PURE__ */ e($, { data: l, dataKey: "y", fill: "#00a5cc", opacity: 0.7 }),
1784
1819
  /* @__PURE__ */ e(
1785
- S,
1820
+ _,
1786
1821
  {
1787
- data: y,
1822
+ data: k,
1788
1823
  dataKey: "y",
1789
1824
  stroke: "#f59e0b",
1790
1825
  strokeWidth: 2,
@@ -1802,7 +1837,7 @@ const Tt = wa(function({
1802
1837
  Oe,
1803
1838
  {
1804
1839
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
1805
- children: ({ Bar: s, ComposedChart: g, Line: A, ResponsiveContainer: L, Tooltip: D, XAxis: oe, YAxis: Z }) => /* @__PURE__ */ e(L, { width: "100%", height: "100%", children: /* @__PURE__ */ n(g, { data: l, margin: { top: 6, right: 4, left: -10, bottom: 0 }, children: [
1840
+ children: ({ Bar: i, ComposedChart: g, Line: A, ResponsiveContainer: L, Tooltip: D, XAxis: oe, YAxis: Z }) => /* @__PURE__ */ e(L, { width: "100%", height: "100%", children: /* @__PURE__ */ n(g, { data: l, margin: { top: 6, right: 4, left: -10, bottom: 0 }, children: [
1806
1841
  /* @__PURE__ */ e(
1807
1842
  oe,
1808
1843
  {
@@ -1838,7 +1873,7 @@ const Tt = wa(function({
1838
1873
  }
1839
1874
  ),
1840
1875
  /* @__PURE__ */ e(
1841
- s,
1876
+ i,
1842
1877
  {
1843
1878
  yAxisId: "v",
1844
1879
  dataKey: "value",
@@ -1868,55 +1903,55 @@ const Tt = wa(function({
1868
1903
  ] });
1869
1904
  else if (a.type === "movers") {
1870
1905
  const l = j.rows ?? [];
1871
- H = 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((s) => /* @__PURE__ */ n("div", { className: "flex items-center gap-2 text-[11.5px]", children: [
1872
- /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: s.dim }),
1906
+ H = 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__ */ n("div", { className: "flex items-center gap-2 text-[11.5px]", children: [
1907
+ /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: i.dim }),
1873
1908
  /* @__PURE__ */ n("span", { className: "tabular-nums text-slate-400", children: [
1874
- s.previous.toLocaleString(),
1909
+ i.previous.toLocaleString(),
1875
1910
  " → ",
1876
- s.current.toLocaleString()
1911
+ i.current.toLocaleString()
1877
1912
  ] }),
1878
1913
  /* @__PURE__ */ n(
1879
1914
  "span",
1880
1915
  {
1881
1916
  className: W(
1882
1917
  "w-[74px] shrink-0 text-right font-semibold tabular-nums",
1883
- s.delta > 0 ? "text-emerald-600 dark:text-emerald-400" : "text-red-500"
1918
+ i.delta > 0 ? "text-emerald-600 dark:text-emerald-400" : "text-red-500"
1884
1919
  ),
1885
1920
  children: [
1886
- s.delta > 0 ? "+" : "",
1887
- s.delta.toLocaleString(),
1888
- s.delta_pct != null && /* @__PURE__ */ n("span", { className: "ml-1 text-[10px] font-normal text-slate-400", children: [
1889
- s.delta_pct > 0 ? "+" : "",
1890
- s.delta_pct.toFixed(0),
1921
+ i.delta > 0 ? "+" : "",
1922
+ i.delta.toLocaleString(),
1923
+ i.delta_pct != null && /* @__PURE__ */ n("span", { className: "ml-1 text-[10px] font-normal text-slate-400", children: [
1924
+ i.delta_pct > 0 ? "+" : "",
1925
+ i.delta_pct.toFixed(0),
1891
1926
  "%"
1892
1927
  ] })
1893
1928
  ]
1894
1929
  }
1895
1930
  )
1896
- ] }, s.dim)) });
1931
+ ] }, i.dim)) });
1897
1932
  } else if (a.type === "table") {
1898
- const l = j.rows ?? [], s = (lt = a.config) != null && lt.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 })) : [], g = s.map((d) => d.field), A = (d) => s.find((C) => C.field === d), L = ((Xe = a.config) == null ? void 0 : Xe.format_rules) ?? [], D = (d) => {
1899
- var C;
1933
+ const l = j.rows ?? [], i = (lt = a.config) != null && lt.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 })) : [], g = i.map((d) => d.field), A = (d) => i.find(($) => $.field === d), L = ((Xe = a.config) == null ? void 0 : Xe.format_rules) ?? [], D = (d) => {
1934
+ var $;
1900
1935
  for (const T of L)
1901
1936
  if ((T.scope ?? "cell") === "row" && Bt(T, d[T.field]))
1902
- return ((C = Wt[T.color]) == null ? void 0 : C.row) ?? null;
1937
+ return (($ = Wt[T.color]) == null ? void 0 : $.row) ?? null;
1903
1938
  return null;
1904
- }, oe = (d, C) => {
1939
+ }, oe = (d, $) => {
1905
1940
  var T;
1906
1941
  for (const V of L)
1907
- if ((V.scope ?? "cell") === "cell" && V.field === C && Bt(V, d[C]))
1942
+ if ((V.scope ?? "cell") === "cell" && V.field === $ && Bt(V, d[$]))
1908
1943
  return ((T = Wt[V.color]) == null ? void 0 : T.cell) ?? null;
1909
1944
  return null;
1910
1945
  }, Z = I.trim().toLowerCase(), R = a.config, B = R != null && R.suppress_zero ? l.filter(
1911
- (d) => g.some((C) => {
1912
- const T = Number(d[C]);
1946
+ (d) => g.some(($) => {
1947
+ const T = Number(d[$]);
1913
1948
  return Number.isFinite(T) && T !== 0;
1914
1949
  })
1915
1950
  ) : l, r = Z ? B.filter(
1916
1951
  (d) => Object.values(d).some(
1917
- (C) => String(C ?? "").toLowerCase().includes(Z)
1952
+ ($) => String($ ?? "").toLowerCase().includes(Z)
1918
1953
  )
1919
- ) : B, h = 12, y = Math.max(1, Math.ceil(r.length / h)), v = Math.min(he, y - 1), S = r.length > h ? r.slice(v * h, v * h + h) : r;
1954
+ ) : B, h = 12, k = Math.max(1, Math.ceil(r.length / h)), y = Math.min(he, k - 1), _ = r.length > h ? r.slice(y * h, y * h + h) : r;
1920
1955
  H = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No rows." }) : /* @__PURE__ */ n("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1921
1956
  l.length > h && /* @__PURE__ */ n("div", { className: "mb-1 flex items-center gap-2", children: [
1922
1957
  /* @__PURE__ */ e(
@@ -1930,26 +1965,26 @@ const Tt = wa(function({
1930
1965
  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"
1931
1966
  }
1932
1967
  ),
1933
- y > 1 && /* @__PURE__ */ n("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
1968
+ k > 1 && /* @__PURE__ */ n("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
1934
1969
  /* @__PURE__ */ e(
1935
1970
  "button",
1936
1971
  {
1937
1972
  type: "button",
1938
- disabled: v <= 0,
1939
- onClick: () => z(v - 1),
1973
+ disabled: y <= 0,
1974
+ onClick: () => z(y - 1),
1940
1975
  className: "rounded px-1 disabled:opacity-30",
1941
1976
  children: "←"
1942
1977
  }
1943
1978
  ),
1944
- v + 1,
1979
+ y + 1,
1945
1980
  "/",
1946
- y,
1981
+ k,
1947
1982
  /* @__PURE__ */ e(
1948
1983
  "button",
1949
1984
  {
1950
1985
  type: "button",
1951
- disabled: v >= y - 1,
1952
- onClick: () => z(v + 1),
1986
+ disabled: y >= k - 1,
1987
+ onClick: () => z(y + 1),
1953
1988
  className: "rounded px-1 disabled:opacity-30",
1954
1989
  children: "→"
1955
1990
  }
@@ -1958,17 +1993,17 @@ const Tt = wa(function({
1958
1993
  ] }),
1959
1994
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ n("table", { className: "w-full text-[11.5px]", children: [
1960
1995
  /* @__PURE__ */ e("thead", { className: "sticky top-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: g.map((d) => {
1961
- var C;
1996
+ var $;
1962
1997
  return /* @__PURE__ */ e(
1963
1998
  "th",
1964
1999
  {
1965
2000
  className: "border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
1966
- children: ((C = A(d)) == null ? void 0 : C.label) ?? d
2001
+ children: (($ = A(d)) == null ? void 0 : $.label) ?? d
1967
2002
  },
1968
2003
  d
1969
2004
  );
1970
2005
  }) }) }),
1971
- /* @__PURE__ */ e("tbody", { children: S.map((d) => /* @__PURE__ */ e(
2006
+ /* @__PURE__ */ e("tbody", { children: _.map((d) => /* @__PURE__ */ e(
1972
2007
  "tr",
1973
2008
  {
1974
2009
  className: W(
@@ -1978,27 +2013,27 @@ const Tt = wa(function({
1978
2013
  onClick: () => {
1979
2014
  a.collection && d.id != null && (x == null || x({ collection: a.collection, itemId: String(d.id) }));
1980
2015
  },
1981
- children: g.map((C) => {
2016
+ children: g.map(($) => {
1982
2017
  var T, V, de, Q;
1983
2018
  return /* @__PURE__ */ e(
1984
2019
  "td",
1985
2020
  {
1986
2021
  className: W(
1987
2022
  "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",
1988
- (typeof d[C] == "number" || We.has(((T = A(C)) == null ? void 0 : T.format) ?? "")) && "text-right tabular-nums",
1989
- oe(d, C)
2023
+ (typeof d[$] == "number" || We.has(((T = A($)) == null ? void 0 : T.format) ?? "")) && "text-right tabular-nums",
2024
+ oe(d, $)
1990
2025
  ),
1991
- children: (V = A(C)) != null && V.format ? Be(d[C], (de = A(C)) == null ? void 0 : de.format, (Q = A(C)) == null ? void 0 : Q.decimals) : String(d[C] ?? "")
2026
+ children: (V = A($)) != null && V.format ? Be(d[$], (de = A($)) == null ? void 0 : de.format, (Q = A($)) == null ? void 0 : Q.decimals) : String(d[$] ?? "")
1992
2027
  },
1993
- C
2028
+ $
1994
2029
  );
1995
2030
  })
1996
2031
  },
1997
2032
  String(d.id)
1998
2033
  )) }),
1999
- (R == null ? void 0 : R.grand_total) && r.length > 1 && /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ e("tr", { className: "border-t border-slate-200 font-semibold dark:border-border", children: g.map((d, C) => {
2034
+ (R == null ? void 0 : R.grand_total) && r.length > 1 && /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ e("tr", { className: "border-t border-slate-200 font-semibold dark:border-border", children: g.map((d, $) => {
2000
2035
  var Q, Se, Ee;
2001
- const T = r.map((ct) => Number(ct[d])).filter((ct) => Number.isFinite(ct)), V = T.length > r.length / 2, de = T.reduce((ct, la) => ct + la, 0);
2036
+ const T = r.map((ct) => Number(ct[d])).filter((ct) => Number.isFinite(ct)), V = T.length > r.length / 2, de = T.reduce((ct, ra) => ct + ra, 0);
2002
2037
  return /* @__PURE__ */ e(
2003
2038
  "td",
2004
2039
  {
@@ -2006,7 +2041,7 @@ const Tt = wa(function({
2006
2041
  "px-1.5 py-1 text-slate-800 dark:text-slate-100",
2007
2042
  V && "text-right tabular-nums"
2008
2043
  ),
2009
- children: C === 0 && !V ? "Total" : V ? (Q = A(d)) != null && Q.format ? Be(de, (Se = A(d)) == null ? void 0 : Se.format, (Ee = A(d)) == null ? void 0 : Ee.decimals) : de.toLocaleString() : ""
2044
+ children: $ === 0 && !V ? "Total" : V ? (Q = A(d)) != null && Q.format ? Be(de, (Se = A(d)) == null ? void 0 : Se.format, (Ee = A(d)) == null ? void 0 : Ee.decimals) : de.toLocaleString() : ""
2010
2045
  },
2011
2046
  d
2012
2047
  );
@@ -2015,12 +2050,12 @@ const Tt = wa(function({
2015
2050
  ] });
2016
2051
  } else {
2017
2052
  let l = j.series ?? [];
2018
- const s = !!((nt = (rt = a.config) == null ? void 0 : rt.dimension) != null && nt.bucket), g = Number((st = a.config) == null ? void 0 : st.rolling_avg) || 0;
2019
- if (g >= 2 && s && !le && l.length >= g && (l = l.map((R, B) => {
2053
+ const i = !!((nt = (rt = a.config) == null ? void 0 : rt.dimension) != null && nt.bucket), g = Number((st = a.config) == null ? void 0 : st.rolling_avg) || 0;
2054
+ if (g >= 2 && i && !le && l.length >= g && (l = l.map((R, B) => {
2020
2055
  if (B < g - 1) return R;
2021
2056
  const r = l.slice(B - g + 1, B + 1);
2022
- return { ...R, ma: r.reduce((h, y) => h + y.value, 0) / g };
2023
- })), le && s) {
2057
+ return { ...R, ma: r.reduce((h, k) => h + k.value, 0) / g };
2058
+ })), le && i) {
2024
2059
  let R = 0, B = 0, r = 0;
2025
2060
  l = l.map((h) => (R += h.value, B += h.prev ?? 0, r += h.value2 ?? 0, {
2026
2061
  ...h,
@@ -2030,8 +2065,8 @@ const Tt = wa(function({
2030
2065
  }));
2031
2066
  }
2032
2067
  const A = l.some((R) => R.value2 != null), L = ((kt = (se = a.config) == null ? void 0 : se.metric2) == null ? void 0 : kt.label) ?? "secondary", D = l.some((R) => R.band != null), oe = (() => {
2033
- if (!s || le || l.length < 8) return /* @__PURE__ */ new Set();
2034
- const R = l.map((h) => h.value), B = R.reduce((h, y) => h + y, 0) / R.length, r = Math.sqrt(R.reduce((h, y) => h + (y - B) ** 2, 0) / R.length);
2068
+ if (!i || le || l.length < 8) return /* @__PURE__ */ new Set();
2069
+ const R = l.map((h) => h.value), B = R.reduce((h, k) => h + k, 0) / R.length, r = Math.sqrt(R.reduce((h, k) => h + (k - B) ** 2, 0) / R.length);
2035
2070
  return r === 0 ? /* @__PURE__ */ new Set() : new Set(
2036
2071
  l.filter((h) => Math.abs(h.value - B) > 2 * r).map((h) => h.dim)
2037
2072
  );
@@ -2047,7 +2082,7 @@ const Tt = wa(function({
2047
2082
  Oe,
2048
2083
  {
2049
2084
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
2050
- children: ({ Cell: B, Pie: r, PieChart: h, ResponsiveContainer: y, Tooltip: v }) => /* @__PURE__ */ e(y, { width: "100%", height: "100%", children: /* @__PURE__ */ n(h, { children: [
2085
+ children: ({ Cell: B, Pie: r, PieChart: h, ResponsiveContainer: k, Tooltip: y }) => /* @__PURE__ */ e(k, { width: "100%", height: "100%", children: /* @__PURE__ */ n(h, { children: [
2051
2086
  /* @__PURE__ */ e(
2052
2087
  r,
2053
2088
  {
@@ -2059,10 +2094,10 @@ const Tt = wa(function({
2059
2094
  paddingAngle: 2,
2060
2095
  strokeWidth: 0,
2061
2096
  className: a.collection ? "cursor-pointer" : void 0,
2062
- onClick: (S) => {
2097
+ onClick: (_) => {
2063
2098
  var T, V, de, Q;
2064
2099
  if (!a.collection) return;
2065
- const d = S == null ? void 0 : S.payload;
2100
+ const d = _ == null ? void 0 : _.payload;
2066
2101
  if (d != null && d.other) return;
2067
2102
  if (Ue.length > re.length) {
2068
2103
  const Se = re.length === 0 ? (V = (T = a.config) == null ? void 0 : T.dimension) == null ? void 0 : V.field : Ue[re.length - 1];
@@ -2074,31 +2109,31 @@ const Tt = wa(function({
2074
2109
  return;
2075
2110
  }
2076
2111
  }
2077
- const C = (Q = (de = a.config) == null ? void 0 : de.dimension) == null ? void 0 : Q.field;
2112
+ const $ = (Q = (de = a.config) == null ? void 0 : de.dimension) == null ? void 0 : Q.field;
2078
2113
  ce({
2079
2114
  conditions: Ft(
2080
2115
  a,
2081
- m,
2116
+ c,
2082
2117
  o,
2083
2118
  (d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim)
2084
2119
  ),
2085
2120
  title: `${a.title || a.collection} — ${(d == null ? void 0 : d.dim) ?? ""}`,
2086
- dimField: C,
2121
+ dimField: $,
2087
2122
  dimRaw: (d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim),
2088
2123
  dimLabel: d == null ? void 0 : d.dim
2089
2124
  });
2090
2125
  },
2091
- children: l.map((S, d) => /* @__PURE__ */ e(
2126
+ children: l.map((_, d) => /* @__PURE__ */ e(
2092
2127
  B,
2093
2128
  {
2094
- fill: S.other ? "#94a3b8" : ue[d % ue.length]
2129
+ fill: _.other ? "#94a3b8" : ue[d % ue.length]
2095
2130
  },
2096
- S.dim
2131
+ _.dim
2097
2132
  ))
2098
2133
  }
2099
2134
  ),
2100
2135
  /* @__PURE__ */ e(
2101
- v,
2136
+ y,
2102
2137
  {
2103
2138
  contentStyle: {
2104
2139
  fontSize: 12,
@@ -2136,16 +2171,16 @@ const Tt = wa(function({
2136
2171
  Oe,
2137
2172
  {
2138
2173
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
2139
- children: ({ Area: R, ComposedChart: B, Line: r, ReferenceLine: h, ResponsiveContainer: y, Tooltip: v, XAxis: S, YAxis: d }) => {
2140
- var C;
2141
- return /* @__PURE__ */ e(y, { width: "100%", height: "100%", children: /* @__PURE__ */ n(
2174
+ children: ({ Area: R, ComposedChart: B, Line: r, ReferenceLine: h, ResponsiveContainer: k, Tooltip: y, XAxis: _, YAxis: d }) => {
2175
+ var $;
2176
+ return /* @__PURE__ */ e(k, { width: "100%", height: "100%", children: /* @__PURE__ */ n(
2142
2177
  B,
2143
2178
  {
2144
2179
  data: l,
2145
2180
  margin: { top: 6, right: A ? 4 : 8, left: -10, bottom: 0 },
2146
2181
  children: [
2147
2182
  /* @__PURE__ */ e(
2148
- S,
2183
+ _,
2149
2184
  {
2150
2185
  dataKey: "dim",
2151
2186
  tick: { fontSize: 10 },
@@ -2184,7 +2219,7 @@ const Tt = wa(function({
2184
2219
  T.id
2185
2220
  )),
2186
2221
  /* @__PURE__ */ e(
2187
- v,
2222
+ y,
2188
2223
  {
2189
2224
  contentStyle: {
2190
2225
  fontSize: 12,
@@ -2209,7 +2244,7 @@ const Tt = wa(function({
2209
2244
  activeDot: !1
2210
2245
  }
2211
2246
  ),
2212
- ((C = a.config) == null ? void 0 : C.compare) && /* @__PURE__ */ e(
2247
+ (($ = a.config) == null ? void 0 : $.compare) && /* @__PURE__ */ e(
2213
2248
  r,
2214
2249
  {
2215
2250
  type: "monotone",
@@ -2282,9 +2317,9 @@ const Tt = wa(function({
2282
2317
  Oe,
2283
2318
  {
2284
2319
  fallback: /* @__PURE__ */ e(De, { className: "h-full w-full", "aria-busy": "true" }),
2285
- children: ({ Bar: B, Cell: r, ComposedChart: h, Line: y, ReferenceLine: v, ResponsiveContainer: S, Tooltip: d, XAxis: C, YAxis: T }) => {
2320
+ children: ({ Bar: B, Cell: r, ComposedChart: h, Line: k, ReferenceLine: y, ResponsiveContainer: _, Tooltip: d, XAxis: $, YAxis: T }) => {
2286
2321
  var V;
2287
- return /* @__PURE__ */ e(S, { width: "100%", height: "100%", children: /* @__PURE__ */ n(
2322
+ return /* @__PURE__ */ e(_, { width: "100%", height: "100%", children: /* @__PURE__ */ n(
2288
2323
  h,
2289
2324
  {
2290
2325
  data: l,
@@ -2292,7 +2327,7 @@ const Tt = wa(function({
2292
2327
  margin: { top: 6, right: 8, left: R ? 30 : -10, bottom: 0 },
2293
2328
  children: [
2294
2329
  R ? /* @__PURE__ */ n(Ie, { children: [
2295
- /* @__PURE__ */ e(C, { type: "number", tick: { fontSize: 10 }, stroke: "#94a3b8" }),
2330
+ /* @__PURE__ */ e($, { type: "number", tick: { fontSize: 10 }, stroke: "#94a3b8" }),
2296
2331
  /* @__PURE__ */ e(
2297
2332
  T,
2298
2333
  {
@@ -2305,7 +2340,7 @@ const Tt = wa(function({
2305
2340
  )
2306
2341
  ] }) : /* @__PURE__ */ n(Ie, { children: [
2307
2342
  /* @__PURE__ */ e(
2308
- C,
2343
+ $,
2309
2344
  {
2310
2345
  dataKey: "dim",
2311
2346
  tick: { fontSize: 10 },
@@ -2335,7 +2370,7 @@ const Tt = wa(function({
2335
2370
  )
2336
2371
  ] }),
2337
2372
  !R && Z.map((de) => /* @__PURE__ */ e(
2338
- v,
2373
+ y,
2339
2374
  {
2340
2375
  x: de.anchor_date,
2341
2376
  stroke: "#f59e0b",
@@ -2375,7 +2410,7 @@ const Tt = wa(function({
2375
2410
  ce({
2376
2411
  conditions: Ft(
2377
2412
  a,
2378
- m,
2413
+ c,
2379
2414
  o,
2380
2415
  (Q == null ? void 0 : Q.raw) ?? (Q == null ? void 0 : Q.dim)
2381
2416
  ),
@@ -2389,7 +2424,7 @@ const Tt = wa(function({
2389
2424
  }
2390
2425
  ),
2391
2426
  A && /* @__PURE__ */ e(
2392
- y,
2427
+ k,
2393
2428
  {
2394
2429
  yAxisId: R ? void 0 : "right",
2395
2430
  type: "monotone",
@@ -2423,12 +2458,12 @@ const Tt = wa(function({
2423
2458
  children: [
2424
2459
  /* @__PURE__ */ n("div", { className: "mb-1.5 flex items-center gap-1.5", children: [
2425
2460
  (() => {
2426
- var s;
2427
- const l = (s = a.config) == null ? void 0 : s.link_report;
2428
- return l != null && l.report_id && $ ? /* @__PURE__ */ n(
2461
+ var i;
2462
+ const l = (i = a.config) == null ? void 0 : i.link_report;
2463
+ return l != null && l.report_id && S ? /* @__PURE__ */ n(
2429
2464
  "a",
2430
2465
  {
2431
- href: $(l.report_id),
2466
+ href: S(l.report_id),
2432
2467
  onClick: () => {
2433
2468
  try {
2434
2469
  sessionStorage.setItem(
@@ -2452,7 +2487,7 @@ const Tt = wa(function({
2452
2487
  {
2453
2488
  "data-tip": Et(a),
2454
2489
  className: "shrink-0 cursor-help text-slate-300 hover:text-slate-500",
2455
- children: /* @__PURE__ */ e(ba, { className: "h-3 w-3" })
2490
+ children: /* @__PURE__ */ e(ga, { className: "h-3 w-3" })
2456
2491
  }
2457
2492
  ),
2458
2493
  /* @__PURE__ */ n("span", { className: "ml-auto flex items-center gap-0.5", children: [
@@ -2466,7 +2501,7 @@ const Tt = wa(function({
2466
2501
  pe ? "text-[#00a5cc]" : "text-slate-300 hover:text-[#00a5cc]"
2467
2502
  ),
2468
2503
  onClick: () => ne((l) => !l),
2469
- children: /* @__PURE__ */ e(ga, { className: "h-3 w-3" })
2504
+ children: /* @__PURE__ */ e(va, { className: "h-3 w-3" })
2470
2505
  }
2471
2506
  ),
2472
2507
  ["bar", "line", "donut", "pareto", "scatter", "heatmap", "waterfall"].includes(
@@ -2477,7 +2512,7 @@ const Tt = wa(function({
2477
2512
  type: "button",
2478
2513
  title: "Copy chart as image",
2479
2514
  className: "rounded p-0.5 text-slate-300 hover:text-[#00a5cc]",
2480
- onClick: () => void ja(k.current, a.title),
2515
+ onClick: () => void Ea(v.current, a.title),
2481
2516
  children: /* @__PURE__ */ e(St, { className: "h-3 w-3" })
2482
2517
  }
2483
2518
  ),
@@ -2496,46 +2531,46 @@ const Tt = wa(function({
2496
2531
  if (P(!0), O || G) return;
2497
2532
  if (ie(!0), me) {
2498
2533
  E.request(
2499
- pt(`/report-studio/${i}/widgets/${a.id}/explain-trend`, {
2534
+ pt(`/report-studio/${s}/widgets/${a.id}/explain-trend`, {
2500
2535
  date_range: o,
2501
- entity_filters: m
2536
+ entity_filters: c
2502
2537
  })
2503
- ).then((s) => {
2504
- U(s.data.explanation || "No explanation available."), J(s.data.movers ?? null);
2538
+ ).then((i) => {
2539
+ U(i.data.explanation || "No explanation available."), J(i.data.movers ?? null);
2505
2540
  }).catch(
2506
- (s) => U(
2507
- (s == null ? void 0 : s.status) === 503 ? "AI is not configured on this instance." : (s == null ? void 0 : s.status) === 400 ? s.message ?? "Not enough data to describe a trend." : "AI is not configured or unavailable."
2541
+ (i) => U(
2542
+ (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."
2508
2543
  )
2509
2544
  ).finally(() => ie(!1));
2510
2545
  return;
2511
2546
  }
2512
2547
  (j ? Promise.resolve(j) : E.request(
2513
- Nt(i, a.id, {
2548
+ Nt(s, a.id, {
2514
2549
  date_range: o,
2515
- entity_filters: m
2550
+ entity_filters: c
2516
2551
  })
2517
- ).then((s) => s.data).catch(() => {
2518
- })).then((s) => {
2552
+ ).then((i) => i.data).catch(() => {
2553
+ })).then((i) => {
2519
2554
  const g = {
2520
2555
  widget: a.title,
2521
2556
  how_computed: Et(a),
2522
- value: (s == null ? void 0 : s.value) ?? null,
2523
- previous_value: (s == null ? void 0 : s.prev_value) ?? null,
2524
- change_pct: (s == null ? void 0 : s.change_pct) ?? null,
2525
- row_count: (s == null ? void 0 : s.row_count) ?? null,
2526
- series: ((s == null ? void 0 : s.series) ?? []).slice(0, 15),
2527
- rows: ((s == null ? void 0 : s.rows) ?? []).slice(0, 10),
2528
- tiles: (s == null ? void 0 : s.tiles) ?? null
2557
+ value: (i == null ? void 0 : i.value) ?? null,
2558
+ previous_value: (i == null ? void 0 : i.prev_value) ?? null,
2559
+ change_pct: (i == null ? void 0 : i.change_pct) ?? null,
2560
+ row_count: (i == null ? void 0 : i.row_count) ?? null,
2561
+ series: ((i == null ? void 0 : i.series) ?? []).slice(0, 15),
2562
+ rows: ((i == null ? void 0 : i.rows) ?? []).slice(0, 10),
2563
+ tiles: (i == null ? void 0 : i.tiles) ?? null
2529
2564
  };
2530
2565
  return E.request(
2531
2566
  pt("/ai/brief", {
2532
2567
  context: JSON.stringify(g),
2533
- instructions: (s == null ? void 0 : s.prev_value) != null || ((s == null ? void 0 : s.series) ?? []).some((A) => A.prev != null) ? "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."
2568
+ instructions: (i == null ? void 0 : i.prev_value) != null || ((i == null ? void 0 : i.series) ?? []).some((A) => A.prev != null) ? "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."
2534
2569
  })
2535
2570
  );
2536
- }).then((s) => {
2571
+ }).then((i) => {
2537
2572
  var A, L;
2538
- const g = ((A = s.data) == null ? void 0 : A.brief) ?? ((L = s.data) == null ? void 0 : L.text) ?? null;
2573
+ const g = ((A = i.data) == null ? void 0 : A.brief) ?? ((L = i.data) == null ? void 0 : L.text) ?? null;
2539
2574
  U(g || "No explanation available.");
2540
2575
  }).catch(() => U("AI is not configured or unavailable.")).finally(() => ie(!1));
2541
2576
  },
@@ -2552,7 +2587,7 @@ const Tt = wa(function({
2552
2587
  le ? "text-[#00a5cc]" : "text-slate-300 hover:text-slate-500"
2553
2588
  ),
2554
2589
  onClick: () => Y((l) => !l),
2555
- children: /* @__PURE__ */ e(va, { className: "h-3 w-3" })
2590
+ children: /* @__PURE__ */ e(ya, { className: "h-3 w-3" })
2556
2591
  }
2557
2592
  ),
2558
2593
  N && /* @__PURE__ */ e(
@@ -2565,7 +2600,7 @@ const Tt = wa(function({
2565
2600
  ((F == null ? void 0 : F.length) ?? 0) > 0 ? "text-amber-500" : "text-slate-300 hover:text-slate-500"
2566
2601
  ),
2567
2602
  onClick: () => ye((l) => !l),
2568
- children: /* @__PURE__ */ e(ya, { className: "h-3 w-3" })
2603
+ children: /* @__PURE__ */ e(ka, { className: "h-3 w-3" })
2569
2604
  }
2570
2605
  ),
2571
2606
  /* @__PURE__ */ e(
@@ -2574,11 +2609,11 @@ const Tt = wa(function({
2574
2609
  type: "button",
2575
2610
  title: "Download as CSV",
2576
2611
  className: "rounded p-0.5 text-slate-300 hover:text-slate-500",
2577
- onClick: () => sl(a, j),
2578
- children: /* @__PURE__ */ e(ka, { className: "h-3 w-3" })
2612
+ onClick: () => il(a, j),
2613
+ children: /* @__PURE__ */ e(Na, { className: "h-3 w-3" })
2579
2614
  }
2580
2615
  ),
2581
- /* @__PURE__ */ e(ll, { reportId: i, widget: a, filterBar: b }),
2616
+ /* @__PURE__ */ e(rl, { reportId: s, widget: a, filterBar: b }),
2582
2617
  /* @__PURE__ */ e(
2583
2618
  "button",
2584
2619
  {
@@ -2606,11 +2641,11 @@ const Tt = wa(function({
2606
2641
  l.note,
2607
2642
  /* @__PURE__ */ e("span", { className: "ml-1 text-[10px] text-slate-400", children: l.created_by_name ?? "" })
2608
2643
  ] }),
2609
- _ && /* @__PURE__ */ e(
2644
+ C && /* @__PURE__ */ e(
2610
2645
  "button",
2611
2646
  {
2612
2647
  type: "button",
2613
- onClick: () => _(l.id),
2648
+ onClick: () => C(l.id),
2614
2649
  className: "shrink-0 rounded p-0.5 text-slate-300 opacity-0 hover:text-red-500 group-hover/note:opacity-100",
2615
2650
  children: /* @__PURE__ */ e(Re, { className: "h-2.5 w-2.5" })
2616
2651
  }
@@ -2655,15 +2690,15 @@ const Tt = wa(function({
2655
2690
  ] })
2656
2691
  ] }),
2657
2692
  p && (() => {
2658
- const l = nl(j), s = p.value;
2659
- if (l == null || s == null) return null;
2660
- const g = s === 0 ? null : (l - s) / Math.abs(s) * 100;
2693
+ const l = sl(j), i = p.value;
2694
+ if (l == null || i == null) return null;
2695
+ const g = i === 0 ? null : (l - i) / Math.abs(i) * 100;
2661
2696
  return /* @__PURE__ */ n("p", { className: "mb-1 flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2662
2697
  /* @__PURE__ */ e(St, { className: "h-2.5 w-2.5" }),
2663
2698
  "vs ",
2664
2699
  p.name,
2665
2700
  ": ",
2666
- s.toLocaleString(),
2701
+ i.toLocaleString(),
2667
2702
  " →",
2668
2703
  " ",
2669
2704
  /* @__PURE__ */ e(
@@ -2722,20 +2757,20 @@ const Tt = wa(function({
2722
2757
  children: "⌂ All"
2723
2758
  }
2724
2759
  ),
2725
- re.map((l, s) => /* @__PURE__ */ n("span", { className: "flex items-center gap-1", children: [
2760
+ re.map((l, i) => /* @__PURE__ */ n("span", { className: "flex items-center gap-1", children: [
2726
2761
  /* @__PURE__ */ e("span", { className: "text-slate-300", children: "›" }),
2727
2762
  /* @__PURE__ */ e(
2728
2763
  "button",
2729
2764
  {
2730
2765
  type: "button",
2731
- onClick: () => Te(re.slice(0, s + 1)),
2766
+ onClick: () => Te(re.slice(0, i + 1)),
2732
2767
  className: "rounded bg-nvr-cyan/[0.08] px-1.5 py-0.5 font-medium text-[#007a99] dark:text-nvr-cyan",
2733
2768
  children: l.value
2734
2769
  }
2735
2770
  )
2736
- ] }, `${l.field}-${s}`))
2771
+ ] }, `${l.field}-${i}`))
2737
2772
  ] }),
2738
- /* @__PURE__ */ e("div", { ref: k, className: "flex min-h-0 flex-1 flex-col", children: pe && ((Le = j == null ? void 0 : j.series) != null && Le.length) ? /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ n("table", { className: "w-full text-[11.5px]", children: [
2773
+ /* @__PURE__ */ e("div", { ref: v, className: "flex min-h-0 flex-1 flex-col", children: pe && ((Le = j == null ? void 0 : j.series) != null && Le.length) ? /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ n("table", { className: "w-full text-[11.5px]", children: [
2739
2774
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { className: "text-left text-[10px] uppercase tracking-wide text-slate-400", children: [
2740
2775
  /* @__PURE__ */ e("th", { className: "px-1.5 pb-1", children: "Dimension" }),
2741
2776
  /* @__PURE__ */ e("th", { className: "px-1.5 pb-1 text-right", children: "Value" })
@@ -2747,7 +2782,7 @@ const Tt = wa(function({
2747
2782
  ] }) }) : H }),
2748
2783
  ((ve = a.config) == null ? void 0 : ve.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 }),
2749
2784
  ae && /* @__PURE__ */ e(
2750
- il,
2785
+ ol,
2751
2786
  {
2752
2787
  collection: a.collection ?? "",
2753
2788
  conditions: ae.conditions,
@@ -2756,8 +2791,8 @@ const Tt = wa(function({
2756
2791
  onOpen: (l) => {
2757
2792
  ce(null), x == null || x(l);
2758
2793
  },
2759
- crossFilter: c && ae.dimField && ae.dimRaw != null ? () => {
2760
- c(
2794
+ crossFilter: m && ae.dimField && ae.dimRaw != null ? () => {
2795
+ m(
2761
2796
  ae.dimField,
2762
2797
  ae.dimRaw,
2763
2798
  ae.dimLabel ?? String(ae.dimRaw)
@@ -2769,16 +2804,16 @@ const Tt = wa(function({
2769
2804
  }
2770
2805
  );
2771
2806
  });
2772
- function Cl({
2807
+ function ql({
2773
2808
  reportId: t,
2774
- widget: i,
2809
+ widget: s,
2775
2810
  dateRange: a = null,
2776
2811
  entityFilters: o = []
2777
2812
  }) {
2778
- const m = Ht(), u = Rt(
2779
- (x) => m == null ? void 0 : m.open(x),
2780
- [m]
2781
- ), b = ut(() => ({ ...i, x: 0 }), [i]);
2813
+ const c = Ht(), u = Rt(
2814
+ (x) => c == null ? void 0 : c.open(x),
2815
+ [c]
2816
+ ), b = ut(() => ({ ...s, x: 0 }), [s]);
2782
2817
  return /* @__PURE__ */ e(
2783
2818
  Tt,
2784
2819
  {
@@ -2786,25 +2821,25 @@ function Cl({
2786
2821
  widget: b,
2787
2822
  dateRange: a,
2788
2823
  entityFilters: o,
2789
- onDrill: m ? u : void 0
2824
+ onDrill: c ? u : void 0
2790
2825
  }
2791
2826
  );
2792
2827
  }
2793
- function $l({
2828
+ function Ml({
2794
2829
  reportId: t,
2795
- showFilterBar: i = !0,
2830
+ showFilterBar: s = !0,
2796
2831
  dateRange: a,
2797
2832
  initialEntityFilters: o = [],
2798
- refetchInterval: m,
2833
+ refetchInterval: c,
2799
2834
  className: u,
2800
2835
  emptyState: b,
2801
2836
  reportUrl: x
2802
2837
  }) {
2803
2838
  var R, B;
2804
- const p = Ke(), K = Ht(), F = Sa("drill.report"), N = F.value, _ = Rt(
2839
+ const p = Ke(), K = Ht(), F = _a("drill.report"), N = F.value, C = Rt(
2805
2840
  (r) => K ? K.open(r) : F.push([r]),
2806
2841
  [K, F.push]
2807
- ), [c, $] = M(void 0), [X, E] = M(o), [I, ee] = M(void 0), [he, z] = M(o), { scopes: ae, ready: ce } = Fa(), [xe, ye] = M(!1), [_e, Ce] = M({}), f = qt(), { data: te = [] } = Ne({
2842
+ ), [m, S] = M(void 0), [X, E] = M(o), [I, ee] = M(void 0), [he, z] = M(o), { scopes: ae, ready: ce } = Aa(), [xe, ye] = M(!1), [_e, Ce] = M({}), f = qt(), { data: te = [] } = Ne({
2808
2843
  queryKey: ["nivaro-report-presets", t],
2809
2844
  queryFn: async () => {
2810
2845
  try {
@@ -2823,7 +2858,7 @@ function $l({
2823
2858
  }
2824
2859
  } catch {
2825
2860
  }
2826
- return p.request(na(t)).then((r) => r.data);
2861
+ return p.request(sa(t)).then((r) => r.data);
2827
2862
  },
2828
2863
  staleTime: 6e4
2829
2864
  }), le = () => void f.invalidateQueries({ queryKey: ["nivaro-report-presets", t] }), Y = Fe({
@@ -2836,9 +2871,9 @@ function $l({
2836
2871
  ),
2837
2872
  onSuccess: le
2838
2873
  }), pe = Fe({
2839
- mutationFn: (r) => p.request(sa(t, r)),
2874
+ mutationFn: (r) => p.request(ia(t, r)),
2840
2875
  onSuccess: le
2841
- }), [ne, re] = M(""), [Te, k] = M(!1), [w, P] = M(null), [O, U] = M(!1), { data: G = [] } = Ne({
2876
+ }), [ne, re] = M(""), [Te, v] = M(!1), [w, P] = M(null), [O, U] = M(!1), { data: G = [] } = Ne({
2842
2877
  queryKey: ["nvr-report-snaps", t],
2843
2878
  queryFn: () => p.request(
2844
2879
  mt(`/report-studio/${t}/snapshots`)
@@ -2865,25 +2900,25 @@ function $l({
2865
2900
  mutationFn: (r) => p.request(pt(`/report-studio/${t}/annotations`, r)),
2866
2901
  onSuccess: me
2867
2902
  }), $e = Fe({
2868
- mutationFn: (r) => p.request(_a(`/report-studio/${t}/annotations/${r}`)),
2903
+ mutationFn: (r) => p.request(Ca(`/report-studio/${t}/annotations/${r}`)),
2869
2904
  onSuccess: me
2870
- }), Pe = Rt((r, h, y) => {
2871
- const v = {
2905
+ }), Pe = Rt((r, h, k) => {
2906
+ const y = {
2872
2907
  field: r,
2873
2908
  values: [h],
2874
- labels: [y]
2909
+ labels: [k]
2875
2910
  };
2876
- E((S) => [...S.filter((d) => d.field !== r), v]), z((S) => [...S.filter((d) => d.field !== r), v]);
2911
+ E((_) => [..._.filter((d) => d.field !== r), y]), z((_) => [..._.filter((d) => d.field !== r), y]);
2877
2912
  }, []), [we, et] = M(!1), [ke, Ae] = M(null), [tt, ze] = M(null), Qe = Fe({
2878
2913
  mutationFn: (r) => p.request(
2879
- Ca(`/report-studio/${t}/widgets`, {
2880
- widgets: r.map((h, y) => ({ ...h, sort: y }))
2914
+ $a(`/report-studio/${t}/widgets`, {
2915
+ widgets: r.map((h, k) => ({ ...h, sort: k }))
2881
2916
  })
2882
2917
  ),
2883
2918
  onSuccess: () => {
2884
2919
  et(!1), Ae(null), ze(null), f.invalidateQueries({ queryKey: ["nivaro-report", t] }), f.invalidateQueries({ queryKey: ["nivaro-report-widget"] });
2885
2920
  }
2886
- }), ht = (r) => [...r].sort((h, y) => (h.y ?? 0) - (y.y ?? 0) || (h.x ?? 0) - (y.x ?? 0)), [Ue, ft] = M(() => /* @__PURE__ */ new Date()), j = () => {
2921
+ }), ht = (r) => [...r].sort((h, k) => (h.y ?? 0) - (k.y ?? 0) || (h.x ?? 0) - (k.x ?? 0)), [Ue, ft] = M(() => /* @__PURE__ */ new Date()), j = () => {
2887
2922
  f.invalidateQueries({ queryKey: ["nivaro-report-widget", t] }), f.invalidateQueries({ queryKey: ["nivaro-report-query"] }), ft(/* @__PURE__ */ new Date());
2888
2923
  }, { data: be = [] } = Ne({
2889
2924
  queryKey: ["nvr-report-firing", t],
@@ -2905,16 +2940,16 @@ function $l({
2905
2940
  }, [t]);
2906
2941
  const vt = () => {
2907
2942
  Ae(ht((se == null ? void 0 : se.widgets) ?? [])), et(!0), window.__nvrReportId = t;
2908
- }, at = (r) => Ae((h) => (h ?? []).map((y) => y.id === r.id ? r : y)), yt = (r, h) => Ae((y) => {
2909
- const v = [...y ?? []], S = v.findIndex((V) => V.id === r), d = S + h;
2910
- if (S < 0 || d < 0 || d >= v.length) return v;
2911
- const C = v[S], T = v[d];
2912
- return v[S] = { ...T, x: C.x, y: C.y }, v[d] = { ...C, x: T.x, y: T.y }, v;
2943
+ }, at = (r) => Ae((h) => (h ?? []).map((k) => k.id === r.id ? r : k)), yt = (r, h) => Ae((k) => {
2944
+ const y = [...k ?? []], _ = y.findIndex((V) => V.id === r), d = _ + h;
2945
+ if (_ < 0 || d < 0 || d >= y.length) return y;
2946
+ const $ = y[_], T = y[d];
2947
+ return y[_] = { ...T, x: $.x, y: $.y }, y[d] = { ...$, x: T.x, y: T.y }, y;
2913
2948
  }), [He, lt] = M(""), [Xe, rt] = M(!1), [nt, st] = M(null), { data: se, isLoading: kt } = Ne({
2914
2949
  queryKey: ["nivaro-report", t],
2915
- queryFn: () => p.request(ia(t)).then((r) => r.data),
2950
+ queryFn: () => p.request(oa(t)).then((r) => r.data),
2916
2951
  staleTime: 3e4
2917
- }), it = Ct(null), ot = Ct([]), dt = ((R = se == null ? void 0 : se.global_filters) == null ? void 0 : R.date_range) ?? null, Le = ut(() => c !== void 0 ? c : a !== void 0 ? a : dt, [c, a, dt]);
2952
+ }), it = Ct(null), ot = Ct([]), dt = ((R = se == null ? void 0 : se.global_filters) == null ? void 0 : R.date_range) ?? null, Le = ut(() => m !== void 0 ? m : a !== void 0 ? a : dt, [m, a, dt]);
2918
2953
  it.current = Le ?? null, ot.current = X;
2919
2954
  const ve = ut(
2920
2955
  () => {
@@ -2930,67 +2965,67 @@ function $l({
2930
2965
  return;
2931
2966
  }
2932
2967
  (async () => {
2933
- var y;
2968
+ var k;
2934
2969
  const r = [], h = {};
2935
- for (const v of ve) {
2936
- const S = Aa(ae, {
2937
- key: v.field,
2938
- collection: (y = v.options) == null ? void 0 : y.collection
2970
+ for (const y of ve) {
2971
+ const _ = Ra(ae, {
2972
+ key: y.field,
2973
+ collection: (k = y.options) == null ? void 0 : k.collection
2939
2974
  });
2940
- if (!S) continue;
2941
- const d = v.options ? v.options.value_field ?? "id" : "id", C = ae.restricted[S.name] ?? [];
2942
- if (C.length > 0) {
2943
- const V = await Pt(p, S, C, d).catch(
2975
+ if (!_) continue;
2976
+ const d = y.options ? y.options.value_field ?? "id" : "id", $ = ae.restricted[_.name] ?? [];
2977
+ if ($.length > 0) {
2978
+ const V = await Pt(p, _, $, d).catch(
2944
2979
  () => []
2945
2980
  );
2946
- V.length > 0 && (h[v.field] = V);
2981
+ V.length > 0 && (h[y.field] = V);
2947
2982
  }
2948
- const T = Ra(ae, S.name);
2983
+ const T = Ta(ae, _.name);
2949
2984
  if (T.length > 0) {
2950
- const V = await Pt(p, S, T, d).catch(
2985
+ const V = await Pt(p, _, T, d).catch(
2951
2986
  () => []
2952
2987
  );
2953
- V.length > 0 && r.push({ field: v.field, values: V, labels: V.map(String) });
2988
+ V.length > 0 && r.push({ field: y.field, values: V, labels: V.map(String) });
2954
2989
  }
2955
2990
  }
2956
2991
  if (Object.keys(h).length > 0 && Ce(h), r.length > 0) {
2957
- const v = (S) => {
2958
- const d = [...S];
2959
- for (const C of r) d.some((T) => T.field === C.field) || d.push(C);
2992
+ const y = (_) => {
2993
+ const d = [..._];
2994
+ for (const $ of r) d.some((T) => T.field === $.field) || d.push($);
2960
2995
  return d;
2961
2996
  };
2962
- z(v), E(v);
2997
+ z(y), E(y);
2963
2998
  }
2964
2999
  ye(!0);
2965
3000
  })();
2966
3001
  }
2967
3002
  }, [xe, ce, se, ae, ve]);
2968
- const l = (se == null ? void 0 : se.widgets) ?? [], s = I !== void 0 ? I : Le, g = X.filter((r) => r.values.length > 0).length + (Le ? 1 : 0), A = JSON.stringify(he) !== JSON.stringify(X) || I !== void 0, L = () => {
2969
- E(he), I !== void 0 && ($(I), ee(void 0));
3003
+ const l = (se == null ? void 0 : se.widgets) ?? [], i = I !== void 0 ? I : Le, g = X.filter((r) => r.values.length > 0).length + (Le ? 1 : 0), A = JSON.stringify(he) !== JSON.stringify(X) || I !== void 0, L = () => {
3004
+ E(he), I !== void 0 && (S(I), ee(void 0));
2970
3005
  }, D = () => {
2971
- z([]), E([]), $(null), ee(void 0);
3006
+ z([]), E([]), S(null), ee(void 0);
2972
3007
  }, oe = (r) => {
2973
- z(r.entity_filters), E(r.entity_filters), $(r.date_range), ee(void 0);
3008
+ z(r.entity_filters), E(r.entity_filters), S(r.date_range), ee(void 0);
2974
3009
  }, Z = async () => {
2975
- var h, y;
3010
+ var h, k;
2976
3011
  const r = He.trim();
2977
3012
  if (!(!r || Xe)) {
2978
3013
  rt(!0), st(null);
2979
3014
  try {
2980
- const v = await p.request(
2981
- ca(
3015
+ const y = await p.request(
3016
+ ma(
2982
3017
  t,
2983
3018
  r,
2984
3019
  ve.map((d) => ({ field: d.field, label: d.label }))
2985
3020
  )
2986
- ), S = (v.data.entity_filters ?? []).filter((d) => {
2987
- var C;
2988
- return ve.some((T) => T.field === d.field) && ((C = d.values) == null ? void 0 : C.length) > 0;
3021
+ ), _ = (y.data.entity_filters ?? []).filter((d) => {
3022
+ var $;
3023
+ return ve.some((T) => T.field === d.field) && (($ = d.values) == null ? void 0 : $.length) > 0;
2989
3024
  }).map((d) => ({ field: d.field, values: d.values, labels: d.values.map(String) }));
2990
- z(S), E(S), $(v.data.date_range ?? null), ee(void 0), lt("");
2991
- } catch (v) {
3025
+ z(_), E(_), S(y.data.date_range ?? null), ee(void 0), lt("");
3026
+ } catch (y) {
2992
3027
  st(
2993
- ((y = (h = v.response) == null ? void 0 : h.data) == null ? void 0 : y.error) ?? "Could not parse that"
3028
+ ((k = (h = y.response) == null ? void 0 : h.data) == null ? void 0 : k.error) ?? "Could not parse that"
2994
3029
  );
2995
3030
  } finally {
2996
3031
  rt(!1);
@@ -2998,7 +3033,7 @@ function $l({
2998
3033
  }
2999
3034
  };
3000
3035
  return kt || !xe ? /* @__PURE__ */ e("div", { className: W("p-6 text-[13px] text-slate-400", u), children: "Loading report…" }) : se ? /* @__PURE__ */ n("div", { className: W("flex flex-col gap-3", u), children: [
3001
- i && (l.length > 0 || ve.length > 0) && /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
3036
+ s && (l.length > 0 || ve.length > 0) && /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
3002
3037
  /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3003
3038
  /* @__PURE__ */ n("span", { className: "flex items-center gap-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-slate-300", children: [
3004
3039
  "Filters",
@@ -3010,9 +3045,9 @@ function $l({
3010
3045
  /* @__PURE__ */ e(
3011
3046
  wt,
3012
3047
  {
3013
- value: (s == null ? void 0 : s.preset) ?? "",
3048
+ value: (i == null ? void 0 : i.preset) ?? "",
3014
3049
  onChange: (r) => ee(r ? { preset: r } : null),
3015
- options: Ya.map((r) => ({ value: r.id, label: r.label })),
3050
+ options: Ja.map((r) => ({ value: r.id, label: r.label })),
3016
3051
  ariaLabel: "Date range",
3017
3052
  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"
3018
3053
  }
@@ -3020,17 +3055,17 @@ function $l({
3020
3055
  ve.map((r) => {
3021
3056
  var h;
3022
3057
  return /* @__PURE__ */ e(
3023
- ea,
3058
+ ta,
3024
3059
  {
3025
3060
  reportId: t,
3026
3061
  field: r.field,
3027
3062
  label: r.label,
3028
3063
  optionSource: r.options,
3029
3064
  allowedValues: _e[r.field],
3030
- selected: ((h = he.find((y) => y.field === r.field)) == null ? void 0 : h.values) ?? [],
3031
- onChange: (y, v) => z((S) => [
3032
- ...S.filter((d) => d.field !== r.field),
3033
- ...y.length > 0 ? [{ field: r.field, values: y, labels: v }] : []
3065
+ selected: ((h = he.find((k) => k.field === r.field)) == null ? void 0 : h.values) ?? [],
3066
+ onChange: (k, y) => z((_) => [
3067
+ ..._.filter((d) => d.field !== r.field),
3068
+ ...k.length > 0 ? [{ field: r.field, values: k, labels: y }] : []
3034
3069
  ])
3035
3070
  },
3036
3071
  r.field
@@ -3094,7 +3129,7 @@ function $l({
3094
3129
  placeholder: "Preset name",
3095
3130
  autoFocus: !0,
3096
3131
  onKeyDown: (r) => {
3097
- r.key === "Enter" && ne.trim() && (Y.mutate(ne.trim()), re(""), k(!1)), r.key === "Escape" && k(!1);
3132
+ r.key === "Enter" && ne.trim() && (Y.mutate(ne.trim()), re(""), v(!1)), r.key === "Escape" && v(!1);
3098
3133
  },
3099
3134
  className: "h-6 w-[130px] rounded-md border border-slate-200 bg-white px-2 text-[11px] dark:border-border dark:bg-card"
3100
3135
  }
@@ -3103,7 +3138,7 @@ function $l({
3103
3138
  {
3104
3139
  type: "button",
3105
3140
  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",
3106
- onClick: () => k(!0),
3141
+ onClick: () => v(!0),
3107
3142
  children: [
3108
3143
  /* @__PURE__ */ e(Ut, { className: "h-2.5 w-2.5" }),
3109
3144
  " Save preset"
@@ -3291,7 +3326,7 @@ function $l({
3291
3326
  type: "button",
3292
3327
  "aria-label": "Remove filter",
3293
3328
  onClick: () => {
3294
- E((h) => h.filter((y) => y.field !== r.field)), z((h) => h.filter((y) => y.field !== r.field));
3329
+ E((h) => h.filter((k) => k.field !== r.field)), z((h) => h.filter((k) => k.field !== r.field));
3295
3330
  },
3296
3331
  className: "rounded-full p-0.5 hover:bg-nvr-cyan/[0.16]",
3297
3332
  children: /* @__PURE__ */ e(Re, { className: "h-2.5 w-2.5" })
@@ -3334,7 +3369,7 @@ function $l({
3334
3369
  }
3335
3370
  ) }),
3336
3371
  we && ke && /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(Mt, { fallback: null, children: /* @__PURE__ */ e(
3337
- Ba,
3372
+ Qa,
3338
3373
  {
3339
3374
  maxY: Math.max(0, ...ke.map((r) => (r.y ?? 0) + (r.h ?? 1))),
3340
3375
  onAdd: (r) => Ae((h) => [...h ?? [], r])
@@ -3358,11 +3393,11 @@ function $l({
3358
3393
  gridRow: void 0
3359
3394
  },
3360
3395
  className: we || fe ? "" : "contents",
3361
- children: fe && !we && r.type !== "divider" ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [fe.a, fe.b].map((y, v) => /* @__PURE__ */ n("div", { className: "flex min-h-[160px] flex-col", children: [
3396
+ children: fe && !we && r.type !== "divider" ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [fe.a, fe.b].map((k, y) => /* @__PURE__ */ n("div", { className: "flex min-h-[160px] flex-col", children: [
3362
3397
  /* @__PURE__ */ n("p", { className: "mb-1 text-[10.5px] font-semibold uppercase tracking-wide text-[#007a99] dark:text-nvr-cyan", children: [
3363
3398
  fe.field.replace(/_/g, " "),
3364
3399
  ": ",
3365
- y
3400
+ k
3366
3401
  ] }),
3367
3402
  /* @__PURE__ */ e(
3368
3403
  Tt,
@@ -3371,27 +3406,27 @@ function $l({
3371
3406
  widget: r,
3372
3407
  dateRange: Le,
3373
3408
  entityFilters: [
3374
- ...X.filter((S) => S.field !== fe.field),
3375
- { field: fe.field, values: [y], labels: [y] }
3409
+ ...X.filter((_) => _.field !== fe.field),
3410
+ { field: fe.field, values: [k], labels: [k] }
3376
3411
  ],
3377
- refetchInterval: m,
3412
+ refetchInterval: c,
3378
3413
  filterBar: ve,
3379
- onDrill: _
3414
+ onDrill: C
3380
3415
  }
3381
3416
  )
3382
- ] }, v)) }) : /* @__PURE__ */ n(Ie, { children: [
3417
+ ] }, y)) }) : /* @__PURE__ */ n(Ie, { children: [
3383
3418
  we && /* @__PURE__ */ e(Mt, { fallback: null, children: /* @__PURE__ */ e(
3384
- Ua,
3419
+ Ya,
3385
3420
  {
3386
3421
  widget: r,
3387
3422
  onConfigure: () => ze(r.id),
3388
- onDelete: () => Ae((y) => (y ?? []).filter((v) => v.id !== r.id)),
3389
- onResize: (y, v) => at({
3423
+ onDelete: () => Ae((k) => (k ?? []).filter((y) => y.id !== r.id)),
3424
+ onResize: (k, y) => at({
3390
3425
  ...r,
3391
- w: Math.min(12, Math.max(2, (r.w || 4) + y)),
3392
- h: Math.min(8, Math.max(1, (r.h || 2) + v))
3426
+ w: Math.min(12, Math.max(2, (r.w || 4) + k)),
3427
+ h: Math.min(8, Math.max(1, (r.h || 2) + y))
3393
3428
  }),
3394
- onMove: (y) => yt(r.id, y)
3429
+ onMove: (k) => yt(r.id, k)
3395
3430
  }
3396
3431
  ) }),
3397
3432
  /* @__PURE__ */ e(
@@ -3401,14 +3436,14 @@ function $l({
3401
3436
  widget: r,
3402
3437
  dateRange: Le,
3403
3438
  entityFilters: X,
3404
- refetchInterval: m,
3439
+ refetchInterval: c,
3405
3440
  filterBar: ve,
3406
- onDrill: _,
3441
+ onDrill: C,
3407
3442
  snapshot: ie && ie.data[r.id] !== void 0 ? { name: ie.name, value: ((h = ie.data[r.id]) == null ? void 0 : h.value) ?? null } : null,
3408
3443
  asOf: O,
3409
- annotations: J.filter((y) => y.widget === r.id),
3410
- onAddAnnotation: (y, v, S) => ge.mutate({ widget: y, note: v, anchor_date: S }),
3411
- onDeleteAnnotation: (y) => $e.mutate(y),
3444
+ annotations: J.filter((k) => k.widget === r.id),
3445
+ onAddAnnotation: (k, y, _) => ge.mutate({ widget: k, note: y, anchor_date: _ }),
3446
+ onDeleteAnnotation: (k) => $e.mutate(k),
3412
3447
  onCrossFilter: Pe,
3413
3448
  reportUrl: x,
3414
3449
  currentFilters: X
@@ -3422,7 +3457,7 @@ function $l({
3422
3457
  }
3423
3458
  ),
3424
3459
  we && tt && (ke == null ? void 0 : ke.some((r) => r.id === tt)) && /* @__PURE__ */ e(Mt, { fallback: null, children: /* @__PURE__ */ e(
3425
- Qa,
3460
+ Ua,
3426
3461
  {
3427
3462
  widget: ke.find((r) => r.id === tt),
3428
3463
  allWidgets: ke,
@@ -3430,9 +3465,9 @@ function $l({
3430
3465
  onClose: () => ze(null)
3431
3466
  }
3432
3467
  ) }),
3433
- /* @__PURE__ */ e(La, {}),
3468
+ /* @__PURE__ */ e(Oa, {}),
3434
3469
  !K && (N != null && N.length) ? /* @__PURE__ */ e(
3435
- Ta,
3470
+ La,
3436
3471
  {
3437
3472
  collection: N[0].collection,
3438
3473
  itemId: N[0].itemId,
@@ -3447,8 +3482,8 @@ function $l({
3447
3482
  ] }) : /* @__PURE__ */ e("div", { className: W("p-6 text-[13px] text-slate-400", u), children: "Report not found." });
3448
3483
  }
3449
3484
  export {
3450
- ll as AlertBell,
3451
- Za as QueryWidgetBody,
3452
- $l as ReportView,
3453
- Cl as ReportWidgetCard
3485
+ rl as AlertBell,
3486
+ Ia as QueryWidgetBody,
3487
+ Ml as ReportView,
3488
+ ql as ReportWidgetCard
3454
3489
  };