@nivaro/react 0.3.113 → 0.3.115

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