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